-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_COMMON.BI
More file actions
171 lines (149 loc) · 8.89 KB
/
Copy path_COMMON.BI
File metadata and controls
171 lines (149 loc) · 8.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
''
' DRAW - COMMON.BI
' =============================================================================
' Common header include.
'
' @author Rick Christy <grymmjack@gmail.com>
'
$INCLUDEONCE
'$DYNAMIC
$CONSOLE
' Start with the graphics window HIDDEN. With $CONSOLE (not $CONSOLE:ONLY) QB64-PE
' opens its default graphics window at process start — before any of our code runs —
' which made console-only CLI ops (--help, --version, --options-list,
' --config-upgrade) briefly flash a blank window. The window is revealed exactly
' once, via _SCREENSHOW in DRAW.BAS, on the normal editor-launch path; every
' CLI op SYSTEMs before reaching that line, so its window is never shown.
$SCREENHIDE
OPTION _EXPLICIT
OPTION _EXPLICITARRAY
$IF FALSE = UNDEFINED AND TRUE = UNDEFINED THEN
$LET TRUE = TRUE
CONST FALSE = 0 : CONST TRUE = NOT FALSE
$END IF
CONST KEY_CAPSLOCK& = 100301 ' Not supported on Linux/macOS
' Application version
CONST APP_VERSION$ = "2.1.1"
' Canvas pan step (pixels) for the Pan actions (470-473) — matches Shift+Wheel pan.
CONST CANVAS_PAN_STEP = 40
' Maximum number of layer slots (increased from 64 to support groups)
CONST MAX_LAYERS = 128
' Title bar tracking (only update _TITLE when state changes)
DIM SHARED AS INTEGER TITLE_PREV_DIRTY ' Previous frame's dirty state
DIM SHARED TITLE_PREV_FILENAME$ ' Previous frame's filename
TITLE_PREV_DIRTY% = -99 ' Force initial update
TITLE_PREV_FILENAME$ = CHR$(0) ' Sentinel to force initial update
CONST KEY_LSHIFT& = 100304
CONST KEY_RSHIFT& = 100303
CONST KEY_LCTRL& = 100305
CONST KEY_RCTRL& = 100306
CONST KEY_RALT& = 100307
CONST KEY_LALT& = 100308
CONST KEY_LSUPER& = 100311 ' Left Command (⌘, macOS) / Windows / Super — GLFW backend
CONST KEY_RSUPER& = 100312 ' Right Command (⌘, macOS) / Windows / Super — GLFW backend
CONST KEY_DELETE& = 21248 ' DELETE key
CONST KEY_BACKSPACE& = 8 ' BACKSPACE key
CONST KEY_PGUP& = 18688 ' Page Up key
CONST KEY_PGDN& = 20736 ' Page Down key
' Last directory for file dialogs (save/load)
DIM SHARED LAST_DIRECTORY$
LAST_DIRECTORY$ = ""
' Current file name (for quick save without prompt)
DIM SHARED CURRENT_FILENAME$
CURRENT_FILENAME$ = ""
' Current DRW project file name (for project save without prompt)
DIM SHARED CURRENT_DRW_FILENAME$
CURRENT_DRW_FILENAME$ = ""
' Recent files tracking (up to 10 recent files)
CONST RECENT_FILES_MAX = 10
DIM SHARED RECENT_FILES(1 TO 10) AS STRING
DIM SHARED RECENT_FILE_COUNT AS INTEGER
RECENT_FILE_COUNT% = 0
' Browser custom "Places" (user-editable favourite folders shown in the browser's
' places bar, on top of the built-in DRAW/Samples/etc.). Persisted to config as
' BROWSER_PLACE_<n>=Label|Path and applied in DRAW_FD_register_custom_places.
CONST BROWSER_PLACES_MAX = 16
DIM SHARED BROWSER_PLACE_LABEL(1 TO 16) AS STRING
DIM SHARED BROWSER_PLACE_PATH(1 TO 16) AS STRING
DIM SHARED BROWSER_PLACE_COUNT AS INTEGER
BROWSER_PLACE_COUNT% = 0
' Recent preview images tracking (up to 10 recent preview images)
CONST RECENT_PREVIEW_MAX = 10
DIM SHARED RECENT_PREVIEW_FILES(1 TO 10) AS STRING
DIM SHARED RECENT_PREVIEW_COUNT AS INTEGER
RECENT_PREVIEW_COUNT% = 0
' Pending command line file to load (deferred until main loop)
DIM SHARED CMDLINE_PENDING_FILE$
CMDLINE_PENDING_FILE$ = ""
DIM SHARED CMDLINE_FIRST_FRAME%
CMDLINE_FIRST_FRAME% = TRUE
' Tool modes - basic drawing tools (1-20)
CONST TOOL_NULL = 0 ' Internal null tool - does nothing, no toolbar button
CONST TOOL_BRUSH = 1
CONST TOOL_FILL = 2
CONST TOOL_DOT = 3
CONST TOOL_LINE = 4
CONST TOOL_MARQUEE = 5
CONST TOOL_POLYGON = 6
CONST TOOL_RECT = 7
CONST TOOL_ELLIPSE = 8
CONST TOOL_RECT_FILLED = 9
CONST TOOL_ELLIPSE_FILLED = 10
CONST TOOL_PICKER = 11
CONST TOOL_POLYGON_FILLED = 12
CONST TOOL_PAN = 13
CONST TOOL_SPRAY = 14
CONST TOOL_CROP = 15
CONST TOOL_ZOOM = 16
' Note: TOOL_MOVE, TOOL_TEXT, TOOL_SAVE, TOOL_OPEN, TOOL_CODE, TOOL_HELP defined in GUI/GUI.BI (30-39)
DIM SHARED AS INTEGER WHEEL_COLOR, KEY_COLOR ' TRUE when color was changed via wheel/key
DIM SHARED AS _UNSIGNED LONG PAINT_COLOR ' Current foreground paint color (RGBA)
DIM SHARED AS _UNSIGNED LONG PAINT_BG_COLOR ' Current background paint color (RGBA)
DIM SHARED AS _UNSIGNED LONG DRAW_COLOR ' Current drawing color (FG or BG based on mouse button)
DIM SHARED AS INTEGER PAINT_OPACITY ' Paint opacity percentage (10-100, default 100)
DIM SHARED AS LONG STROKE_BACKUP ' Saved layer image before stroke (for opacity compositing)
DIM SHARED AS INTEGER STROKE_ACTIVE ' TRUE when a stroke is in progress with opacity < 100%
DIM SHARED AS INTEGER CONSTRAIN_X, CONSTRAIN_Y ' TRUE when axis-constrained drawing is active
DIM SHARED AS INTEGER CURRENT_TOOL ' Currently active tool constant (TOOL_*)
DIM SHARED AS INTEGER PREVIOUS_TOOL ' Tool to return to after temporary picker
DIM SHARED AS INTEGER CANVAS_DIRTY ' Track if canvas has unsaved changes
DIM SHARED TEXT_BUFFER(0 TO 99) AS STRING ' Text tool buffer for 100 lines
DIM SHARED AS INTEGER FRAME_IDLE ' TRUE when nothing needs updating (idle throttling)
DIM SHARED AS INTEGER IDLE_PREV_MOUSE_X, IDLE_PREV_MOUSE_Y ' Previous frame mouse position
DIM SHARED AS INTEGER KEYBOARD_SUPPRESS_FRAMES ' Frames to suppress _KEYDOWN shortcut handlers after native dialogs
DIM SHARED AS INTEGER GRID_G_KEY_ARMED ' TRUE when G was freshly pressed without modifiers (grid resize/offset mode)
DIM SHARED AS INTEGER GRID_OFFSET_PICK_MODE ' TRUE when user triggered G+O offset-pick mode (next click sets grid origin)
' FPS limits now in CFG.FPS_IDLE%, CFG.FPS_CURSOR%, CFG.FPS_DIALOG% (DRAW.cfg)
' NOTE: MAC_ALT_HELD% is now declared in INPUT/MODIFIERS.BI
CONSTRAIN_X% = FALSE : CONSTRAIN_Y% = FALSE
WHEEL_COLOR% = FALSE : KEY_COLOR% = FALSE
PAINT_OPACITY% = 100 ' Default to fully opaque
PAINT_COLOR~& = 0 ' Will be set from palette after init
PAINT_BG_COLOR~& = _RGB32(0, 0, 0) ' Background color defaults to black
CURRENT_TOOL% = TOOL_NULL ' Default to null tool - user must select a tool
PREVIOUS_TOOL% = TOOL_NULL ' Initialize to same AS current
CANVAS_DIRTY% = FALSE ' Start with clean canvas
' ---------------------------------------------------------------------------
' Composite dirty rect — tracks canvas region modified per frame so
' RENDER_layers can recomposite only the changed area instead of the
' full canvas. Set by drawing dispatch; reset in LOOP_start.
' ---------------------------------------------------------------------------
DIM SHARED AS INTEGER COMP_DIRTY_X1, COMP_DIRTY_Y1 ' Top-left (canvas coords)
DIM SHARED AS INTEGER COMP_DIRTY_X2, COMP_DIRTY_Y2 ' Bot-right (canvas coords)
DIM SHARED AS INTEGER COMP_DIRTY_VALID ' TRUE when rect set this frame
' ---------------------------------------------------------------------------
' APRON — phantom draw area around the canvas. When CFG.APRON_ENABLED% is
' TRUE and a layer's content needs to live off-canvas (Move/Transform past
' the edge, paint past the edge, etc.), the layer is lazily promoted to an
' apron-extended buffer of size (canvasW + 2*APRON_W) x (canvasH + 2*APRON_H).
' APRON_W/APRON_H reflect the GLOBAL apron dims for newly-promoted layers;
' each LAYER also stores its own apronW/apronH (= 0 when compact).
' Apron pixels are session-only — not persisted on save (cull-on-save).
' ---------------------------------------------------------------------------
DIM SHARED AS INTEGER APRON_W, APRON_H ' Current global apron size in canvas pixels (0 when disabled)
DIM SHARED APRON_RENDER_SCRATCH AS LONG ' Canvas-sized scratch image for extracting canvas region from extended layers during render
DIM SHARED KEYHIT_CHAR AS STRING ' _KEYHIT → CHR$ fallback for INKEY$
DIM SHARED LAST_KEYHIT_RAW AS LONG ' Raw k& from _KEYHIT this frame (0 = none)
' ---------------------------------------------------------------------------
' INVALIDATE helpers — collapse repeated 3-5-line dirty-flag sequences.
' ---------------------------------------------------------------------------