annotate semicongine/panel.nim @ 444:f9d25bc331b3

did: same for panels
author Sam <sam@basx.dev>
date Sat, 24 Feb 2024 15:35:52 +0700
parents 36b907544820
children 7e89c8fe57a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
1 import std/strformat
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
2 import std/tables
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
3
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
4 import ./core
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
5 import ./mesh
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
6 import ./material
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
7 import ./vulkan/shader
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
8 import ./events
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
9
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
10 const
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
11 # font shader
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
12 SHADER_ATTRIB_PREFIX = "semicon_panel_"
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
13 MAX_PANEL_MATERIALS = 10
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
14 POSITION_ATTRIB = SHADER_ATTRIB_PREFIX & "position"
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
15 UV_ATTRIB = SHADER_ATTRIB_PREFIX & "uv"
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
16 PANEL_MATERIAL_TYPE* = MaterialType(
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
17 name: "default-panel-material-type",
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
18 vertexAttributes: {TRANSFORM_ATTRIB: Mat4F32, POSITION_ATTRIB: Vec3F32, UV_ATTRIB: Vec2F32}.toTable,
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
19 attributes: {"panelTexture": TextureType, "color": Vec4F32}.toTable,
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
20 )
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
21 PANEL_SHADER* = createShaderConfiguration(
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
22 inputs = [
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
23 attr[Mat4](TRANSFORM_ATTRIB, memoryPerformanceHint = PreferFastWrite, perInstance = true),
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
24 attr[Vec3f](POSITION_ATTRIB, memoryPerformanceHint = PreferFastWrite),
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
25 attr[Vec2f](UV_ATTRIB, memoryPerformanceHint = PreferFastWrite),
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
26 attr[uint16](MATERIALINDEX_ATTRIBUTE, memoryPerformanceHint = PreferFastRead, perInstance = true),
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
27 ],
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
28 intermediates = [
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
29 attr[Vec2f]("uvFrag"),
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
30 attr[uint16]("materialIndexOut", noInterpolation = true)
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
31 ],
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
32 outputs = [attr[Vec4f]("color")],
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
33 uniforms = [attr[Vec4f]("color", arrayCount = MAX_PANEL_MATERIALS), attr[float32](ASPECT_RATIO_ATTRIBUTE)],
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
34 samplers = [attr[Texture]("panelTexture", arrayCount = MAX_PANEL_MATERIALS)],
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
35 vertexCode = &"""
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
36 gl_Position = vec4({POSITION_ATTRIB}.x, {POSITION_ATTRIB}.y * Uniforms.{ASPECT_RATIO_ATTRIBUTE}, {POSITION_ATTRIB}.z, 1.0) * {TRANSFORM_ATTRIB};
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
37 uvFrag = {UV_ATTRIB};
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
38 materialIndexOut = {MATERIALINDEX_ATTRIBUTE};
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
39 """,
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
40 fragmentCode = &"""color = Uniforms.color[materialIndexOut] * texture(panelTexture[materialIndexOut], uvFrag);"""
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
41 )
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
42
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
43 var instanceCounter = 0
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
44
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
45 type
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
46 Panel* = object
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
47 texture: Texture
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
48 horizontalAlignment: HorizontalAlignment = Center
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
49 verticalAlignment: VerticalAlignment = Center
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
50 dirty: bool
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
51 mesh*: Mesh
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
52 # input handling
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
53 onMouseDown*: proc(panel: var Panel, buttons: set[MouseButton])
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
54 onMouseUp*: proc(panel: var Panel, buttons: set[MouseButton])
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
55 onMouseEnter*: proc(panel: var Panel)
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
56 onMouseMove*: proc(panel: var Panel)
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
57 onMouseLeave*: proc(panel: var Panel)
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
58 hasMouse*: bool
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
59
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
60 proc `$`*(panel: Panel): string =
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
61 &"Panel {panel.mesh}"
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
62
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
63 proc refresh*(panel: var Panel) =
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
64 if not panel.dirty:
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
65 return
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
66
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
67 var
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
68 offsetX = case panel.horizontalAlignment
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
69 of Left: 0.5
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
70 of Center: 0
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
71 of Right: -0.5
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
72 offsetY = case panel.verticalAlignment
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
73 of Top: 0.5
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
74 of Center: 0
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
75 of Bottom: -0.5
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
76
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
77 panel.mesh[POSITION_ATTRIB, 0] = newVec3f(-0.5 + offsetX, -0.5 + offsetY)
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
78 panel.mesh[POSITION_ATTRIB, 1] = newVec3f(+0.5 + offsetX, -0.5 + offsetY)
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
79 panel.mesh[POSITION_ATTRIB, 2] = newVec3f(+0.5 + offsetX, +0.5 + offsetY)
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
80 panel.mesh[POSITION_ATTRIB, 3] = newVec3f(-0.5 + offsetX, +0.5 + offsetY)
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
81
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
82 panel.dirty = false
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
83
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
84 proc initPanel*(
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
85 transform = Unit4,
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
86 color = newVec4f(1, 1, 1, 1),
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
87 texture = EMPTY_TEXTURE,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
88 horizontalAlignment = HorizontalAlignment.Center,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
89 verticalAlignment = VerticalAlignment.Center,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
90 onMouseDown: proc(panel: var Panel, buttons: set[MouseButton]) = nil,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
91 onMouseUp: proc(panel: var Panel, buttons: set[MouseButton]) = nil,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
92 onMouseEnter: proc(panel: var Panel) = nil,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
93 onMouseMove: proc(panel: var Panel) = nil,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
94 onMouseLeave: proc(panel: var Panel) = nil,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
95 ): Panel =
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
96
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
97 result = Panel(
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
98 texture: texture,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
99 horizontalAlignment: horizontalAlignment,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
100 verticalAlignment: verticalAlignment,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
101 onMouseDown: onMouseDown,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
102 onMouseUp: onMouseUp,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
103 onMouseEnter: onMouseEnter,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
104 onMouseMove: onMouseMove,
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
105 onMouseLeave: onMouseLeave,
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
106 dirty: true,
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
107 )
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
108
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
109 result.mesh = newMesh(
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
110 name = &"panel-{instanceCounter}",
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
111 positions = newSeq[Vec3f](4),
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
112 indices = @[
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
113 [uint16(0), uint16(1), uint16(2)],
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
114 [uint16(2), uint16(3), uint16(0)],
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
115 ],
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
116 uvs = @[newVec2f(0, 1), newVec2f(1, 1), newVec2f(1, 0), newVec2f(0, 0)],
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
117 transform = transform
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
118 )
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
119 result.mesh[].renameAttribute("position", POSITION_ATTRIB)
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
120 result.mesh[].renameAttribute("uv", UV_ATTRIB)
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
121 result.mesh.material = initMaterialData(
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
122 theType = PANEL_MATERIAL_TYPE,
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
123 name = "Panel material",
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
124 attributes = {"panelTexture": initDataList(@[texture]), "color": initDataList(@[color])},
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
125 )
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
126 inc instanceCounter
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
127 result.refresh()
431
e13b75bff00c intermediate commit :P
Sam <sam@basx.dev>
parents: 430
diff changeset
128
433
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
129 proc color*(panel: Panel): Vec4f =
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
130 panel.mesh.material["color", 0, Vec4f]
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
131 proc `color=`*(panel: var Panel, value: Vec4f) =
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
132 if value != panel.color:
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
133 panel.mesh.material["color", 0] = value
08b8facaf3b7 add: initial implementation of "panels"
Sam <sam@basx.dev>
parents: 431
diff changeset
134
430
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
135 proc horizontalAlignment*(panel: Panel): HorizontalAlignment =
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
136 panel.horizontalAlignment
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
137 proc `horizontalAlignment=`*(panel: var Panel, value: HorizontalAlignment) =
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
138 if value != panel.horizontalAlignment:
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
139 panel.horizontalAlignment = value
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
140 panel.dirty = true
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
141
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
142 proc verticalAlignment*(panel: Panel): VerticalAlignment =
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
143 panel.verticalAlignment
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
144 proc `verticalAlignment=`*(panel: var Panel, value: VerticalAlignment) =
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
145 if value != panel.verticalAlignment:
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
146 panel.verticalAlignment = value
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
147 panel.dirty = true
c5999345f42c add: panels
Sam <sam@basx.dev>
parents:
diff changeset
148
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
149 proc contains*(panel: Panel, p: Vec2f, aspectRatio: float32): bool =
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
150 let
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
151 cursor = panel.mesh.transform.inversed * p.toVec3
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
152 p1 = panel.mesh[POSITION_ATTRIB, 0, Vec3f]
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
153 p2 = panel.mesh[POSITION_ATTRIB, 2, Vec3f]
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
154 left = min(p1.x, p2.x)
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
155 right = max(p1.x, p2.x)
444
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
156 top = min(p1.y * aspectRatio, p2.y * aspectRatio)
f9d25bc331b3 did: same for panels
Sam <sam@basx.dev>
parents: 436
diff changeset
157 bottom = max(p1.y * aspectRatio, p2.y * aspectRatio)
434
30cc1deda4c1 add: input-processing for panels
Sam <sam@basx.dev>
parents: 433
diff changeset
158 return left <= cursor.x and cursor.x <= right and top <= cursor.y and cursor.y <= bottom