Răsfoiți Sursa

Fixed text related controls. Added some missing apis.

Brucey 5 ani în urmă
părinte
comite
0dd7cdc00b
2 a modificat fișierele cu 323 adăugiri și 15 ștergeri
  1. 265 1
      gui.mod/common.bmx
  2. 58 14
      gui.mod/gui.bmx

+ 265 - 1
gui.mod/common.bmx

@@ -70,7 +70,7 @@ Extern
 	Function bmx_raygui_GuiGrid:RVector2(bounds:RRectangle, spacing:Float, subdivs:Int)="GuiGrid"
 
 	Function bmx_raygui_GuiListView:Int(bounds:RRectangle, txt:Byte Ptr, scrollIndex:Int Var, active:Int)="GuiListView"
-	Function bmx_raygui_GuiListViewEx:Int(bounds:RRectangle, txt:Size_T Ptr, focus:Int Var, scrollIndex:Int Var, active:Int)="GuiListViewEx"
+	Function bmx_raygui_GuiListViewEx:Int(bounds:RRectangle, txt:Size_T Ptr, count:Int, focus:Int Var, scrollIndex:Int Var, active:Int)="GuiListViewEx"
 	Function bmx_raygui_GuiMessageBox:Int(bounds:RRectangle, title:Byte Ptr, message:Byte Ptr, buttons:Byte Ptr)="GuiMessageBox"
 	Function bmx_raygui_GuiColorPicker:RColor(bounds:RRectangle, color:RColor)="GuiColorPicker"
 	Function bmx_raygui_GuiTextInputBox:Int(bounds:RRectangle, title:Byte Ptr, message:Byte Ptr, buttons:Byte Ptr, txt:Byte Ptr)="GuiTextInputBox"
@@ -78,6 +78,11 @@ Extern
 	Function bmx_raygui_GuiLoadStyle(fileName:Byte Ptr)="GuiLoadStyle"
 	Function bmx_raygui_GuiLoadStyleDefault()="GuiLoadStyleDefault"
 
+	Function bmx_raygui_GuiIconText:Byte Ptr(iconId:Int, txt:Byte Ptr)="GuiIconText"
+	Function bmx_raygui_GuiDrawIcon(iconId:Int, position:RVector2, pixelSize:Int, color:RColor)="GuiDrawIcon"
+	
+	Function bmx_raygui_GuiColorBarAlpha:Float(bounds:RRectangle, alpha:Float)="GuiColorBarAlpha"
+	Function bmx_raygui_GuiColorBarHue:Float(bounds:RRectangle, value:Float)="GuiColorBarHue"
 End Extern
 
 Const GUI_DEFAULT:Int = 0
@@ -171,3 +176,262 @@ Const HUEBAR_WIDTH:Int = 17
 Const HUEBAR_PADDING:Int = 18
 Const HUEBAR_SELECTOR_HEIGHT:Int = 19
 Const HUEBAR_SELECTOR_OVERFLOW:Int = 20
