mirror of
https://github.com/raysan5/raygui.git
synced 2026-07-11 00:01:56 -04:00
Compare commits
3 Commits
b94d3a8b19
...
3af034bfab
| Author | SHA1 | Date | |
|---|---|---|---|
| 3af034bfab | |||
| 3e8bd3a8b3 | |||
| 6c68a8deac |
59
src/raygui.h
59
src/raygui.h
@ -604,7 +604,7 @@ typedef enum {
|
|||||||
TEXT_COLOR_DISABLED = 11, // Control text color in STATE_DISABLED
|
TEXT_COLOR_DISABLED = 11, // Control text color in STATE_DISABLED
|
||||||
BORDER_WIDTH = 12, // Control border size, 0 for no border
|
BORDER_WIDTH = 12, // Control border size, 0 for no border
|
||||||
TEXT_PADDING = 13, // Control text padding, not considering border
|
TEXT_PADDING = 13, // Control text padding, not considering border
|
||||||
TEXT_ALIGNMENT = 14, // Control text horizontal alignment inside control text bound (after border and padding)
|
TEXT_ALIGNMENT = 14, // Control text horizontal alignment inside control text bound (after border and padding): 0-Left, 1-Center, 2-Right
|
||||||
BASEPROP16 = 15 // Not used yet...
|
BASEPROP16 = 15 // Not used yet...
|
||||||
} GuiControlProperty;
|
} GuiControlProperty;
|
||||||
|
|
||||||
@ -621,17 +621,17 @@ typedef enum {
|
|||||||
|
|
||||||
|
|
||||||
// Controls EXTENDED properties (RAYGUI_MAX_PROPS_EXTENDED = 8)
|
// Controls EXTENDED properties (RAYGUI_MAX_PROPS_EXTENDED = 8)
|
||||||
|
// WARNING: Only 8 slots vailable for those properties per control, including DEFAULT
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// DEFAULT control, extended properties
|
// DEFAULT control, extended properties
|
||||||
// NOTE: Those properties are global for all controls, they can not be setup per control
|
// NOTE: Those properties are global for all controls, they can not be setup per control
|
||||||
// WARNING: Only 8 slots vailable for those properties by default
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TEXT_SIZE = 16, // Text size (glyphs max height)
|
TEXT_SIZE = 16, // Text size (glyphs max height)
|
||||||
TEXT_SPACING = 17, // Text spacing between glyphs
|
TEXT_SPACING = 17, // Text spacing between glyphs
|
||||||
LINE_COLOR = 18, // Line control color
|
LINE_COLOR = 18, // Line control color
|
||||||
BACKGROUND_COLOR = 19, // Background color
|
BACKGROUND_COLOR = 19, // Background color
|
||||||
TEXT_LINE_SPACING = 20, // Text spacing between lines
|
TEXT_LINE_SPACING = 20, // Text spacing between lines
|
||||||
TEXT_ALIGNMENT_VERTICAL = 21, // Text vertical alignment inside text bounds (after border and padding)
|
TEXT_ALIGNMENT_VERTICAL = 21, // Text vertical alignment inside text bounds (after border and padding): 0-Top, 1-Middle, 2-Bottom
|
||||||
TEXT_WRAP_MODE = 22, // Text wrap-mode inside text bounds
|
TEXT_WRAP_MODE = 22, // Text wrap-mode inside text bounds
|
||||||
EXTPROP08 = 23 // Not used yet...
|
EXTPROP08 = 23 // Not used yet...
|
||||||
} GuiDefaultProperty;
|
} GuiDefaultProperty;
|
||||||
@ -639,17 +639,18 @@ typedef enum {
|
|||||||
// Other possible text extended properties:
|
// Other possible text extended properties:
|
||||||
// TEXT_DECORATION // Text decoration: 0-None, 1-Underline, 2-Line-through, 3-Overline
|
// TEXT_DECORATION // Text decoration: 0-None, 1-Underline, 2-Line-through, 3-Overline
|
||||||
// TEXT_DECORATION_THICK // Text decoration line thickness
|
// TEXT_DECORATION_THICK // Text decoration line thickness
|
||||||
// TEXT_FONT_WEIGHT // Text font weight: Normal, Italic, Bold -> Requires specific font change
|
// TEXT_FONT_WEIGHT // Text font weight: 0-Normal, 1-Bold, 2-Italic -> Requires specific font change
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
//typedef enum { } GuiLabelProperty;
|
//typedef enum { } GuiLabelProperty;
|
||||||
|
|
||||||
// Button/Spinner
|
// Button
|
||||||
//typedef enum { } GuiButtonProperty;
|
//typedef enum { } GuiButtonProperty;
|
||||||
|
|
||||||
// Toggle/ToggleGroup
|
// Toggle/ToggleGroup
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GROUP_PADDING = 16, // ToggleGroup separation between toggles
|
GROUP_PADDING = 16, // ToggleGroup separation between toggles
|
||||||
|
GROUP_WIDTH_FULL // ToggleGroup bounds width considers all items: 0-Width per item, 1-Full width
|
||||||
} GuiToggleProperty;
|
} GuiToggleProperty;
|
||||||
|
|
||||||
// Slider/SliderBar
|
// Slider/SliderBar
|
||||||
@ -661,7 +662,7 @@ typedef enum {
|
|||||||
// ProgressBar
|
// ProgressBar
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PROGRESS_PADDING = 16, // ProgressBar internal padding
|
PROGRESS_PADDING = 16, // ProgressBar internal padding
|
||||||
PROGRESS_SIDE, // ProgressBar increment side: 0-left->right, 1-right-left
|
PROGRESS_SIDE, // ProgressBar increment side: 0-Left->Right, 1-Right->Left
|
||||||
} GuiProgressBarProperty;
|
} GuiProgressBarProperty;
|
||||||
|
|
||||||
// ScrollBar
|
// ScrollBar
|
||||||
@ -690,12 +691,12 @@ typedef enum {
|
|||||||
ARROW_PADDING = 16, // DropdownBox arrow separation from border and items
|
ARROW_PADDING = 16, // DropdownBox arrow separation from border and items
|
||||||
DROPDOWN_ITEMS_SPACING, // DropdownBox items separation
|
DROPDOWN_ITEMS_SPACING, // DropdownBox items separation
|
||||||
DROPDOWN_ARROW_HIDDEN, // DropdownBox arrow hidden
|
DROPDOWN_ARROW_HIDDEN, // DropdownBox arrow hidden
|
||||||
DROPDOWN_ROLL_UP // DropdownBox roll up flag (default rolls down)
|
DROPDOWN_ROLL_UP // DropdownBox roll up flag: 0-Roll down, 1-Roll up
|
||||||
} GuiDropdownBoxProperty;
|
} GuiDropdownBoxProperty;
|
||||||
|
|
||||||
// TextBox/TextBoxMulti/ValueBox/Spinner
|
// TextBox/TextBoxMulti/ValueBox/Spinner
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TEXT_READONLY = 16, // TextBox in read-only mode: 0-text editable, 1-text no-editable
|
TEXT_READONLY = 16, // TextBox in read-only mode: 0-Text editable, 1-Text read-only
|
||||||
} GuiTextBoxProperty;
|
} GuiTextBoxProperty;
|
||||||
|
|
||||||
// ValueBox/Spinner
|
// ValueBox/Spinner
|
||||||
@ -707,8 +708,8 @@ typedef enum {
|
|||||||
// TabBar
|
// TabBar
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TAB_ITEMS_WIDTH = 16, // TabBar tab items width
|
TAB_ITEMS_WIDTH = 16, // TabBar tab items width
|
||||||
TAB_CLOSE_BUTTON, // TabBar tab close button (0-Not shown, 1-Shown)
|
TAB_CLOSE_BUTTON, // TabBar tab close button: 0-Not shown, 1-Shown
|
||||||
TAB_LINE_SIDE, // TabBar tabs side (0-Bottom, 1-Top)
|
TAB_LINE_SIDE, // TabBar tabs side: 0-Bottom, 1-Top
|
||||||
} GuiTabBarProperty;
|
} GuiTabBarProperty;
|
||||||
|
|
||||||
// ListView
|
// ListView
|
||||||
@ -719,14 +720,14 @@ typedef enum {
|
|||||||
LIST_ITEMS_HEIGHT = 16, // ListView items height
|
LIST_ITEMS_HEIGHT = 16, // ListView items height
|
||||||
LIST_ITEMS_SPACING, // ListView items separation
|
LIST_ITEMS_SPACING, // ListView items separation
|
||||||
SCROLLBAR_WIDTH, // ListView scrollbar size (usually width)
|
SCROLLBAR_WIDTH, // ListView scrollbar size (usually width)
|
||||||
SCROLLBAR_SIDE, // ListView scrollbar side (0-SCROLLBAR_LEFT_SIDE, 1-SCROLLBAR_RIGHT_SIDE)
|
SCROLLBAR_SIDE, // ListView scrollbar side: 0-Left side, 1-Right Side
|
||||||
LIST_ITEMS_BORDER_NORMAL, // ListView items border enabled in normal state
|
LIST_ITEMS_BORDER_NORMAL, // ListView items border enabled in normal state
|
||||||
LIST_ITEMS_BORDER_WIDTH // ListView items border width
|
LIST_ITEMS_BORDER_WIDTH // ListView items border width
|
||||||
} GuiListViewProperty;
|
} GuiListViewProperty;
|
||||||
|
|
||||||
// ColorPicker
|
// ColorPicker
|
||||||
typedef enum {
|
typedef enum {
|
||||||
COLOR_SELECTOR_SIZE = 16,
|
COLOR_SELECTOR_SIZE = 16, // ColorPicker selector square size
|
||||||
HUEBAR_WIDTH, // ColorPicker right hue bar width
|
HUEBAR_WIDTH, // ColorPicker right hue bar width
|
||||||
HUEBAR_PADDING, // ColorPicker right hue bar separation from panel
|
HUEBAR_PADDING, // ColorPicker right hue bar separation from panel
|
||||||
HUEBAR_SELECTOR_HEIGHT, // ColorPicker right hue bar selector height
|
HUEBAR_SELECTOR_HEIGHT, // ColorPicker right hue bar selector height
|
||||||
@ -2198,6 +2199,15 @@ int GuiToggleGroup(Rectangle bounds, const char *text, int *active)
|
|||||||
float initBoundsX = bounds.x;
|
float initBoundsX = bounds.x;
|
||||||
float initBoundsY = bounds.y;
|
float initBoundsY = bounds.y;
|
||||||
|
|
||||||
|
if (GuiGetStyle(TOGGLE, GROUP_WIDTH_FULL))
|
||||||
|
{
|
||||||
|
// Calculate item width considring all horizontal items
|
||||||
|
// NOTE: bounds.height still considers individual items height
|
||||||
|
int itemCount = 1;
|
||||||
|
for (int c = 0; textPtr[c] != '\0'; c++) { if (textPtr[c] == ';') itemCount++; }
|
||||||
|
bounds.width /= itemCount;
|
||||||
|
}
|
||||||
|
|
||||||
// Text parsing needed to consider potential row and col entries (vertical/horizontal layout)
|
// Text parsing needed to consider potential row and col entries (vertical/horizontal layout)
|
||||||
// when '\n' found move vertically next toggle, when ';' found move horizontally
|
// when '\n' found move vertically next toggle, when ';' found move horizontally
|
||||||
for (int c = 0, k = 0, itemIndex = 0, row = 0, col = 0, exit = 0; exit == 0; c++)
|
for (int c = 0, k = 0, itemIndex = 0, row = 0, col = 0, exit = 0; exit == 0; c++)
|
||||||
@ -3818,14 +3828,14 @@ int GuiListViewEx(Rectangle bounds, char **text, int count, int *scrollIndex, in
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Color Panel control - Color (RGBA) variant
|
// Color Panel control
|
||||||
int GuiColorPanel(Rectangle bounds, const char *text, Color *color)
|
int GuiColorPanel(Rectangle bounds, const char *text, Color *color)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
Vector3 vcolor = { (float)color->r/255.0f, (float)color->g/255.0f, (float)color->b/255.0f };
|
Vector3 vcolor = { (float)color->r/255.0f, (float)color->g/255.0f, (float)color->b/255.0f };
|
||||||
Vector3 hsv = ConvertRGBtoHSV(vcolor);
|
Vector3 hsv = ConvertRGBtoHSV(vcolor);
|
||||||
Vector3 prevHsv = hsv; // workaround to see if GuiColorPanelHSV modifies the hsv
|
Vector3 prevHsv = hsv; // NOTE: Workaround to see if GuiColorPanelHSV() modifies the hsv
|
||||||
|
|
||||||
GuiColorPanelHSV(bounds, text, &hsv);
|
GuiColorPanelHSV(bounds, text, &hsv);
|
||||||
|
|
||||||
@ -3834,16 +3844,12 @@ int GuiColorPanel(Rectangle bounds, const char *text, Color *color)
|
|||||||
// Thus the assignment from HSV to Color should only be made, if the HSV has a new user-entered value
|
// Thus the assignment from HSV to Color should only be made, if the HSV has a new user-entered value
|
||||||
// Otherwise GuiColorPanel would often modify it's color without user input
|
// Otherwise GuiColorPanel would often modify it's color without user input
|
||||||
// TODO: GuiColorPanelHSV could return 1 if the slider was dragged, to simplify this check
|
// TODO: GuiColorPanelHSV could return 1 if the slider was dragged, to simplify this check
|
||||||
if (hsv.x != prevHsv.x || hsv.y != prevHsv.y || hsv.z != prevHsv.z)
|
if ((hsv.x != prevHsv.x) || (hsv.y != prevHsv.y) || (hsv.z != prevHsv.z))
|
||||||
{
|
{
|
||||||
Vector3 rgb = ConvertHSVtoRGB(hsv);
|
Vector3 rgb = ConvertHSVtoRGB(hsv);
|
||||||
|
*color = RAYGUI_CLITERAL(Color){ (unsigned char)(255.0f*rgb.x), (unsigned char)(255.0f*rgb.y), (unsigned char)(255.0f*rgb.z), color->a };
|
||||||
// NOTE: Vector3ToColor() only available on raylib 1.8.1
|
|
||||||
*color = RAYGUI_CLITERAL(Color){ (unsigned char)(255.0f*rgb.x),
|
|
||||||
(unsigned char)(255.0f*rgb.y),
|
|
||||||
(unsigned char)(255.0f*rgb.z),
|
|
||||||
color->a };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4079,7 +4085,7 @@ int GuiColorPickerHSV(Rectangle bounds, const char *text, Vector3 *colorHsv)
|
|||||||
|
|
||||||
GuiColorPanelHSV(bounds, NULL, colorHsv);
|
GuiColorPanelHSV(bounds, NULL, colorHsv);
|
||||||
|
|
||||||
const Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
|
Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
|
||||||
|
|
||||||
GuiColorBarHue(boundsHue, NULL, &colorHsv->x);
|
GuiColorBarHue(boundsHue, NULL, &colorHsv->x);
|
||||||
|
|
||||||
@ -4101,9 +4107,7 @@ int GuiColorPanelHSV(Rectangle bounds, const char *text, Vector3 *colorHsv)
|
|||||||
|
|
||||||
Vector3 maxHue = { colorHsv->x, 1.0f, 1.0f };
|
Vector3 maxHue = { colorHsv->x, 1.0f, 1.0f };
|
||||||
Vector3 rgbHue = ConvertHSVtoRGB(maxHue);
|
Vector3 rgbHue = ConvertHSVtoRGB(maxHue);
|
||||||
Color maxHueCol = { (unsigned char)(255.0f*rgbHue.x),
|
Color maxHueCol = { (unsigned char)(255.0f*rgbHue.x), (unsigned char)(255.0f*rgbHue.y), (unsigned char)(255.0f*rgbHue.z), 255 };
|
||||||
(unsigned char)(255.0f*rgbHue.y),
|
|
||||||
(unsigned char)(255.0f*rgbHue.z), 255 };
|
|
||||||
|
|
||||||
// Update control
|
// Update control
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
@ -4127,12 +4131,11 @@ int GuiColorPanelHSV(Rectangle bounds, const char *text, Vector3 *colorHsv)
|
|||||||
// Calculate color from picker
|
// Calculate color from picker
|
||||||
Vector2 colorPick = { pickerSelector.x - bounds.x, pickerSelector.y - bounds.y };
|
Vector2 colorPick = { pickerSelector.x - bounds.x, pickerSelector.y - bounds.y };
|
||||||
|
|
||||||
colorPick.x /= (float)bounds.width; // Get normalized value on x
|
colorPick.x /= (float)bounds.width; // Get normalized value on x
|
||||||
colorPick.y /= (float)bounds.height; // Get normalized value on y
|
colorPick.y /= (float)bounds.height; // Get normalized value on y
|
||||||
|
|
||||||
colorHsv->y = colorPick.x;
|
colorHsv->y = colorPick.x;
|
||||||
colorHsv->z = 1.0f - colorPick.y;
|
colorHsv->z = 1.0f - colorPick.y;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user