Rename unzip tool.
[SquirrelJME.git] / nanocoat / include / lib / scritchui / scritchuiTypes.h
blob761766a115eff971ed2717fa112427d074940f6a
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 /**
11 * Internal ScritchUI types.
13 * @since 2024/04/02
16 #ifndef SQUIRRELJME_SCRITCHUITYPES_H
17 #define SQUIRRELJME_SCRITCHUITYPES_H
19 #include "sjme/atomic.h"
20 #include "lib/scritchui/scritchui.h"
21 #include "lib/scritchui/scritchuiImpl.h"
22 #include "lib/scritchui/scritchuiPencil.h"
23 #include "lib/scritchui/scritchuiPencilFont.h"
24 #include "lib/scritchui/scritchuiText.h"
25 #include "lib/scritchui/scritchuiTypesListener.h"
27 /* Anti-C++. */
28 #ifdef __cplusplus
29 #ifndef SJME_CXX_IS_EXTERNED
30 #define SJME_CXX_IS_EXTERNED
31 #define SJME_CXX_SQUIRRELJME_SCRITCHUITYPES_H
32 extern "C" {
33 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
34 #endif /* #ifdef __cplusplus */
36 /*--------------------------------------------------------------------------*/
38 /**
39 * The state of the pencil lock.
41 * @since 2024/07/08
43 typedef struct sjme_scritchui_pencilLockState
45 /** Spin lock for access to the buffer. */
46 sjme_thread_spinLock spinLock;
48 /** The times this was opened. */
49 sjme_atomic_sjme_jint count;
51 /** The front end source for drawing. */
52 sjme_frontEnd source;
54 /** The base address where drawing should occur. */
55 sjme_pointer base;
57 /** The buffer limit of the base, in bytes. */
58 sjme_jint baseLimitBytes;
60 /** Is this a copy? */
61 sjme_jboolean isCopy;
62 } sjme_scritchui_pencilLockState;
64 /**
65 * Base pencil drawing structure.
67 * @since 2024/05/04
69 typedef struct sjme_scritchui_pencilBase
71 /** Common data. */
72 sjme_scritchui_uiCommonBase common;
74 /** The current state of the pencil. */
75 sjme_scritchui_pencilState state;
77 /** External API. */
78 const sjme_scritchui_pencilFunctions* api;
80 /** Implementation API. */
81 const sjme_scritchui_pencilImplFunctions* impl;
83 /** Utility functions. */
84 const sjme_scritchui_pencilUtilFunctions* util;
86 /** Optional locking functions, for buffer access as required. */
87 const sjme_scritchui_pencilLockFunctions* lock;
89 /** The lock state. */
90 sjme_scritchui_pencilLockState lockState;
92 /** Lowest level primitive pencil functions. */
93 sjme_scritchui_pencilPrimFunctions prim;
95 /** Front end information for paint. */
96 sjme_frontEnd frontEnd;
98 /** The pixel format used. */
99 sjme_gfx_pixelFormat pixelFormat;
101 /** Is there an alpha channel? */
102 sjme_jboolean hasAlpha;
104 /** The default font to use. */
105 sjme_scritchui_pencilFont defaultFont;
107 /** The width of the surface. */
108 sjme_jint width;
110 /** The height of the surface. */
111 sjme_jint height;
113 /** The scanline length, in pixels. */
114 sjme_jint scanLenPixels;
116 /** The scan line length, in bytes. */
117 sjme_jint scanLenBytes;
119 /** Bits per pixel. */
120 sjme_jint bitsPerPixel;
122 /** The bytes per pixel. */
123 sjme_jint bytesPerPixel;
125 /** Forced X/Y translate. */
126 sjme_scritchui_point forceTranslate;
128 /** Color palette. */
129 struct
131 /** The colors available. */
132 const sjme_jint* colors;
134 /** The number of colors used. */
135 sjme_jint numColors;
136 } palette;
137 } sjme_scritchui_pencilBase;
139 /** The string length of a component ID. */
140 #define SJME_SCRITCHUI_UI_COMPONENT_ID_STRLEN 32
143 * Stores the mouse state.
145 * @since 2024/08/07
147 typedef struct sjme_scritchui_uiMouseState
149 /** The mouse buttons being held down. */
150 sjme_jint mouseButtons;
152 /** The modifiers being held down. */
153 sjme_jint mouseModifiers;
155 /** Last mouse X position. */
156 sjme_jint mouseX;
158 /** Last mouse Y position. */
159 sjme_jint mouseY;
160 } sjme_scritchui_uiMouseState;
162 typedef struct sjme_scritchui_uiComponentBase
164 /** Common data. */
165 sjme_scritchui_uiCommonBase common;
167 /** The parent of this component. */
168 sjme_scritchui_uiComponent parent;
170 /** User and core listeners for the component. */
171 sjme_scritchui_uiComponentListeners listeners[SJME_NUM_SCRITCHUI_LISTENER];
173 /** The bounds which were set for this component. */
174 sjme_scritchui_rect bounds;
176 /** String ID for this component. */
177 sjme_cchar strId[SJME_SCRITCHUI_UI_COMPONENT_ID_STRLEN];
179 /** General component state. */
180 struct
182 /** Is this component currently visible? */
183 sjme_jboolean isVisible;
185 /** Is this visible to the user? */
186 sjme_jboolean isUserVisible;
188 /** Current and next logical mouse state. */
189 sjme_scritchui_uiMouseState mouse[2];
190 } state;
191 } sjme_scritchui_uiComponentBase;
193 /** List of component. */
194 SJME_LIST_DECLARE(sjme_scritchui_uiComponent, 0);
196 /** Type that component pointers are. */
197 #define SJME_TYPEOF_BASIC_sjme_scritchui_uiComponent \
198 SJME_TYPEOF_BASIC_sjme_pointer
201 * Contains the information of a single item within a choice.
203 * @since 2024/07/16
205 typedef struct sjme_scritchui_uiChoiceItemBase
207 /** Is this selected? */
208 sjme_jboolean isSelected;
210 /** Is this enabled? */
211 sjme_jboolean isEnabled;
213 /** The string text for the item. */
214 sjme_lpcstr string;
216 /** The font to display the text in, @c NULL is default. */
217 sjme_scritchui_pencilFont font;
219 /** The image data, if there is one for this. */
220 sjme_jint* imageRgb;
222 /** The dimensions of the image RGB data. */
223 sjme_scritchui_dim imageRgbDim;
225 /** The number of pixels in the image. */
226 sjme_jint imageRgbNumPixels;
227 } sjme_scritchui_uiChoiceItemBase;
229 /** A list of choice items. */
230 SJME_LIST_DECLARE(sjme_scritchui_uiChoiceItem, 0);
233 * Contains all of the information on choice items.
235 * @since 2024/07/16
237 typedef struct sjme_scritchui_uiChoiceBase
239 /** The type of choice this is. */
240 sjme_scritchui_choiceType type;
242 /** The number of valid entries on the list. */
243 sjme_jint numItems;
245 /** The items on this list. */
246 sjme_list_sjme_scritchui_uiChoiceItem* items;
247 } sjme_scritchui_uiChoiceBase;
250 * Base data for containers which may contain components.
252 * @since 2024/04/20
254 typedef struct sjme_scritchui_uiContainerBase
256 /** Components within the container. */
257 sjme_list_sjme_scritchui_uiComponent* components;
258 } sjme_scritchui_uiContainerBase;
261 * Base data for anything which may have a label.
263 * @since 2024/07/22
265 typedef struct sjme_scritchui_uiLabeledBase
267 /** The current label, which is always a copy. */
268 sjme_lpcstr label;
269 } sjme_scritchui_uiLabeledBase;
272 * Base data for lists.
274 * @since 2024/07/16
276 typedef struct sjme_scritchui_uiListBase
278 /** Common data. */
279 sjme_scritchui_uiComponentBase component;
281 /** Choice information. */
282 sjme_scritchui_uiChoiceBase choice;
283 } sjme_scritchui_uiListBase;
285 /** Menu item list. */
286 SJME_LIST_DECLARE(sjme_scritchui_uiMenuKind, 0);
288 struct sjme_scritchui_uiMenuKindBase
290 /** Common data. */
291 sjme_scritchui_uiCommonBase common;
293 /** The index of this item in the parent. */
294 sjme_jint index;
297 struct sjme_scritchui_uiMenuHasChildrenBase
299 /** The number of valid children. */
300 sjme_jint numChildren;
302 /** The children to this. */
303 sjme_list_sjme_scritchui_uiMenuKind* children;
306 struct sjme_scritchui_uiMenuHasParentBase
308 /** The parent menu. */
309 sjme_scritchui_uiMenuKind parent;
313 * Base data for menus.
315 * @since 2024/07/21
317 typedef struct sjme_scritchui_uiMenuBase
319 /** The menu kind information. */
320 sjme_scritchui_uiMenuKindBase menuKind;
322 /** Labeled item. */
323 sjme_scritchui_uiLabeledBase labeled;
325 /** Menu children. */
326 sjme_scritchui_uiMenuHasChildrenBase children;
328 /** Menu parent. */
329 sjme_scritchui_uiMenuHasParentBase parent;
330 } sjme_scritchui_uiMenuBase;
333 * Base data for menu bars.
335 * @since 2024/07/21
337 typedef struct sjme_scritchui_uiMenuBarBase
339 /** The menu kind information. */
340 sjme_scritchui_uiMenuKindBase menuKind;
342 /** Menu children. */
343 sjme_scritchui_uiMenuHasChildrenBase children;
345 /** The window this is within. */
346 sjme_scritchui_uiWindow window;
347 } sjme_scritchui_uiMenuBarBase;
350 * Base data for menu items.
352 * @since 2024/07/21
354 typedef struct sjme_scritchui_uiMenuItemBase
356 /** The menu kind information. */
357 sjme_scritchui_uiMenuKindBase menuKind;
359 /** Labeled item. */
360 sjme_scritchui_uiLabeledBase labeled;
362 /** Menu children. */
363 sjme_scritchui_uiMenuHasChildrenBase children;
365 /** Menu parent. */
366 sjme_scritchui_uiMenuHasParentBase parent;
368 /** The accelerator key @c sjme_scritchinput_key , if any. */
369 sjme_jint accelKey;
371 /** The accelerator modifiers @c sjme_scritchinput_modifier , if any. */
372 sjme_jint accelMod;
374 /** Some windowing systems need some ID to be specified. */
375 sjme_jint opaqueId;
376 } sjme_scritchui_uiMenuItemBase;
379 * Base data for paintable components.
381 * @since 2024/04/06
383 typedef struct sjme_scritchui_uiPaintableBase
385 /** Listeners. */
386 sjme_scritchui_uiPaintableListeners listeners[SJME_NUM_SCRITCHUI_LISTENER];
388 /** Extra data if needed. */
389 sjme_intPointer extra;
391 /** Is this currently in paint? */
392 sjme_atomic_sjme_jint inPaint;
394 /** Belayed painting. */
395 sjme_scritchui_rect belayRect;
397 /** Last error while in paint. */
398 sjme_errorCode lastError;
400 /** Pencil drawing information. */
401 sjme_scritchui_pencilBase pencil;
402 } sjme_scritchui_uiPaintableBase;
404 typedef struct sjme_scritchui_uiPanelBase
406 /** Common data. */
407 sjme_scritchui_uiComponentBase component;
409 /** Container related. */
410 sjme_scritchui_uiContainerBase container;
412 /** Paint related. */
413 sjme_scritchui_uiPaintableBase paint;
415 /** Is focus enabled? */
416 sjme_jboolean enableFocus;
418 /** Is default focus enabled? */
419 sjme_jboolean defaultFocus;
420 } sjme_scritchui_uiPanelBase;
422 typedef struct sjme_scritchui_uiScreenBase
424 /** Common data. */
425 sjme_scritchui_uiCommonBase common;
427 /** The screen Id. */
428 sjme_jint id;
430 /** Generic display handle such as for X11. */
431 sjme_scritchui_handle displayHandle;
432 } sjme_scritchui_uiScreenBase;
434 struct sjme_scritchui_uiViewBase
436 /** User and core listeners for the view. */
437 sjme_scritchui_uiViewListeners listeners[SJME_NUM_SCRITCHUI_LISTENER];
439 /** The current view area. */
440 sjme_scritchui_dim area;
442 /** The current view rectangle. */
443 sjme_scritchui_rect view;
445 /** The current page size. */
446 sjme_scritchui_dim pageSize;
449 struct sjme_scritchui_uiScrollPanelBase
451 /** Common data. */
452 sjme_scritchui_uiComponentBase component;
454 /** Container related. */
455 sjme_scritchui_uiContainerBase container;
457 /** Viewport data. */
458 sjme_scritchui_uiViewBase view;
461 typedef struct sjme_scritchui_uiWindowBase
463 /** Common data. */
464 sjme_scritchui_uiComponentBase component;
466 /** Container related. */
467 sjme_scritchui_uiContainerBase container;
469 /** Labeled item. */
470 sjme_scritchui_uiLabeledBase labeled;
472 /** The current menu bar. */
473 sjme_scritchui_uiMenuBar menuBar;
475 /** Listeners. */
476 sjme_scritchui_uiWindowListeners listeners[SJME_NUM_SCRITCHUI_LISTENER];
478 /** The minimum window size. */
479 sjme_scritchui_dim min;
481 /** The window overhead size, to account for menus, titlebar, etc. */
482 sjme_scritchui_dim minOverhead;
484 /** The component that has the focus. */
485 sjme_scritchui_uiComponent focusedComponent;
486 } sjme_scritchui_uiWindowBase;
488 struct sjme_scritchui_pencilFontBase
490 /** Common data. */
491 sjme_scritchui_uiCommonBase common;
493 /** Internal context pointer for implementation needs. */
494 sjme_pointer context;
496 /** External API. */
497 const sjme_scritchui_pencilFontFunctions* api;
499 /** Internal implementation. */
500 const sjme_scritchui_pencilFontImplFunctions* impl;
502 /** Font cache details. */
503 struct
505 /** The name of the font. */
506 sjme_lpcstr name;
508 /** The face of the font. */
509 sjme_scritchui_pencilFontFace face;
511 /** The style of the font. */
512 sjme_scritchui_pencilFontStyle style;
514 /** The pixel size of the font. */
515 sjme_jint pixelSize;
517 /** The height of the font. */
518 sjme_jint height;
520 /** The baseline of the font. */
521 sjme_jint baseline;
523 /** The leading of the font. */
524 sjme_jint leading;
526 /** The ascent of the font. */
527 sjme_jint ascent[2];
529 /** The descent of the font. */
530 sjme_jint descent[2];
532 /** Font fraction, for pseudo fonts. */
533 sjme_fixed fraction;
535 /** Inverted font fraction, for pseudo fonts. */
536 sjme_fixed ifraction;
537 } cache;
540 struct sjme_scritchui_textBase
542 /** Common data. */
543 sjme_scritchui_uiCommonBase common;
546 /*--------------------------------------------------------------------------*/
548 /* Anti-C++. */
549 #ifdef __cplusplus
550 #ifdef SJME_CXX_SQUIRRELJME_SCRITCHUITYPES_H
552 #undef SJME_CXX_SQUIRRELJME_SCRITCHUITYPES_H
553 #undef SJME_CXX_IS_EXTERNED
554 #endif /* #ifdef SJME_CXX_SQUIRRELJME_SCRITCHUITYPES_H */
555 #endif /* #ifdef __cplusplus */
557 #endif /* SQUIRRELJME_SCRITCHUITYPES_H */