+
+
+
+Const RICON_NONE:Int = 0
+Const RICON_FOLDER_FILE_OPEN:Int = 1
+Const RICON_FILE_SAVE_CLASSIC:Int = 2
+Const RICON_FOLDER_OPEN:Int = 3
+Const RICON_FOLDER_SAVE:Int = 4
+Const RICON_FILE_OPEN:Int = 5
+Const RICON_FILE_SAVE:Int = 6
+Const RICON_FILE_EXPORT:Int = 7
+Const RICON_FILE_NEW:Int = 8
+Const RICON_FILE_DELETE:Int = 9
+Const RICON_FILETYPE_TEXT:Int = 10
+Const RICON_FILETYPE_AUDIO:Int = 11
+Const RICON_FILETYPE_IMAGE:Int = 12
+Const RICON_FILETYPE_PLAY:Int = 13
+Const RICON_FILETYPE_VIDEO:Int = 14
+Const RICON_FILETYPE_INFO:Int = 15
+Const RICON_FILE_COPY:Int = 16
+Const RICON_FILE_CUT:Int = 17
+Const RICON_FILE_PASTE:Int = 18
+Const RICON_CURSOR_HAND:Int = 19
+Const RICON_CURSOR_POINTER:Int = 20
+Const RICON_CURSOR_CLASSIC:Int = 21
+Const RICON_PENCIL:Int = 22
+Const RICON_PENCIL_BIG:Int = 23
+Const RICON_BRUSH_CLASSIC:Int = 24
+Const RICON_BRUSH_PAINTER:Int = 25
+Const RICON_WATER_DROP:Int = 26
+Const RICON_COLOR_PICKER:Int = 27
+Const RICON_RUBBER:Int = 28
+Const RICON_COLOR_BUCKET:Int = 29
+Const RICON_TEXT_T:Int = 30
+Const RICON_TEXT_A:Int = 31
+Const RICON_SCALE:Int = 32
+Const RICON_RESIZE:Int = 33
+Const RICON_FILTER_POINT:Int = 34
+Const RICON_FILTER_BILINEAR:Int = 35
+Const RICON_CROP:Int = 36
+Const RICON_CROP_ALPHA:Int = 37
+Const RICON_SQUARE_TOGGLE:Int = 38
+Const RICON_SIMMETRY:Int = 39
+Const RICON_SIMMETRY_HORIZONTAL:Int = 40
+Const RICON_SIMMETRY_VERTICAL:Int = 41
+Const RICON_LENS:Int = 42
+Const RICON_LENS_BIG:Int = 43
+Const RICON_EYE_ON:Int = 44
+Const RICON_EYE_OFF:Int = 45
+Const RICON_FILTER_TOP:Int = 46
+Const RICON_FILTER:Int = 47
+Const RICON_TARGET_POINT:Int = 48
+Const RICON_TARGET_SMALL:Int = 49
+Const RICON_TARGET_BIG:Int = 50
+Const RICON_TARGET_MOVE:Int = 51
+Const RICON_CURSOR_MOVE:Int = 52
+Const RICON_CURSOR_SCALE:Int = 53
+Const RICON_CURSOR_SCALE_RIGHT:Int = 54
+Const RICON_CURSOR_SCALE_LEFT:Int = 55
+Const RICON_UNDO:Int = 56
+Const RICON_REDO:Int = 57
+Const RICON_REREDO:Int = 58
+Const RICON_MUTATE:Int = 59
+Const RICON_ROTATE:Int = 60
+Const RICON_REPEAT:Int = 61
+Const RICON_SHUFFLE:Int = 62
+Const RICON_EMPTYBOX:Int = 63
+Const RICON_TARGET:Int = 64
+Const RICON_TARGET_SMALL_FILL:Int = 65
+Const RICON_TARGET_BIG_FILL:Int = 66
+Const RICON_TARGET_MOVE_FILL:Int = 67
+Const RICON_CURSOR_MOVE_FILL:Int = 68
+Const RICON_CURSOR_SCALE_FILL:Int = 69
+Const RICON_CURSOR_SCALE_RIGHT_FILL:Int = 70
+Const RICON_CURSOR_SCALE_LEFT_FILL:Int = 71
+Const RICON_UNDO_FILL:Int = 72
+Const RICON_REDO_FILL:Int = 73
+Const RICON_REREDO_FILL:Int = 74
+Const RICON_MUTATE_FILL:Int = 75
+Const RICON_ROTATE_FILL:Int = 76
+Const RICON_REPEAT_FILL:Int = 77
+Const RICON_SHUFFLE_FILL:Int = 78
+Const RICON_EMPTYBOX_SMALL:Int = 79
+Const RICON_BOX:Int = 80
+Const RICON_BOX_TOP:Int = 81
+Const RICON_BOX_TOP_RIGHT:Int = 82
+Const RICON_BOX_RIGHT:Int = 83
+Const RICON_BOX_BOTTOM_RIGHT:Int = 84
+Const RICON_BOX_BOTTOM:Int = 85
+Const RICON_BOX_BOTTOM_LEFT:Int = 86
+Const RICON_BOX_LEFT:Int = 87
+Const RICON_BOX_TOP_LEFT:Int = 88
+Const RICON_BOX_CENTER:Int = 89
+Const RICON_BOX_CIRCLE_MASK:Int = 90
+Const RICON_POT:Int = 91
+Const RICON_ALPHA_MULTIPLY:Int = 92
+Const RICON_ALPHA_CLEAR:Int = 93
+Const RICON_DITHERING:Int = 94
+Const RICON_MIPMAPS:Int = 95
+Const RICON_BOX_GRID:Int = 96
+Const RICON_GRID:Int = 97
+Const RICON_BOX_CORNERS_SMALL:Int = 98
+Const RICON_BOX_CORNERS_BIG:Int = 99
+Const RICON_FOUR_BOXES:Int = 100
+Const RICON_GRID_FILL:Int = 101
+Const RICON_BOX_MULTISIZE:Int = 102
+Const RICON_ZOOM_SMALL:Int = 103
+Const RICON_ZOOM_MEDIUM:Int = 104
+Const RICON_ZOOM_BIG:Int = 105
+Const RICON_ZOOM_ALL:Int = 106
+Const RICON_ZOOM_CENTER:Int = 107
+Const RICON_BOX_DOTS_SMALL:Int = 108
+Const RICON_BOX_DOTS_BIG:Int = 109
+Const RICON_BOX_CONCENTRIC:Int = 110
+Const RICON_BOX_GRID_BIG:Int = 111
+Const RICON_OK_TICK:Int = 112
+Const RICON_CROSS:Int = 113
+Const RICON_ARROW_LEFT:Int = 114
+Const RICON_ARROW_RIGHT:Int = 115
+Const RICON_ARROW_BOTTOM:Int = 116
+Const RICON_ARROW_TOP:Int = 117
+Const RICON_ARROW_LEFT_FILL:Int = 118
+Const RICON_ARROW_RIGHT_FILL:Int = 119
+Const RICON_ARROW_BOTTOM_FILL:Int = 120
+Const RICON_ARROW_TOP_FILL:Int = 121
+Const RICON_AUDIO:Int = 122
+Const RICON_FX:Int = 123
+Const RICON_WAVE:Int = 124
+Const RICON_WAVE_SINUS:Int = 125
+Const RICON_WAVE_SQUARE:Int = 126
+Const RICON_WAVE_TRIANGULAR:Int = 127
+Const RICON_CROSS_SMALL:Int = 128
+Const RICON_PLAYER_PREVIOUS:Int = 129
+Const RICON_PLAYER_PLAY_BACK:Int = 130
+Const RICON_PLAYER_PLAY:Int = 131
+Const RICON_PLAYER_PAUSE:Int = 132
+Const RICON_PLAYER_STOP:Int = 133
+Const RICON_PLAYER_NEXT:Int = 134
+Const RICON_PLAYER_RECORD:Int = 135
+Const RICON_MAGNET:Int = 136
+Const RICON_LOCK_CLOSE:Int = 137
+Const RICON_LOCK_OPEN:Int = 138
+Const RICON_CLOCK:Int = 139
+Const RICON_TOOLS:Int = 140
+Const RICON_GEAR:Int = 141
+Const RICON_GEAR_BIG:Int = 142
+Const RICON_BIN:Int = 143
+Const RICON_HAND_POINTER:Int = 144
+Const RICON_LASER:Int = 145
+Const RICON_COIN:Int = 146
+Const RICON_EXPLOSION:Int = 147
+Const RICON_1UP:Int = 148
+Const RICON_PLAYER:Int = 149
+Const RICON_PLAYER_JUMP:Int = 150
+Const RICON_KEY:Int = 151
+Const RICON_DEMON:Int = 152
+Const RICON_TEXT_POPUP:Int = 153
+Const RICON_GEAR_EX:Int = 154
+Const RICON_CRACK:Int = 155
+Const RICON_CRACK_POINTS:Int = 156
+Const RICON_STAR:Int = 157
+Const RICON_DOOR:Int = 158
+Const RICON_EXIT:Int = 159
+Const RICON_MODE_2D:Int = 160
+Const RICON_MODE_3D:Int = 161
+Const RICON_CUBE:Int = 162
+Const RICON_CUBE_FACE_TOP:Int = 163
+Const RICON_CUBE_FACE_LEFT:Int = 164
+Const RICON_CUBE_FACE_FRONT:Int = 165
+Const RICON_CUBE_FACE_BOTTOM:Int = 166
+Const RICON_CUBE_FACE_RIGHT:Int = 167
+Const RICON_CUBE_FACE_BACK:Int = 168
+Const RICON_CAMERA:Int = 169
+Const RICON_SPECIAL:Int = 170
+Const RICON_LINK_NET:Int = 171
+Const RICON_LINK_BOXES:Int = 172
+Const RICON_LINK_MULTI:Int = 173
+Const RICON_LINK:Int = 174
+Const RICON_LINK_BROKE:Int = 175
+Const RICON_TEXT_NOTES:Int = 176
+Const RICON_NOTEBOOK:Int = 177
+Const RICON_SUITCASE:Int = 178
+Const RICON_SUITCASE_ZIP:Int = 179
+Const RICON_MAILBOX:Int = 180
+Const RICON_MONITOR:Int = 181
+Const RICON_PRINTER:Int = 182
+Const RICON_PHOTO_CAMERA:Int = 183
+Const RICON_PHOTO_CAMERA_FLASH:Int = 184
+Const RICON_HOUSE:Int = 185
+Const RICON_HEART:Int = 186
+Const RICON_CORNER:Int = 187
+Const RICON_VERTICAL_BARS:Int = 188
+Const RICON_VERTICAL_BARS_FILL:Int = 189
+Const RICON_LIFE_BARS:Int = 190
+Const RICON_INFO:Int = 191
+Const RICON_CROSSLINE:Int = 192
+Const RICON_HELP:Int = 193
+Const RICON_FILETYPE_ALPHA:Int = 194
+Const RICON_FILETYPE_HOME:Int = 195
+Const RICON_LAYERS_VISIBLE:Int = 196
+Const RICON_LAYERS:Int = 197
+Const RICON_WINDOW:Int = 198
+Const RICON_HIDPI:Int = 199
+Const RICON_200:Int = 200
+Const RICON_201:Int = 201
+Const RICON_202:Int = 202
+Const RICON_203:Int = 203
+Const RICON_204:Int = 204
+Const RICON_205:Int = 205
+Const RICON_206:Int = 206
+Const RICON_207:Int = 207
+Const RICON_208:Int = 208
+Const RICON_209:Int = 209
+Const RICON_210:Int = 210
+Const RICON_211:Int = 211
+Const RICON_212:Int = 212
+Const RICON_213:Int = 213
+Const RICON_214:Int = 214
+Const RICON_215:Int = 215
+Const RICON_216:Int = 216
+Const RICON_217:Int = 217
+Const RICON_218:Int = 218
+Const RICON_219:Int = 219
+Const RICON_220:Int = 220
+Const RICON_221:Int = 221
+Const RICON_222:Int = 222
+Const RICON_223:Int = 223
+Const RICON_224:Int = 224
+Const RICON_225:Int = 225
+Const RICON_226:Int = 226
+Const RICON_227:Int = 227
+Const RICON_228:Int = 228
+Const RICON_229:Int = 229
+Const RICON_230:Int = 230
+Const RICON_231:Int = 231
+Const RICON_232:Int = 232
+Const RICON_233:Int = 233
+Const RICON_234:Int = 234
+Const RICON_235:Int = 235
+Const RICON_236:Int = 236
+Const RICON_237:Int = 237
+Const RICON_238:Int = 238
+Const RICON_239:Int = 239
+Const RICON_240:Int = 240
+Const RICON_241:Int = 241
+Const RICON_242:Int = 242
+Const RICON_243:Int = 243
+Const RICON_244:Int = 244
+Const RICON_245:Int = 245
+Const RICON_246:Int = 246
+Const RICON_247:Int = 247
+Const RICON_248:Int = 248
+Const RICON_249:Int = 249
+Const RICON_250:Int = 250
+Const RICON_251:Int = 251
+Const RICON_252:Int = 252
+Const RICON_253:Int = 253
+Const RICON_254:Int = 254
+Const RICON_255:Int = 255

