blob: 0232502b0a917b20f31cdb9162785cdbcab41f6f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  | 
// 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
	Win    *gui.Node // 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)
	UsePB  bool      // the bottom box (stack style)
	Custom func()    // a user defined close() window function
}
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() {
		if gw.UsePB {
			gw.UsePB = false
			log.Log(WARN, "Toggle() USING PB")
			gw.Win.TestDrawPB(true)
		} else {
			gw.UsePB = true
			log.Log(WARN, "Toggle() USING OLD WAY")
			gw.Win.TestDrawPB(false)
		}
		return
		// gw.Show()
	} else {
		gw.Hide()
	}
}
func (gw *GenericWindow) Show() {
	if gw == nil {
		return
	}
	if gw.Win == nil {
		return
	}
	gw.Win.Show()
	/*
		if gw.UsePB {
			log.Log(WARN, "Toggle() USING PB")
			gw.Win.TestDrawPB(false)
		} else {
			log.Log(WARN, "Toggle() USING OLD WAY")
			gw.Win.TestDrawPB(false)
		}
	*/
	return
}
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 = gui.RawWindow(title)
	gw.Win.SetVisable(false)
	// gw.Win.Make()
	gw.Win.Custom = func() {
		log.Log(WARN, "GenericWindow.Custom()")
		// sets the hidden flag to false so Toggle() works
		gw.Win.Hide()
		if gw.Custom != nil {
			gw.Custom()
		}
	}
	gw.Shelf = gw.Win.NewHorizontalBox("Shelf")
	// gw.Shelf.Vertical().SetProgName("ShelfBox")
	gw.Stack = gw.Shelf.NewVerticalBox("Stack")
	gw.Top = gw.Stack.NewVerticalBox("Top")
	gw.Middle = gw.Stack.Box().SetProgName("Middle")
	gw.Bottom = gw.Stack.NewVerticalBox("Bottom")
	gw.Group = gw.Top.NewGroup(grouptxt)
	gw.Show()
	return gw
}
  |