summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c10
-rw-r--r--src/ui/labelwidget.c11
-rw-r--r--src/ui/sidebarwidget.c12
-rw-r--r--src/ui/widget.c32
-rw-r--r--src/ui/widget.h17
-rw-r--r--src/ui/window.c39
6 files changed, 85 insertions, 36 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index cb075c49..683793ea 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -2894,12 +2894,10 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
2894 } 2894 }
2895 if (run->flags & siteBanner_GmRunFlag) { 2895 if (run->flags & siteBanner_GmRunFlag) {
2896 /* Banner background. */ 2896 /* Banner background. */
2897 fillRect_Paint( 2897 iRect bannerBack = initCorners_Rect(topLeft_Rect(d->widgetBounds),
2898 &d->paint, 2898 init_I2(right_Rect(bounds_Widget(constAs_Widget(d->widget))),
2899 initCorners_Rect(topLeft_Rect(d->widgetBounds), 2899 visPos.y + height_Rect(run->visBounds)));
2900 init_I2(right_Rect(bounds_Widget(constAs_Widget(d->widget))), 2900 fillRect_Paint(&d->paint, bannerBack, tmBannerBackground_ColorId);
2901 visPos.y + height_Rect(run->visBounds))),
2902 tmBannerBackground_ColorId);
2903 drawBannerRun_DrawContext_(d, run, visPos); 2901 drawBannerRun_DrawContext_(d, run, visPos);
2904 } 2902 }
2905 else { 2903 else {
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index a0664433..1b16a028 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -139,16 +139,17 @@ static void keyStr_LabelWidget_(const iLabelWidget *d, iString *str) {
139 139
140static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int *frame1, int *frame2) { 140static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int *frame1, int *frame2) {
141 const iWidget *w = constAs_Widget(d); 141 const iWidget *w = constAs_Widget(d);
142 const iBool isPress = (flags_Widget(w) & pressed_WidgetFlag) != 0; 142 const int64_t flags = flags_Widget(w);
143 const iBool isSel = (flags_Widget(w) & selected_WidgetFlag) != 0; 143 const iBool isPress = (flags & pressed_WidgetFlag) != 0;
144 const iBool isFrameless = (flags_Widget(w) & frameless_WidgetFlag) != 0; 144 const iBool isSel = (flags & selected_WidgetFlag) != 0;
145 const iBool isFrameless = (flags & frameless_WidgetFlag) != 0;
145 const iBool isButton = d->click.button != 0; 146 const iBool isButton = d->click.button != 0;
146 /* Default color state. */ 147 /* Default color state. */
147 *bg = isButton ? uiBackground_ColorId : none_ColorId; 148 *bg = isButton && ~flags & noBackground_WidgetFlag ? uiBackground_ColorId : none_ColorId;
148 *fg = uiText_ColorId; 149 *fg = uiText_ColorId;
149 *frame1 = isButton ? uiEmboss1_ColorId : d->widget.frameColor; 150 *frame1 = isButton ? uiEmboss1_ColorId : d->widget.frameColor;
150 *frame2 = isButton ? uiEmboss2_ColorId : *frame1; 151 *frame2 = isButton ? uiEmboss2_ColorId : *frame1;
151 if (flags_Widget(w) & disabled_WidgetFlag && isButton) { 152 if (flags & disabled_WidgetFlag && isButton) {
152 *fg = uiTextDisabled_ColorId; 153 *fg = uiTextDisabled_ColorId;
153 } 154 }
154 if (isSel) { 155 if (isSel) {
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 5c6285fb..456bcee7 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -428,11 +428,11 @@ iBool setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) {
428} 428}
429 429
430enum iSidebarMode mode_SidebarWidget(const iSidebarWidget *d) { 430enum iSidebarMode mode_SidebarWidget(const iSidebarWidget *d) {
431 return d->mode; 431 return d ? d->mode : 0;
432} 432}
433 433
434int width_SidebarWidget(const iSidebarWidget *d) { 434int width_SidebarWidget(const iSidebarWidget *d) {
435 return d->width; 435 return d ? d->width : 0;
436} 436}
437 437
438static const char *normalModeLabels_[max_SidebarMode] = { 438static const char *normalModeLabels_[max_SidebarMode] = {
@@ -488,12 +488,16 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) {
488 addChildFlags_Widget(vdiv, 488 addChildFlags_Widget(vdiv,
489 iClob(buttons), 489 iClob(buttons),
490 arrangeHorizontal_WidgetFlag | resizeWidthOfChildren_WidgetFlag | 490 arrangeHorizontal_WidgetFlag | resizeWidthOfChildren_WidgetFlag |
491 arrangeHeight_WidgetFlag | resizeToParentWidth_WidgetFlag); 491 arrangeHeight_WidgetFlag | resizeToParentWidth_WidgetFlag |
492 drawBackgroundToHorizontalSafeArea_WidgetFlag);
493 if (deviceType_App() == phone_AppDeviceType) {
494 setBackgroundColor_Widget(buttons, uiBackground_ColorId);
495 }
492 iWidget *content = new_Widget(); 496 iWidget *content = new_Widget();
493 setFlags_Widget(content, resizeChildren_WidgetFlag, iTrue); 497 setFlags_Widget(content, resizeChildren_WidgetFlag, iTrue);
494 d->list = new_ListWidget(); 498 d->list = new_ListWidget();
495 setPadding_Widget(as_Widget(d->list), 0, gap_UI, 0, gap_UI); 499 setPadding_Widget(as_Widget(d->list), 0, gap_UI, 0, gap_UI);
496 addChild_Widget(content, iClob(d->list)); 500 addChildFlags_Widget(content, iClob(d->list), drawBackgroundToHorizontalSafeArea_WidgetFlag);
497 d->contextItem = NULL; 501 d->contextItem = NULL;
498 d->blank = new_Widget(); 502 d->blank = new_Widget();
499 addChildFlags_Widget(content, iClob(d->blank), resizeChildren_WidgetFlag); 503 addChildFlags_Widget(content, iClob(d->blank), resizeChildren_WidgetFlag);
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 128aa39c..0e020080 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -629,7 +629,9 @@ iBool processEvent_Widget(iWidget *d, const SDL_Event *ev) {
629} 629}
630 630
631void drawBackground_Widget(const iWidget *d) { 631void drawBackground_Widget(const iWidget *d) {
632 if (d->flags & hidden_WidgetFlag) return; 632 if (d->flags & (hidden_WidgetFlag | noBackground_WidgetFlag)) {
633 return;
634 }
633 if (flags_Widget(d) & borderTop_WidgetFlag) { 635 if (flags_Widget(d) & borderTop_WidgetFlag) {
634 const iRect rect = bounds_Widget(d); 636 const iRect rect = bounds_Widget(d);
635 iPaint p; 637 iPaint p;
@@ -637,10 +639,36 @@ void drawBackground_Widget(const iWidget *d) {
637 drawHLine_Paint(&p, topLeft_Rect(rect), width_Rect(rect), uiBackgroundFramelessHover_ColorId); 639 drawHLine_Paint(&p, topLeft_Rect(rect), width_Rect(rect), uiBackgroundFramelessHover_ColorId);
638 } 640 }
639 if (d->bgColor >= 0 || d->frameColor >= 0) { 641 if (d->bgColor >= 0 || d->frameColor >= 0) {
640 const iRect rect = bounds_Widget(d); 642 iRect rect = bounds_Widget(d);
641 iPaint p; 643 iPaint p;
642 init_Paint(&p); 644 init_Paint(&p);
643 if (d->bgColor >= 0) { 645 if (d->bgColor >= 0) {
646#if defined (iPlatformAppleMobile)
647 if (d->flags & (drawBackgroundToHorizontalSafeArea_WidgetFlag |
648 drawBackgroundToVerticalSafeArea_WidgetFlag)) {
649 const iInt2 rootSize = rootSize_Window(get_Window());
650 const iInt2 center = divi_I2(rootSize, 2);
651 int top = 0, right = 0, bottom = 0, left = 0;
652 if (d->flags & drawBackgroundToHorizontalSafeArea_WidgetFlag) {
653 const iBool isWide = width_Rect(rect) > rootSize.x * 9 / 10;
654 if (isWide || mid_Rect(rect).x < center.x) {
655 left = -left_Rect(rect);
656 }
657 if (isWide || mid_Rect(rect).x > center.x) {
658 right = rootSize.x - right_Rect(rect);
659 }
660 }
661 if (d->flags & drawBackgroundToVerticalSafeArea_WidgetFlag) {
662 if (top_Rect(rect) > center.y) {
663 bottom = rootSize.y - bottom_Rect(rect);
664 }
665 if (bottom_Rect(rect) < center.y) {
666 top = -top_Rect(rect);
667 }
668 }
669 adjustEdges_Rect(&rect, top, right, bottom, left);
670 }
671#endif
644 fillRect_Paint(&p, rect, d->bgColor); 672 fillRect_Paint(&p, rect, d->bgColor);
645 } 673 }
646 if (d->frameColor >= 0 && ~d->flags & frameless_WidgetFlag) { 674 if (d->frameColor >= 0 && ~d->flags & frameless_WidgetFlag) {
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 0b7a76e1..66fe222b 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -93,6 +93,9 @@ enum iWidgetFlag {
93#define focusRoot_WidgetFlag iBit64(39) 93#define focusRoot_WidgetFlag iBit64(39)
94#define unhittable_WidgetFlag iBit64(40) 94#define unhittable_WidgetFlag iBit64(40)
95#define touchDrag_WidgetFlag iBit64(41) /* touch event behavior: immediate drag */ 95#define touchDrag_WidgetFlag iBit64(41) /* touch event behavior: immediate drag */
96#define noBackground_WidgetFlag iBit64(42)
97#define drawBackgroundToHorizontalSafeArea_WidgetFlag iBit64(43)
98#define drawBackgroundToVerticalSafeArea_WidgetFlag iBit64(44)
96 99
97enum iWidgetAddPos { 100enum iWidgetAddPos {
98 back_WidgetAddPos, 101 back_WidgetAddPos,
@@ -159,12 +162,18 @@ void drawBackground_Widget(const iWidget *);
159void drawChildren_Widget (const iWidget *); 162void drawChildren_Widget (const iWidget *);
160 163
161iLocalDef int width_Widget(const iAnyObject *d) { 164iLocalDef int width_Widget(const iAnyObject *d) {
162 iAssert(isInstance_Object(d, &Class_Widget)); 165 if (d) {
163 return ((const iWidget *) d)->rect.size.x; 166 iAssert(isInstance_Object(d, &Class_Widget));
167 return ((const iWidget *) d)->rect.size.x;
168 }
169 return 0;
164} 170}
165iLocalDef int height_Widget(const iAnyObject *d) { 171iLocalDef int height_Widget(const iAnyObject *d) {
166 iAssert(isInstance_Object(d, &Class_Widget)); 172 if (d) {
167 return ((const iWidget *) d)->rect.size.y; 173 iAssert(isInstance_Object(d, &Class_Widget));
174 return ((const iWidget *) d)->rect.size.y;
175 }
176 return 0;
168} 177}
169iLocalDef iObjectList *children_Widget(iAnyObject *d) { 178iLocalDef iObjectList *children_Widget(iAnyObject *d) {
170 iAssert(isInstance_Object(d, &Class_Widget)); 179 iAssert(isInstance_Object(d, &Class_Widget));
diff --git a/src/ui/window.c b/src/ui/window.c
index 2b04244c..559b41a6 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -164,6 +164,7 @@ static const iMenuItem navMenuItems_[] = {
164 { "Quit Lagrange", 'q', KMOD_PRIMARY, "quit" } 164 { "Quit Lagrange", 'q', KMOD_PRIMARY, "quit" }
165}; 165};
166#else 166#else
167/* Phone menu. */
167static const iMenuItem navMenuItems_[] = { 168static const iMenuItem navMenuItems_[] = {
168 { "New Tab", 't', KMOD_PRIMARY, "tabs.new" }, 169 { "New Tab", 't', KMOD_PRIMARY, "tabs.new" },
169 { "Close Tab", 'w', KMOD_PRIMARY, "tabs.close" }, 170 { "Close Tab", 'w', KMOD_PRIMARY, "tabs.close" },
@@ -171,19 +172,15 @@ static const iMenuItem navMenuItems_[] = {
171 { "Save to Downloads", SDLK_s, KMOD_PRIMARY, "document.save" }, 172 { "Save to Downloads", SDLK_s, KMOD_PRIMARY, "document.save" },
172 { "Copy Source Text", SDLK_c, KMOD_PRIMARY, "copy" }, 173 { "Copy Source Text", SDLK_c, KMOD_PRIMARY, "copy" },
173 { "---", 0, 0, NULL }, 174 { "---", 0, 0, NULL },
174 { "Toggle Left Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" }, 175 { "Toggle Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" },
175 { "Toggle Right Sidebar", SDLK_p, KMOD_PRIMARY | KMOD_SHIFT, "sidebar2.toggle" },
176 { "Zoom In", SDLK_EQUALS, KMOD_PRIMARY, "zoom.delta arg:10" }, 176 { "Zoom In", SDLK_EQUALS, KMOD_PRIMARY, "zoom.delta arg:10" },
177 { "Zoom Out", SDLK_MINUS, KMOD_PRIMARY, "zoom.delta arg:-10" }, 177 { "Zoom Out", SDLK_MINUS, KMOD_PRIMARY, "zoom.delta arg:-10" },
178 { "Reset Zoom", SDLK_0, KMOD_PRIMARY, "zoom.set arg:100" }, 178 { "Reset Zoom", SDLK_0, KMOD_PRIMARY, "zoom.set arg:100" },
179 { "---", 0, 0, NULL }, 179 { "---", 0, 0, NULL },
180 { "List All Bookmarks", 0, 0, "!open url:about:bookmarks" }, 180 { "List All Bookmarks", 0, 0, "!open url:about:bookmarks" },
181 { "List Bookmarks by Tag", 0, 0, "!open url:about:bookmarks?tags" }, 181 { "List Feed Entries", 0, 0, "!open url:about:feeds" },
182 { "List Bookmarks by Creation Time", 0, 0, "!open url:about:bookmarks?created" },
183 { "---", 0, 0, NULL },
184 { "Show Feed Entries", 0, 0, "!open url:about:feeds" },
185 { "---", 0, 0, NULL }, 182 { "---", 0, 0, NULL },
186 { "Preferences...", SDLK_COMMA, KMOD_PRIMARY, "preferences" }, 183 { "Settings...", SDLK_COMMA, KMOD_PRIMARY, "preferences" },
187 { "Help", SDLK_F1, 0, "!open url:about:help" }, 184 { "Help", SDLK_F1, 0, "!open url:about:help" },
188 { "Release Notes", 0, 0, "!open url:about:version" }, 185 { "Release Notes", 0, 0, "!open url:about:version" },
189}; 186};
@@ -450,8 +447,6 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
450 else { 447 else {
451 arrange_Widget(navBar); 448 arrange_Widget(navBar);
452 } 449 }
453 printf("navbar hgt:%i\n", height_Widget(findWidget_App("navbar")));
454 printf("navbar.child[0] w:%i\n", width_Widget(child_Widget(findWidget_App("navbar"), 0)));
455 refresh_Widget(navBar); 450 refresh_Widget(navBar);
456 postCommand_Widget(navBar, "layout.changed id:navbar"); 451 postCommand_Widget(navBar, "layout.changed id:navbar");
457 return iFalse; 452 return iFalse;
@@ -689,8 +684,11 @@ static void setupUserInterface_Window(iWindow *d) {
689 int topPad = !findChild_Widget(div, "winbar") ? gap_UI / 2 : 0; 684 int topPad = !findChild_Widget(div, "winbar") ? gap_UI / 2 : 0;
690 setPadding_Widget(navBar, gap_UI, topPad, gap_UI, gap_UI / 2); 685 setPadding_Widget(navBar, gap_UI, topPad, gap_UI, gap_UI / 2);
691 setFlags_Widget(navBar, 686 setFlags_Widget(navBar,
692 arrangeHeight_WidgetFlag | resizeChildren_WidgetFlag | 687 arrangeHeight_WidgetFlag |
693 arrangeHorizontal_WidgetFlag, 688 resizeChildren_WidgetFlag |
689 arrangeHorizontal_WidgetFlag |
690 drawBackgroundToHorizontalSafeArea_WidgetFlag |
691 drawBackgroundToVerticalSafeArea_WidgetFlag,
694 iTrue); 692 iTrue);
695 addChild_Widget(div, iClob(navBar)); 693 addChild_Widget(div, iClob(navBar));
696 setBackgroundColor_Widget(navBar, uiBackground_ColorId); 694 setBackgroundColor_Widget(navBar, uiBackground_ColorId);
@@ -769,7 +767,11 @@ static void setupUserInterface_Window(iWindow *d) {
769 setBackgroundColor_Widget(tabBar, uiBackground_ColorId); 767 setBackgroundColor_Widget(tabBar, uiBackground_ColorId);
770 appendTabPage_Widget(tabBar, iClob(new_DocumentWidget()), "Document", 0, 0); 768 appendTabPage_Widget(tabBar, iClob(new_DocumentWidget()), "Document", 0, 0);
771 iWidget *buttons = findChild_Widget(tabBar, "tabs.buttons"); 769 iWidget *buttons = findChild_Widget(tabBar, "tabs.buttons");
772 setFlags_Widget(buttons, collapse_WidgetFlag | hidden_WidgetFlag, iTrue); 770 setFlags_Widget(buttons, collapse_WidgetFlag | hidden_WidgetFlag |
771 drawBackgroundToHorizontalSafeArea_WidgetFlag, iTrue);
772 if (deviceType_App() == phone_AppDeviceType) {
773 setBackgroundColor_Widget(buttons, uiBackground_ColorId);
774 }
773 setId_Widget( 775 setId_Widget(
774 addChild_Widget(buttons, iClob(newIcon_LabelWidget("\u2795", 0, 0, "tabs.new"))), 776 addChild_Widget(buttons, iClob(newIcon_LabelWidget("\u2795", 0, 0, "tabs.new"))),
775 "newtab"); 777 "newtab");
@@ -778,8 +780,10 @@ static void setupUserInterface_Window(iWindow *d) {
778 iWidget *content = findChild_Widget(d->root, "tabs.content"); 780 iWidget *content = findChild_Widget(d->root, "tabs.content");
779 iSidebarWidget *sidebar1 = new_SidebarWidget(left_SideBarSide); 781 iSidebarWidget *sidebar1 = new_SidebarWidget(left_SideBarSide);
780 addChildPos_Widget(content, iClob(sidebar1), front_WidgetAddPos); 782 addChildPos_Widget(content, iClob(sidebar1), front_WidgetAddPos);
781 iSidebarWidget *sidebar2 = new_SidebarWidget(right_SideBarSide); 783 if (deviceType_App() != phone_AppDeviceType) {
782 addChildPos_Widget(content, iClob(sidebar2), back_WidgetAddPos); 784 iSidebarWidget *sidebar2 = new_SidebarWidget(right_SideBarSide);
785 addChildPos_Widget(content, iClob(sidebar2), back_WidgetAddPos);
786 }
783 } 787 }
784 /* Lookup results. */ { 788 /* Lookup results. */ {
785 iLookupWidget *lookup = new_LookupWidget(); 789 iLookupWidget *lookup = new_LookupWidget();
@@ -815,13 +819,18 @@ static void setupUserInterface_Window(iWindow *d) {
815 setId_Widget(toolBar, "toolbar"); 819 setId_Widget(toolBar, "toolbar");
816 setFlags_Widget(toolBar, collapse_WidgetFlag | resizeWidthOfChildren_WidgetFlag | 820 setFlags_Widget(toolBar, collapse_WidgetFlag | resizeWidthOfChildren_WidgetFlag |
817 arrangeHeight_WidgetFlag | arrangeHorizontal_WidgetFlag, iTrue); 821 arrangeHeight_WidgetFlag | arrangeHorizontal_WidgetFlag, iTrue);
818 setBackgroundColor_Widget(toolBar, uiBackground_ColorId); 822 setBackgroundColor_Widget(toolBar, tmBannerBackground_ColorId);
819 addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f870", "navigate.back")), frameless_WidgetFlag); 823 addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f870", "navigate.back")), frameless_WidgetFlag);
820 addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f872", "navigate.forward")), frameless_WidgetFlag); 824 addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f872", "navigate.forward")), frameless_WidgetFlag);
821 addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f464", "sidebar.mode arg:3 show:1")), frameless_WidgetFlag); 825 addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f464", "sidebar.mode arg:3 show:1")), frameless_WidgetFlag);
822 iLabelWidget *menuButton = makeMenuButton_LabelWidget("\U0001d362", navMenuItems_, iElemCount(navMenuItems_)); 826 iLabelWidget *menuButton = makeMenuButton_LabelWidget("\U0001d362", navMenuItems_, iElemCount(navMenuItems_));
823 setFont_LabelWidget(menuButton, uiLabelLarge_FontId); 827 setFont_LabelWidget(menuButton, uiLabelLarge_FontId);
824 addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag); 828 addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag);
829 iForEach(ObjectList, i, children_Widget(toolBar)) {
830 iLabelWidget *btn = i.object;
831 setFlags_Widget(i.object, noBackground_WidgetFlag, iTrue);
832 setTextColor_LabelWidget(i.object, tmBannerIcon_ColorId);
833 }
825 } 834 }
826#endif 835#endif
827 updatePadding_Window_(d); 836 updatePadding_Window_(d);