From 78ab2ead2f907ea869cc71fb9900bdfcb1bf2834 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 23 Feb 2021 19:04:42 +0200 Subject: SidebarWidget: Improved appearance Added a color for sidebar background. Removed the right-edge separator line; instead, use color to separate. Page outline uses bold font for level 1 headings. --- src/ui/color.c | 21 +++++++++++++++------ src/ui/color.h | 1 + src/ui/sidebarwidget.c | 24 ++++++++++++++---------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/ui/color.c b/src/ui/color.c index 3adf857d..ab95906d 100644 --- a/src/ui/color.c +++ b/src/ui/color.c @@ -79,6 +79,8 @@ void setThemePalette_Color(enum iColorTheme theme) { copy_(uiBackgroundPressed_ColorId, orange_ColorId); copy_(uiBackgroundSelected_ColorId, teal_ColorId); copy_(uiBackgroundFramelessHover_ColorId, teal_ColorId); + set_Color(uiBackgroundSidebar_ColorId, + mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.66f)); copy_(uiText_ColorId, gray75_ColorId); copy_(uiTextPressed_ColorId, black_ColorId); copy_(uiTextStrong_ColorId, white_ColorId); @@ -125,6 +127,8 @@ void setThemePalette_Color(enum iColorTheme theme) { copy_(uiBackgroundPressed_ColorId, orange_ColorId); copy_(uiBackgroundSelected_ColorId, teal_ColorId); copy_(uiBackgroundFramelessHover_ColorId, teal_ColorId); + set_Color(uiBackgroundSidebar_ColorId, + mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.66f)); copy_(uiText_ColorId, gray75_ColorId); copy_(uiTextPressed_ColorId, black_ColorId); copy_(uiTextStrong_ColorId, white_ColorId); @@ -170,6 +174,8 @@ void setThemePalette_Color(enum iColorTheme theme) { copy_(uiBackgroundSelected_ColorId, orange_ColorId); copy_(uiBackgroundPressed_ColorId, cyan_ColorId); copy_(uiBackgroundFramelessHover_ColorId, orange_ColorId); + set_Color(uiBackgroundSidebar_ColorId, + mix_Color(get_Color(white_ColorId), get_Color(gray75_ColorId), 0.5f)); copy_(uiText_ColorId, black_ColorId); copy_(uiTextStrong_ColorId, black_ColorId); copy_(uiTextDim_ColorId, gray25_ColorId); @@ -215,6 +221,8 @@ void setThemePalette_Color(enum iColorTheme theme) { copy_(uiBackgroundSelected_ColorId, orange_ColorId); copy_(uiBackgroundPressed_ColorId, cyan_ColorId); copy_(uiBackgroundFramelessHover_ColorId, orange_ColorId); + set_Color(uiBackgroundSidebar_ColorId, + mix_Color(get_Color(white_ColorId), get_Color(gray75_ColorId), 0.5f)); set_Color(uiText_ColorId, mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.5f)); copy_(uiTextPressed_ColorId, black_ColorId); @@ -260,14 +268,15 @@ void setThemePalette_Color(enum iColorTheme theme) { mix_Color(get_Color(uiText_ColorId), get_Color(uiIcon_ColorId), isDark_ColorTheme(theme) ? 0.5f : 0.75f)); - set_Color(uiBackgroundUnfocusedSelection_ColorId, mix_Color(get_Color(uiBackground_ColorId), - get_Color(uiBackgroundSelected_ColorId), - isDark_ColorTheme(theme) ? 0.25f : 0.66f)); + set_Color(uiBackgroundUnfocusedSelection_ColorId, + mix_Color(get_Color(uiBackground_ColorId), + get_Color(uiBackgroundSelected_ColorId), + isDark_ColorTheme(theme) ? 0.25f : 0.66f)); setHsl_Color(uiBackgroundFolder_ColorId, - addSatLum_HSLColor(get_HSLColor(uiBackground_ColorId), + addSatLum_HSLColor(get_HSLColor(uiBackgroundSidebar_ColorId), 0, - theme == pureBlack_ColorTheme ? 0.075 - : theme == dark_ColorTheme ? -0.033 + theme == pureBlack_ColorTheme ? -1 + : theme == dark_ColorTheme ? -0.04 : -0.075)); palette_[uiMarked_ColorId].a = 128; palette_[uiMatching_ColorId].a = 128; diff --git a/src/ui/color.h b/src/ui/color.h index 8039506f..f65600d2 100644 --- a/src/ui/color.h +++ b/src/ui/color.h @@ -107,6 +107,7 @@ enum iColorId { uiTextDim_ColorId, uiSubheading_ColorId, uiTextAppTitle_ColorId, + uiBackgroundSidebar_ColorId, /* content theme colors */ tmFirst_ColorId, diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 9ca09fe8..e7eb6bde 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c @@ -212,6 +212,7 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { item->id = index_ArrayConstIterator(&i); setRange_String(&item->label, head->text); item->indent = head->level * 5 * gap_UI; + item->isBold = head->level == 0; addItem_ListWidget(d->list, item); iRelease(item); } @@ -425,7 +426,7 @@ iBool setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) { } setBackgroundColor_Widget(as_Widget(d->list), d->mode == documentOutline_SidebarMode ? tmBannerBackground_ColorId - : uiBackground_ColorId); + : uiBackgroundSidebar_ColorId); updateItemHeight_SidebarWidget_(d); /* Restore previous scroll position. */ setScrollPos_ListWidget(d->list, d->modeScroll[mode]); @@ -473,7 +474,7 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) { iTrue); iZap(d->modeScroll); d->side = side; - d->mode = -1; + d->mode = -1; #if defined (iPlatformAppleMobile) d->width = 73 * gap_UI; d->itemFonts[0] = defaultBig_FontId; @@ -501,17 +502,18 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) { iClob(new_LabelWidget( tightModeLabels_[i], format_CStr("%s.mode arg:%d", cstr_String(id_Widget(w)), i))), - frameless_WidgetFlag | (isPhone ? noBackground_WidgetFlag : 0)); + frameless_WidgetFlag | noBackground_WidgetFlag); } setButtonFont_SidebarWidget(d, isPhone ? uiLabelLarge_FontId : uiLabel_FontId); addChildFlags_Widget(vdiv, iClob(buttons), - arrangeHorizontal_WidgetFlag | resizeWidthOfChildren_WidgetFlag | + arrangeHorizontal_WidgetFlag | + resizeWidthOfChildren_WidgetFlag | arrangeHeight_WidgetFlag | resizeToParentWidth_WidgetFlag | drawBackgroundToHorizontalSafeArea_WidgetFlag); - if (deviceType_App() == phone_AppDeviceType) { - setBackgroundColor_Widget(buttons, uiBackground_ColorId); - } +// if (deviceType_App() == phone_AppDeviceType) { + setBackgroundColor_Widget(buttons, uiBackgroundSidebar_ColorId); + // } } else { iLabelWidget *heading = new_LabelWidget("Identities", NULL); @@ -1227,8 +1229,10 @@ static void draw_SidebarWidget_(const iSidebarWidget *d) { iPaint p; init_Paint(&p); draw_Widget(w); - drawVLine_Paint( - &p, addX_I2(topRight_Rect(bounds), -1), height_Rect(bounds), uiSeparator_ColorId); + if (d->mode == documentOutline_SidebarMode) { + drawVLine_Paint( + &p, addX_I2(topRight_Rect(bounds), -1), height_Rect(bounds), uiSeparator_ColorId); + } } static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, @@ -1243,7 +1247,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, const int iconColor = isHover ? (isPressing ? uiTextPressed_ColorId : uiIconHover_ColorId) : uiIcon_ColorId; const int font = sidebar->itemFonts[d->isBold ? 1 : 0]; - int bg = uiBackground_ColorId; + int bg = uiBackgroundSidebar_ColorId; if (isHover) { bg = isPressing ? uiBackgroundPressed_ColorId : uiBackgroundFramelessHover_ColorId; -- cgit v1.2.3