annotate mde/gui/renderer/IRenderer.d @ 109:2a1428ec5344

Optional, visible spacing in grid layouts.
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 04 Dec 2008 10:32:20 +0000
parents c9fc2d303178
children 1655693702fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
1 /* LICENSE BLOCK
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
2 Part of mde: a Modular D game-oriented Engine
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
3 Copyright © 2007-2008 Diggory Hardy
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
4
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
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
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
6 of the GNU General Public License as published by the Free Software Foundation, either
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
7 version 2 of the License, or (at your option) any later version.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
8
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
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;
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
11 See the GNU General Public License for more details.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
12
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
13 You should have received a copy of the GNU General Public License
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
15
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
16 /** Interface for the renderer. This is planned to replace decoration.d */
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
17 module mde.gui.renderer.IRenderer;
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
18
80
ea58f277f487 Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
19 public import mde.gui.types;
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
20 import mde.font.font;
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
21
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
22 /** Interface for renderers.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
23 *
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
24 * Renderers provide unified drawing methods for widget, e.g. to draw a window background, a frame,
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
25 * or a button. The renderer will effectively be synonymous with the theme, except that a scripted
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
26 * renderer may also be available.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
27 *
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
28 * The renderer is intended to be per-GUI. */
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
29 interface IRenderer
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
30 {
97
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
31 //BEGIN Types
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
32 /** For floating widget borders. Like TextAdapter above, could be more flexible. */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
33 struct Border {
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
34 /** Border type.
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
35 *
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
36 * No border, small non-functional border, movement only border, resize only border, or
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
37 * full border. */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
38 enum BTYPE : int {
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
39 NONE = 0, SMALL = 1, LARGE = 2, MOVE = 4, RESIZE = 8, BOTH = MOVE | RESIZE
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
40 }
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
41 /** Which edges of a window are being resized.
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
42 *
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
43 * E.g. X1 == left, X2 | Y1 == right and top. */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
44 enum RESIZE : int {
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
45 NONE = 0x0, X1 = 0x1, X2 = 0x2, Y1 = 0x4, Y2 = 0x8
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
46 }
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
47
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
48 wdim x1,x2; /// First and second (lef & right) horizontal borders
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
49 wdim y1,y2; /// First and second vertical borders
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
50 RESIZE capability; /// Which resizes are possible.
38
8c4c96f04e7f Windows can now be resized!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
51
97
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
52 void opAddAssign (Border d) {
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
53 x1 += d.x1;
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
54 x2 += d.x2;
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
55 y1 += d.y1;
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
56 y2 += d.y2;
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
57 }
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
58
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
59 /** Used to tell if a click on a window's border is for resizing or moving.
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
60 *
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
61 * Depends on setSizable's parameters.
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
62 *
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
63 * Params:
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
64 * cx =
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
65 * cy = click coordinates relative to window border
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
66 * w =
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
67 * h = window size
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
68 *
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
69 * Returns:
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
70 * RESIZE = Describes whether the click resizes or moves the widget. */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
71 RESIZE getResize (wdim cx, wdim cy, wdim w, wdim h) {
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
72 RESIZE r = RESIZE.NONE;
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
73 if (cx + cy < x1 + y1)
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
74 r = RESIZE.X1 | RESIZE.Y1;
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
75 else if (cx + h - cy < x1 + y2)
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
76 r = RESIZE.X1 | RESIZE.Y2;
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
77 else if (w - cx + cy < x2 + y1)
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
78 r = RESIZE.X2 | RESIZE.Y1;
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
79 else if (w - cx + h - cy < x2 + y2)
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
80 r = RESIZE.X2 | RESIZE.Y2;
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
81 return r & capability;
38
8c4c96f04e7f Windows can now be resized!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
82 }
8c4c96f04e7f Windows can now be resized!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
83 }
8c4c96f04e7f Windows can now be resized!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
84
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
85 /** For drawing text - one instance per string.
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
86 *
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
87 * NOTE: currently inflexible. Could use (function) pointers, class interfaces or struct
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
88 * interfaces when available to allow flexibility. */
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
89 struct TextAdapter {
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
90 char[] text () {
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
91 return content;
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
92 }
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
93 void text (char[] str) {
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
94 content = str;
99
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 97
diff changeset
95 textCache.cacheVer = -1; // force update
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
96 }
99
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 97
diff changeset
97
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
98 void colour (int colour = 0xFFFFFF) {
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
99 colour_ = Colour (colour);
99
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 97
diff changeset
100 }
100
0ea4a3e651ae There is now a position marker for text editing.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
101
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
102 /** If not size_t.max, an edit marker is drawn before character index. */
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
103 void index (size_t index = size_t.max) {
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
104 index_ = index;
100
0ea4a3e651ae There is now a position marker for text editing.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
105 }
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
106
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
107 void getDimensions (out wdsize w, out wdsize h) {
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
108 font.updateBlock (content, textCache);
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
109 w = cast(wdim) textCache.w;
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
110 h = cast(wdim) textCache.h;
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
111 }
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
112
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
113 void draw (wdabs x, wdabs y) {
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
114 font.textBlock (x,y, content, textCache, colour_, index_);
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
115 }
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
116
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
117 char[] content;
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
118 TextBlock textCache;
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
119 size_t index_;
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 100
diff changeset
120 Colour colour_;
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
121 FontStyle font;
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
122 }
97
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
123 //END Types
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
124
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
125 //BEGIN Methods
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
126 /** Returns a Border containing dimensions.
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
127 *
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
128 * The dimensions may depend on whether the widget is resizable (horizontally and vertically).
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
129 */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
130 Border getBorder (Border.BTYPE type, bool wSizable, bool hSizable);
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
131
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
132 /** Return the renderer's between-widget spacing (for layout widgets). */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
133 wdim layoutSpacing ();
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
134
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
135 /** Restrict following draw operations to given box.
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
136 *
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
137 * Restrict "pushes" a restriction onto a stack; relax must be called afterwards to "pop" the
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
138 * restriction. */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
139 void restrict (wdim x, wdim y, wdim w, wdim h);
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
140 void relax (); /// ditto
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
141
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
142 /** Draw a window border plus background. */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
143 void drawWindow (Border* border, wdim x, wdim y, wdim w, wdim h);
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
144
109
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 108
diff changeset
145 /** Draw vertical and horizontal spacers.
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 108
diff changeset
146 *
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 108
diff changeset
147 * x,y and w,h are the position and size of the grid containing spacers.
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 108
diff changeset
148 *
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 108
diff changeset
149 * For each col in cols, spacers should be drawn in the rectangle
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 108
diff changeset
150 * [x+col-layoutSpacing,x+col)*[y,y+h), and similarly for rows. */
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 108
diff changeset
151 void drawSpacers (wdabs x, wdabs y, wdsize w, wdsize h, wdims cols, wdims rows);
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 108
diff changeset
152
108
c9fc2d303178 Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
153 /** Draws a widget background. Usually doesn't do anything since backgrounds are transparent.
c9fc2d303178 Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
154 *
c9fc2d303178 Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
155 * It used to be required for all widgets to do this, but I lapsed since mostly it's unused. */
97
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
156 void drawWidgetBack (wdim x, wdim y, wdim w, wdim h);
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
157
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
158 /** Draws a blank widget (temporary) */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
159 void drawBlank (wdim x, wdim y, wdim w, wdim h);
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
160
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
161 /** Draws a button frame, in if pushed == true. */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
162 void drawButton (wdim x, wdim y, wdim w, wdim h, bool pushed);
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
163
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
164 /** Toggle buttons.
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
165 *
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
166 * These have a fixed size which getToggleSize returns. */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
167 wdimPair getToggleSize ();
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
168 void drawToggle (wdim x, wdim y, bool state, bool pushed); /// ditto
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
169
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
170 /** Get a TextAdapter to draw some text.
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
171 *
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
172 * If no colour is passes, a default is used (white). */
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
173 TextAdapter getAdapter (char[] text, int colour = 0xFFFFFF);
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
174 //END Methods
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
175 }