Changeset 66:f54ae4fc2b2f
- Timestamp:
- 07/02/08 12:10:07
(6 months ago)
- Author:
- Diggory Hardy <diggory.hardy@gmail.com>
- branch:
- default
- Message:
Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r31 |
r66 |
|
| 6 | 6 | |
|---|
| 7 | 7 | GUI: |
|---|
| 8 | | -> Basic OpenGL code to: |
|---|
| 9 | | ->* create orthographic projection |
|---|
| 10 | | ->* draw boxes |
|---|
| 11 | | -> maybe more (text, textures, ...) |
|---|
| 12 | | ->* Windows with size & position |
|---|
| 13 | 8 | -> Widgets: |
|---|
| | 9 | -> rethink how widgets are created and receive creation data, so that they don't have to be created by the Window |
|---|
| 14 | 10 | ->* minimum size but expandable, auto-set |
|---|
| 15 | | -> no ability to resize yet except from config files |
|---|
| 16 | 11 | ->* grid "layout" widgets |
|---|
| 17 | 12 | -> scripted widgets |
|---|
| 18 | 13 | -> decent rendering/theme system |
|---|
| 19 | | -> Text rendering |
|---|
| 20 | | -> text library? |
|---|
| | 14 | -> lists from content lists |
|---|
| | 15 | -> Content: |
|---|
| | 16 | -> lists |
|---|
| r65 |
r66 |
|
| 130 | 130 | bool isHSizable (); /// ditto |
|---|
| 131 | 131 | |
|---|
| 132 | | /** Calculate the minimal size the widget could be shrunk to (or its fixed size), taking into |
|---|
| 133 | | * account child-widgets or other contents. */ |
|---|
| 134 | | void getMinimalSize (out wdim w, out wdim h); |
|---|
| | 132 | /** The minimal size the widget could be shrunk to (or its fixed size). |
|---|
| | 133 | * |
|---|
| | 134 | * Takes into account child-widgets and any other contents. */ |
|---|
| | 135 | wdim minWidth (); |
|---|
| | 136 | wdim minHeight (); /// ditto |
|---|
| 135 | 137 | |
|---|
| 136 | 138 | /** Get the current size of the widget. */ |
|---|
| r65 |
r66 |
|
| 63 | 63 | |
|---|
| 64 | 64 | /* Return minimal/fixed size. */ |
|---|
| 65 | | void getMinimalSize (out wdim a, out wdim b) { |
|---|
| 66 | | a = mw; |
|---|
| 67 | | b = mh; |
|---|
| | 65 | wdim minWidth () { |
|---|
| | 66 | return mw; |
|---|
| | 67 | } |
|---|
| | 68 | wdim minHeight () { |
|---|
| | 69 | return mh; |
|---|
| 68 | 70 | } |
|---|
| 69 | 71 | |
|---|
| r65 |
r66 |
|
| 92 | 92 | |
|---|
| 93 | 93 | // Calculate mw/mh and xw/yh (cached data): |
|---|
| 94 | | widget.getMinimalSize (mw, mh); |
|---|
| 95 | | mw += border.l + border.r; |
|---|
| 96 | | mh += border.t + border.b; |
|---|
| | 94 | mw = widget.minWidth + border.l + border.r; |
|---|
| | 95 | mh = widget.minHeight + border.t + border.b; |
|---|
| 97 | 96 | |
|---|
| 98 | 97 | xw = x+w; |
|---|
| … | … | |
| 255 | 254 | } |
|---|
| 256 | 255 | |
|---|
| 257 | | void getMinimalSize (out wdim wM, out wdim hM) { |
|---|
| 258 | | // mw/mh are calculated by finalise(); |
|---|
| 259 | | wM = mw; |
|---|
| 260 | | hM = mh; |
|---|
| | 256 | wdim minWidth () { |
|---|
| | 257 | return mw; |
|---|
| | 258 | } |
|---|
| | 259 | wdim minHeight () { |
|---|
| | 260 | return mh; |
|---|
| 261 | 261 | } |
|---|
| 262 | 262 | void getCurrentSize (out wdim cw, out wdim ch) { |
|---|
| r65 |
r66 |
|
| 36 | 36 | * |
|---|
| 37 | 37 | * The grid has no border but has spacing between widgets. */ |
|---|
| | 38 | /* TODO: |
|---|
| | 39 | separate positioning & sub-widget handling from creation/saving |
|---|
| | 40 | other types of layouts (e.g. lists from content) |
|---|
| | 41 | */ |
|---|
| 38 | 42 | class GridLayoutWidget : Widget |
|---|
| 39 | 43 | { |
|---|
| … | … | |
| 138 | 142 | } |
|---|
| 139 | 143 | |
|---|
| 140 | | /* Calculates the minimal size from all rows and columns of widgets. */ |
|---|
| 141 | | void getMinimalSize (out wdim mw, out wdim mh) { |
|---|
| 142 | | mw = this.mw; |
|---|
| 143 | | mh = this.mh; |
|---|
| 144 | | } |
|---|
| 145 | | |
|---|
| 146 | 144 | void setWidth (wdim nw, int dir) { |
|---|
| 147 | 145 | if (nw == w) return; |
|---|
| … | … | |
| 224 | 222 | col.minWidth = new wdim[cols]; |
|---|
| 225 | 223 | row.minWidth = new wdim[rows]; |
|---|
| 226 | | wdim ww, wh; // sub-widget minimal sizes |
|---|
| 227 | 224 | foreach (i,widget; subWidgets) { |
|---|
| 228 | | widget.getMinimalSize (ww, wh); |
|---|
| 229 | | |
|---|
| 230 | 225 | // Increase dimensions if current minimal size is larger: |
|---|
| 231 | 226 | myIt n = i % cols; // column |
|---|
| 232 | | if (col.minWidth[n] < ww) col.minWidth[n] = ww; |
|---|
| | 227 | wdim md = widget.minWidth; |
|---|
| | 228 | if (col.minWidth[n] < md) col.minWidth[n] = md; |
|---|
| 233 | 229 | n = i / cols; // row |
|---|
| 234 | | if (row.minWidth[n] < wh) row.minWidth[n] = wh; |
|---|
| | 230 | md = widget.minHeight; |
|---|
| | 231 | if (row.minWidth[n] < md) row.minWidth[n] = md; |
|---|
| 235 | 232 | } |
|---|
| 236 | 233 | |
|---|