Compare commits
14 Commits
5.0
...
47066b1b9f
| Author | SHA1 | Date | |
|---|---|---|---|
| 47066b1b9f | |||
| 580961b63b | |||
| e414c7e065 | |||
| 30e3034007 | |||
| 181e77961b | |||
| fbf5d95e19 | |||
| 0132e47671 | |||
| 9fed992452 | |||
| 70f440b2d1 | |||
| 4f917532aa | |||
| 3f81e2bd02 | |||
| 63465e55c2 | |||
| 220b6a85ba | |||
| 3ea06d4c3d |
@ -10,7 +10,7 @@
|
||||
|
||||
<br>
|
||||
|
||||
**WARNING: Latest `raygui` from master branch is always aligned with latest `raylib` from master branch and all raylibtech tools. Make sure to use the appropriate versions.**
|
||||
**WARNING: Latest `raygui` from master branch is always aligned with latest `raylib` from master branch and all raylibtech tools. Make sure to use the latest versions.**
|
||||
|
||||
**WARNING: Latest `raygui 5.0` introduces some API-BREAKING changes, now all functions return a result value.**
|
||||
|
||||
|
||||
@ -324,7 +324,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
# Libraries for OSX 10.9 desktop compiling
|
||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
||||
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo -framework QuartzCore
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||
|
||||
@ -58,6 +58,12 @@
|
||||
#include "../styles/style_sunny.h" // raygui style: sunny
|
||||
#include "../styles/style_amber.h" // raygui style: amber
|
||||
#include "../styles/style_genesis.h" // raygui style: genesis
|
||||
#include "../styles/style_brick.h" // raygui style: genesis
|
||||
#include "../styles/style_turbo.h" // raygui style: genesis
|
||||
#include "../styles/style_wisteria.h" // raygui style: genesis
|
||||
#include "../styles/style_advance.h" // raygui style: genesis
|
||||
#include "../styles/style_rltech.h" // raygui style: genesis
|
||||
#include "../styles/style_pocket.h" // raygui style: genesis
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
@ -139,6 +145,8 @@ int main()
|
||||
//GuiSetStyle(DEFAULT, TEXT_PADDING, 0);
|
||||
//GuiSetStyle(DEFAULT, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
|
||||
|
||||
int frameCounter = 0;
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@ -174,6 +182,16 @@ int main()
|
||||
if (progressValue > 1.0f) progressValue = 1.0f;
|
||||
else if (progressValue < 0.0f) progressValue = 0.0f;
|
||||
|
||||
/*
|
||||
// Style updater auto
|
||||
frameCounter++;
|
||||
if ((frameCounter > 300) && (frameCounter%60) == 0)
|
||||
{
|
||||
visualStyleActive++;
|
||||
if (visualStyleActive >= 20) visualStyleActive = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
if (visualStyleActive != prevVisualStyleActive)
|
||||
{
|
||||
GuiLoadStyleDefault();
|
||||
@ -194,6 +212,12 @@ int main()
|
||||
case 11: GuiLoadStyleSunny(); break;
|
||||
case 12: GuiLoadStyleAmber(); break;
|
||||
case 13: GuiLoadStyleGenesis(); break;
|
||||
case 14: GuiLoadStyleBrick(); break;
|
||||
case 15: GuiLoadStylePocket(); break;
|
||||
case 16: GuiLoadStyleTurbo(); break;
|
||||
case 17: GuiLoadStyleWisteria(); break;
|
||||
case 18: GuiLoadStyleAdvance(); break;
|
||||
case 19: GuiLoadStyleRLTech(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@ -244,7 +268,7 @@ int main()
|
||||
|
||||
GuiSetStyle(COMBOBOX, COMBO_BUTTON_WIDTH, 40);
|
||||
GuiComboBox((Rectangle){ 25, 480 + 20, 125, 30 },
|
||||
"default;Jungle;Lavanda;Dark;Bluish;Cyber;Terminal;Candy;Cherry;Ashes;Enefete;Sunny;Amber;Genesis", &visualStyleActive);
|
||||
"default;Jungle;Lavanda;Dark;Bluish;Cyber;Terminal;Candy;Cherry;Ashes;Enefete;Sunny;Amber;Genesis;Brick;Pocket;Turbo;Wisteria;Advance;RLTech", &visualStyleActive);
|
||||
|
||||
// NOTE: GuiDropdownBox must draw after any other control that can be covered on unfolding
|
||||
if (dropDown000EditMode || dropDown001EditMode) GuiUnlock();
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raygui - controls test suite
|
||||
*
|
||||
* COMPILATION (Windows - MinGW):
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* Copyright (c) 2016-2024 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#include "../../src/raygui.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//---------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raygui - controls test suite");
|
||||
|
||||
float valueBoxValue = 0.0f;
|
||||
bool valueBoxEditMode = false;
|
||||
char valueBoxTextValue[32] = { 0 };
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
|
||||
|
||||
if (GuiValueBoxFloat((Rectangle){ 25, 175, 125, 30 }, NULL, valueBoxTextValue, &valueBoxValue, valueBoxEditMode))
|
||||
{
|
||||
valueBoxEditMode = !valueBoxEditMode;
|
||||
|
||||
printf("Value: %2.2f\n", valueBoxValue);
|
||||
}
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -11,7 +11,7 @@
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define ADVANCE_STYLE_PROPS_COUNT 25
|
||||
#define ADVANCE_STYLE_PROPS_COUNT 26
|
||||
|
||||
// Custom style name: Advance
|
||||
static const GuiStyleProp advanceStyleProps[ADVANCE_STYLE_PROPS_COUNT] = {
|
||||
@ -31,6 +31,7 @@ static const GuiStyleProp advanceStyleProps[ADVANCE_STYLE_PROPS_COUNT] = {
|
||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||
{ 0, 18, (int)0x9eadd0ff }, // DEFAULT_LINE_COLOR
|
||||
{ 0, 19, (int)0xe6e6e6ff }, // DEFAULT_BACKGROUND_COLOR
|
||||
{ 0, 20, (int)0x00000006 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 1, 5, (int)0x917de2ff }, // LABEL_TEXT_COLOR_FOCUSED
|
||||
{ 1, 8, (int)0xffb033ff }, // LABEL_TEXT_COLOR_PRESSED
|
||||
{ 4, 5, (int)0xb0b0e1ff }, // SLIDER_TEXT_COLOR_FOCUSED
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define BRICK_STYLE_PROPS_COUNT 17
|
||||
#define BRICK_STYLE_PROPS_COUNT 18
|
||||
|
||||
// Custom style name: Brick
|
||||
static const GuiStyleProp brickStyleProps[BRICK_STYLE_PROPS_COUNT] = {
|
||||
@ -29,6 +29,7 @@ static const GuiStyleProp brickStyleProps[BRICK_STYLE_PROPS_COUNT] = {
|
||||
{ 0, 11, (int)0x8c9c9eff }, // DEFAULT_TEXT_COLOR_DISABLED
|
||||
{ 0, 18, (int)0x71a8aeff }, // DEFAULT_LINE_COLOR
|
||||
{ 0, 19, (int)0xeff0f3ff }, // DEFAULT_BACKGROUND_COLOR
|
||||
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 1, 5, (int)0x568a90ff }, // LABEL_TEXT_COLOR_FOCUSED
|
||||
{ 9, 5, (int)0x5e9095ff }, // TEXTBOX_TEXT_COLOR_FOCUSED
|
||||
{ 10, 5, (int)0x639196ff }, // VALUEBOX_TEXT_COLOR_FOCUSED
|
||||
|
||||
@ -31,7 +31,7 @@ static const GuiStyleProp pocketStyleProps[POCKET_STYLE_PROPS_COUNT] = {
|
||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||
{ 0, 18, (int)0x56591eff }, // DEFAULT_LINE_COLOR
|
||||
{ 0, 19, (int)0xd9d9ceff }, // DEFAULT_BACKGROUND_COLOR
|
||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
};
|
||||
|
||||
// WARNING: This style uses a custom font: "GMSN.ttf" (size: 16, spacing: 0)
|
||||
|
||||
@ -30,7 +30,7 @@ static const GuiStyleProp turboStyleProps[TURBO_STYLE_PROPS_COUNT] = {
|
||||
{ 0, 16, (int)0x00000010 }, // DEFAULT_TEXT_SIZE
|
||||
{ 0, 18, (int)0xbbaf6cff }, // DEFAULT_LINE_COLOR
|
||||
{ 0, 19, (int)0x60645fff }, // DEFAULT_BACKGROUND_COLOR
|
||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 1, 8, (int)0xf0e4c4ff }, // LABEL_TEXT_COLOR_PRESSED
|
||||
{ 1, 11, (int)0x959680ff }, // LABEL_TEXT_COLOR_DISABLED
|
||||
{ 4, 8, (int)0xb4aa8dff }, // SLIDER_TEXT_COLOR_PRESSED
|
||||
|
||||
@ -31,7 +31,7 @@ static const GuiStyleProp wisteriaStyleProps[WISTERIA_STYLE_PROPS_COUNT] = {
|
||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||
{ 0, 18, (int)0x9b74d2ff }, // DEFAULT_LINE_COLOR
|
||||
{ 0, 19, (int)0xe9eaf6ff }, // DEFAULT_BACKGROUND_COLOR
|
||||
{ 0, 20, (int)0x00000012 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 4, 3, (int)0xa9bdcfff }, // SLIDER_BORDER_COLOR_FOCUSED
|
||||
{ 4, 5, (int)0xacc4d8ff }, // SLIDER_TEXT_COLOR_FOCUSED
|
||||
{ 5, 3, (int)0xb5c7d9ff }, // PROGRESSBAR_BORDER_COLOR_FOCUSED
|
||||
|
||||
122
src/raygui.h
@ -1,6 +1,6 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raygui v5.0 - A simple and easy-to-use immediate-mode gui library
|
||||
* raygui v5.1-dev - A simple and easy-to-use immediate-mode gui library
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* raygui is a tools-dev-focused immediate-mode-gui library based on raylib but also
|
||||
@ -145,6 +145,8 @@
|
||||
* Draw text bounds rectangles for debug
|
||||
*
|
||||
* VERSIONS HISTORY:
|
||||
* 6.0 (xx-xx-2027) ADDED: Advance controls set?
|
||||
*
|
||||
* 5.0 (20-Jul-2026) ADDED: NEW control: GuiTabBar()
|
||||
* ADDED: Support up to 512 icons (v500)
|
||||
* ADDED: Support icons baking into font atlas image
|
||||
@ -353,9 +355,9 @@
|
||||
#define RAYGUI_H
|
||||
|
||||
#define RAYGUI_VERSION_MAJOR 5
|
||||
#define RAYGUI_VERSION_MINOR 0
|
||||
#define RAYGUI_VERSION_MINOR 1
|
||||
#define RAYGUI_VERSION_PATCH 0
|
||||
#define RAYGUI_VERSION "5.0"
|
||||
#define RAYGUI_VERSION "5.1-dev"
|
||||
|
||||
#if !defined(RAYGUI_STANDALONE)
|
||||
#include "raylib.h"
|
||||
@ -1584,7 +1586,7 @@ static void UnloadCodepoints(int *codepoints); // -- GuiLoadStyle(
|
||||
|
||||
static unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // -- GuiLoadStyle()
|
||||
|
||||
static Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // Measure string size for Font
|
||||
static void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint)
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
// raylib functions already implemented in raygui
|
||||
@ -1612,6 +1614,7 @@ static const char *GetTextIcon(const char *text, int *iconId); // Get text icon
|
||||
|
||||
static void GuiDrawText(const char *text, Rectangle textBounds, int alignment, Color tint); // Gui draw text using default font
|
||||
static void GuiDrawRectangle(Rectangle rec, int borderWidth, Color borderColor, Color color); // Gui draw rectangle using default raygui style
|
||||
static Vector2 GuiMeasureText(const char *text); // Measure text size for current gui style
|
||||
|
||||
static char **GuiTextSplit(const char *text, char delimiter, int *count); // Split controls text into multiple strings
|
||||
static Vector3 ConvertHSVtoRGB(Vector3 hsv); // Convert color data from HSV to RGB
|
||||
@ -3881,7 +3884,7 @@ int GuiTabBar(Rectangle bounds, const char *text, int *hscroll, int *active)
|
||||
|
||||
// Tab Bar control, using text entries list and returning focus entry
|
||||
// NOTE: In case of tab close result, consider focused tab
|
||||
// TODO: Reeplace GuiToggle() usage for custom implementation for the TABS
|
||||
// TODO: Replace GuiToggle() usage for custom implementation for the TABS
|
||||
int GuiTabBarEx(Rectangle bounds, char **text, int count, int *hscroll, int *active, int *focus)
|
||||
{
|
||||
int result = RESULT_NONE;
|
||||
@ -4157,22 +4160,22 @@ int GuiColorBarHue(Rectangle bounds, const char *text, float *hue)
|
||||
{
|
||||
// Draw hue bar:color bars
|
||||
// NOTE: Using DrawRectangleGradientEx(bounds, color1, color2, color2, color1);
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y, bounds.width, bounds.height/6.0f },
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y, bounds.width, bounds.height/6.0f },
|
||||
Fade(RAYGUI_CLITERAL(Color){ 255, 0, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 255, 255, 0, 255 }, guiAlpha),
|
||||
Fade(RAYGUI_CLITERAL(Color){ 255, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 255, 0, 0, 255 }, guiAlpha));
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + 1*(bounds.height/6.0f), bounds.width, bounds.height/6.0f },
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + 1*(bounds.height/6.0f), bounds.width, bounds.height/6.0f },
|
||||
Fade(RAYGUI_CLITERAL(Color){ 255, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 0, 255, 0, 255 }, guiAlpha),
|
||||
Fade(RAYGUI_CLITERAL(Color){ 0, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 255, 255, 0, 255 }, guiAlpha));
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + 2*(bounds.height/6.0f), bounds.width, bounds.height/6.0f },
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + 2*(bounds.height/6.0f), bounds.width, bounds.height/6.0f },
|
||||
Fade(RAYGUI_CLITERAL(Color){ 0, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 0, 255, 255, 255 }, guiAlpha),
|
||||
Fade(RAYGUI_CLITERAL(Color){ 0, 255, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 0, 255, 0, 255 }, guiAlpha));
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + 3*(bounds.height/6.0f), bounds.width, bounds.height/6.0f },
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + 3*(bounds.height/6.0f), bounds.width, bounds.height/6.0f },
|
||||
Fade(RAYGUI_CLITERAL(Color){ 0, 255, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 0, 0, 255, 255 }, guiAlpha),
|
||||
Fade(RAYGUI_CLITERAL(Color){ 0, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 0, 255, 255, 255 }, guiAlpha));
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + 4*(bounds.height/6.0f), bounds.width, bounds.height/6.0f },
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + 4*(bounds.height/6.0f), bounds.width, bounds.height/6.0f },
|
||||
Fade(RAYGUI_CLITERAL(Color){ 0, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 255, 0, 255, 255 }, guiAlpha),
|
||||
Fade(RAYGUI_CLITERAL(Color){ 255, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 0, 0, 255, 255 }, guiAlpha));
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + 5*(bounds.height/6.0f), bounds.width, bounds.height/6.0f },
|
||||
DrawRectangleGradientEx(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + 5*(bounds.height/6.0f), bounds.width, bounds.height/6.0f },
|
||||
Fade(RAYGUI_CLITERAL(Color){ 255, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 255, 0, 0, 255 }, guiAlpha),
|
||||
Fade(RAYGUI_CLITERAL(Color){ 255, 0, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color){ 255, 0, 255, 255 }, guiAlpha));
|
||||
}
|
||||
@ -4214,7 +4217,7 @@ int GuiColorPicker(Rectangle bounds, const char *text, Color *color)
|
||||
// NOTE: this conversion can cause low hue-resolution, if the r, g and b value are very similar, which causes the hue bar to shift around when only the GuiColorPanel is used
|
||||
Vector3 hsv = ConvertRGBtoHSV(RAYGUI_CLITERAL(Vector3){ (*color).r/255.0f, (*color).g/255.0f, (*color).b/255.0f });
|
||||
|
||||
if (result != RESULT_CHANGED) result = GuiColorBarHue(boundsHue, NULL, &hsv.x);
|
||||
result = GuiColorBarHue(boundsHue, NULL, &hsv.x);
|
||||
|
||||
//color.a = (unsigned char)(GuiColorBarAlpha(boundsAlpha, (float)color.a/255.0f)*255.0f);
|
||||
Vector3 rgb = ConvertHSVtoRGB(hsv);
|
||||
@ -4449,11 +4452,11 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, ch
|
||||
Rectangle textBounds = { 0 };
|
||||
if (message != NULL)
|
||||
{
|
||||
int textSize = GuiGetTextWidth(message) + 2;
|
||||
int messageTextSize = GuiGetTextWidth(message) + 2;
|
||||
|
||||
textBounds.x = bounds.x + bounds.width/2 - textSize/2;
|
||||
textBounds.x = bounds.x + bounds.width/2 - messageTextSize/2;
|
||||
textBounds.y = bounds.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + messageInputHeight/4 - (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
|
||||
textBounds.width = (float)textSize;
|
||||
textBounds.width = (float)messageTextSize;
|
||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||
}
|
||||
|
||||
@ -4641,8 +4644,8 @@ void GuiLoadStyle(const char *fileName)
|
||||
{
|
||||
case 'v':
|
||||
{
|
||||
sscanf(buffer, "v %d", &version);
|
||||
}
|
||||
sscanf(buffer, "v %u", &version);
|
||||
} break;
|
||||
case 'p':
|
||||
{
|
||||
// Style property: p <control_id> <property_id> <property_value> <property_name>
|
||||
@ -5388,7 +5391,7 @@ static int GetLineWidth(const char *text)
|
||||
|
||||
if ((text != NULL) && (text[0] != '\0'))
|
||||
{
|
||||
// Icon marker: '#' + 1..3 digits + '#' (matches GetTextIcon())
|
||||
// Check icon marker: '#' + 1..3 digits + '#' (matches GetTextIcon())
|
||||
if (text[0] == '#')
|
||||
{
|
||||
int pos = 1;
|
||||
@ -5398,35 +5401,11 @@ static int GetLineWidth(const char *text)
|
||||
|
||||
text += textIconOffset;
|
||||
|
||||
// Make sure guiFont is set, GuiGetStyle() initializes it lazynessly
|
||||
float fontSize = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||
// WARNING: Make sure guiFont is set,
|
||||
// GuiGetStyle() does a lazy initialization
|
||||
GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||
|
||||
// Custom MeasureText() implementation -- single line only
|
||||
if ((guiFont.texture.id > 0) && (text != NULL))
|
||||
{
|
||||
// Get size in bytes of the line, considering end of line and line break
|
||||
int size = 0;
|
||||
for (int i = 0; i < MAX_LINE_BUFFER_SIZE; i++)
|
||||
{
|
||||
if ((text[i] != '\0') && (text[i] != '\n')) size++;
|
||||
else break;
|
||||
}
|
||||
|
||||
float scaleFactor = fontSize/(float)guiFont.baseSize;
|
||||
textSize.y = (float)guiFont.baseSize*scaleFactor;
|
||||
float glyphWidth = 0.0f;
|
||||
|
||||
for (int i = 0, codepointSize = 0; i < size; i += codepointSize)
|
||||
{
|
||||
int codepoint = GetCodepointNext(&text[i], &codepointSize);
|
||||
int codepointIndex = GetGlyphIndex(guiFont, codepoint);
|
||||
|
||||
if (guiFont.glyphs[codepointIndex].advanceX == 0) glyphWidth = ((float)guiFont.recs[codepointIndex].width*scaleFactor);
|
||||
else glyphWidth = ((float)guiFont.glyphs[codepointIndex].advanceX*scaleFactor);
|
||||
|
||||
textSize.x += (glyphWidth + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||
}
|
||||
}
|
||||
textSize = GuiMeasureText(text);
|
||||
|
||||
if (textIconOffset > 0) textSize.x += (RAYGUI_ICON_SIZE + RAYGUI_ICON_TEXT_PADDING);
|
||||
}
|
||||
@ -5450,12 +5429,12 @@ static Rectangle GetTextBounds(int control, Rectangle bounds)
|
||||
case COMBOBOX:
|
||||
case DROPDOWNBOX:
|
||||
case LISTVIEW:
|
||||
// TODO: Special cases (no label): COMBOBOX, DROPDOWNBOX, LISTVIEW
|
||||
// NOTE: Special cases (no label): COMBOBOX, DROPDOWNBOX, LISTVIEW
|
||||
case SLIDER:
|
||||
case CHECKBOX:
|
||||
case VALUEBOX:
|
||||
case TABBAR:
|
||||
// TODO: Special cases (label on side): SLIDER, CHECKBOX, VALUEBOX, SPINNER
|
||||
// NOTE: Special cases (label on side): SLIDER, CHECKBOX, VALUEBOX, SPINNER
|
||||
default:
|
||||
{
|
||||
// WARNING: TEXT_ALIGNMENT is already considered in GuiDrawText()
|
||||
@ -5586,7 +5565,7 @@ static void GuiDrawText(const char *text, Rectangle textBounds, int alignment, C
|
||||
int alignmentVertical = GuiGetStyle(DEFAULT, TEXT_ALIGNMENT_VERTICAL);
|
||||
int wrapMode = GuiGetStyle(DEFAULT, TEXT_WRAP_MODE); // Wrap-mode only available in read-only mode, no for text editing
|
||||
|
||||
// TODO: WARNING: This totalHeight is not valid for vertical alignment in case of word-wrap
|
||||
// WARNING: This totalHeight is not valid for vertical alignment in case of word-wrap
|
||||
float totalHeight = (float)(lineCount*GuiGetStyle(DEFAULT, TEXT_SIZE) + (lineCount - 1)*GuiGetStyle(DEFAULT, TEXT_LINE_SPACING));
|
||||
float posOffsetY = 0.0f;
|
||||
|
||||
@ -5800,23 +5779,56 @@ static void GuiDrawRectangle(Rectangle rec, int borderWidth, Color borderColor,
|
||||
#endif
|
||||
}
|
||||
|
||||
// Measure text size for current gui style
|
||||
// TODO: Consider multiline text
|
||||
static Vector2 GuiMeasureText(const char *text)
|
||||
{
|
||||
Vector2 size = { 0 };
|
||||
|
||||
if ((guiFont.texture.id > 0) && (text != NULL))
|
||||
{
|
||||
// Get size in bytes of the line, considering end of line and line break
|
||||
int size = 0;
|
||||
for (int i = 0; i < MAX_LINE_BUFFER_SIZE; i++)
|
||||
{
|
||||
if ((text[i] != '\0') && (text[i] != '\n')) size++;
|
||||
else break;
|
||||
}
|
||||
|
||||
float scaleFactor = (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/(float)guiFont.baseSize;
|
||||
textSize.y = (float)guiFont.baseSize*scaleFactor;
|
||||
float glyphWidth = 0.0f;
|
||||
|
||||
for (int i = 0, codepointSize = 0; i < size; i += codepointSize)
|
||||
{
|
||||
int codepoint = GetCodepointNext(&text[i], &codepointSize);
|
||||
int codepointIndex = GetGlyphIndex(guiFont, codepoint);
|
||||
|
||||
if (guiFont.glyphs[codepointIndex].advanceX == 0) glyphWidth = ((float)guiFont.recs[codepointIndex].width*scaleFactor);
|
||||
else glyphWidth = ((float)guiFont.glyphs[codepointIndex].advanceX*scaleFactor);
|
||||
|
||||
textSize.x += (glyphWidth + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
// Draw tooltip using control bounds
|
||||
static void GuiTooltip(Rectangle controlRec)
|
||||
{
|
||||
if (!guiLocked && guiTooltip && (guiTooltipPtr != NULL) && !guiControlExclusiveMode)
|
||||
{
|
||||
Vector2 textSize = MeasureTextEx(guiFont, guiTooltipPtr, (float)GuiGetStyle(DEFAULT, TEXT_SIZE),
|
||||
(float)GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||
Vector2 textSize = GuiMeasureText(guiTooltipPtr);
|
||||
|
||||
if ((controlRec.x + textSize.x + 16) > GetScreenWidth()) controlRec.x -= (textSize.x + 16 - controlRec.width);
|
||||
|
||||
int lineCount = 0;
|
||||
GetTextLines(guiTooltipPtr, &lineCount); // Only using the line count
|
||||
if ((controlRec.y + controlRec.height + textSize.y + 4 + 8*lineCount) > GetScreenHeight())
|
||||
controlRec.y -= (controlRec.height + textSize.y + 4 + 8*lineCount);
|
||||
if ((controlRec.y + controlRec.height + textSize.y + 4 + GuiGetStyle(DEFAULT, TEXT_LINE_SPACING)*lineCount) > GetScreenHeight())
|
||||
controlRec.y -= (controlRec.height + textSize.y + 4 + GuiGetStyle(DEFAULT, TEXT_LINE_SPACING)*lineCount);
|
||||
|
||||
// TODO: Probably TEXT_LINE_SPACING should be considered on panel size instead of hardcoding 8.0f
|
||||
GuiPanel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize.y + 8.0f*lineCount }, NULL);
|
||||
GuiPanel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize.y + GuiGetStyle(DEFAULT, TEXT_LINE_SPACING)*lineCount }, NULL);
|
||||
|
||||
int textPadding = GuiGetStyle(LABEL, TEXT_PADDING);
|
||||
int textAlignment = GuiGetStyle(LABEL, TEXT_ALIGNMENT);
|
||||
|
||||
|
Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 129 KiB |
@ -11,7 +11,7 @@
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define ADVANCE_STYLE_PROPS_COUNT 25
|
||||
#define ADVANCE_STYLE_PROPS_COUNT 26
|
||||
|
||||
// Custom style name: Advance
|
||||
static const GuiStyleProp advanceStyleProps[ADVANCE_STYLE_PROPS_COUNT] = {
|
||||
@ -31,6 +31,7 @@ static const GuiStyleProp advanceStyleProps[ADVANCE_STYLE_PROPS_COUNT] = {
|
||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||
{ 0, 18, (int)0x9eadd0ff }, // DEFAULT_LINE_COLOR
|
||||
{ 0, 19, (int)0xe6e6e6ff }, // DEFAULT_BACKGROUND_COLOR
|
||||
{ 0, 20, (int)0x00000006 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 1, 5, (int)0x917de2ff }, // LABEL_TEXT_COLOR_FOCUSED
|
||||
{ 1, 8, (int)0xffb033ff }, // LABEL_TEXT_COLOR_PRESSED
|
||||
{ 4, 5, (int)0xb0b0e1ff }, // SLIDER_TEXT_COLOR_FOCUSED
|
||||
|
||||
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
@ -25,6 +25,7 @@ p 00 16 0x0000000c TEXT_SIZE
|
||||
p 00 17 0x00000000 TEXT_SPACING
|
||||
p 00 18 0x9eadd0ff LINE_COLOR
|
||||
p 00 19 0xe6e6e6ff BACKGROUND_COLOR
|
||||
p 00 20 0x00000006 TEXT_LINE_SPACING
|
||||
p 01 05 0x917de2ff LABEL_TEXT_COLOR_FOCUSED
|
||||
p 01 08 0xffb033ff LABEL_TEXT_COLOR_PRESSED
|
||||
p 04 05 0xb0b0e1ff SLIDER_TEXT_COLOR_FOCUSED
|
||||
|
||||
|
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 133 KiB |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 104 KiB |
|
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 124 KiB |
@ -11,7 +11,7 @@
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define BRICK_STYLE_PROPS_COUNT 17
|
||||
#define BRICK_STYLE_PROPS_COUNT 18
|
||||
|
||||
// Custom style name: Brick
|
||||
static const GuiStyleProp brickStyleProps[BRICK_STYLE_PROPS_COUNT] = {
|
||||
@ -29,6 +29,7 @@ static const GuiStyleProp brickStyleProps[BRICK_STYLE_PROPS_COUNT] = {
|
||||
{ 0, 11, (int)0x8c9c9eff }, // DEFAULT_TEXT_COLOR_DISABLED
|
||||
{ 0, 18, (int)0x71a8aeff }, // DEFAULT_LINE_COLOR
|
||||
{ 0, 19, (int)0xeff0f3ff }, // DEFAULT_BACKGROUND_COLOR
|
||||
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 1, 5, (int)0x568a90ff }, // LABEL_TEXT_COLOR_FOCUSED
|
||||
{ 9, 5, (int)0x5e9095ff }, // TEXTBOX_TEXT_COLOR_FOCUSED
|
||||
{ 10, 5, (int)0x639196ff }, // VALUEBOX_TEXT_COLOR_FOCUSED
|
||||
|
||||
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
@ -23,6 +23,7 @@ p 00 10 0xc8d7d9ff DEFAULT_BASE_COLOR_DISABLED
|
||||
p 00 11 0x8c9c9eff DEFAULT_TEXT_COLOR_DISABLED
|
||||
p 00 18 0x71a8aeff LINE_COLOR
|
||||
p 00 19 0xeff0f3ff BACKGROUND_COLOR
|
||||
p 00 20 0x00000008 TEXT_LINE_SPACING
|
||||
p 01 05 0x568a90ff LABEL_TEXT_COLOR_FOCUSED
|
||||
p 09 05 0x5e9095ff TEXTBOX_TEXT_COLOR_FOCUSED
|
||||
p 10 05 0x639196ff VALUEBOX_TEXT_COLOR_FOCUSED
|
||||
|
||||
|
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 127 KiB |
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 144 KiB |
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 142 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
@ -31,7 +31,7 @@ static const GuiStyleProp pocketStyleProps[POCKET_STYLE_PROPS_COUNT] = {
|
||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||
{ 0, 18, (int)0x56591eff }, // DEFAULT_LINE_COLOR
|
||||
{ 0, 19, (int)0xd9d9ceff }, // DEFAULT_BACKGROUND_COLOR
|
||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
};
|
||||
|
||||
// WARNING: This style uses a custom font: "GMSN.ttf" (size: 16, spacing: 0)
|
||||
|
||||
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
@ -25,4 +25,4 @@ p 00 16 0x00000010 TEXT_SIZE
|
||||
p 00 17 0x00000000 TEXT_SPACING
|
||||
p 00 18 0x56591eff LINE_COLOR
|
||||
p 00 19 0xd9d9ceff BACKGROUND_COLOR
|
||||
p 00 20 0x00000018 TEXT_LINE_SPACING
|
||||
p 00 20 0x00000008 TEXT_LINE_SPACING
|
||||
|
||||
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
@ -30,7 +30,7 @@ static const GuiStyleProp turboStyleProps[TURBO_STYLE_PROPS_COUNT] = {
|
||||
{ 0, 16, (int)0x00000010 }, // DEFAULT_TEXT_SIZE
|
||||
{ 0, 18, (int)0xbbaf6cff }, // DEFAULT_LINE_COLOR
|
||||
{ 0, 19, (int)0x60645fff }, // DEFAULT_BACKGROUND_COLOR
|
||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 1, 8, (int)0xf0e4c4ff }, // LABEL_TEXT_COLOR_PRESSED
|
||||
{ 1, 11, (int)0x959680ff }, // LABEL_TEXT_COLOR_DISABLED
|
||||
{ 4, 8, (int)0xb4aa8dff }, // SLIDER_TEXT_COLOR_PRESSED
|
||||
|
||||
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
@ -24,7 +24,7 @@ p 00 11 0x696a5dff DEFAULT_TEXT_COLOR_DISABLED
|
||||
p 00 16 0x00000010 TEXT_SIZE
|
||||
p 00 18 0xbbaf6cff LINE_COLOR
|
||||
p 00 19 0x60645fff BACKGROUND_COLOR
|
||||
p 00 20 0x00000018 TEXT_LINE_SPACING
|
||||
p 00 20 0x00000008 TEXT_LINE_SPACING
|
||||
p 01 08 0xf0e4c4ff LABEL_TEXT_COLOR_PRESSED
|
||||
p 01 11 0x959680ff LABEL_TEXT_COLOR_DISABLED
|
||||
p 04 08 0xb4aa8dff SLIDER_TEXT_COLOR_PRESSED
|
||||
|
||||
|
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 127 KiB |
@ -31,7 +31,7 @@ static const GuiStyleProp wisteriaStyleProps[WISTERIA_STYLE_PROPS_COUNT] = {
|
||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||
{ 0, 18, (int)0x9b74d2ff }, // DEFAULT_LINE_COLOR
|
||||
{ 0, 19, (int)0xe9eaf6ff }, // DEFAULT_BACKGROUND_COLOR
|
||||
{ 0, 20, (int)0x00000012 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||
{ 4, 3, (int)0xa9bdcfff }, // SLIDER_BORDER_COLOR_FOCUSED
|
||||
{ 4, 5, (int)0xacc4d8ff }, // SLIDER_TEXT_COLOR_FOCUSED
|
||||
{ 5, 3, (int)0xb5c7d9ff }, // PROGRESSBAR_BORDER_COLOR_FOCUSED
|
||||
|
||||
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
@ -25,7 +25,7 @@ p 00 16 0x0000000c TEXT_SIZE
|
||||
p 00 17 0x00000000 TEXT_SPACING
|
||||
p 00 18 0x9b74d2ff LINE_COLOR
|
||||
p 00 19 0xe9eaf6ff BACKGROUND_COLOR
|
||||
p 00 20 0x00000012 TEXT_LINE_SPACING
|
||||
p 00 20 0x00000008 TEXT_LINE_SPACING
|
||||
p 04 03 0xa9bdcfff SLIDER_BORDER_COLOR_FOCUSED
|
||||
p 04 05 0xacc4d8ff SLIDER_TEXT_COLOR_FOCUSED
|
||||
p 05 03 0xb5c7d9ff PROGRESSBAR_BORDER_COLOR_FOCUSED
|
||||
|
||||