From 9193f38424f75290eb3b53db6a940606daa14af9 Mon Sep 17 00:00:00 2001 From: mimshipio <95988311+mimshipio@users.noreply.github.com> Date: Fri, 29 Aug 2025 05:49:47 +0900 Subject: [PATCH] Fixed examples (#505) --- examples/custom_input_box/custom_input_box.c | 6 +++--- examples/custom_sliders/custom_sliders.c | 12 ++++++------ examples/image_exporter/image_exporter.c | 4 ++-- examples/image_importer_raw/image_importer_raw.c | 6 +++--- examples/property_list/dm_property_list.h | 14 +++++++------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/custom_input_box/custom_input_box.c b/examples/custom_input_box/custom_input_box.c index 5dbbf86..18b7ffc 100644 --- a/examples/custom_input_box/custom_input_box.c +++ b/examples/custom_input_box/custom_input_box.c @@ -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)); } diff --git a/examples/custom_sliders/custom_sliders.c b/examples/custom_sliders/custom_sliders.c index de7be56..ecd7e27 100644 --- a/examples/custom_sliders/custom_sliders.c +++ b/examples/custom_sliders/custom_sliders.c @@ -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); diff --git a/examples/image_exporter/image_exporter.c b/examples/image_exporter/image_exporter.c index 3c0a16b..cf5cd58 100644 --- a/examples/image_exporter/image_exporter.c +++ b/examples/image_exporter/image_exporter.c @@ -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"; diff --git a/examples/image_importer_raw/image_importer_raw.c b/examples/image_importer_raw/image_importer_raw.c index 6c1d1ed..4f86082 100644 --- a/examples/image_importer_raw/image_importer_raw.c +++ b/examples/image_importer_raw/image_importer_raw.c @@ -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; diff --git a/examples/property_list/dm_property_list.h b/examples/property_list/dm_property_list.h index cf8bece..838a161 100644 --- a/examples/property_list/dm_property_list.h +++ b/examples/property_list/dm_property_list.h @@ -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 @@ -865,4 +865,4 @@ bool GuiDMSaveProperties(const char* file, GuiDMProperty* props, int count) { return true; } -#endif // GUI_PROPERTY_LIST_IMPLEMENTATION \ No newline at end of file +#endif // GUI_PROPERTY_LIST_IMPLEMENTATION