lxn / walk

A Windows GUI toolkit for the Go Programming Language
Other
6.8k stars 885 forks source link

Format of dialog box with checkboxes not working after recent update. #654

Closed StephanVerbeeck closed 4 years ago

StephanVerbeeck commented 4 years ago

Expected: The following code did display 4 lines with a label and checkbox (before the update) Observed: Only the checkbox called "View extern" is shown,

Related: formatting throughout my accounting program (based on GO and WALK) is not performed. Even simple resize of main window is no longer resizing its children. Related to issue #650

Schermafdruk 2019-11-18 15 11 52

package main

import (
    "github.com/lxn/walk"
    . "github.com/lxn/walk/declarative"
)

func RunDocumentTypeDialog(documentType *DocumentType) (int, error) {

    var dataBinder *walk.DataBinder
    var dlg *walk.Dialog
    var acceptPB *walk.PushButton
    var cancelPB *walk.PushButton
    var allowTypeChange = documentType.ID == ""

    return Dialog{
        AssignTo:      &dlg,
        Title:         "DocumentType",
        Name:          "DocumentTypeDialog",
        Icon:          appIcon,
        Font:          accountSettings.Font,
        DefaultButton: &acceptPB,
        CancelButton:  &cancelPB,
        Layout:        VBox{SpacingZero: true, MarginsZero: true},
        MinSize:       Size{400, 200},
        Children: []Widget{
            ScrollView{
                DataBinder: DataBinder{
                    AssignTo:   &dataBinder,
                    DataSource: documentType,
                },
                Layout: VBox{},
                Children: []Widget{
                    GroupBox{
                        Title:   "DocumentType",
                        Name:    "DocumentTypeBox",
                        MinSize: Size{300, 100},
                        MaxSize: Size{1000, 100},
                        Layout:  Grid{Columns: 3},
                        Children: []Widget{
                            Label{Text: "type"},
                            LineEdit{Text: Bind("ID"), Enabled: allowTypeChange, ColumnSpan: 2},

                            Label{Text: "description"},
                            LineEdit{Text: Bind("Title"), ColumnSpan: 2},

                            Label{Text: "view intern"},
                            CheckBox{Checked: Bind("ViewIntern")},
                            Label{Text: "( use internal viewer )"},

                            Label{Text: "view extern"},
                            CheckBox{Checked: Bind("ViewExtern")},
                            Label{Text: "( use external viewer )"},

                            Label{Text: "ignore"},
                            CheckBox{Checked: Bind("Ignore")},
                            Label{Text: "( ignore file / ignore external viewer )"},

                            Label{Text: "strict"},
                            CheckBox{Checked: Bind("Strict")},
                            Label{Text: "( overrule system default viewer )"},

                            Label{Text: "exe"},
                            ComboBox{Value: Bind("Exe"), Editable: true, Model: ListPathRunningExe(documentType.Exe), ColumnSpan: 2},
                        },
                    },
                    Composite{
                        Layout: HBox{},
                        Children: []Widget{
                            HSpacer{},
                            PushButton{
                                AssignTo: &acceptPB,
                                Text:     "OK",
                                MinSize:  Size{100, 40},
                                MaxSize:  Size{100, 40},
                                OnClicked: func() {
                                    dataBinder.Submit()
                                    dlg.Accept()
                                },
                            },
                            PushButton{
                                AssignTo: &cancelPB,
                                Text:     "Cancel",
                                MinSize:  Size{100, 40},
                                MaxSize:  Size{100, 40},
                                OnClicked: func() {
                                    dlg.Cancel()
                                },
                            },
                        },
                    },
                },
            },
        },
    }.Run(mainWindow)
}
lxn commented 4 years ago

Removal or increasing height of MaxSize: Size{1000, 100}, brings them widgets back.

StephanVerbeeck commented 4 years ago

Removal or increasing height of MaxSize: Size{1000, 100}, brings them widgets back.

Tried that and it works. It fixes all layout problems in form dialogs related to height (was an error of me caused by that the max height param in the past did not work everywhere). I fixed it by only setting the width param of MaxSize but not the height param (as follows)

    GroupBox{
        Title:   "Who am I",
        MinSize: Size{400, 100},
        MaxSize: Size{800, 0},
        . . .

2 problems remain

1) new tabs in a tab widget are not shown 2) a scrollview with a list of groupboxes as children (widgets) only gets wider when resizing the main window but it does not get smaller again when resizing the main windows to a smaller size. Width can only be restored by deleting the GUIsettings.ini file when the program is not running.

                TabPage{
                    AssignTo: &tabPageSettings,
                    Name:     "Settings",
                    Title:    "Settings",
                    Layout:   VBox{SpacingZero: true, MarginsZero: true},
                    Children: []Widget{
                        ScrollView{
                            Layout:   Flow{},
                            Children: SettingWidgets(),
                        },
                    },
                },

var (
    guiSettings        = walk.NewIniFileSettings("GUI_Settings.ini")
)

Hi Alexander, Given the large number of helper functions in both layout problems (that were introduced by the latest WALK update) I would like to give you access to the full source code. Like that you would have a commercial/complex program to test your library with. can you send a small email to digitronic at telenet dot be so that we can arrange access for you

StephanVerbeeck commented 4 years ago

Rescued my project by using local fork of old version. Still have to fix several functionality that broke by recent commits. You really have to be more careful when doing a commit guys. Some testing is advised, sorry to miss out on all the new features but an unstable version for 12 months is a no go for me.