+ 58 - 14
gui.mod/gui.bmx

@@ -353,12 +353,14 @@ End Function
 
 Rem
 bbdoc: Text Box control, which updates input text.
+about: @textSize is the maximum number of UTF-8 characters.
 End Rem
 Function GuiTextBox:Int(bounds:RRectangle, txt:String Var, textSize:Int, editMode:Int)
-	Local length:Size_T = Max(textSize, txt.length * 3 + 1)
-	Local t:Byte Ptr = StackAlloc(length)
+	Local length:Size_T = Min(textSize, txt.length * 3 + 1)
+	Local t:Byte Ptr = StackAlloc(textSize)
+	MemClear(t, textSize)
 	txt.ToUTF8StringBuffer(t, length)
-	Local res:Int = bmx_raygui_GuiTextBox(bounds, t, Int(length), editMode)
+	Local res:Int = bmx_raygui_GuiTextBox(bounds, t, textSize, editMode)
 	txt = String.FromUTF8String(t)
 	Return res
 End Function
@@ -367,10 +369,11 @@ Rem
 bbdoc: Text Box control with multiple lines
 End Rem
 Function GuiTextBoxMulti:Int(bounds:RRectangle, txt:String Var, textSize:Int, editMode:Int)
-	Local length:Size_T = Max(textSize, txt.length * 3 + 1)
-	Local t:Byte Ptr = StackAlloc(length)
+	Local length:Size_T = Min(textSize, txt.length * 3 + 1)
+	Local t:Byte Ptr = StackAlloc(textSize)
+	MemClear(t, Size_T(textSize))
 	txt.ToUTF8StringBuffer(t, length)
