diff options
Diffstat (limited to 'src/ui')
-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 |
4 files changed, 73 insertions, 52 deletions
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 | ||