mirror of
https://github.com/boolean-maybe/tiki
synced 2026-04-21 13:37:20 +00:00
Merge pull request #7 from boolean-maybe/fix/fix-scrolling-gradient
fix scrolling and gradient in plugins
This commit is contained in:
commit
c732bf751f
4 changed files with 55 additions and 15 deletions
|
|
@ -87,4 +87,4 @@ def calculate_average(numbers):
|
|||
return sum(numbers) / len(numbers)
|
||||
```
|
||||
|
||||
Happy tiking!
|
||||
Happy tiking!
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue