draftingff

This commit is contained in:
5684185+vsariola@users.noreply.github.com
2025-05-05 13:35:25 +03:00
parent db48c9e523
commit b1e9e0c974
8 changed files with 59 additions and 56 deletions

View File

@ -16,7 +16,6 @@ import (
"gioui.org/op/clip"
"gioui.org/op/paint"
"gioui.org/unit"
"gioui.org/widget/material"
"github.com/vsariola/sointu/tracker"
)
@ -34,10 +33,16 @@ type DragList struct {
}
type FilledDragListStyle struct {
dragList *DragList
HoverColor color.NRGBA
SelectedColor color.NRGBA
CursorColor color.NRGBA
dragList *DragList
HoverColor color.NRGBA
Cursor struct {
Active color.NRGBA
Inactive color.NRGBA
}
Selection struct {
Active color.NRGBA
Inactive color.NRGBA
}
ScrollBarWidth unit.Dp
element, bg func(gtx C, i int) D
}
@ -46,14 +51,14 @@ func NewDragList(model tracker.List, axis layout.Axis) *DragList {
return &DragList{TrackerList: model, List: &layout.List{Axis: axis}, HoverItem: -1, ScrollBar: &ScrollBar{Axis: axis}}
}
func FilledDragList(th *material.Theme, dragList *DragList, element, bg func(gtx C, i int) D) FilledDragListStyle {
func FilledDragList(th *Theme, dragList *DragList, element, bg func(gtx C, i int) D) FilledDragListStyle {
return FilledDragListStyle{
dragList: dragList,
element: element,
bg: bg,
HoverColor: dragListHoverColor,
SelectedColor: dragListSelectedColor,
CursorColor: cursorColor,
HoverColor: hoveredColor(th.Selection.Active),
Cursor: th.Cursor,
Selection: th.Selection,
ScrollBarWidth: unit.Dp(10),
}
}
@ -147,12 +152,16 @@ func (s FilledDragListStyle) Layout(gtx C) D {
var color color.NRGBA
if s.dragList.TrackerList.Selected() == index {
if s.dragList.focused {
color = s.CursorColor
color = s.Cursor.Active
} else {
color = s.SelectedColor
color = s.Cursor.Inactive
}
} else if between(s.dragList.TrackerList.Selected(), index, s.dragList.TrackerList.Selected2()) {
color = s.SelectedColor
if s.dragList.focused {
color = s.Selection.Active
} else {
color = s.Selection.Inactive
}
} else if s.dragList.HoverItem == index {
color = s.HoverColor
}