-	Local res:Int = bmx_raygui_GuiTextBoxMulti(bounds, t, Int(length), editMode)
+	Local res:Int = bmx_raygui_GuiTextBoxMulti(bounds, t, textSize, editMode)
 	txt = String.FromUTF8String(t)
 	Return res
 End Function
@@ -486,15 +489,14 @@ Rem
 bbdoc: List View with extended parameters.
 End Rem
 Function GuiListViewEx:Int(bounds:RRectangle, txt:String[], focus:Int Var, scrollIndex:Int Var, active:Int)
-	Local list:Size_T Ptr = MemAlloc(Size_T(txt.length * 8))
+	Local list:Byte Ptr Ptr = StackAlloc(Size_T(txt.length * 8))
 	For Local i:Int = 0 Until txt.length
-		list[i] = Size_T(txt[i].ToUTF8String())
+		list[i] = txt[i].ToUTF8String()
 	Next
-	Local res:Int = bmx_raygui_GuiListViewEx(bounds, list, focus, scrollIndex, active)
+	Local res:Int = bmx_raygui_GuiListViewEx(bounds, list, txt.length, focus, scrollIndex, active)
 	For Local i:Int = 0 Until txt.length
-		MemFree(Byte Ptr(list[i]))
+		MemFree(list[i])
 	Next
