diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-13 21:15:51 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-13 21:16:15 +0200 |
commit | d2f3c851a7273f35f128d4ea58b752251c5d5001 (patch) | |
tree | e0333a1e41e5e53f6b9de0e52ec38e0d69ea8e02 /src | |
parent | b8673100bd8d02dcfc997260fd6dc297287b8c71 (diff) |
Windows: Custom frame preference; further minor tweaks
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 21 | ||||
-rw-r--r-- | src/prefs.c | 1 | ||||
-rw-r--r-- | src/prefs.h | 1 | ||||
-rw-r--r-- | src/ui/color.c | 4 | ||||
-rw-r--r-- | src/ui/color.h | 1 | ||||
-rw-r--r-- | src/ui/util.c | 9 | ||||
-rw-r--r-- | src/ui/window.c | 111 |
7 files changed, 96 insertions, 52 deletions
@@ -158,6 +158,9 @@ static iString *serializePrefs_App_(const iApp *d) { | |||
158 | iString *str = new_String(); | 158 | iString *str = new_String(); |
159 | const iSidebarWidget *sidebar = findWidget_App("sidebar"); | 159 | const iSidebarWidget *sidebar = findWidget_App("sidebar"); |
160 | const iSidebarWidget *sidebar2 = findWidget_App("sidebar2"); | 160 | const iSidebarWidget *sidebar2 = findWidget_App("sidebar2"); |
161 | #if defined (LAGRANGE_CUSTOM_FRAME) | ||
162 | appendFormat_String(str, "customframe arg:%d\n", d->prefs.customFrame); | ||
163 | #endif | ||
161 | appendFormat_String(str, "window.retain arg:%d\n", d->prefs.retainWindowSize); | 164 | appendFormat_String(str, "window.retain arg:%d\n", d->prefs.retainWindowSize); |
162 | if (d->prefs.retainWindowSize) { | 165 | if (d->prefs.retainWindowSize) { |
163 | int w, h, x, y; | 166 | int w, h, x, y; |
@@ -283,6 +286,9 @@ static void loadPrefs_App_(iApp *d) { | |||
283 | if (equal_Command(cmd, "uiscale")) { | 286 | if (equal_Command(cmd, "uiscale")) { |
284 | setUiScale_Window(get_Window(), argf_Command(cmd)); | 287 | setUiScale_Window(get_Window(), argf_Command(cmd)); |
285 | } | 288 | } |
289 | else if (equal_Command(cmd, "customframe")) { | ||
290 | d->prefs.customFrame = arg_Command(cmd); | ||
291 | } | ||
286 | else if (equal_Command(cmd, "window.setrect") && !argLabel_Command(cmd, "snap")) { | 292 | else if (equal_Command(cmd, "window.setrect") && !argLabel_Command(cmd, "snap")) { |
287 | const iInt2 pos = coord_Command(cmd); | 293 | const iInt2 pos = coord_Command(cmd); |
288 | d->initialWindowRect = init_Rect( | 294 | d->initialWindowRect = init_Rect( |
@@ -298,6 +304,9 @@ static void loadPrefs_App_(iApp *d) { | |||
298 | else { | 304 | else { |
299 | /* default preference values */ | 305 | /* default preference values */ |
300 | } | 306 | } |
307 | #if !defined (LAGRANGE_CUSTOM_FRAME) | ||
308 | d->prefs.customFrame = iFalse; | ||
309 | #endif | ||
301 | iRelease(f); | 310 | iRelease(f); |
302 | } | 311 | } |
303 | 312 | ||
@@ -603,6 +612,11 @@ void processEvents_App(enum iAppEventMode eventMode) { | |||
603 | switch (ev.type) { | 612 | switch (ev.type) { |
604 | case SDL_QUIT: | 613 | case SDL_QUIT: |
605 | d->isRunning = iFalse; | 614 | d->isRunning = iFalse; |
615 | if (findWidget_App("prefs")) { | ||
616 | /* Make sure changed preferences get saved. */ | ||
617 | postCommand_App("prefs.dismiss"); | ||
618 | processEvents_App(postedEventsOnly_AppEventMode); | ||
619 | } | ||
606 | goto backToMainLoop; | 620 | goto backToMainLoop; |
607 | case SDL_DROPFILE: { | 621 | case SDL_DROPFILE: { |
608 | iBool wasUsed = processEvent_Window(d->window, &ev); | 622 | iBool wasUsed = processEvent_Window(d->window, &ev); |
@@ -909,6 +923,8 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) { | |||
909 | postCommandf_App("downloads path:%s", | 923 | postCommandf_App("downloads path:%s", |
910 | cstr_String(text_InputWidget(findChild_Widget(d, "prefs.downloads")))); | 924 | cstr_String(text_InputWidget(findChild_Widget(d, "prefs.downloads")))); |
911 | #endif | 925 | #endif |
926 | postCommandf_App("customframe arg:%d", | ||
927 | isSelected_Widget(findChild_Widget(d, "prefs.customframe"))); | ||
912 | postCommandf_App("window.retain arg:%d", | 928 | postCommandf_App("window.retain arg:%d", |
913 | isSelected_Widget(findChild_Widget(d, "prefs.retainwindow"))); | 929 | isSelected_Widget(findChild_Widget(d, "prefs.retainwindow"))); |
914 | postCommandf_App("smoothscroll arg:%d", | 930 | postCommandf_App("smoothscroll arg:%d", |
@@ -1120,6 +1136,10 @@ iBool handleCommand_App(const char *cmd) { | |||
1120 | d->prefs.retainWindowSize = arg_Command(cmd); | 1136 | d->prefs.retainWindowSize = arg_Command(cmd); |
1121 | return iTrue; | 1137 | return iTrue; |
1122 | } | 1138 | } |
1139 | else if (equal_Command(cmd, "customframe")) { | ||
1140 | d->prefs.customFrame = arg_Command(cmd); | ||
1141 | return iTrue; | ||
1142 | } | ||
1123 | else if (equal_Command(cmd, "window.maximize")) { | 1143 | else if (equal_Command(cmd, "window.maximize")) { |
1124 | if (!argLabel_Command(cmd, "toggle")) { | 1144 | if (!argLabel_Command(cmd, "toggle")) { |
1125 | setSnap_Window(d->window, maximized_WindowSnap); | 1145 | setSnap_Window(d->window, maximized_WindowSnap); |
@@ -1409,6 +1429,7 @@ iBool handleCommand_App(const char *cmd) { | |||
1409 | setToggle_Widget(findChild_Widget(dlg, "prefs.smoothscroll"), d->prefs.smoothScrolling); | 1429 | setToggle_Widget(findChild_Widget(dlg, "prefs.smoothscroll"), d->prefs.smoothScrolling); |
1410 | setToggle_Widget(findChild_Widget(dlg, "prefs.imageloadscroll"), d->prefs.loadImageInsteadOfScrolling); | 1430 | setToggle_Widget(findChild_Widget(dlg, "prefs.imageloadscroll"), d->prefs.loadImageInsteadOfScrolling); |
1411 | setToggle_Widget(findChild_Widget(dlg, "prefs.ostheme"), d->prefs.useSystemTheme); | 1431 | setToggle_Widget(findChild_Widget(dlg, "prefs.ostheme"), d->prefs.useSystemTheme); |
1432 | setToggle_Widget(findChild_Widget(dlg, "prefs.customframe"), d->prefs.customFrame); | ||
1412 | setToggle_Widget(findChild_Widget(dlg, "prefs.retainwindow"), d->prefs.retainWindowSize); | 1433 | setToggle_Widget(findChild_Widget(dlg, "prefs.retainwindow"), d->prefs.retainWindowSize); |
1413 | setText_InputWidget(findChild_Widget(dlg, "prefs.uiscale"), | 1434 | setText_InputWidget(findChild_Widget(dlg, "prefs.uiscale"), |
1414 | collectNewFormat_String("%g", uiScale_Window(d->window))); | 1435 | collectNewFormat_String("%g", uiScale_Window(d->window))); |
diff --git a/src/prefs.c b/src/prefs.c index fe755c63..89e7f203 100644 --- a/src/prefs.c +++ b/src/prefs.c | |||
@@ -26,6 +26,7 @@ void init_Prefs(iPrefs *d) { | |||
26 | d->dialogTab = 0; | 26 | d->dialogTab = 0; |
27 | d->useSystemTheme = iTrue; | 27 | d->useSystemTheme = iTrue; |
28 | d->theme = dark_ColorTheme; | 28 | d->theme = dark_ColorTheme; |
29 | d->customFrame = iTrue; | ||
29 | d->retainWindowSize = iTrue; | 30 | d->retainWindowSize = iTrue; |
30 | d->uiScale = 1.0f; /* default set elsewhere */ | 31 | d->uiScale = 1.0f; /* default set elsewhere */ |
31 | d->zoomPercent = 100; | 32 | d->zoomPercent = 100; |
diff --git a/src/prefs.h b/src/prefs.h index 1c3274d9..de354a04 100644 --- a/src/prefs.h +++ b/src/prefs.h | |||
@@ -38,6 +38,7 @@ struct Impl_Prefs { | |||
38 | /* Window */ | 38 | /* Window */ |
39 | iBool useSystemTheme; | 39 | iBool useSystemTheme; |
40 | enum iColorTheme theme; | 40 | enum iColorTheme theme; |
41 | iBool customFrame; /* when LAGRANGE_CUSTOM_FRAME is defined */ | ||
41 | iBool retainWindowSize; | 42 | iBool retainWindowSize; |
42 | float uiScale; | 43 | float uiScale; |
43 | int zoomPercent; | 44 | int zoomPercent; |
diff --git a/src/ui/color.c b/src/ui/color.c index 0227bd3e..870db2d0 100644 --- a/src/ui/color.c +++ b/src/ui/color.c | |||
@@ -89,6 +89,7 @@ void setThemePalette_Color(enum iColorTheme theme) { | |||
89 | copy_(uiTextShortcut_ColorId, cyan_ColorId); | 89 | copy_(uiTextShortcut_ColorId, cyan_ColorId); |
90 | copy_(uiTextAction_ColorId, cyan_ColorId); | 90 | copy_(uiTextAction_ColorId, cyan_ColorId); |
91 | copy_(uiTextCaution_ColorId, orange_ColorId); | 91 | copy_(uiTextCaution_ColorId, orange_ColorId); |
92 | copy_(uiTextAppTitle_ColorId, cyan_ColorId); | ||
92 | copy_(uiFrame_ColorId, black_ColorId); | 93 | copy_(uiFrame_ColorId, black_ColorId); |
93 | copy_(uiEmboss1_ColorId, gray25_ColorId); | 94 | copy_(uiEmboss1_ColorId, gray25_ColorId); |
94 | copy_(uiEmboss2_ColorId, black_ColorId); | 95 | copy_(uiEmboss2_ColorId, black_ColorId); |
@@ -134,6 +135,7 @@ void setThemePalette_Color(enum iColorTheme theme) { | |||
134 | copy_(uiTextShortcut_ColorId, cyan_ColorId); | 135 | copy_(uiTextShortcut_ColorId, cyan_ColorId); |
135 | copy_(uiTextAction_ColorId, cyan_ColorId); | 136 | copy_(uiTextAction_ColorId, cyan_ColorId); |
136 | copy_(uiTextCaution_ColorId, orange_ColorId); | 137 | copy_(uiTextCaution_ColorId, orange_ColorId); |
138 | copy_(uiTextAppTitle_ColorId, cyan_ColorId); | ||
137 | copy_(uiFrame_ColorId, gray25_ColorId); | 139 | copy_(uiFrame_ColorId, gray25_ColorId); |
138 | copy_(uiEmboss1_ColorId, gray50_ColorId); | 140 | copy_(uiEmboss1_ColorId, gray50_ColorId); |
139 | copy_(uiEmboss2_ColorId, black_ColorId); | 141 | copy_(uiEmboss2_ColorId, black_ColorId); |
@@ -178,6 +180,7 @@ void setThemePalette_Color(enum iColorTheme theme) { | |||
178 | copy_(uiTextShortcut_ColorId, brown_ColorId); | 180 | copy_(uiTextShortcut_ColorId, brown_ColorId); |
179 | copy_(uiTextAction_ColorId, brown_ColorId); | 181 | copy_(uiTextAction_ColorId, brown_ColorId); |
180 | copy_(uiTextCaution_ColorId, teal_ColorId); | 182 | copy_(uiTextCaution_ColorId, teal_ColorId); |
183 | copy_(uiTextAppTitle_ColorId, teal_ColorId); | ||
181 | copy_(uiFrame_ColorId, gray50_ColorId); | 184 | copy_(uiFrame_ColorId, gray50_ColorId); |
182 | copy_(uiEmboss1_ColorId, white_ColorId); | 185 | copy_(uiEmboss1_ColorId, white_ColorId); |
183 | copy_(uiEmboss2_ColorId, gray50_ColorId); | 186 | copy_(uiEmboss2_ColorId, gray50_ColorId); |
@@ -223,6 +226,7 @@ void setThemePalette_Color(enum iColorTheme theme) { | |||
223 | copy_(uiTextShortcut_ColorId, brown_ColorId); | 226 | copy_(uiTextShortcut_ColorId, brown_ColorId); |
224 | copy_(uiTextAction_ColorId, brown_ColorId); | 227 | copy_(uiTextAction_ColorId, brown_ColorId); |
225 | copy_(uiTextCaution_ColorId, teal_ColorId); | 228 | copy_(uiTextCaution_ColorId, teal_ColorId); |
229 | copy_(uiTextAppTitle_ColorId, teal_ColorId); | ||
226 | copy_(uiFrame_ColorId, gray75_ColorId); | 230 | copy_(uiFrame_ColorId, gray75_ColorId); |
227 | copy_(uiEmboss1_ColorId, white_ColorId); | 231 | copy_(uiEmboss1_ColorId, white_ColorId); |
228 | copy_(uiEmboss2_ColorId, white_ColorId); | 232 | copy_(uiEmboss2_ColorId, white_ColorId); |
diff --git a/src/ui/color.h b/src/ui/color.h index 6849ff2b..69dbe797 100644 --- a/src/ui/color.h +++ b/src/ui/color.h | |||
@@ -106,6 +106,7 @@ enum iColorId { | |||
106 | uiBackgroundFolder_ColorId, | 106 | uiBackgroundFolder_ColorId, |
107 | uiTextDim_ColorId, | 107 | uiTextDim_ColorId, |
108 | uiSubheading_ColorId, | 108 | uiSubheading_ColorId, |
109 | uiTextAppTitle_ColorId, | ||
109 | 110 | ||
110 | /* content theme colors */ | 111 | /* content theme colors */ |
111 | tmFirst_ColorId, | 112 | tmFirst_ColorId, |
diff --git a/src/ui/util.c b/src/ui/util.c index d64a93b6..75a770eb 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -1083,10 +1083,15 @@ iWidget *makePreferences_Widget(void) { | |||
1083 | setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure White", "theme.set arg:3"))), "prefs.theme.3"); | 1083 | setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure White", "theme.set arg:3"))), "prefs.theme.3"); |
1084 | } | 1084 | } |
1085 | addChildFlags_Widget(values, iClob(themes), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); | 1085 | addChildFlags_Widget(values, iClob(themes), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); |
1086 | addChild_Widget(headings, iClob(makeHeading_Widget("Retain window size:"))); | 1086 | #if defined (LAGRANGE_CUSTOM_FRAME) |
1087 | addChild_Widget(values, iClob(makeToggle_Widget("prefs.retainwindow"))); | 1087 | addChild_Widget(headings, iClob(makeHeading_Widget("Custom window frame:"))); |
1088 | addChild_Widget(values, iClob(makeToggle_Widget("prefs.customframe"))); | ||
1089 | #endif | ||
1090 | makeTwoColumnHeading_("SIZING", headings, values); | ||
1088 | addChild_Widget(headings, iClob(makeHeading_Widget("UI scale factor:"))); | 1091 | addChild_Widget(headings, iClob(makeHeading_Widget("UI scale factor:"))); |
1089 | setId_Widget(addChild_Widget(values, iClob(new_InputWidget(8))), "prefs.uiscale"); | 1092 | setId_Widget(addChild_Widget(values, iClob(new_InputWidget(8))), "prefs.uiscale"); |
1093 | addChild_Widget(headings, iClob(makeHeading_Widget("Retain placement:"))); | ||
1094 | addChild_Widget(values, iClob(makeToggle_Widget("prefs.retainwindow"))); | ||
1090 | makeTwoColumnHeading_("WIDE LAYOUT", headings, values); | 1095 | makeTwoColumnHeading_("WIDE LAYOUT", headings, values); |
1091 | addChild_Widget(headings, iClob(makeHeading_Widget("Site icon:"))); | 1096 | addChild_Widget(headings, iClob(makeHeading_Widget("Site icon:"))); |
1092 | addChild_Widget(values, iClob(makeToggle_Widget("prefs.sideicon"))); | 1097 | addChild_Widget(values, iClob(makeToggle_Widget("prefs.sideicon"))); |
diff --git a/src/ui/window.c b/src/ui/window.c index ef4a6fca..39e43340 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -91,7 +91,7 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) { | |||
91 | return iFalse; | 91 | return iFalse; |
92 | } | 92 | } |
93 | else if (equal_Command(cmd, "window.focus.gained")) { | 93 | else if (equal_Command(cmd, "window.focus.gained")) { |
94 | setTextColor_LabelWidget(findWidget_App("winbar.app"), uiTextShortcut_ColorId); | 94 | setTextColor_LabelWidget(findWidget_App("winbar.app"), uiTextAppTitle_ColorId); |
95 | setTextColor_LabelWidget(findWidget_App("winbar.title"), uiTextStrong_ColorId); | 95 | setTextColor_LabelWidget(findWidget_App("winbar.title"), uiTextStrong_ColorId); |
96 | return iFalse; | 96 | return iFalse; |
97 | } | 97 | } |
@@ -557,7 +557,8 @@ static void setupUserInterface_Window(iWindow *d) { | |||
557 | addChild_Widget(d->root, iClob(div)); | 557 | addChild_Widget(d->root, iClob(div)); |
558 | 558 | ||
559 | #if defined (LAGRANGE_CUSTOM_FRAME) | 559 | #if defined (LAGRANGE_CUSTOM_FRAME) |
560 | /* Window title bar. */ { | 560 | /* Window title bar. */ |
561 | if (prefs_App()->customFrame) { | ||
561 | setPadding1_Widget(div, 1); | 562 | setPadding1_Widget(div, 1); |
562 | iWidget *winBar = new_Widget(); | 563 | iWidget *winBar = new_Widget(); |
563 | setPadding_Widget(winBar, 0, gap_UI / 3, 0, 0); | 564 | setPadding_Widget(winBar, 0, gap_UI / 3, 0, 0); |
@@ -573,7 +574,7 @@ static void setupUserInterface_Window(iWindow *d) { | |||
573 | addChildFlags_Widget(winBar, | 574 | addChildFlags_Widget(winBar, |
574 | iClob(new_LabelWidget("Lagrange", NULL)), | 575 | iClob(new_LabelWidget("Lagrange", NULL)), |
575 | fixedHeight_WidgetFlag | frameless_WidgetFlag); | 576 | fixedHeight_WidgetFlag | frameless_WidgetFlag); |
576 | setTextColor_LabelWidget(appButton, uiTextShortcut_ColorId); | 577 | setTextColor_LabelWidget(appButton, uiTextAppTitle_ColorId); |
577 | setId_Widget(as_Widget(appButton), "winbar.app"); | 578 | setId_Widget(as_Widget(appButton), "winbar.app"); |
578 | iLabelWidget *appTitle; | 579 | iLabelWidget *appTitle; |
579 | setFont_LabelWidget(appButton, uiContentBold_FontId); | 580 | setFont_LabelWidget(appButton, uiContentBold_FontId); |
@@ -862,17 +863,21 @@ SDL_HitTestResult hitTest_Window(const iWindow *d, iInt2 pos) { | |||
862 | iBool create_Window_(iWindow *d, iRect rect, uint32_t flags) { | 863 | iBool create_Window_(iWindow *d, iRect rect, uint32_t flags) { |
863 | flags |= SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN; | 864 | flags |= SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN; |
864 | #if defined (LAGRANGE_CUSTOM_FRAME) | 865 | #if defined (LAGRANGE_CUSTOM_FRAME) |
865 | /* We are drawing a custom frame so hide the default one. */ | 866 | if (prefs_App()->customFrame) { |
866 | flags |= SDL_WINDOW_BORDERLESS; | 867 | /* We are drawing a custom frame so hide the default one. */ |
868 | flags |= SDL_WINDOW_BORDERLESS; | ||
869 | } | ||
867 | #endif | 870 | #endif |
868 | if (SDL_CreateWindowAndRenderer( | 871 | if (SDL_CreateWindowAndRenderer( |
869 | width_Rect(rect), height_Rect(rect), flags, &d->win, &d->render)) { | 872 | width_Rect(rect), height_Rect(rect), flags, &d->win, &d->render)) { |
870 | return iFalse; | 873 | return iFalse; |
871 | } | 874 | } |
872 | #if defined (LAGRANGE_CUSTOM_FRAME) | 875 | #if defined (LAGRANGE_CUSTOM_FRAME) |
873 | /* Register a handler for window hit testing (drag, resize). */ | 876 | if (prefs_App()->customFrame) { |
874 | SDL_SetWindowHitTest(d->win, hitTest_Window_, d); | 877 | /* Register a handler for window hit testing (drag, resize). */ |
875 | SDL_SetWindowResizable(d->win, SDL_TRUE); | 878 | SDL_SetWindowHitTest(d->win, hitTest_Window_, d); |
879 | SDL_SetWindowResizable(d->win, SDL_TRUE); | ||
880 | } | ||
876 | #endif | 881 | #endif |
877 | return iTrue; | 882 | return iTrue; |
878 | } | 883 | } |
@@ -979,15 +984,16 @@ void init_Window(iWindow *d, iRect rect) { | |||
979 | updateRootSize_Window_(d, iFalse); | 984 | updateRootSize_Window_(d, iFalse); |
980 | d->appIcon = NULL; | 985 | d->appIcon = NULL; |
981 | #if defined (LAGRANGE_CUSTOM_FRAME) | 986 | #if defined (LAGRANGE_CUSTOM_FRAME) |
982 | /* Load the app icon for drawing in the title bar. */ { | 987 | /* Load the app icon for drawing in the title bar. */ |
988 | if (prefs_App()->customFrame) { | ||
983 | SDL_Surface *surf = loadAppIconSurface_(appIconSize_()); | 989 | SDL_Surface *surf = loadAppIconSurface_(appIconSize_()); |
984 | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); | 990 | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); |
985 | d->appIcon = SDL_CreateTextureFromSurface(d->render, surf); | 991 | d->appIcon = SDL_CreateTextureFromSurface(d->render, surf); |
986 | free(surf->pixels); | 992 | free(surf->pixels); |
987 | SDL_FreeSurface(surf); | 993 | SDL_FreeSurface(surf); |
994 | /* We need to observe non-client-area events. */ | ||
995 | SDL_EventState(SDL_SYSWMEVENT, SDL_TRUE); | ||
988 | } | 996 | } |
989 | /* We need to observe non-client-area events. */ | ||
990 | SDL_EventState(SDL_SYSWMEVENT, SDL_TRUE); | ||
991 | #endif | 997 | #endif |
992 | } | 998 | } |
993 | 999 | ||
@@ -1027,6 +1033,9 @@ static iBool isNormalPlacement_Window_(const iWindow *d) { | |||
1027 | 1033 | ||
1028 | static iBool unsnap_Window_(iWindow *d, const iInt2 *newPos) { | 1034 | static iBool unsnap_Window_(iWindow *d, const iInt2 *newPos) { |
1029 | #if defined (LAGRANGE_CUSTOM_FRAME) | 1035 | #if defined (LAGRANGE_CUSTOM_FRAME) |
1036 | if (!prefs_App()->customFrame) { | ||
1037 | return iFalse; | ||
1038 | } | ||
1030 | const int snap = snap_Window(d); | 1039 | const int snap = snap_Window(d); |
1031 | if (snap == yMaximized_WindowSnap || snap == left_WindowSnap || snap == right_WindowSnap) { | 1040 | if (snap == yMaximized_WindowSnap || snap == left_WindowSnap || snap == right_WindowSnap) { |
1032 | if (!newPos || (d->place.lastHit == SDL_HITTEST_RESIZE_LEFT || | 1041 | if (!newPos || (d->place.lastHit == SDL_HITTEST_RESIZE_LEFT || |
@@ -1088,7 +1097,8 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | |||
1088 | return iFalse; | 1097 | return iFalse; |
1089 | } | 1098 | } |
1090 | #if defined (LAGRANGE_CUSTOM_FRAME) | 1099 | #if defined (LAGRANGE_CUSTOM_FRAME) |
1091 | /* Set the snap position depending on where the mouse cursor is. */ { | 1100 | /* Set the snap position depending on where the mouse cursor is. */ |
1101 | if (prefs_App()->customFrame) { | ||
1092 | SDL_Rect usable; | 1102 | SDL_Rect usable; |
1093 | iInt2 mouse = cursor_Win32(); /* SDL is unaware of the current cursor pos */ | 1103 | iInt2 mouse = cursor_Win32(); /* SDL is unaware of the current cursor pos */ |
1094 | SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(d->win), &usable); | 1104 | SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(d->win), &usable); |
@@ -1281,17 +1291,17 @@ void draw_Window(iWindow *d) { | |||
1281 | if (d->isDrawFrozen) { | 1291 | if (d->isDrawFrozen) { |
1282 | return; | 1292 | return; |
1283 | } | 1293 | } |
1284 | //#if !defined (NDEBUG) | 1294 | const int winFlags = SDL_GetWindowFlags(d->win); |
1285 | // printf("draw %d\n", d->frameTime); fflush(stdout); | 1295 | const iBool gotFocus = (winFlags & SDL_WINDOW_INPUT_FOCUS) != 0; |
1286 | //#endif | 1296 | /* Clear the window. The clear color is visible as a border around the window |
1287 | /* Clear the window. */ | 1297 | when the custom frame is being used. */ { |
1288 | const int winFlags = SDL_GetWindowFlags(d->win); | 1298 | const iColor back = get_Color(gotFocus && d->place.snap != maximized_WindowSnap && |
1289 | const iColor back = | 1299 | ~winFlags & SDL_WINDOW_FULLSCREEN_DESKTOP |
1290 | get_Color(winFlags & SDL_WINDOW_INPUT_FOCUS && d->place.snap != maximized_WindowSnap | 1300 | ? uiAnnotation_ColorId |
1291 | ? uiAnnotation_ColorId | 1301 | : uiSeparator_ColorId); |
1292 | : uiSeparator_ColorId); | 1302 | SDL_SetRenderDrawColor(d->render, back.r, back.g, back.b, 255); |
1293 | SDL_SetRenderDrawColor(d->render, back.r, back.g, back.b, 255); | 1303 | SDL_RenderClear(d->render); |
1294 | SDL_RenderClear(d->render); | 1304 | } |
1295 | /* Draw widgets. */ | 1305 | /* Draw widgets. */ |
1296 | d->frameTime = SDL_GetTicks(); | 1306 | d->frameTime = SDL_GetTicks(); |
1297 | draw_Widget(d->root); | 1307 | draw_Widget(d->root); |
@@ -1302,6 +1312,10 @@ void draw_Window(iWindow *d) { | |||
1302 | const int size = appIconSize_(); | 1312 | const int size = appIconSize_(); |
1303 | const iRect rect = bounds_Widget(appIcon); | 1313 | const iRect rect = bounds_Widget(appIcon); |
1304 | const iInt2 mid = mid_Rect(rect); | 1314 | const iInt2 mid = mid_Rect(rect); |
1315 | const iBool isLight = isLight_ColorTheme(colorTheme_App()); | ||
1316 | iColor iconColor = get_Color(gotFocus || isLight ? white_ColorId : cyan_ColorId); | ||
1317 | SDL_SetTextureColorMod(d->appIcon, iconColor.r, iconColor.g, iconColor.b); | ||
1318 | SDL_SetTextureAlphaMod(d->appIcon, gotFocus || !isLight ? 255 : 92); | ||
1305 | SDL_RenderCopy( | 1319 | SDL_RenderCopy( |
1306 | d->render, | 1320 | d->render, |
1307 | d->appIcon, | 1321 | d->appIcon, |
@@ -1401,38 +1415,25 @@ iWindow *get_Window(void) { | |||
1401 | return theWindow_; | 1415 | return theWindow_; |
1402 | } | 1416 | } |
1403 | 1417 | ||
1404 | #if !defined (LAGRANGE_CUSTOM_FRAME) | ||
1405 | void setSnap_Window(iWindow *d, int snapMode) { | 1418 | void setSnap_Window(iWindow *d, int snapMode) { |
1406 | if (snapMode == maximized_WindowSnap) { | 1419 | if (!prefs_App()->customFrame) { |
1407 | SDL_MaximizeWindow(d->win); | 1420 | if (snapMode == maximized_WindowSnap) { |
1408 | } | 1421 | SDL_MaximizeWindow(d->win); |
1409 | else if (snapMode == fullscreen_WindowSnap) { | 1422 | } |
1410 | SDL_SetWindowFullscreen(d->win, SDL_WINDOW_FULLSCREEN_DESKTOP); | 1423 | else if (snapMode == fullscreen_WindowSnap) { |
1411 | } | 1424 | SDL_SetWindowFullscreen(d->win, SDL_WINDOW_FULLSCREEN_DESKTOP); |
1412 | else { | ||
1413 | if (snap_Window(d) == fullscreen_WindowSnap) { | ||
1414 | SDL_SetWindowFullscreen(d->win, 0); | ||
1415 | } | 1425 | } |
1416 | else { | 1426 | else { |
1417 | SDL_RestoreWindow(d->win); | 1427 | if (snap_Window(d) == fullscreen_WindowSnap) { |
1428 | SDL_SetWindowFullscreen(d->win, 0); | ||
1429 | } | ||
1430 | else { | ||
1431 | SDL_RestoreWindow(d->win); | ||
1432 | } | ||
1418 | } | 1433 | } |
1434 | return; | ||
1419 | } | 1435 | } |
1420 | } | ||
1421 | |||
1422 | int snap_Window(const iWindow *d) { | ||
1423 | const int flags = SDL_GetWindowFlags(d->win); | ||
1424 | if (flags & SDL_WINDOW_FULLSCREEN_DESKTOP) { | ||
1425 | return fullscreen_WindowSnap; | ||
1426 | } | ||
1427 | else if (flags & SDL_WINDOW_MAXIMIZED) { | ||
1428 | return maximized_WindowSnap; | ||
1429 | } | ||
1430 | return none_WindowSnap; | ||
1431 | } | ||
1432 | #endif | ||
1433 | |||
1434 | #if defined (LAGRANGE_CUSTOM_FRAME) | 1436 | #if defined (LAGRANGE_CUSTOM_FRAME) |
1435 | void setSnap_Window(iWindow *d, int snapMode) { | ||
1436 | if (d->place.snap == snapMode) { | 1437 | if (d->place.snap == snapMode) { |
1437 | return; | 1438 | return; |
1438 | } | 1439 | } |
@@ -1497,9 +1498,19 @@ void setSnap_Window(iWindow *d, int snapMode) { | |||
1497 | arrange_Widget(d->root); | 1498 | arrange_Widget(d->root); |
1498 | postRefresh_App(); | 1499 | postRefresh_App(); |
1499 | } | 1500 | } |
1501 | #endif /* defined (LAGRANGE_CUSTOM_FRAME) */ | ||
1500 | } | 1502 | } |
1501 | 1503 | ||
1502 | int snap_Window(const iWindow *d) { | 1504 | int snap_Window(const iWindow *d) { |
1505 | if (!prefs_App()->customFrame) { | ||
1506 | const int flags = SDL_GetWindowFlags(d->win); | ||
1507 | if (flags & SDL_WINDOW_FULLSCREEN_DESKTOP) { | ||
1508 | return fullscreen_WindowSnap; | ||
1509 | } | ||
1510 | else if (flags & SDL_WINDOW_MAXIMIZED) { | ||
1511 | return maximized_WindowSnap; | ||
1512 | } | ||
1513 | return none_WindowSnap; | ||
1514 | } | ||
1503 | return d->place.snap; | 1515 | return d->place.snap; |
1504 | } | 1516 | } |
1505 | #endif | ||