Fixed GUI resize

This commit is contained in:
Yousef Khadadeh 2026-04-07 20:33:48 +03:00
parent 3ee17cfd2b
commit a181a4d51d
6 changed files with 20 additions and 11 deletions

View file

@ -1060,7 +1060,5 @@ void InputManager::update() {
void InputManager::frame_reset(const Vector2i& windowSize) {
cursorIcon = SystemCursorType::DEFAULT;
toggleFullscreen = false;
hideCursor = false;
}

View file

@ -63,8 +63,6 @@ struct InputManager {
} cursorIcon;
bool hideCursor = false;
bool toggleFullscreen = false;
struct KeyData {
bool held = false;
std::chrono::steady_clock::time_point lastPressTime;

View file

@ -361,7 +361,18 @@ void MainProgram::input_key_callback(const InputManager::KeyCallbackArgs& key) {
}
case InputManager::KEY_FULLSCREEN: {
if(key.down && !key.repeat)
input.toggleFullscreen = true;
toggle_full_screen();
break;
}
case InputManager::KEY_SAVE: {
if(key.down && !key.repeat)
toolbar.save_func();
break;
}
case InputManager::KEY_SAVE_AS: {
if(key.down && !key.repeat)
toolbar.save_as_func();
break;
}
}
g.input_key_callback(key);
@ -451,6 +462,11 @@ void MainProgram::input_window_scale_callback(const InputManager::WindowScaleCal
post_callback();
}
void MainProgram::toggle_full_screen() {
window.fullscreen = !window.fullscreen;
SDL_SetWindowFullscreen(window.sdlWindow, window.fullscreen);
}
void MainProgram::close_set_to_close_tabs() {
if(!tabsToClose.empty()) {
std::erase_if(worlds, [&](auto& w) {

View file

@ -102,6 +102,7 @@ class MainProgram {
void update_scale_and_density();
float get_scale_and_density_factor_gui();
bool app_close_requested();
void toggle_full_screen();
void refresh_draw_surfaces();

View file

@ -320,6 +320,7 @@ bool Toolbar::app_close_requested() {
add_world_to_close_popup_data(w);
}
closePopupData.closeAppWhenDone = true;
main.g.gui.set_to_layout();
return closePopupData.worldsToClose.empty();
}

View file

@ -650,11 +650,6 @@ SDL_AppResult SDL_AppIterate(void *appstate) {
if(mS.m->setToQuit)
return SDL_APP_SUCCESS;
if(mS.m->input.toggleFullscreen) {
SDL_SetWindowFullscreen(mS.window, !mS.m->window.fullscreen);
mS.m->window.fullscreen = !mS.m->window.fullscreen;
}
if(mS.m->input.hideCursor) {
SDL_HideCursor();
SDL_SetCursor(mS.hiddenCursor); // Using this because SDL hidden cursor sometimes doesnt work
@ -840,7 +835,7 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) {
}
#endif
return SDL_APP_CONTINUE;
return mS.m->setToQuit ? SDL_APP_SUCCESS : SDL_APP_CONTINUE;
}
void SDL_AppQuit(void *appstate, SDL_AppResult result) {