mirror of
https://github.com/raysan5/raygui.git
synced 2025-12-25 10:22:33 -05:00
Fixed examples (#505)
This commit is contained in:
@ -97,7 +97,7 @@ int GuiFloatBox(Rectangle bounds, const char* text, float* value, int minValue,
|
||||
Rectangle textBounds = { 0 };
|
||||
if (text != NULL)
|
||||
{
|
||||
textBounds.width = (float)GetTextWidth(text) + 2;
|
||||
textBounds.width = (float)GuiGetTextWidth(text) + 2;
|
||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||
textBounds.x = bounds.x + bounds.width + GuiGetStyle(VALUEBOX, TEXT_PADDING);
|
||||
textBounds.y = bounds.y + bounds.height / 2.0f - GuiGetStyle(DEFAULT, TEXT_SIZE) / 2.0f;
|
||||
@ -124,7 +124,7 @@ int GuiFloatBox(Rectangle bounds, const char* text, float* value, int minValue,
|
||||
// Only allow keys in range [48..57]
|
||||
if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
|
||||
{
|
||||
if (GetTextWidth(textValue) < bounds.width)
|
||||
if (GuiGetTextWidth(textValue) < bounds.width)
|
||||
{
|
||||
int key = GetCharPressed();
|
||||
if ((key >= 48) && (key <= 57) && guiFloatingPointIndex)
|
||||
@ -211,7 +211,7 @@ int GuiFloatBox(Rectangle bounds, const char* text, float* value, int minValue,
|
||||
if (editMode)
|
||||
{
|
||||
// NOTE: ValueBox internal text is always centered
|
||||
Rectangle cursor = { bounds.x + GetTextWidth(textValue) / 2.0f + bounds.width / 2.0f + 1, bounds.y + 2.0f * GuiGetStyle(VALUEBOX, BORDER_WIDTH), 4, bounds.height - 4 * GuiGetStyle(VALUEBOX, BORDER_WIDTH) };
|
||||
Rectangle cursor = { bounds.x + GuiGetTextWidth(textValue) / 2.0f + bounds.width / 2.0f + 1, bounds.y + 2.0f * GuiGetStyle(VALUEBOX, BORDER_WIDTH), 4, bounds.height - 4 * GuiGetStyle(VALUEBOX, BORDER_WIDTH) };
|
||||
GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)), guiAlpha));
|
||||
}
|
||||
|
||||
|
||||
@ -182,7 +182,7 @@ float GuiVerticalSliderPro(Rectangle bounds, const char *textTop, const char *te
|
||||
if (textTop != NULL)
|
||||
{
|
||||
Rectangle textBounds = { 0 };
|
||||
textBounds.width = (float)GetTextWidth(textTop);
|
||||
textBounds.width = (float)GuiGetTextWidth(textTop);
|
||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
||||
textBounds.y = bounds.y - textBounds.height - GuiGetStyle(SLIDER, TEXT_PADDING);
|
||||
@ -193,7 +193,7 @@ float GuiVerticalSliderPro(Rectangle bounds, const char *textTop, const char *te
|
||||
if (textBottom != NULL)
|
||||
{
|
||||
Rectangle textBounds = { 0 };
|
||||
textBounds.width = (float)GetTextWidth(textBottom);
|
||||
textBounds.width = (float)GuiGetTextWidth(textBottom);
|
||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
||||
textBounds.y = bounds.y + bounds.height + GuiGetStyle(SLIDER, TEXT_PADDING);
|
||||
@ -304,7 +304,7 @@ bool GuiSliderProOwning(Rectangle bounds, const char *textLeft, const char *text
|
||||
if (textLeft != NULL)
|
||||
{
|
||||
Rectangle textBounds = { 0 };
|
||||
textBounds.width = (float)GetTextWidth(textLeft);
|
||||
textBounds.width = (float)GuiGetTextWidth(textLeft);
|
||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||
textBounds.x = bounds.x - textBounds.width - GuiGetStyle(SLIDER, TEXT_PADDING);
|
||||
textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
|
||||
@ -315,7 +315,7 @@ bool GuiSliderProOwning(Rectangle bounds, const char *textLeft, const char *text
|
||||
if (textRight != NULL)
|
||||
{
|
||||
Rectangle textBounds = { 0 };
|
||||
textBounds.width = (float)GetTextWidth(textRight);
|
||||
textBounds.width = (float)GuiGetTextWidth(textRight);
|
||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||
textBounds.x = bounds.x + bounds.width + GuiGetStyle(SLIDER, TEXT_PADDING);
|
||||
textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
|
||||
@ -435,7 +435,7 @@ bool GuiVerticalSliderProOwning(Rectangle bounds, const char *textTop, const cha
|
||||
if (textTop != NULL)
|
||||
{
|
||||
Rectangle textBounds = { 0 };
|
||||
textBounds.width = (float)GetTextWidth(textTop);
|
||||
textBounds.width = (float)GuiGetTextWidth(textTop);
|
||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
||||
textBounds.y = bounds.y - textBounds.height - GuiGetStyle(SLIDER, TEXT_PADDING);
|
||||
@ -446,7 +446,7 @@ bool GuiVerticalSliderProOwning(Rectangle bounds, const char *textTop, const cha
|
||||
if (textBottom != NULL)
|
||||
{
|
||||
Rectangle textBounds = { 0 };
|
||||
textBounds.width = (float)GetTextWidth(textBottom);
|
||||
textBounds.width = (float)GuiGetTextWidth(textBottom);
|
||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
||||
textBounds.y = bounds.y + bounds.height + GuiGetStyle(SLIDER, TEXT_PADDING);
|
||||
|
||||
@ -38,10 +38,10 @@ int main(int argc, char *argv[])
|
||||
bool windowBoxActive = false;
|
||||
|
||||
int fileFormatActive = 0;
|
||||
char *fileFormatTextList[3] = { "IMAGE (.png)", "DATA (.raw)", "CODE (.h)" };
|
||||
const char *fileFormatTextList[3] = { "IMAGE (.png)", "DATA (.raw)", "CODE (.h)" };
|
||||
|
||||
int pixelFormatActive = 0;
|
||||
char *pixelFormatTextList[7] = { "GRAYSCALE", "GRAY ALPHA", "R5G6B5", "R8G8B8", "R5G5B5A1", "R4G4B4A4", "R8G8B8A8" };
|
||||
const char *pixelFormatTextList[7] = { "GRAYSCALE", "GRAY ALPHA", "R5G6B5", "R8G8B8", "R5G5B5A1", "R4G4B4A4", "R8G8B8A8" };
|
||||
|
||||
bool textBoxEditMode = false;
|
||||
char fileName[64] = "untitled";
|
||||
|
||||
@ -50,12 +50,12 @@ int main()
|
||||
bool heightEditMode = false;
|
||||
|
||||
int pixelFormatActive = 0;
|
||||
char *pixelFormatTextList[8] = { "CUSTOM", "GRAYSCALE", "GRAY ALPHA", "R5G6B5", "R8G8B8", "R5G5B5A1", "R4G4B4A4", "R8G8B8A8" };
|
||||
const char *pixelFormatTextList[8] = { "CUSTOM", "GRAYSCALE", "GRAY ALPHA", "R5G6B5", "R8G8B8", "R5G5B5A1", "R4G4B4A4", "R8G8B8A8" };
|
||||
|
||||
int channelsActive = 3;
|
||||
char *channelsTextList[4] = { "1", "2", "3", "4" };
|
||||
const char *channelsTextList[4] = { "1", "2", "3", "4" };
|
||||
int bitDepthActive = 0;
|
||||
char *bitDepthTextList[3] = { "8", "16", "32" };
|
||||
const char *bitDepthTextList[3] = { "8", "16", "32" };
|
||||
|
||||
int headerSizeValue = 0;
|
||||
bool headerSizeEditMode = false;
|
||||
|
||||
@ -323,7 +323,7 @@ double GuiDMValueBox(Rectangle bounds, double value, double minValue, double max
|
||||
Rectangle textBounds = {bounds.x + GuiGetStyle(VALUEBOX, BORDER_WIDTH) + textPadding, bounds.y + GuiGetStyle(VALUEBOX, BORDER_WIDTH),
|
||||
bounds.width - 2*(GuiGetStyle(VALUEBOX, BORDER_WIDTH) + textPadding), bounds.height - 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH)};
|
||||
|
||||
int textWidth = GetTextWidth(textValue);
|
||||
int textWidth = GuiGetTextWidth(textValue);
|
||||
if(textWidth > textBounds.width) textBounds.width = textWidth;
|
||||
|
||||
if (state == STATE_PRESSED)
|
||||
@ -338,7 +338,7 @@ double GuiDMValueBox(Rectangle bounds, double value, double minValue, double max
|
||||
if(cursor > 0) {
|
||||
char c = textValue[cursor];
|
||||
textValue[cursor] = '\0';
|
||||
textWidthCursor = GetTextWidth(textValue);
|
||||
textWidthCursor = GuiGetTextWidth(textValue);
|
||||
textValue[cursor] = c;
|
||||
}
|
||||
//DrawRectangle(bounds.x + textWidthCursor + textPadding + 2, bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 1, bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)), guiAlpha));
|
||||
@ -608,7 +608,7 @@ void GuiDMPropertyList(Rectangle bounds, GuiDMProperty* props, int count, int* f
|
||||
// draw X, Y, Z, W values (only when expanded)
|
||||
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED)) {
|
||||
Rectangle slotBounds = { propBounds.x, propBounds.y+GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)+1, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2};
|
||||
Rectangle lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GetTextWidth("A"), slotBounds.height};
|
||||
Rectangle lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GuiGetTextWidth("A"), slotBounds.height};
|
||||
Rectangle valBounds = { lblBounds.x+lblBounds.width+PROPERTY_PADDING, slotBounds.y, propBounds.width-lblBounds.width-2*PROPERTY_PADDING, slotBounds.height};
|
||||
GuiDrawText("X", lblBounds, TEXT_ALIGN_LEFT, textColor);
|
||||
props[p].value.v2.x = GuiDMSpinner(valBounds, props[p].value.v2.x, 0.0, 0.0, 1.0, PROPERTY_DECIMAL_DIGITS, (propState == STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||
@ -647,7 +647,7 @@ void GuiDMPropertyList(Rectangle bounds, GuiDMProperty* props, int count, int* f
|
||||
// draw X, Y, Width, Height values (only when expanded)
|
||||
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED)) {
|
||||
Rectangle slotBounds = { propBounds.x, propBounds.y+GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)+1, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2};
|
||||
Rectangle lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GetTextWidth("Height"), slotBounds.height};
|
||||
Rectangle lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GuiGetTextWidth("Height"), slotBounds.height};
|
||||
Rectangle valBounds = { lblBounds.x+lblBounds.width+PROPERTY_PADDING, slotBounds.y, propBounds.width-lblBounds.width-2*PROPERTY_PADDING, slotBounds.height};
|
||||
GuiDrawText("X", lblBounds, TEXT_ALIGN_LEFT, textColor);
|
||||
props[p].value.vrect.x = GuiDMSpinner(valBounds, props[p].value.vrect.x, 0.0, 0.0, 1.0, 0, (propState == STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||
@ -685,8 +685,8 @@ void GuiDMPropertyList(Rectangle bounds, GuiDMProperty* props, int count, int* f
|
||||
// draw R, G, B, A values (only when expanded)
|
||||
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED)) {
|
||||
Rectangle slotBounds = { propBounds.x, propBounds.y+GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)+1, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2};
|
||||
Rectangle lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GetTextWidth("A"), slotBounds.height};
|
||||
Rectangle valBounds = { lblBounds.x+lblBounds.width+PROPERTY_PADDING, slotBounds.y, GetTextWidth("000000"), slotBounds.height};
|
||||
Rectangle lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GuiGetTextWidth("A"), slotBounds.height};
|
||||
Rectangle valBounds = { lblBounds.x+lblBounds.width+PROPERTY_PADDING, slotBounds.y, GuiGetTextWidth("000000"), slotBounds.height};
|
||||
Rectangle sbarBounds = { valBounds.x + valBounds.width + PROPERTY_PADDING, slotBounds.y, slotBounds.width - 3*PROPERTY_PADDING - lblBounds.width - valBounds.width, slotBounds.height };
|
||||
|
||||
if(sbarBounds.width <= GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2) valBounds.width = propBounds.width-lblBounds.width-2*PROPERTY_PADDING; // hide slider when no space
|
||||
|
||||
Reference in New Issue
Block a user