new standard: GenericWindow()
This commit is contained in:
parent
e8e36ee802
commit
18fc6238df
|
@ -0,0 +1,106 @@
|
||||||
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the GPL 3.0
|
||||||
|
|
||||||
|
package gadgets
|
||||||
|
|
||||||
|
// This model works for 99.9% of all windows
|
||||||
|
// This is the Default Standard Window Model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
|
||||||
|
"go.wit.com/gui"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GenericWindow struct {
|
||||||
|
Win *BasicWindow // the window widget itself
|
||||||
|
Shelf *gui.Node // the overall box: the shelf
|
||||||
|
Stack *gui.Node // the first box is a stack
|
||||||
|
Top *gui.Node // the first item in the stack is always a shelf like box
|
||||||
|
Group *gui.Node // the first item top box is always a group
|
||||||
|
Middle *gui.Node // the middle box (shelf style)
|
||||||
|
Bottom *gui.Node // the bottom box (stack style)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gw *GenericWindow) Hidden() bool {
|
||||||
|
if gw == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if gw.Win == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return gw.Win.Hidden()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gw *GenericWindow) Toggle() {
|
||||||
|
if gw.Hidden() {
|
||||||
|
gw.Show()
|
||||||
|
} else {
|
||||||
|
gw.Hide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gw *GenericWindow) Show() {
|
||||||
|
if gw == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if gw.Win == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
gw.Win.Show()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gw *GenericWindow) Hide() {
|
||||||
|
if gw == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if gw.Win == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
gw.Win.Hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gw *GenericWindow) Disable() {
|
||||||
|
if gw == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if gw.Shelf == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
gw.Shelf.Disable()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gw *GenericWindow) Enable() {
|
||||||
|
if gw == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if gw.Shelf == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
gw.Shelf.Enable()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGenericWindow(title string, grouptxt string) *GenericWindow {
|
||||||
|
gw := new(GenericWindow)
|
||||||
|
gw.Win = RawBasicWindow(title)
|
||||||
|
gw.Win.Make()
|
||||||
|
|
||||||
|
gw.Win.Custom = func() {
|
||||||
|
log.Warn("Found Window close. setting hidden=true")
|
||||||
|
// sets the hidden flag to false so Toggle() works
|
||||||
|
gw.Win.Hide()
|
||||||
|
}
|
||||||
|
gw.Shelf = gw.Win.Box()
|
||||||
|
// gw.Shelf.Vertical().SetProgName("ShelfBox")
|
||||||
|
gw.Stack = gw.Shelf.NewVerticalBox("Stackbox")
|
||||||
|
|
||||||
|
gw.Top = gw.Stack.NewVerticalBox("Stackbox")
|
||||||
|
gw.Middle = gw.Stack.Box()
|
||||||
|
gw.Bottom = gw.Stack.Box()
|
||||||
|
|
||||||
|
gw.Group = gw.Top.NewGroup(grouptxt)
|
||||||
|
|
||||||
|
gw.Show()
|
||||||
|
|
||||||
|
return gw
|
||||||
|
}
|
Loading…
Reference in New Issue