-	MemFree(list)
 	Return res
 End Function
 
@@ -527,7 +529,7 @@ End Function
 Rem
 bbdoc: Text Input Box control, asks for text.
 End Rem
-Function GuiTextInputBox:Int(bounds:RRectangle, title:String, message:String, buttons:String, txt:String)
+Function GuiTextInputBox:Int(bounds:RRectangle, title:String, message:String, buttons:String, txt:String Var)
 	Local length:Size_T = title.length * 3 + 1
 	Local t:Byte Ptr = StackAlloc(length)
 	title.ToUTF8StringBuffer(t, length)
@@ -540,9 +542,15 @@ Function GuiTextInputBox:Int(bounds:RRectangle, title:String, message:String, bu
 	Local b:Byte Ptr = StackAlloc(length)
 	buttons.ToUTF8StringBuffer(b, length)
 
-	Local t2:Byte Ptr = txt.ToUTF8String()
+	Local t2:Byte Ptr = StackAlloc(256)
+	If txt Then
+		length = txt.length * 3 + 1
+		txt.ToUTF8StringBuffer(t2, length)
+	Else
+		t2[0] = 0
+	End If
 	Local res:Int = bmx_raygui_GuiTextInputBox(bounds, t, m, b, t2)
-	MemFree(t2)
+	txt = String.FromUTF8String(t2)
 	
 	Return res
 End Function
@@ -567,3 +575,39 @@ Function GuiLoadStyleDefault()
 	bmx_raygui_GuiLoadStyleDefault()
 End Function
 
+Rem
+bbdoc: Gets text with icon id prepended.
+about: Useful to add icons by name id (enum) instead of a number that can change between ricon versions
+End Rem
+Function GuiIconText:String(iconId:Int, txt:String)
+	Local t:Byte Ptr
+	If txt Then
+		Local length:Size_T = txt.length * 3 + 1
+		t = StackAlloc(length)
+		txt.ToUTF8StringBuffer(t, length)
+	End If
+	Return String.FromUTF8String(bmx_raygui_GuiIconText(iconId, t))
+End Function
+
+Rem
+bbdoc: Draws a an icon.
+End Rem
+Function GuiDrawIcon(iconId:Int, position:RVector2, pixelSize:Int, color:RColor)
+	bmx_raygui_GuiDrawIcon(iconId, position, pixelSize, color)
+End Function
+
+Rem
+bbdoc: Color Bar Alpha control.
+about: Returns alpha value normalized `[0..1]`.
+End Rem
+Function GuiColorBarAlpha:Float(bounds:RRectangle, alpha:Float)
+	Return bmx_raygui_GuiColorBarAlpha(bounds, alpha)
+End Function
+
+Rem
+bbdoc: Color Bar Hue control.
+about: Returns hue value normalized `[0..1]`.
+End Rem
+Function GuiColorBarHue:Float(bounds:RRectangle, value:Float)
+	Return bmx_raygui_GuiColorBarHue(bounds, value)
+End Function