summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/paint.c27
-rw-r--r--src/ui/paint.h1
-rw-r--r--src/ui/util.c6
-rw-r--r--src/ui/widget.c8
-rw-r--r--src/ui/window.c22
-rw-r--r--src/ui/window.h1
6 files changed, 49 insertions, 16 deletions
diff --git a/src/ui/paint.c b/src/ui/paint.c
index 1ac12a66..36e3f703 100644
--- a/src/ui/paint.c
+++ b/src/ui/paint.c
@@ -108,6 +108,33 @@ void fillRect_Paint(const iPaint *d, iRect rect, int color) {
108 SDL_RenderFillRect(renderer_Paint_(d), (SDL_Rect *) &rect); 108 SDL_RenderFillRect(renderer_Paint_(d), (SDL_Rect *) &rect);
109} 109}
110 110
111void drawSoftShadow_Paint(const iPaint *d, iRect inner, int thickness, int color, int alpha) {
112 SDL_Renderer *render = renderer_Paint_(d);
113 SDL_Texture *shadow = get_Window()->borderShadow;
114 const iInt2 size = size_SDLTexture(shadow);
115 const iRect outer = expanded_Rect(inner, init1_I2(thickness));
116 const iColor clr = get_Color(color);
117 SDL_SetTextureColorMod(shadow, clr.r, clr.g, clr.b);
118 SDL_SetTextureAlphaMod(shadow, alpha);
119 /* Classic stretched segmented border. */
120 SDL_RenderCopy(render, shadow, &(SDL_Rect){ 0, 0, size.x / 2, size.y / 2},
121 &(SDL_Rect){ outer.pos.x, outer.pos.y, thickness, thickness });
122 SDL_RenderCopy(render, shadow, &(SDL_Rect){ size.x / 2, 0, 1, size.y / 2},
123 &(SDL_Rect){ inner.pos.x, outer.pos.y, inner.size.x, thickness });
124 SDL_RenderCopy(render, shadow, &(SDL_Rect){ size.x / 2, 0, size.x / 2, size.y / 2},
125 &(SDL_Rect){ right_Rect(outer) - thickness, outer.pos.y, thickness, thickness });
126 SDL_RenderCopy(render, shadow, &(SDL_Rect){ size.x / 2, size.y / 2, size.x / 2, 1 },
127 &(SDL_Rect){ right_Rect(inner), inner.pos.y, thickness, inner.size.y });
128 SDL_RenderCopy(render, shadow, &(SDL_Rect){ size.x / 2, size.y / 2, size.x / 2, size.y / 2},
129 &(SDL_Rect){ right_Rect(inner), bottom_Rect(inner), thickness, thickness });
130 SDL_RenderCopy(render, shadow, &(SDL_Rect){ size.x / 2, size.y / 2, 1, size.y / 2},
131 &(SDL_Rect){ inner.pos.x, bottom_Rect(inner), inner.size.x, thickness });
132 SDL_RenderCopy(render, shadow, &(SDL_Rect){ 0, size.y / 2, size.x / 2, size.y / 2},
133 &(SDL_Rect){ outer.pos.x, bottom_Rect(inner), thickness, thickness });
134 SDL_RenderCopy(render, shadow, &(SDL_Rect){ 0, size.y / 2, size.x / 2, 1 },
135 &(SDL_Rect){ outer.pos.x, inner.pos.y, thickness, inner.size.y });
136}
137
111void drawLines_Paint(const iPaint *d, const iInt2 *points, size_t count, int color) { 138void drawLines_Paint(const iPaint *d, const iInt2 *points, size_t count, int color) {
112 setColor_Paint_(d, color); 139 setColor_Paint_(d, color);
113 SDL_RenderDrawLines(renderer_Paint_(d), (const SDL_Point *) points, count); 140 SDL_RenderDrawLines(renderer_Paint_(d), (const SDL_Point *) points, count);
diff --git a/src/ui/paint.h b/src/ui/paint.h
index 89a01da6..90cc2aef 100644
--- a/src/ui/paint.h
+++ b/src/ui/paint.h
@@ -47,6 +47,7 @@ void unsetClip_Paint (iPaint *);
47void drawRect_Paint (const iPaint *, iRect rect, int color); 47void drawRect_Paint (const iPaint *, iRect rect, int color);
48void drawRectThickness_Paint (const iPaint *, iRect rect, int thickness, int color); 48void drawRectThickness_Paint (const iPaint *, iRect rect, int thickness, int color);
49void fillRect_Paint (const iPaint *, iRect rect, int color); 49void fillRect_Paint (const iPaint *, iRect rect, int color);
50void drawSoftShadow_Paint (const iPaint *, iRect rect, int thickness, int color, int alpha);
50 51
51void drawLines_Paint (const iPaint *, const iInt2 *points, size_t count, int color); 52void drawLines_Paint (const iPaint *, const iInt2 *points, size_t count, int color);
52 53
diff --git a/src/ui/util.c b/src/ui/util.c
index 13d1bf78..8fbe5d41 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -395,6 +395,7 @@ static iBool isCommandIgnoredByMenus_(const char *cmd) {
395 startsWith_CStr(cmd, "feeds.update.") || 395 startsWith_CStr(cmd, "feeds.update.") ||
396 equal_Command(cmd, "bookmarks.request.started") || 396 equal_Command(cmd, "bookmarks.request.started") ||
397 equal_Command(cmd, "bookmarks.request.finished") || 397 equal_Command(cmd, "bookmarks.request.finished") ||
398 equal_Command(cmd, "bookmarks.changed") ||
398 equal_Command(cmd, "document.autoreload") || 399 equal_Command(cmd, "document.autoreload") ||
399 equal_Command(cmd, "document.reload") || 400 equal_Command(cmd, "document.reload") ||
400 equal_Command(cmd, "document.request.started") || 401 equal_Command(cmd, "document.request.started") ||
@@ -459,10 +460,13 @@ static iWidget *makeMenuSeparator_(void) {
459 460
460iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { 461iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) {
461 iWidget *menu = new_Widget(); 462 iWidget *menu = new_Widget();
462 setBackgroundColor_Widget(menu, uiBackground_ColorId); 463 setBackgroundColor_Widget(menu, uiBackgroundMenu_ColorId);
463 if (deviceType_App() != desktop_AppDeviceType) { 464 if (deviceType_App() != desktop_AppDeviceType) {
464 setPadding1_Widget(menu, 2 * gap_UI); 465 setPadding1_Widget(menu, 2 * gap_UI);
465 } 466 }
467 else {
468 setPadding1_Widget(menu, gap_UI / 2);
469 }
466 const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App()); 470 const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App());
467 int64_t itemFlags = (deviceType_App() != desktop_AppDeviceType ? 0 : 0) | 471 int64_t itemFlags = (deviceType_App() != desktop_AppDeviceType ? 0 : 0) |
468 (isPortraitPhone ? extraPadding_WidgetFlag : 0); 472 (isPortraitPhone ? extraPadding_WidgetFlag : 0);
diff --git a/src/ui/widget.c b/src/ui/widget.c
index fa0a20c9..81853c2a 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -858,13 +858,7 @@ void drawBackground_Widget(const iWidget *d) {
858 if (shadowBorder) { 858 if (shadowBorder) {
859 iPaint p; 859 iPaint p;
860 init_Paint(&p); 860 init_Paint(&p);
861 const iBool isLight = isLight_ColorTheme(colorTheme_App()); 861 drawSoftShadow_Paint(&p, bounds_Widget(d), 12 * gap_UI, black_ColorId, 30);
862 p.alpha = isLight ? 0xc : 0x20;
863 SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_BLEND);
864 iRect shadowRect = expanded_Rect(bounds_Widget(d), mulf_I2(gap2_UI, 8));
865// shadowRect.pos.y += gap_UI * 4;
866 fillRect_Paint(&p, shadowRect, /*isLight ? white_ColorId :*/ black_ColorId);
867 SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_NONE);
868 } 862 }
869 if (fadeBackground) { 863 if (fadeBackground) {
870 iPaint p; 864 iPaint p;
diff --git a/src/ui/window.c b/src/ui/window.c
index e7945c62..d67d3f5b 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1328,13 +1328,12 @@ iBool create_Window_(iWindow *d, iRect rect, uint32_t flags) {
1328} 1328}
1329 1329
1330#if defined (iPlatformLinux) || defined (LAGRANGE_CUSTOM_FRAME) 1330#if defined (iPlatformLinux) || defined (LAGRANGE_CUSTOM_FRAME)
1331static SDL_Surface *loadAppIconSurface_(int resized) { 1331static SDL_Surface *loadImage_(const iBlock *data, int resized) {
1332 const iBlock *icon = &imageLagrange64_Embedded; 1332 int w = 0, h = 0, num = 4;
1333 int w, h, num; 1333 stbi_uc *pixels = stbi_load_from_memory(
1334 stbi_uc * pixels = stbi_load_from_memory( 1334 constData_Block(data), size_Block(data), &w, &h, &num, STBI_rgb_alpha);
1335 constData_Block(icon), size_Block(icon), &w, &h, &num, STBI_rgb_alpha);
1336 if (resized) { 1335 if (resized) {
1337 stbi_uc * rsPixels = malloc(num * resized * resized); 1336 stbi_uc *rsPixels = malloc(num * resized * resized);
1338 stbir_resize_uint8(pixels, w, h, 0, rsPixels, resized, resized, 0, num); 1337 stbir_resize_uint8(pixels, w, h, 0, rsPixels, resized, resized, 0, num);
1339 free(pixels); 1338 free(pixels);
1340 pixels = rsPixels; 1339 pixels = rsPixels;
@@ -1414,7 +1413,7 @@ void init_Window(iWindow *d, iRect rect) {
1414#if defined (iPlatformLinux) 1413#if defined (iPlatformLinux)
1415 SDL_SetWindowMinimumSize(d->win, minSize.x * d->pixelRatio, minSize.y * d->pixelRatio); 1414 SDL_SetWindowMinimumSize(d->win, minSize.x * d->pixelRatio, minSize.y * d->pixelRatio);
1416 /* Load the window icon. */ { 1415 /* Load the window icon. */ {
1417 SDL_Surface *surf = loadAppIconSurface_(0); 1416 SDL_Surface *surf = loadImage_(&imageLagrange64_Embedded, 0);
1418 SDL_SetWindowIcon(d->win, surf); 1417 SDL_SetWindowIcon(d->win, surf);
1419 free(surf->pixels); 1418 free(surf->pixels);
1420 SDL_FreeSurface(surf); 1419 SDL_FreeSurface(surf);
@@ -1433,11 +1432,18 @@ void init_Window(iWindow *d, iRect rect) {
1433 setupUserInterface_Window(d); 1432 setupUserInterface_Window(d);
1434 postCommand_App("bindings.changed"); /* update from bindings */ 1433 postCommand_App("bindings.changed"); /* update from bindings */
1435 updateRootSize_Window_(d, iFalse); 1434 updateRootSize_Window_(d, iFalse);
1435 /* Load the border shadow texture. */ {
1436 SDL_Surface *surf = loadImage_(&imageShadow_Embedded, 0);
1437 d->borderShadow = SDL_CreateTextureFromSurface(d->render, surf);
1438 SDL_SetTextureBlendMode(d->borderShadow, SDL_BLENDMODE_BLEND);
1439 free(surf->pixels);
1440 SDL_FreeSurface(surf);
1441 }
1436 d->appIcon = NULL; 1442 d->appIcon = NULL;
1437#if defined (LAGRANGE_CUSTOM_FRAME) 1443#if defined (LAGRANGE_CUSTOM_FRAME)
1438 /* Load the app icon for drawing in the title bar. */ 1444 /* Load the app icon for drawing in the title bar. */
1439 if (prefs_App()->customFrame) { 1445 if (prefs_App()->customFrame) {
1440 SDL_Surface *surf = loadAppIconSurface_(appIconSize_()); 1446 SDL_Surface *surf = loadImage_(&imageLagrange64_Embedded, appIconSize_());
1441 SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); 1447 SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
1442 d->appIcon = SDL_CreateTextureFromSurface(d->render, surf); 1448 d->appIcon = SDL_CreateTextureFromSurface(d->render, surf);
1443 free(surf->pixels); 1449 free(surf->pixels);
diff --git a/src/ui/window.h b/src/ui/window.h
index 9ac3bc00..cd2e3814 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -72,6 +72,7 @@ struct Impl_Window {
72 uint32_t frameTime; 72 uint32_t frameTime;
73 double presentTime; 73 double presentTime;
74 SDL_Texture * appIcon; 74 SDL_Texture * appIcon;
75 SDL_Texture * borderShadow;
75 SDL_Cursor * cursors[SDL_NUM_SYSTEM_CURSORS]; 76 SDL_Cursor * cursors[SDL_NUM_SYSTEM_CURSORS];
76 SDL_Cursor * pendingCursor; 77 SDL_Cursor * pendingCursor;
77 int loadAnimTimer; 78 int loadAnimTimer;