Skip to content

Commit

Permalink
Breaking change! Refactor widget construction methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenDang committed Jan 1, 2021
1 parent 9440d87 commit 91647e3
Show file tree
Hide file tree
Showing 25 changed files with 996 additions and 588 deletions.
16 changes: 8 additions & 8 deletions Msgbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,35 @@ func buildMsgboxButtons(buttons MsgboxButtons, callback DialogResultCallback) La
switch buttons {
case MsgboxButtonsOk:
return Layout{
Button(" Ok ", func() {
Button(" Ok ").OnClick(func() {
msgboxInvokeCallback(DialogResultOK, callback)
}),
}
case MsgboxButtonsOkCancel:
return Layout{
Line(
Button(" Ok ", func() {
Button(" Ok ").OnClick(func() {
msgboxInvokeCallback(DialogResultOK, callback)
}),
Button("Cancel", func() {
Button("Cancel").OnClick(func() {
msgboxInvokeCallback(DialogResultCancel, callback)
}),
),
}
case MsgboxButtonsYesNo:
return Layout{
Line(
Button(" Yes ", func() {
Button(" Yes ").OnClick(func() {
msgboxInvokeCallback(DialogResultYes, callback)
}),
Button(" No ", func() {
Button(" No ").OnClick(func() {
msgboxInvokeCallback(DialogResultNo, callback)
}),
),
}
default:
return Layout{
Button(" Ok ", func() {
Button(" Ok ").OnClick(func() {
msgboxInvokeCallback(DialogResultOK, callback)
}),
}
Expand Down Expand Up @@ -102,12 +102,12 @@ func PrepareMsgbox() Layout {
state.open = false
}
SetNextWindowSize(300, 0)
PopupModal(fmt.Sprintf("%s%s", state.title, msgboxId), Layout{
PopupModal(fmt.Sprintf("%s%s", state.title, msgboxId)).Layout(Layout{
Custom(func() {
// Ensure the state is valid.
Context.GetState(msgboxId)
}),
LabelWrapped(state.content),
Label(state.content).Wrapped(true),
buildMsgboxButtons(state.buttons, state.resultCallback),
}).Build()
}),
Expand Down
2 changes: 1 addition & 1 deletion ProgressIndicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (p *ProgressIndicatorWidget) Build() {
} else {
state := s.(*ProgressIndicatorState)

child := Child(fmt.Sprintf("%s-container", p.id), false, p.width, p.height, 0, Layout{
child := Child(fmt.Sprintf("%s-container", p.id)).Border(false).Size(p.width, p.height).Layout(Layout{
Custom(func() {
// Process width and height
width, height := GetAvaiableRegion()
Expand Down
6 changes: 3 additions & 3 deletions SplitLayout.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (s *SplitLayoutWidget) buildChild(id string, width, height float32, layout
PushFramePadding(0, 0)
}
}),
Child(id, !isSplitLayoutWidget && s.border, width, height, 0, s.restoreItemSpacing(layout)),
Child(id).Border(!isSplitLayoutWidget && s.border).Size(width, height).Layout(s.restoreItemSpacing(layout)),
Custom(func() {
if isSplitLayoutWidget || !s.border {
PopStyle()
Expand Down Expand Up @@ -100,14 +100,14 @@ func (s *SplitLayoutWidget) Build() {
layout = Layout{
Line(
s.buildChild(fmt.Sprintf("%s_layout1", stateId), splitLayoutState.sashPos, 0, s.layout1),
VSplitter(fmt.Sprintf("%s_vsplitter", stateId), itemSpacingX, 0, &(splitLayoutState.delta)),
VSplitter(fmt.Sprintf("%s_vsplitter", stateId), &(splitLayoutState.delta)).Size(itemSpacingX, 0),
s.buildChild(fmt.Sprintf("%s_layout2", stateId), 0, 0, s.layout2),
),
}
} else {
layout = Layout{
s.buildChild(fmt.Sprintf("%s_layout1", stateId), 0, splitLayoutState.sashPos, s.layout1),
HSplitter(fmt.Sprintf("%s_hsplitter", stateId), 0, itemSpacingY, &(splitLayoutState.delta)),
HSplitter(fmt.Sprintf("%s_hsplitter", stateId), &(splitLayoutState.delta)).Size(0, itemSpacingY),
s.buildChild(fmt.Sprintf("%s_layout2", stateId), 0, 0, s.layout2),
}
}
Expand Down
Loading

0 comments on commit 91647e3

Please sign in to comment.