File is now configurable

This commit is contained in:
Sasha Koshka 2023-03-23 15:55:18 -04:00
parent 6c8ff55dc1
commit 6638a471c7
2 changed files with 23 additions and 7 deletions

View File

@ -171,14 +171,16 @@ func (element *DirectoryView) Child (index int) (child elements.Element) {
}
func (element *DirectoryView) HandleMouseDown (x, y int, button input.Button) {
var file *File
for _, entry := range element.children {
if image.Pt(x, y).In(entry.Bounds) {
file = entry.File
if button == input.ButtonLeft {
var file *File
for _, entry := range element.children {
if image.Pt(x, y).In(entry.Bounds) {
file = entry.File
}
}
if file != nil {
file.SetSelected(!file.Selected())
}
}
if file != nil {
file.SetSelected(!file.Selected())
}
element.Propagator.HandleMouseDown(x, y, button)
}

View File

@ -141,6 +141,20 @@ func (element *File) HandleMouseUp (x, y int, button input.Button) {
element.drawAndPush()
}
// SetTheme sets the element's theme.
func (element *File) SetTheme (new theme.Theme) {
if new == element.theme.Theme { return }
element.theme.Theme = new
element.drawAndPush()
}
// SetConfig sets the element's configuration.
func (element *File) SetConfig (new config.Config) {
if new == element.config.Config { return }
element.config.Config = new
element.drawAndPush()
}
func (element *File) state () theme.State {
return theme.State {
Disabled: !element.Enabled(),