summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-26 12:56:07 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-26 12:56:07 +0300
commit790a2c49a0290ce872ec8929b063337eacde9880 (patch)
treed4bcc54ece3b4bec58fad9f1920ed2ca0c70c6b8 /src/ui/documentwidget.c
parent84d3089735bd81a9d628acf416b481f2535765cf (diff)
Preferences: Added side icon, hover outline
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c65
1 files changed, 32 insertions, 33 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 0079465f..ec6288d5 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -133,7 +133,7 @@ struct Impl_OutlineItem {
133 iRangecc text; 133 iRangecc text;
134 int font; 134 int font;
135 iRect rect; 135 iRect rect;
136 int seenColor; 136 int seenColor; /* TODO: not used */
137 int sepColor; 137 int sepColor;
138}; 138};
139 139
@@ -2058,13 +2058,15 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
2058// drawRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, red_ColorId); 2058// drawRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, red_ColorId);
2059} 2059}
2060 2060
2061static void drawSideRect_(iPaint *p, iRect rect, int thickness) { 2061static int drawSideRect_(iPaint *p, iRect rect) { //}, int thickness) {
2062 if (equal_Color(get_Color(tmBannerBackground_ColorId), get_Color(tmBackground_ColorId))) { 2062 int bg = tmBannerBackground_ColorId;
2063 drawRectThickness_Paint(p, rect, thickness, tmBannerIcon_ColorId); 2063 int fg = tmBannerIcon_ColorId;
2064 } 2064 if (equal_Color(get_Color(bg), get_Color(tmBackground_ColorId))) {
2065 else { 2065 bg = tmBannerIcon_ColorId;
2066 fillRect_Paint(p, rect, tmBannerBackground_ColorId); 2066 fg = tmBannerBackground_ColorId;
2067 } 2067 }
2068 fillRect_Paint(p, rect, bg);
2069 return fg;
2068} 2070}
2069 2071
2070static void drawSideElements_DocumentWidget_(const iDocumentWidget *d) { 2072static void drawSideElements_DocumentWidget_(const iDocumentWidget *d) {
@@ -2079,7 +2081,7 @@ static void drawSideElements_DocumentWidget_(const iDocumentWidget *d) {
2079 iPaint p; 2081 iPaint p;
2080 init_Paint(&p); 2082 init_Paint(&p);
2081 setClip_Paint(&p, bounds); 2083 setClip_Paint(&p, bounds);
2082 if (avail > minBannerSize) { 2084 if (prefs_App()->sideIcon && avail > minBannerSize) {
2083 if (banner && opacity > 0) { 2085 if (banner && opacity > 0) {
2084 setOpacity_Text(opacity); 2086 setOpacity_Text(opacity);
2085 SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_BLEND); 2087 SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_BLEND);
@@ -2088,16 +2090,16 @@ static void drawSideElements_DocumentWidget_(const iDocumentWidget *d) {
2088 p.alpha = opacity * 255; 2090 p.alpha = opacity * 255;
2089 //int offset = iMax(0, bottom_Rect(banner->visBounds) - d->scrollY); 2091 //int offset = iMax(0, bottom_Rect(banner->visBounds) - d->scrollY);
2090 rect.pos.y += height_Rect(bounds) / 2 - rect.size.y / 2 - (banner ? banner->visBounds.size.y / 2 : 0); // offset; 2092 rect.pos.y += height_Rect(bounds) / 2 - rect.size.y / 2 - (banner ? banner->visBounds.size.y / 2 : 0); // offset;
2091 drawSideRect_(&p, rect, gap_UI / 2); 2093 int fg = drawSideRect_(&p, rect); //, gap_UI / 2);
2092 if (equal_Color(get_Color(tmBannerBackground_ColorId), get_Color(tmBackground_ColorId))) { 2094// if (equal_Color(get_Color(tmBannerBackground_ColorId), get_Color(tmBackground_ColorId))) {
2093 drawRectThickness_Paint(&p, rect, gap_UI / 2, tmBannerIcon_ColorId); 2095// drawRectThickness_Paint(&p, rect, gap_UI / 2, tmBannerIcon_ColorId);
2094 } 2096// }
2095 else { 2097// else {
2096 fillRect_Paint(&p, rect, tmBannerBackground_ColorId); 2098// fillRect_Paint(&p, rect, tmBannerBackground_ColorId);
2097 } 2099// }
2098 iString str; 2100 iString str;
2099 initUnicodeN_String(&str, &icon, 1); 2101 initUnicodeN_String(&str, &icon, 1);
2100 drawCentered_Text(banner_FontId, rect, iTrue, tmBannerIcon_ColorId, "%s", cstr_String(&str)); 2102 drawCentered_Text(banner_FontId, rect, iTrue, fg, "%s", cstr_String(&str));
2101#if 0 2103#if 0
2102 if (avail >= minBannerSize * 2) { 2104 if (avail >= minBannerSize * 2) {
2103 const char *endp; 2105 const char *endp;
@@ -2139,7 +2141,7 @@ static void drawSideElements_DocumentWidget_(const iDocumentWidget *d) {
2139 } 2141 }
2140 /* Outline on the right side. */ 2142 /* Outline on the right side. */
2141 const float outlineOpacity = value_Anim(&d->outlineOpacity); 2143 const float outlineOpacity = value_Anim(&d->outlineOpacity);
2142 if (!isEmpty_Array(&d->outline) && outlineOpacity > 0.0f) { 2144 if (prefs_App()->hoverOutline && !isEmpty_Array(&d->outline) && outlineOpacity > 0.0f) {
2143// const int font = uiLabel_FontId; 2145// const int font = uiLabel_FontId;
2144 //iRect outlineRect = initCorners_Rect(topRight_Rect(docBounds), bottomRight_Rect(bounds)); 2146 //iRect outlineRect = initCorners_Rect(topRight_Rect(docBounds), bottomRight_Rect(bounds));
2145 //const int excess = width_Rect(outlineRect) - 75 * gap_UI; 2147 //const int excess = width_Rect(outlineRect) - 75 * gap_UI;
@@ -2170,26 +2172,23 @@ static void drawSideElements_DocumentWidget_(const iDocumentWidget *d) {
2170 setOpacity_Text(outlineOpacity); 2172 setOpacity_Text(outlineOpacity);
2171 SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_BLEND); 2173 SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_BLEND);
2172 p.alpha = outlineOpacity * 255; 2174 p.alpha = outlineOpacity * 255;
2173 drawSideRect_( 2175 iRect outlineFrame = {
2174 &p, 2176 addY_I2(pos, -outlinePadding_DocumentWidget_ * gap_UI / 2),
2175 (iRect){ addY_I2(pos, -outlinePadding_DocumentWidget_ * gap_UI / 2), 2177 init_I2(outWidth, outHeight + outlinePadding_DocumentWidget_ * gap_UI * 1.5f)
2176 init_I2(outWidth, outHeight + outlinePadding_DocumentWidget_ * gap_UI * 1.5f) }, 2178 };
2177 1); 2179 fillRect_Paint(&p, outlineFrame, tmBannerBackground_ColorId);
2180 const int textFg = drawSideRect_(&p, outlineFrame); //, 1);
2178 iConstForEach(Array, i, &d->outline) { 2181 iConstForEach(Array, i, &d->outline) {
2179 const iOutlineItem *item = i.value; 2182 const iOutlineItem *item = i.value;
2180 iInt2 visPos = addX_I2(add_I2(pos, item->rect.pos), outlinePadding_DocumentWidget_ * gap_UI); 2183 iInt2 visPos = addX_I2(add_I2(pos, item->rect.pos), outlinePadding_DocumentWidget_ * gap_UI);
2181// visPos.y -= scroll;
2182// if (item->sepColor != none_ColorId) {
2183// drawHLine_Paint(&p, addY_I2(visPos, -gap_UI), outWidth, item->sepColor);
2184// }
2185// drawRect_Paint(&p, (iRect){ visPos, item->rect.size }, red_ColorId);
2186 const iBool isVisible = d->lastVisibleRun && d->lastVisibleRun->text.start >= item->text.start; 2184 const iBool isVisible = d->lastVisibleRun && d->lastVisibleRun->text.start >= item->text.start;
2187 drawWrapRange_Text(item->font, 2185 const int fg = index_ArrayConstIterator(&i) == 0 || isVisible ? textFg
2188 visPos, 2186 : tmQuoteIcon_ColorId;
2189 innerWidth - left_Rect(item->rect), 2187 drawWrapRange_Text(
2190 index_ArrayConstIterator(&i) == 0 || isVisible ? item->seenColor 2188 item->font, visPos, innerWidth - left_Rect(item->rect), fg, item->text);
2191 : tmQuoteIcon_ColorId, 2189 if (left_Rect(item->rect) > 0) {
2192 item->text); 2190 drawRange_Text(item->font, addX_I2(visPos, -3 * gap_UI), fg, range_CStr("\u2013"));
2191 }
2193 } 2192 }
2194 setOpacity_Text(1.0f); 2193 setOpacity_Text(1.0f);
2195 SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_NONE); 2194 SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_NONE);