Bladeren bron

Update the examples to match the latest raygui.h (#184)

Rob Loach 3 jaren geleden
bovenliggende
commit
151c4c5dce

+ 1 - 1
examples/controls_test_suite/controls_test_suite.c

@@ -219,7 +219,7 @@ int main()
             if (showTextInputBox)
             {
                 DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.8f));
-                int result = GuiTextInputBox((Rectangle){ GetScreenWidth()/2 - 120, GetScreenHeight()/2 - 60, 240, 140 }, GuiIconText(RAYGUI_ICON_FILE_SAVE, "Save file as..."), "Introduce a save file name", "Ok;Cancel", textInput);
+                int result = GuiTextInputBox((Rectangle){ GetScreenWidth()/2 - 120, GetScreenHeight()/2 - 60, 240, 140 }, "Save", GuiIconText(RAYGUI_ICON_FILE_SAVE, "Save file as..."), "Introduce a save file name", "Ok;Cancel", textInput, NULL);
 
                 if (result == 1)
                 {

+ 6 - 6
examples/property_list/dm_property_list.h

@@ -368,8 +368,8 @@ double GuiDMValueBox(Rectangle bounds, double value, double minValue, double max
 double GuiDMSpinner(Rectangle bounds, double value, double minValue, double maxValue, double step, int precision, bool editMode) {
     GuiControlState state = GuiGetState();
 
-    Rectangle spinner = { bounds.x + GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_PADDING), bounds.y,
-                          bounds.width - 2*(GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_PADDING)), bounds.height };
+    Rectangle spinner = { bounds.x + GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_SPACING), bounds.y,
+                          bounds.width - 2*(GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_SPACING)), bounds.height };
     Rectangle leftButtonBound = { (float)bounds.x, (float)bounds.y, (float)GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.height };
     Rectangle rightButtonBound = { (float)bounds.x + bounds.width - GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.y, (float)GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.height };
     
@@ -457,9 +457,9 @@ void GuiDMPropertyList(Rectangle bounds, GuiDMProperty* props, int count, int* f
     Rectangle scrollBarBounds = {bounds.x + GuiGetStyle(LISTVIEW, BORDER_WIDTH), bounds.y + GuiGetStyle(LISTVIEW, BORDER_WIDTH),
                 GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH),  bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH)};
                 
-    absoluteBounds.x = bounds.x + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH);
-    absoluteBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH) + scroll;
-    absoluteBounds.width = bounds.width - 2*(GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH));
+    absoluteBounds.x = bounds.x + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING) + GuiGetStyle(DEFAULT, BORDER_WIDTH);
+    absoluteBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING) + GuiGetStyle(DEFAULT, BORDER_WIDTH) + scroll;
+    absoluteBounds.width = bounds.width - 2*(GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING) + GuiGetStyle(DEFAULT, BORDER_WIDTH));
     
     if(useScrollBar) {
         if(GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)
@@ -469,7 +469,7 @@ void GuiDMPropertyList(Rectangle bounds, GuiDMProperty* props, int count, int* f
         absoluteBounds.width -= GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH); // adjust width to fit the scrollbar
     }
     
-    int maxScroll = absoluteBounds.height + 2*(GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH))-bounds.height;
+    int maxScroll = absoluteBounds.height + 2*(GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING) + GuiGetStyle(DEFAULT, BORDER_WIDTH))-bounds.height;
     
     // Update control
     //--------------------------------------------------------------------

+ 1 - 1
examples/property_list/property_list.c

@@ -74,7 +74,7 @@ int main()
         
             ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
         
-            GuiGrid((Rectangle){0, 0, screenWidth, screenHeight},20.0f, 2); // Draw a fancy grid
+            GuiGrid((Rectangle){0, 0, screenWidth, screenHeight}, "Property List", 20.0f, 2); // Draw a fancy grid
             
             GuiDMPropertyList((Rectangle){(screenWidth - 180)/2, (screenHeight - 280)/2, 180, 280}, prop, SIZEOF(prop), &focus, &scroll);
         

+ 4 - 4
examples/text_box_selection/textbox_extended_demo.c

@@ -95,8 +95,8 @@ int main(int argc, char **argv)
     int fontSpacing = GuiGetStyle(DEFAULT, TEXT_SPACING);
     int padding = GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING);
     int border = GuiGetStyle(TEXTBOX, BORDER_WIDTH);
-    Color colorFG = GetColor(GuiGetStyle(TEXTBOX, COLOR_SELECTED_FG)); 
-    Color colorBG = GetColor(GuiGetStyle(TEXTBOX, COLOR_SELECTED_BG));
+    Color colorFG = GetColor(GuiGetStyle(TEXTBOX, TEXT_COLOR_FOCUSED)); // Color Selected Foreground
+    Color colorBG = GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_FOCUSED)); // Color Selected Background
     Color *colorSelected = &colorFG;
 
     bool showMenu = false;
@@ -195,8 +195,8 @@ int main(int argc, char **argv)
             GuiSetStyle(DEFAULT, TEXT_SPACING, fontSpacing);
             GuiSetStyle(TEXTBOX, TEXT_INNER_PADDING, padding);
             GuiSetStyle(TEXTBOX, BORDER_WIDTH, border);
-            GuiSetStyle(TEXTBOX, COLOR_SELECTED_BG, ColorToInt(colorBG));
-            GuiSetStyle(TEXTBOX, COLOR_SELECTED_FG, ColorToInt(colorFG));
+            GuiSetStyle(TEXTBOX, BASE_COLOR_FOCUSED, ColorToInt(colorBG));
+            GuiSetStyle(TEXTBOX, TEXT_COLOR_FOCUSED, ColorToInt(colorFG));
 
             // TODO: GuiTextBoxEx() is not following editMode logic like GuiTextBox()
             if (GuiTextBoxEx(textboxBounds[0], text01, SIZEOF(text01) - 1, textBox01EditMode)) textBox01EditMode = !textBox01EditMode;

+ 1 - 1
src/extras/gui_textbox_extended.h

@@ -970,7 +970,7 @@ RAYGUIAPI bool GuiTextBoxEx(Rectangle bounds, char *text, int textSize, bool edi
     }
 
     // Finally draw the text and selection
-    DrawTextRecEx(guiFont, &text[textStartIndex], textRec, GuiGetStyle(DEFAULT, TEXT_SIZE), GuiGetStyle(DEFAULT, TEXT_SPACING), false, Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha), selStart, selLength, GetColor(GuiGetStyle(TEXTBOX, COLOR_SELECTED_FG)), GetColor(GuiGetStyle(TEXTBOX, COLOR_SELECTED_BG)));
+    DrawTextRecEx(guiFont, &text[textStartIndex], textRec, GuiGetStyle(DEFAULT, TEXT_SIZE), GuiGetStyle(DEFAULT, TEXT_SPACING), false, Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha), selStart, selLength, GetColor(GuiGetStyle(TEXTBOX, TEXT_COLOR_FOCUSED)), GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_FOCUSED)));
     
     return pressed;
 }