From ab8764fdf9e7fc6c4432881dca5b10b9f0a668b6 Mon Sep 17 00:00:00 2001 From: Katie M Date: Thu, 4 Apr 2024 15:23:31 -0400 Subject: [PATCH 1/3] Revert "Update src/sdltiles.cpp" This reverts commit 80f011801066dd471c200b7b9df77678423f8c1a. --- src/sdltiles.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index d99ad5eb431fd..d8edc4d98c52b 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -3788,6 +3788,7 @@ input_event input_manager::get_input_event( const keyboard_mode preferred_keyboa // we can skip screen update if `needupdate` is false to improve performance during mouse // move events. wnoutrefresh( catacurses::stdscr ); + // This statement is required when the screen is made very small if( ui_adaptor::has_imgui() ) { needupdate = true; From d27a1b4d0b850c25ca9b204da385439a03e9d629 Mon Sep 17 00:00:00 2001 From: Katie M Date: Thu, 4 Apr 2024 15:24:09 -0400 Subject: [PATCH 2/3] Revert "Fixing an issue where, when the screen is made very small, imgui screens stop being drawn." This reverts commit 853198e929c9243248933c818b5ea1546ff769f5. --- src/sdltiles.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index d8edc4d98c52b..b773c3f97af7d 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -3788,12 +3788,6 @@ input_event input_manager::get_input_event( const keyboard_mode preferred_keyboa // we can skip screen update if `needupdate` is false to improve performance during mouse // move events. wnoutrefresh( catacurses::stdscr ); - - // This statement is required when the screen is made very small - if( ui_adaptor::has_imgui() ) { - needupdate = true; - } - if( needupdate ) { refresh_display(); } From 2eeced244aee1805a129937ba16c09521f637158 Mon Sep 17 00:00:00 2001 From: Katie M Date: Thu, 4 Apr 2024 16:25:36 -0400 Subject: [PATCH 3/3] Fixed the position/size of the ui_adaptor of imgui windows to show the proper dimensions, not scaled based on console cursor position. --- src/cata_imgui.cpp | 2 +- src/ui_manager.cpp | 9 +++++++++ src/ui_manager.h | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cata_imgui.cpp b/src/cata_imgui.cpp index 40439cb2b087e..c5b43d88e4b5e 100644 --- a/src/cata_imgui.cpp +++ b/src/cata_imgui.cpp @@ -435,7 +435,7 @@ class cataimgui::window_impl ImVec2 imsize = ImGui::GetWindowSize(); imvec2_to_point( &impos, &catapos ); imvec2_to_point( &imsize, &catasize ); - window_adaptor->position( catapos, catasize ); + window_adaptor->position_absolute( catapos, catasize ); } ); window_adaptor->on_screen_resize( [this]( ui_adaptor & ) { is_resized = true; diff --git a/src/ui_manager.cpp b/src/ui_manager.cpp index ec7cea68e0dab..d5b0ed7eea1e8 100644 --- a/src/ui_manager.cpp +++ b/src/ui_manager.cpp @@ -131,6 +131,15 @@ void ui_adaptor::position( const point &topleft, const point &size ) ui_manager::invalidate( old_dimensions, false ); } +void ui_adaptor::position_absolute( const point &topleft, const point &size ) +{ + const rectangle old_dimensions = dimensions; + // ensure position is updated before calling invalidate + dimensions = rectangle( topleft, topleft + size ); + invalidated = true; + ui_manager::invalidate( old_dimensions, false ); +} + void ui_adaptor::on_redraw( const redraw_callback_t &fun ) { redraw_cb = fun; diff --git a/src/ui_manager.h b/src/ui_manager.h index 48a1d2110c868..1c117fe937bca 100644 --- a/src/ui_manager.h +++ b/src/ui_manager.h @@ -127,6 +127,11 @@ class ui_adaptor * and curses builds. **/ void position( const point &topleft, const point &size ); + /** + * like 'position', except topleft and size are given as + * pixels in tiled builds and console cells on curses builds + **/ + void position_absolute( const point &topleft, const point &size ); /** * Set redraw and resize callbacks. The resize callback should * call `position` or `position_from_window` to set the size of the UI,