console and mining tab visual improvements
This commit is contained in:
71
src/main.cpp
71
src/main.cpp
@@ -778,6 +778,37 @@ int main(int argc, char* argv[])
|
||||
dragonx::util::PerfLog::instance().init(perfPath);
|
||||
}
|
||||
|
||||
// If the user had a font scale > 1.0 saved, app.init() rebuilt fonts
|
||||
// at that scale. Resize the window now so the larger UI fits.
|
||||
{
|
||||
float fs = dragonx::ui::Layout::userFontScale();
|
||||
if (fs > 1.01f) {
|
||||
int curW = 0, curH = 0;
|
||||
SDL_GetWindowSize(window, &curW, &curH);
|
||||
int newW = (int)lroundf(curW * fs);
|
||||
int newH = (int)lroundf(curH * fs);
|
||||
|
||||
// Clamp to display work area
|
||||
SDL_DisplayID did = SDL_GetDisplayForWindow(window);
|
||||
if (did) {
|
||||
SDL_Rect usable;
|
||||
if (SDL_GetDisplayUsableBounds(did, &usable)) {
|
||||
newW = std::min(newW, usable.w);
|
||||
newH = std::min(newH, usable.h);
|
||||
}
|
||||
}
|
||||
|
||||
float hwDpi = dragonx::ui::Layout::rawDpiScale();
|
||||
SDL_SetWindowSize(window, newW, newH);
|
||||
SDL_SetWindowMinimumSize(window,
|
||||
(int)(1024 * hwDpi * fs),
|
||||
(int)(720 * hwDpi * fs));
|
||||
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
DEBUG_LOGF("Font-scale startup: window %dx%d -> %dx%d (fontScale %.1f)\n",
|
||||
curW, curH, newW, newH, fs);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle pending payment URI from command line
|
||||
if (!pendingURI.empty()) {
|
||||
DEBUG_LOGF("Processing payment URI: %s\n", pendingURI.c_str());
|
||||
@@ -825,6 +856,9 @@ int main(int argc, char* argv[])
|
||||
if (in_resize_render) return true;
|
||||
in_resize_render = true;
|
||||
|
||||
// Pre-frame: font atlas rebuilds before NewFrame()
|
||||
ctx->app->preFrame();
|
||||
|
||||
#ifdef DRAGONX_USE_DX11
|
||||
ctx->dx->resize(event->window.data1, event->window.data2);
|
||||
ImGui_ImplDX11_NewFrame();
|
||||
@@ -1259,6 +1293,43 @@ int main(int argc, char* argv[])
|
||||
// --- PerfLog: begin frame ---
|
||||
dragonx::util::PerfLog::instance().beginFrame();
|
||||
|
||||
// Pre-frame: font atlas rebuilds and schema hot-reload must
|
||||
// happen BEFORE NewFrame() because NewFrame() caches font ptrs.
|
||||
float prevFontScale = dragonx::ui::Layout::userFontScale();
|
||||
app.preFrame();
|
||||
|
||||
// If font scale changed (user dragged the slider), resize window
|
||||
{
|
||||
float curFS = dragonx::ui::Layout::userFontScale();
|
||||
if (std::fabs(curFS - prevFontScale) > 0.001f) {
|
||||
int curW = 0, curH = 0;
|
||||
SDL_GetWindowSize(window, &curW, &curH);
|
||||
float ratio = curFS / prevFontScale;
|
||||
int newW = (int)lroundf(curW * ratio);
|
||||
int newH = (int)lroundf(curH * ratio);
|
||||
|
||||
// Clamp to display work area
|
||||
SDL_DisplayID did = SDL_GetDisplayForWindow(window);
|
||||
if (did) {
|
||||
SDL_Rect usable;
|
||||
if (SDL_GetDisplayUsableBounds(did, &usable)) {
|
||||
newW = std::min(newW, usable.w);
|
||||
newH = std::min(newH, usable.h);
|
||||
}
|
||||
}
|
||||
|
||||
float hwDpi = dragonx::ui::Layout::rawDpiScale();
|
||||
SDL_SetWindowSize(window, newW, newH);
|
||||
SDL_SetWindowMinimumSize(window,
|
||||
(int)(1024 * hwDpi * curFS),
|
||||
(int)(720 * hwDpi * curFS));
|
||||
lastKnownW = newW;
|
||||
lastKnownH = newH;
|
||||
DEBUG_LOGF("Font-scale resize: %dx%d -> %dx%d (%.1fx -> %.1fx)\n",
|
||||
curW, curH, newW, newH, prevFontScale, curFS);
|
||||
}
|
||||
}
|
||||
|
||||
// Start the Dear ImGui frame
|
||||
PERF_BEGIN(_perfNewFrame);
|
||||
#ifdef DRAGONX_USE_DX11
|
||||
|
||||
Reference in New Issue
Block a user