diff --git a/.doc/tiki/tiki-ddqlbd.md b/.doc/tiki/tiki-ddqlbd.md index 2b0c5d9..9c0fd3c 100644 --- a/.doc/tiki/tiki-ddqlbd.md +++ b/.doc/tiki/tiki-ddqlbd.md @@ -87,4 +87,4 @@ def calculate_average(numbers): return sum(numbers) / len(numbers) ``` -Happy tiking! +Happy tiking! \ No newline at end of file diff --git a/view/doki_plugin_view.go b/view/doki_plugin_view.go index 7afabb3..cec915c 100644 --- a/view/doki_plugin_view.go +++ b/view/doki_plugin_view.go @@ -59,7 +59,7 @@ func (dv *DokiView) build() { if dv.pluginDef.Foreground != tcell.ColorDefault { textColor = dv.pluginDef.Foreground } - titleGradient := gradientFromPrimaryColor(dv.pluginDef.Background, config.GetColors().BoardPaneTitleGradient) + titleGradient := pluginCaptionGradient(dv.pluginDef.Background, config.GetColors().BoardPaneTitleGradient) dv.titleBar = NewGradientCaptionRow([]string{dv.pluginDef.Name}, titleGradient, textColor) // content view (Navigable Markdown) diff --git a/view/gradient_caption_row.go b/view/gradient_caption_row.go index 98de0e4..dcb80c6 100644 --- a/view/gradient_caption_row.go +++ b/view/gradient_caption_row.go @@ -133,6 +133,40 @@ func gradientFromPrimaryColor(primary tcell.Color, fallback config.Gradient) con } } +const ( + useVibrantPluginGradient = true + // increase this to get vibrance boost + vibrantBoost = 2.6 +) + +// pluginCaptionGradient selects the gradient derivation for plugin captions. +func pluginCaptionGradient(primary tcell.Color, fallback config.Gradient) config.Gradient { + if useVibrantPluginGradient { + return gradientFromPrimaryColorVibrant(primary, fallback) + } + return gradientFromPrimaryColor(primary, fallback) +} + +// gradientFromPrimaryColorVibrant derives a brighter gradient without desaturating. +func gradientFromPrimaryColorVibrant(primary tcell.Color, fallback config.Gradient) config.Gradient { + if primary == tcell.ColorDefault || !primary.Valid() { + return fallback + } + + r, g, b := primary.TrueColor().RGB() + base := [3]int{int(r), int(g), int(b)} + edge := [3]int{ + clampRGB(int(float64(base[0]) * vibrantBoost)), + clampRGB(int(float64(base[1]) * vibrantBoost)), + clampRGB(int(float64(base[2]) * vibrantBoost)), + } + + return config.Gradient{ + Start: base, + End: edge, + } +} + func lightenRGB(rgb [3]int, ratio float64) [3]int { return [3]int{ clampRGB(int(float64(rgb[0]) + (255.0-float64(rgb[0]))*ratio)), diff --git a/view/tiki_plugin_view.go b/view/tiki_plugin_view.go index de57121..d163da1 100644 --- a/view/tiki_plugin_view.go +++ b/view/tiki_plugin_view.go @@ -58,7 +58,7 @@ func (pv *PluginView) build() { if pv.pluginDef.Foreground != tcell.ColorDefault { textColor = pv.pluginDef.Foreground } - titleGradient := gradientFromPrimaryColor(pv.pluginDef.Background, config.GetColors().BoardPaneTitleGradient) + titleGradient := pluginCaptionGradient(pv.pluginDef.Background, config.GetColors().BoardPaneTitleGradient) paneNames := make([]string, len(pv.pluginDef.Panes)) for i, pane := range pv.pluginDef.Panes { paneNames[i] = pane.Name @@ -106,15 +106,21 @@ func (pv *PluginView) refresh() { if viewMode == model.ViewModeExpanded { itemHeight = config.TaskBoxHeightExpanded } - pv.panes.Clear() - pv.paneBoxes = pv.paneBoxes[:0] - selectedPane := pv.pluginConfig.GetSelectedPane() + if len(pv.paneBoxes) != len(pv.pluginDef.Panes) { + pv.paneBoxes = make([]*ScrollableList, 0, len(pv.pluginDef.Panes)) + for range pv.pluginDef.Panes { + pv.paneBoxes = append(pv.paneBoxes, NewScrollableList()) + } + } + + pv.panes.Clear() + for paneIdx := range pv.pluginDef.Panes { - // task container for this pane - paneContainer := NewScrollableList().SetItemHeight(itemHeight) - pv.paneBoxes = append(pv.paneBoxes, paneContainer) + paneContainer := pv.paneBoxes[paneIdx] + paneContainer.SetItemHeight(itemHeight) + paneContainer.Clear() isSelectedPane := paneIdx == selectedPane pv.panes.AddItem(paneContainer, 0, 1, isSelectedPane) @@ -132,12 +138,6 @@ func (pv *PluginView) refresh() { selectedIndex := pv.pluginConfig.GetSelectedIndexForPane(paneIdx) selectedRow := selectedIndex / columns - if isSelectedPane { - paneContainer.SetSelection(selectedRow) - } else { - paneContainer.SetSelection(-1) - } - numRows := (len(tasks) + columns - 1) / columns for row := 0; row < numRows; row++ { rowFlex := tview.NewFlex().SetDirection(tview.FlexColumn) @@ -160,6 +160,12 @@ func (pv *PluginView) refresh() { } paneContainer.AddItem(rowFlex) } + + if isSelectedPane { + paneContainer.SetSelection(selectedRow) + } else { + paneContainer.SetSelection(-1) + } } }