Skip to content

Commit

Permalink
Float the desktop number over window icons
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Jan 22, 2024
1 parent 37f9400 commit 3af4cb5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/desktops/desktops.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (d *desktops) Shortcuts() map[*fynedesk.Shortcut]func() {
}

func (d *desktops) StatusAreaWidget() fyne.CanvasObject {
return container.NewStack(d.gui.ui, d.gui.wins)
return container.NewStack(d.gui.buttons, d.gui.wins, d.gui.labels)
}

func (d *desktops) setDesktop(id int) {
Expand Down
25 changes: 17 additions & 8 deletions modules/desktops/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,30 @@ import (
)

type pager struct {
ui fyne.CanvasObject
wins *fyne.Container
buttons, labels *fyne.Container
wins *fyne.Container
}

func newPager(d *desktops) *pager {
p := &pager{wins: container.NewWithoutLayout()}

items := make([]fyne.CanvasObject, deskCount)
buttons := make([]fyne.CanvasObject, deskCount)
labels := make([]fyne.CanvasObject, deskCount)
for i := 0; i < deskCount; i++ {
id := strconv.Itoa(i + 1)
deskID := i
items[i] = widget.NewButton(id, func() {
buttons[i] = widget.NewButton("", func() {
d.setDesktop(deskID)
})
labels[i] = widget.NewLabelWithStyle(id, fyne.TextAlignCenter, fyne.TextStyle{Bold: true})
}

if fynedesk.Instance() != nil && fynedesk.Instance().Settings().NarrowWidgetPanel() {
p.ui = container.NewGridWithColumns(1, items...)
p.buttons = container.NewGridWithColumns(1, buttons...)
p.labels = container.NewGridWithColumns(1, labels...)
} else {
p.ui = container.NewGridWithColumns(4, items...)
p.buttons = container.NewGridWithColumns(4, buttons...)
p.labels = container.NewGridWithColumns(4, labels...)
}
p.refresh()
fynedesk.Instance().WindowManager().AddStackListener(p)
Expand Down Expand Up @@ -66,15 +70,20 @@ func (p *pager) refreshFrom(oldID int) {
wins := fynedesk.Instance().WindowManager().Windows()

var rects []fyne.CanvasObject
for i, b := range p.ui.(*fyne.Container).Objects {
for i, b := range p.buttons.Objects {
l := p.labels.Objects[i]
if i == desk.Desktop() {
b.(*widget.Button).Importance = widget.HighImportance
l.(*widget.Label).Importance = widget.LowImportance
} else {
b.(*widget.Button).Importance = widget.MediumImportance
l.(*widget.Label).Importance = widget.MediumImportance
}

b.Refresh()
l.Refresh()
}
pivot := p.ui.(*fyne.Container).Objects[oldID]
pivot := p.buttons.Objects[oldID]

for j := len(wins) - 1; j >= 0; j-- {
win := wins[j]
Expand Down

0 comments on commit 3af4cb5

Please sign in to comment.