diff options
Diffstat (limited to 'src/libui_sdl')
-rw-r--r-- | src/libui_sdl/DlgAudioSettings.cpp | 2 | ||||
-rw-r--r-- | src/libui_sdl/DlgEmuSettings.cpp | 2 | ||||
-rw-r--r-- | src/libui_sdl/DlgInputConfig.cpp | 4 | ||||
-rw-r--r-- | src/libui_sdl/libui/ui.h | 6 | ||||
-rw-r--r-- | src/libui_sdl/libui/unix/window.c | 35 | ||||
-rw-r--r-- | src/libui_sdl/main.cpp | 31 |
6 files changed, 65 insertions, 15 deletions
diff --git a/src/libui_sdl/DlgAudioSettings.cpp b/src/libui_sdl/DlgAudioSettings.cpp index b02b474..41ce177 100644 --- a/src/libui_sdl/DlgAudioSettings.cpp +++ b/src/libui_sdl/DlgAudioSettings.cpp @@ -101,7 +101,7 @@ void Open() } opened = true; - win = uiNewWindow("Audio settings - melonDS", 400, 100, 0, 0); + win = uiNewWindow("Audio settings - melonDS", 400, 100, 0, 0, 0); uiWindowSetMargined(win, 1); uiWindowOnClosing(win, OnCloseWindow, NULL); diff --git a/src/libui_sdl/DlgEmuSettings.cpp b/src/libui_sdl/DlgEmuSettings.cpp index 42c95b8..7caaa0c 100644 --- a/src/libui_sdl/DlgEmuSettings.cpp +++ b/src/libui_sdl/DlgEmuSettings.cpp @@ -76,7 +76,7 @@ void Open() } opened = true; - win = uiNewWindow("Emu settings - melonDS", 300, 200, 0, 0); + win = uiNewWindow("Emu settings - melonDS", 300, 200, 0, 0, 0); uiWindowSetMargined(win, 1); uiWindowOnClosing(win, OnCloseWindow, NULL); diff --git a/src/libui_sdl/DlgInputConfig.cpp b/src/libui_sdl/DlgInputConfig.cpp index 0fc7f4a..7482817 100644 --- a/src/libui_sdl/DlgInputConfig.cpp +++ b/src/libui_sdl/DlgInputConfig.cpp @@ -337,7 +337,7 @@ void Open(int type) memcpy(dlg->keymap, Config::KeyMapping, sizeof(int)*12); memcpy(dlg->joymap, Config::JoyMapping, sizeof(int)*12); - dlg->win = uiNewWindow("Input config - melonDS", 600, 100, 0, 0); + dlg->win = uiNewWindow("Input config - melonDS", 600, 100, 0, 0, 0); } else if (type == 1) { @@ -345,7 +345,7 @@ void Open(int type) memcpy(dlg->keymap, Config::HKKeyMapping, sizeof(int)*HK_MAX); memcpy(dlg->joymap, Config::HKJoyMapping, sizeof(int)*HK_MAX); - dlg->win = uiNewWindow("Hotkey config - melonDS", 600, 100, 0, 0); + dlg->win = uiNewWindow("Hotkey config - melonDS", 600, 100, 0, 0, 0); } uiControl(dlg->win)->UserData = dlg; diff --git a/src/libui_sdl/libui/ui.h b/src/libui_sdl/libui/ui.h index 1af8f59..b100c08 100644 --- a/src/libui_sdl/libui/ui.h +++ b/src/libui_sdl/libui/ui.h @@ -110,6 +110,10 @@ _UI_EXTERN char *uiWindowTitle(uiWindow *w); _UI_EXTERN void uiWindowSetTitle(uiWindow *w, const char *title); _UI_EXTERN void uiWindowContentSize(uiWindow *w, int *width, int *height); _UI_EXTERN void uiWindowSetContentSize(uiWindow *w, int width, int height); +_UI_EXTERN int uiWindowMinimized(uiWindow *w); +_UI_EXTERN void uiWindowSetMinimized(uiWindow *w, int minimized); +_UI_EXTERN int uiWindowMaximized(uiWindow *w); +_UI_EXTERN void uiWindowSetMaximized(uiWindow *w, int maximized); _UI_EXTERN int uiWindowFullscreen(uiWindow *w); _UI_EXTERN void uiWindowSetFullscreen(uiWindow *w, int fullscreen); _UI_EXTERN int uiWindowBorderless(uiWindow *w); @@ -118,7 +122,7 @@ _UI_EXTERN void uiWindowSetChild(uiWindow *w, uiControl *child); _UI_EXTERN int uiWindowMargined(uiWindow *w); _UI_EXTERN void uiWindowSetMargined(uiWindow *w, int margined); _UI_EXTERN void uiWindowSetDropTarget(uiWindow* w, int drop); -_UI_EXTERN uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar, int resizable); +_UI_EXTERN uiWindow *uiNewWindow(const char *title, int width, int height, int maximized, int hasMenubar, int resizable); _UI_EXTERN void uiWindowOnContentSizeChanged(uiWindow *w, void (*f)(uiWindow *, void *), void *data); _UI_EXTERN void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *w, void *data), void *data); diff --git a/src/libui_sdl/libui/unix/window.c b/src/libui_sdl/libui/unix/window.c index 04630bc..8eb50b4 100644 --- a/src/libui_sdl/libui/unix/window.c +++ b/src/libui_sdl/libui/unix/window.c @@ -209,6 +209,34 @@ void uiWindowSetContentSize(uiWindow *w, int width, int height) gtk_window_resize(w->window, winWidth, winHeight); } +int uiWindowMinimized(uiWindow *w) +{ + // TODO!! + return 0; +} + +void uiWindowSetMinimized(uiWindow *w, int minimized) +{ + if (minimized) + gtk_window_iconify(w->window); + else + gtk_window_deiconify(w->window); +} + +int uiWindowMaximized(uiWindow *w) +{ + return gtk_window_is_maximized(w->window); +} + +void uiWindowSetMaximized(uiWindow *w, int maximized) +{ + if (maximized) + gtk_window_maximize(w->window); + else + gtk_window_unmaximize(w->window); +} + + int uiWindowFullscreen(uiWindow *w) { return w->fullscreen; @@ -344,9 +372,11 @@ void uiWindowSetDropTarget(uiWindow* w, int drop) g_signal_connect(w->widget, "drag-data-received", G_CALLBACK(onDragDataReceived), w); } -uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar, int resizable) +uiWindow *uiNewWindow(const char *title, int width, int height, int maximized, int hasMenubar, int resizable) { uiWindow *w; + + if (!resizable) maximized = 0; uiUnixNewControl(uiWindow, w); @@ -404,6 +434,9 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar, w->width = width; w->height = height; + + if (maximized) + gtk_window_maximize(w->window); return w; } diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 9f8f678..44c29f8 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -60,6 +60,8 @@ char* EmuDirectory; uiWindow* MainWindow; uiArea* MainDrawArea; +int WindowWidth, WindowHeight; + uiMenuItem* MenuItem_SaveState; uiMenuItem* MenuItem_LoadState; uiMenuItem* MenuItem_UndoStateLoad; @@ -522,7 +524,7 @@ int EmuThreadFunc(void* burp) if (guess != AutoScreenSizing) { AutoScreenSizing = guess; - SetupScreenRects(Config::WindowWidth, Config::WindowHeight); + SetupScreenRects(WindowWidth, WindowHeight); } } @@ -1002,8 +1004,18 @@ void OnAreaResize(uiAreaHandler* handler, uiArea* area, int width, int height) // should those be the size of the uiArea, or the size of the window client area? // for now the uiArea fills the whole window anyway // but... we never know, I guess - Config::WindowWidth = width; - Config::WindowHeight = height; + WindowWidth = width; + WindowHeight = height; + + int max = uiWindowMaximized(MainWindow); + int min = uiWindowMinimized(MainWindow); + + Config::WindowMaximized = max; + if (!max && !min) + { + Config::WindowWidth = width; + Config::WindowHeight = height; + } } @@ -1502,8 +1514,6 @@ void OnSetScreenRotation(uiMenuItem* item, uiWindow* window, void* param) w = blarg; uiWindowSetContentSize(window, w, h); - Config::WindowWidth = w; - Config::WindowHeight = h; } } @@ -1521,7 +1531,7 @@ void OnSetScreenGap(uiMenuItem* item, uiWindow* window, void* param) ScreenGap = gap; EnsureProperMinSize(); - SetupScreenRects(Config::WindowWidth, Config::WindowHeight); + SetupScreenRects(WindowWidth, WindowHeight); for (int i = 0; i < 6; i++) uiMenuItemSetChecked(MenuItem_ScreenGap[i], kScreenGap[i]==ScreenGap); @@ -1533,7 +1543,7 @@ void OnSetScreenLayout(uiMenuItem* item, uiWindow* window, void* param) ScreenLayout = layout; EnsureProperMinSize(); - SetupScreenRects(Config::WindowWidth, Config::WindowHeight); + SetupScreenRects(WindowWidth, WindowHeight); for (int i = 0; i < 3; i++) uiMenuItemSetChecked(MenuItem_ScreenLayout[i], i==ScreenLayout); @@ -1544,7 +1554,7 @@ void OnSetScreenSizing(uiMenuItem* item, uiWindow* window, void* param) int sizing = *(int*)param; ScreenSizing = sizing; - SetupScreenRects(Config::WindowWidth, Config::WindowHeight); + SetupScreenRects(WindowWidth, WindowHeight); for (int i = 0; i < 4; i++) uiMenuItemSetChecked(MenuItem_ScreenSizing[i], i==ScreenSizing); @@ -1818,8 +1828,11 @@ int main(int argc, char** argv) int h = Config::WindowHeight; //if (w < 256) w = 256; //if (h < 384) h = 384; + + WindowWidth = w; + WindowHeight = h; - MainWindow = uiNewWindow("melonDS " MELONDS_VERSION, w, h, 1, 1); + MainWindow = uiNewWindow("melonDS " MELONDS_VERSION, w, h, Config::WindowMaximized, 1, 1); uiWindowOnClosing(MainWindow, OnCloseWindow, NULL); uiWindowSetDropTarget(MainWindow, 1); |