Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hswidget/PaletteSelectWidget: refactor #312

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
hswidget/PaletteSelectWidget: fix bug, when was unable to close widge…
…t with `X` button
  • Loading branch information
gucio321 committed Jul 4, 2021
commit e7562a2d91a07a0c102c2491d802bb23e5380385
44 changes: 23 additions & 21 deletions hswidget/selectpalettewidget/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
type SelectPaletteWidget struct {
mpqExplorer *hsmpqexplorer.MPQExplorer
projectExplorer *hsprojectexplorer.ProjectExplorer
isOpen *bool
id string
saveCB func(colors *[256]d2interface.Color)
closeCB func()
Expand Down Expand Up @@ -101,28 +102,29 @@ func NewSelectPaletteWidget(
return result
}

func (p *SelectPaletteWidget) IsOpen(isOpen *bool) *SelectPaletteWidget {
p.isOpen = isOpen
return p
}

// Build builds a widget
func (p *SelectPaletteWidget) Build() {
// always true (we don't use this feature in this case
isOpen := true
giu.Layout{
giu.PopupModal("##" + p.id + "popUpSelectPalette").IsOpen(&isOpen).Layout(giu.Layout{
giu.Child("##"+p.id+"popUpSelectPaletteChildWidget").Size(paletteSelectW, paletteSelectH).Layout(giu.Layout{
p.projectExplorer.GetProjectTreeNodes(),
giu.Layout(p.mpqExplorer.GetMpqTreeNodes()),
giu.Separator(),
giu.Button("Don't use any palette##"+p.id+"selectPaletteDonotUseAny").
Size(actionButtonW, actionButtonH).
OnClick(func() {
p.saveCB(nil)
p.closeCB()
}),
giu.Button("Exit##"+p.id+"selectPaletteExit").
Size(actionButtonW, actionButtonH).
OnClick(func() {
p.closeCB()
}),
}),
giu.PopupModal("##" + p.id + "popUpSelectPalette").IsOpen(p.isOpen).Layout(giu.Layout{
giu.Child("##"+p.id+"popUpSelectPaletteChildWidget").Size(paletteSelectW, paletteSelectH).Layout(giu.Layout{
p.projectExplorer.GetProjectTreeNodes(),
giu.Layout(p.mpqExplorer.GetMpqTreeNodes()),
giu.Separator(),
giu.Button("Don't use any palette##"+p.id+"selectPaletteDonotUseAny").
Size(actionButtonW, actionButtonH).
OnClick(func() {
p.saveCB(nil)
p.closeCB()
}),
giu.Button("Exit##"+p.id+"selectPaletteExit").
Size(actionButtonW, actionButtonH).
OnClick(func() {
p.closeCB()
}),
}),
}.Build()
}).Build()
}
2 changes: 1 addition & 1 deletion hswindow/hseditor/hsdc6editor/dc6_editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (e *DC6Editor) Build() {
func() {
e.selectPalette = false
},
)
).IsOpen(&e.selectPalette)
}

e.Layout(e.selectPaletteWidget)
Expand Down
4 changes: 2 additions & 2 deletions hswindow/hseditor/hsdcceditor/dcc_editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ func (e *DCCEditor) Build() {
func() {
e.selectPalette = false
},
)
).IsOpen(&e.selectPalette)
}

e.Layout(g.Layout{e.selectPaletteWidget})
e.Layout(e.selectPaletteWidget)
}

// UpdateMainMenuLayout updates main menu to it contain editor's options
Expand Down
2 changes: 1 addition & 1 deletion hswindow/hseditor/hsdt1editor/dt1_editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (e *DT1Editor) Build() {
func() {
e.selectPalette = false
},
)
).IsOpen(&e.selectPalette)
}

e.Layout(g.Layout{e.selectPaletteWidget})
Expand Down