Mercurial > projects > mde
annotate mde/gui/widget/ParentContent.d @ 176:d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 12 Sep 2009 09:14:43 +0200 |
parents | 1cbde9807293 |
children | af40e9679436 |
rev | line source |
---|---|
108
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
1 /* LICENSE BLOCK |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
2 Part of mde: a Modular D game-oriented Engine |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
3 Copyright © 2007-2008 Diggory Hardy |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
4 |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify it under the terms |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
6 of the GNU General Public License as published by the Free Software Foundation, either |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
8 |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
11 See the GNU General Public License for more details. |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
12 |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
15 |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
16 /****************************************************************************** |
147
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
17 * A pop-up widget, a switch (tab) widget, and a collapsible widget |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
18 * (all parent widgets using content). |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
19 * |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
20 * Also a border widget (parent not using content). |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
21 *****************************************************************************/ |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
22 module mde.gui.widget.ParentContent; |
108
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
23 |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
24 import mde.gui.widget.AParentWidget; |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
25 import mde.gui.widget.layout; |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
26 import mde.content.AStringContent; |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
27 import mde.gui.exception; |
108
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
28 |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
29 import tango.util.log.Log : Log, Logger; |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
30 private Logger logger; |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
31 static this () { |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
32 logger = Log.getLogger ("mde.gui.widget.ParentContent"); |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
33 } |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
34 |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
35 /****************************************************************************** |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
36 * Widget which pops up a ContentListWidget created with its content. |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
37 * |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
38 * Is a button displaying a content string, just like DisplayContentWidget. |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
39 * |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
40 * Popped up widget is a ContentListWidget created from the same creation data. |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
41 *****************************************************************************/ |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
42 class PopupMenuWidget : APopupParentWidget |
108
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
43 { |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
44 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent c) { |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
45 content_ = cast(Content)c; |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
46 WDCMinCheck (data, 3,1, content_); |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
47 super (mgr, parent, id); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
119
diff
changeset
|
48 |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
49 popup = new ContentListWidget (mgr, this, id, data, c); |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
50 subWidgets = [popup]; |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
51 |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
52 cIndex = data.ints[2]; |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
53 if (cIndex == 0) |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
54 content_.addCallback (&updateVal); |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
55 adapter = mgr.renderer.getAdapter; |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
56 adapter.text = content_.toString (cIndex); |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
57 adapter.getDimensions (mw, mh); |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
58 w = mw; |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
59 h = mh; |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
60 } |
165
bb2f1a76346d
Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
61 |
158
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
155
diff
changeset
|
62 override bool setup (uint n, uint flags) { |
165
bb2f1a76346d
Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
63 bool ret = super.setup (n, flags); |
bb2f1a76346d
Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
64 if (!(flags & 3)) return ret; |
bb2f1a76346d
Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
65 // else string or renderer (and possibly font) changed |
bb2f1a76346d
Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
66 adapter.text = content_.toString (cIndex); |
bb2f1a76346d
Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
67 wdim omw = mw, omh = mh; |
158
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
155
diff
changeset
|
68 adapter.getDimensions (mw, mh); |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
155
diff
changeset
|
69 if (omw != mw || omh != mh) { |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
155
diff
changeset
|
70 w = mw; |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
155
diff
changeset
|
71 h = mh; |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
155
diff
changeset
|
72 return true; |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
155
diff
changeset
|
73 } |
165
bb2f1a76346d
Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
74 return ret; |
158
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
155
diff
changeset
|
75 } |
165
bb2f1a76346d
Fixed a few bugs; most notably changing the translation reloads the text on PopupMenuWidgets now.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
76 |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
77 override IContent content () { |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
78 return content_; |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
79 } |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
80 |
162
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
158
diff
changeset
|
81 override bool dropContent (IContent content) { |
163
24d77c52243f
Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
162
diff
changeset
|
82 if (content_.set (content)) |
162
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
158
diff
changeset
|
83 return true; |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
158
diff
changeset
|
84 return parent.dropContent (content); |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
158
diff
changeset
|
85 } |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
158
diff
changeset
|
86 |
133
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
87 override void recursionCheck (widgetID wID, IContent c) { |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
88 if (wID is id && c is content_) |
133
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
89 throw new WidgetRecursionException (wID); |
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
90 parent.recursionCheck (wID, c); |
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
91 } |
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
92 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
93 override int clickEvent (wdabs, wdabs, ubyte b, bool state) { |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
94 if (b == 1 && state == true) { |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
95 if (!pushed) { |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
96 parentIPPW.addChildIPPW (this); |
152
c67d074a7111
Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
147
diff
changeset
|
97 parentIPPW.menuActive = mgr.positionPopup (this, popup); |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
98 pushed = true; |
133
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
99 } else if (!parentIPPW.parentMenuActive) { // if not a submenu |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
100 parentIPPW.removeChildIPPW (this); |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
101 } |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
102 } |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
103 return 0; |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
104 } |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
105 |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
106 override void removedIPPW () { |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
107 super.removedIPPW; |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
108 pushed = false; |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
109 } |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
110 |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
111 override void underMouse (bool state) { |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
112 if (state && !pushed && parentIPPW.menuActive) { |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
113 parentIPPW.addChildIPPW (this); |
152
c67d074a7111
Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
147
diff
changeset
|
114 menuActive = mgr.positionPopup (this, popup, parentIPPW.parentMenuActive); |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
115 pushed = true; |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
116 } |
117
aba2dd815a1f
Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
117 } |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
118 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
119 override void draw () { |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
120 mgr.renderer.drawButton (x,y, w,h, pushed); |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
121 adapter.draw (x,y); |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
122 } |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
123 |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
124 protected: |
170
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
125 void updateVal (IContent) { // callback |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
126 adapter.text = content_.toString(cIndex); |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
127 wdim omw = mw, omh = mh; |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
128 adapter.getDimensions (mw, mh); |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
129 if (omw != mw) |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
130 parent.minWChange (this, mw); |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
131 if (omh != mh) |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
132 parent.minHChange (this, mh); |
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
133 } |
158
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
155
diff
changeset
|
134 |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
135 bool pushed = false; |
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
136 IRenderer.TextAdapter adapter; |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
137 Content content_; |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
138 int cIndex; |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
139 } |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
140 |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
141 /** A "tab" widget: it doesn't display the tabs, but shows one of a number of |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
142 * widgets dependant on an EnumContent. |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
143 * |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
144 * Sizability is set once. Min-size is updated when switching. */ |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
145 class SwitchWidget : AParentWidget |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
146 { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
147 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent c) { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
148 super (mgr, parent, id); |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
149 content_ = cast(EnumContent) c; |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
150 if (content_ is null || (subWidgets.length = content_.list.length) == 0) |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
151 throw new ContentException (this); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
152 WDCheck (data, 1, subWidgets.length); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
153 |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
154 foreach (i,sc; content_.list) |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
155 subWidgets[i] = mgr.makeWidget (this, data.strings[i], sc); |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
156 currentW = subWidgets[content_()]; |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
157 |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
158 content_.addCallback (&switchWidget); |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
159 } |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
160 |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
161 override IContent content () { |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
162 return content_; |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
163 } |
172
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
164 override void setContent (IContent) { |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
165 logger.warn ("SwitchWidget: resetting content is not yet supported"); |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
166 } |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
167 |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
168 override bool setup (uint n, uint flags) { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
169 bool r = super.setup (n, flags); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
170 if (r) { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
171 mw = currentW.minWidth; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
172 mh = currentW.minHeight; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
173 w = currentW.width; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
174 h = currentW.height; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
175 static if (SIZABILITY & SIZABILITY_ENUM.START_TRUE) |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
176 isWS = isHS = true; |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
177 foreach (i,sc; content_.list) { |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
178 static if (SIZABILITY == SIZABILITY_ENUM.ANY_SUBWIDGETS) { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
179 isWS |= subWidgets[i].isWSizable; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
180 isHS |= subWidgets[i].isHSizable; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
181 } else static if (SIZABILITY == SIZABILITY_ENUM.ALL_SUBWIDGETS) { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
182 isWS &= subWidgets[i].isWSizable; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
183 isHS &= subWidgets[i].isHSizable; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
184 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
185 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
186 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
187 return r; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
188 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
189 |
170
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
190 override void recursionCheck (widgetID wID, IContent c) { |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
191 if (wID is id && c is content_) |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
192 throw new WidgetRecursionException (wID); |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
193 parent.recursionCheck (wID, c); |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
194 } |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
195 |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
196 override void minWChange (IChildWidget widget, wdim nmw) { |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
197 if (widget is currentW) { |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
198 mw = nmw; |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
199 parent.minWChange (this, nmw); |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
200 } else { // changes won't be seen, but we must follow function spec |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
201 if (widget.width < nmw) |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
202 widget.setWidth (nmw, -1); |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
203 } |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
204 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
205 override void minHChange (IChildWidget widget, wdim nmh) { |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
206 if (widget is currentW) { |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
207 mh = nmh; |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
208 parent.minHChange (this, nmh); |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
209 } else { |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
210 if (widget.height < nmh) |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
211 widget.setHeight (nmh, -1); |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
212 } |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
213 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
214 |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
215 override bool isWSizable () { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
216 return isWS; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
217 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
218 override bool isHSizable () { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
219 return isHS; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
220 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
221 |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
222 override void setWidth (wdim nw, int dir) { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
223 w = (nw >= mw ? nw : mw); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
224 currentW.setWidth (w, dir); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
225 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
226 override void setHeight (wdim nh, int dir) { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
227 h = (nh >= mh ? nh : mh); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
228 currentW.setHeight (h, dir); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
229 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
230 |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
231 override void setPosition (wdim nx, wdim ny) { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
232 x = nx; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
233 y = ny; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
234 currentW.setPosition (nx,ny); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
235 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
236 |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
237 override IChildWidget getWidget (wdim cx, wdim cy) { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
238 return currentW.getWidget (cx, cy); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
239 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
240 |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
241 override void draw () { |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
242 currentW.draw; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
243 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
244 |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
245 protected: |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
246 // callback on content_ |
170
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
247 void switchWidget (IContent) { |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
248 currentW = subWidgets[content_()]; |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
249 mw = currentW.minWidth; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
250 mh = currentW.minHeight; |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
251 parent.minWChange (this, mw); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
252 parent.minHChange (this, mh); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
253 // Parent may change size. If it doesn't, we must set child's size. |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
254 // We can't tell if it did, so do it (call will be fast if size isn't |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
255 // changed anyway). |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
256 currentW.setWidth (w, -1); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
257 currentW.setHeight (h, -1); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
258 currentW.setPosition (x,y); |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
259 } |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
260 |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
261 IChildWidget currentW; |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
262 EnumContent content_; |
143
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
263 |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
264 bool isWS, isHS; // no infrastructure for changing sizability, so need to fix it. |
2ac3e0012788
Added a simple Slider widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
265 } |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
266 |
170
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
267 /** A collapsible widget: shows/hides a child dependant on an IBoolContent. |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
268 * |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
269 * Sizability is set once. Min-size is changed (but cannot force size to 0). |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
270 * |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
271 * Uses its content as a switch, which means content cannot be passed through. |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
272 * A builtin button would improve this. */ |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
273 class CollapsibleWidget : AParentWidget |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
274 { |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
275 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent c) { |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
276 super (mgr, parent, id); |
170
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
277 content_ = cast(IBoolContent) c; |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
278 WDCCheck (data, 1, 1, content_); |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
279 |
155
4e8819b65882
Changed collapsible widget in GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
152
diff
changeset
|
280 subWidgets = [mgr.makeWidget (this, data.strings[0], c)]; |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
281 |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
282 content_.addCallback (&cbDisplay); |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
283 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
284 |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
285 override bool setup (uint n, uint flags) { |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
286 bool r = super.setup (n, flags); |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
287 if (r) { |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
288 display = content_(); |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
289 if (display) { |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
290 mw = subWidgets[0].minWidth; |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
291 mh = subWidgets[0].minHeight; |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
292 w = subWidgets[0].width; |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
293 h = subWidgets[0].height; |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
294 debug assert (w >= mw && h >= mh); |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
295 } |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
296 // else dims remain 0 |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
297 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
298 return r; |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
299 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
300 |
170
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
301 override void recursionCheck (widgetID wID, IContent c) { |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
302 if (wID is id && c is content_) |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
303 throw new WidgetRecursionException (wID); |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
304 parent.recursionCheck (wID, c); |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
305 } |
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
306 |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
307 override IContent content () { |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
308 return content_; |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
309 } |
172
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
310 override void setContent (IContent c) { |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
311 auto cont = cast(IBoolContent) c; |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
312 if (!cont) { |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
313 logger.warn ("CollapsibleWidget: invalid content set: {}; ignoring", c); |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
314 return; |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
315 } |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
316 content_ = cont; |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
317 cbDisplay (content_); |
172
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
318 } |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
319 |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
320 override void minWChange (IChildWidget widget, wdim nmw) { |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
321 debug assert (widget is subWidgets[0]); |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
322 if (display) { |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
323 mw = nmw; |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
324 parent.minWChange (this, nmw); |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
325 } else // update widget without affecting self |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
326 super.minWChange (widget, nmw); |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
327 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
328 override void minHChange (IChildWidget widget, wdim nmh) { |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
329 debug assert (widget is subWidgets[0]); |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
330 if (display) { |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
331 mh = nmh; |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
332 parent.minHChange (this, nmh); |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
333 } else |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
334 super.minHChange (widget, nmh); |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
335 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
336 |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
337 // Doesn't change: |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
338 override bool isWSizable () { |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
339 return subWidgets[0].isWSizable; |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
340 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
341 override bool isHSizable () { |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
342 return subWidgets[0].isHSizable; |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
343 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
344 |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
345 override void setWidth (wdim nw, int dir) { |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
346 w = (nw >= mw ? nw : mw); |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
347 if (display) |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
348 subWidgets[0].setWidth (w, dir); |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
349 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
350 override void setHeight (wdim nh, int dir) { |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
351 h = (nh >= mh ? nh : mh); |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
352 if (display) |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
353 subWidgets[0].setHeight (h, dir); |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
354 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
355 |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
356 override void setPosition (wdim nx, wdim ny) { |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
357 x = nx; |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
358 y = ny; |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
359 if (display) |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
360 subWidgets[0].setPosition (nx,ny); |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
361 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
362 |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
363 override IChildWidget getWidget (wdim cx, wdim cy) { |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
364 if (display) |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
365 return subWidgets[0].getWidget (cx, cy); |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
366 else return this; |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
367 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
368 |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
369 override void draw () { |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
370 if (display) |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
371 subWidgets[0].draw; |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
372 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
373 |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
374 protected: |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
375 // callback on content_ |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
376 void cbDisplay (IContent) { |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
377 if (display == content_()) return; |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
378 display = content_(); |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
379 logger.trace ("{}.cbDisplay ({})", id, display); |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
380 if (display) { |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
381 mw = subWidgets[0].minWidth; |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
382 mh = subWidgets[0].minHeight; |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
383 } else { |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
384 mw = mh = 0; |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
385 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
386 parent.minWChange (this, mw); |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
387 parent.minHChange (this, mh); |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
388 if (!display) return; |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
389 // set incase parent didn't: |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
390 subWidgets[0].setWidth (w, -1); |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
391 subWidgets[0].setHeight (h, -1); |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
392 subWidgets[0].setPosition (x,y); |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
393 } |
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
394 |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
395 bool display = false; |
170
e45226d3deae
Context menu services not applicable to the current type can now be hidden.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
396 IBoolContent content_; |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
143
diff
changeset
|
397 } |
147
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
398 |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
399 /** Puts a border around its child widget. |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
400 * |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
401 * This doesn't allow dragging like widgets in a floating area. |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
402 * |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
403 * data.ints[1] is interpreted as flags from IRenderer.Border.BTYPE. |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
404 * data.strings[0] is an ID for the child widget. */ |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
405 class BorderWidget : AParentWidget |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
406 { |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
407 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent c) { |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
408 super (mgr, parent, id); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
409 WDCheck (data, 2, 1); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
410 |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
411 subWidgets = [mgr.makeWidget (this, data.strings[0], c)]; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
412 borderType = cast(BTYPE) data.ints[1]; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
413 } |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
414 |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
415 override bool setup (uint n, uint flags) { |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
416 bool noChanges = !subWidgets[0].setup (n, flags); |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
417 if (noChanges && !(flags & 1)) return false; |
147
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
418 |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
419 border = mgr.renderer.getBorder (borderType, false, false); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
420 mw = subWidgets[0].minWidth + border.x1 + border.x2; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
421 mh = subWidgets[0].minHeight + border.y1 + border.y2; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
422 if (w < mw || !subWidgets[0].isWSizable) w = mw; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
423 if (h < mh || !subWidgets[0].isHSizable) h = mh; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
424 return true; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
425 } |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
426 |
172
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
427 override void setContent (IContent c) { |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
428 subWidgets[0].setContent = c; |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
429 } |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
170
diff
changeset
|
430 |
147
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
431 override void setWidth (wdim nw, int) { |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
432 debug assert (nw >= mw); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
433 w = nw; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
434 subWidgets[0].setWidth (w - border.x1 - border.x2, -1); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
435 } |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
436 override void setHeight (wdim nh, int) { |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
437 debug assert (nh >= mh); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
438 h = nh; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
439 subWidgets[0].setHeight (h - border.y1 - border.y2, -1); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
440 } |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
441 |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
442 override bool isWSizable () { |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
443 return subWidgets[0].isWSizable; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
444 } |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
445 override bool isHSizable () { |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
446 return subWidgets[0].isHSizable; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
447 } |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
448 |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
449 override void setPosition (wdim nx, wdim ny) { |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
450 x = nx; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
451 y = ny; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
452 subWidgets[0].setPosition (x + border.x1, y + border.y1); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
453 } |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
454 |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
455 override void minWChange (IChildWidget widget, wdim nmw) { |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
456 debug assert (widget is subWidgets[0]); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
457 mw = nmw + border.x1 + border.x2; |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
458 parent.minWChange (this, mw); |
147
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
459 } |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
460 override void minHChange (IChildWidget widget, wdim nmh) { |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
461 debug assert (widget is subWidgets[0]); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
462 mh = nmh + border.y1 + border.y2; |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
463 parent.minHChange (this, mh); |
147
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
464 } |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
465 |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
466 override void draw () { |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
467 mgr.renderer.drawBorder (&border, x, y, w, h); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
468 subWidgets[0].draw; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
469 } |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
470 |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
471 override IChildWidget getWidget (wdim cx, wdim cy) { |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
472 debug assert (cx >= x && cx < x + w && cy >= y && cy < y + h, "getWidget: not on widget (code error)"); |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
473 |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
474 if (subWidgets[0].onSelf (cx, cy)) |
168
da8d3091fdaf
More work on the context menu: now roughly usable like an ordinary context menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
165
diff
changeset
|
475 return subWidgets[0].getWidget (cx, cy); |
147
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
476 else |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
477 return this; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
478 } |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
479 |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
480 protected: |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
481 invariant { |
174
3d58adc17d20
Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents:
173
diff
changeset
|
482 /+TODO |
3d58adc17d20
Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents:
173
diff
changeset
|
483 assert (subWidgets.length == 1); |
3d58adc17d20
Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents:
173
diff
changeset
|
484 assert (mw == subWidgets[0].minWidth + border.x1 + border.x2); |
3d58adc17d20
Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents:
173
diff
changeset
|
485 assert (mh == subWidgets[0].minHeight + border.y1 + border.y2); |
3d58adc17d20
Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents:
173
diff
changeset
|
486 +/ |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
487 } |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
488 |
147
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
489 alias IRenderer.Border.BTYPE BTYPE; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
490 alias IRenderer.Border.RESIZE RESIZE; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
491 BTYPE borderType; // what type of border to put around the widget |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
492 IRenderer.Border border; |
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
493 } |