From b3fea573821c9eb9bba29343958564f61cf72d6f Mon Sep 17 00:00:00 2001 From: aiafrasinei Date: Thu, 29 Feb 2024 12:45:31 +0200 Subject: [PATCH] Fix compilation error and remove warnings from examples (#380) --- examples/animation_curve/animation_curve.c | 16 ++++++++-------- examples/animation_curve/gui_curve_editor.h | 11 ----------- .../controls_test_suite/controls_test_suite.c | 2 -- examples/custom_input_box/custom_input_box.c | 2 +- examples/style_selector/style_selector.c | 7 ------- 5 files changed, 9 insertions(+), 29 deletions(-) diff --git a/examples/animation_curve/animation_curve.c b/examples/animation_curve/animation_curve.c index 143b7d7..2f9b2f0 100644 --- a/examples/animation_curve/animation_curve.c +++ b/examples/animation_curve/animation_curve.c @@ -256,12 +256,12 @@ int main() GuiLabel((Rectangle){ contentRect.x, contentRect.y + contentRect.height + scrollOffset.y, contentRect.width, fontSize }, "Position"); contentRect.height += fontSize; - if (!editValueBox[i][0]) gcvt(p->position.x, 6, valTextBox[i][0]); // Transform x position to string + if (!editValueBox[i][0]) gcvt(p->position.x, 6, (char *)valTextBox[i][0]); // Transform x position to string - if (!editValueBox[i][1]) gcvt(curves[i].start + (curves[i].end-curves[i].start)*p->position.y, 6, valTextBox[i][1]); // Transform y position to string + if (!editValueBox[i][1]) gcvt(curves[i].start + (curves[i].end-curves[i].start)*p->position.y, 6, (char *)valTextBox[i][1]); // Transform y position to string // X pos - if (GuiTextBox((Rectangle){ contentRect.x, contentRect.y + contentRect.height + scrollOffset.y, contentRect.width/2-margin, 1.5f*fontSize }, valTextBox[i][0], 20, editValueBox[i][0])) + if (GuiTextBox((Rectangle){ contentRect.x, contentRect.y + contentRect.height + scrollOffset.y, contentRect.width/2-margin, 1.5f*fontSize }, (char *)valTextBox[i][0], 20, editValueBox[i][0])) { editValueBox[i][0] = !editValueBox[i][0]; @@ -277,7 +277,7 @@ int main() } // Y pos - if (GuiTextBox((Rectangle){ contentRect.x + contentRect.width/2, contentRect.y + contentRect.height + scrollOffset.y, contentRect.width/2.0f, 1.5f*fontSize }, valTextBox[i][1], 20, editValueBox[i][1])) + if (GuiTextBox((Rectangle){ contentRect.x + contentRect.width/2, contentRect.y + contentRect.height + scrollOffset.y, contentRect.width/2.0f, 1.5f*fontSize }, (char *)valTextBox[i][1], 20, editValueBox[i][1])) { editValueBox[i][1] = !editValueBox[i][1]; @@ -303,12 +303,12 @@ int main() GuiLabel((Rectangle){ contentRect.x, contentRect.y + contentRect.height + scrollOffset.y, contentRect.width, fontSize }, "Tangents"); contentRect.height += fontSize; - if (!editValueBox[i][2]) gcvt(p->tangents.x, 6, valTextBox[i][2]); // Transform left tangent to string + if (!editValueBox[i][2]) gcvt(p->tangents.x, 6, (char *)valTextBox[i][2]); // Transform left tangent to string - if (!editValueBox[i][3]) gcvt(p->tangents.y, 6, valTextBox[i][3]); // Transform right tangent to string + if (!editValueBox[i][3]) gcvt(p->tangents.y, 6, (char *)valTextBox[i][3]); // Transform right tangent to string // Left tan - if (GuiTextBox((Rectangle){ contentRect.x, contentRect.y + contentRect.height + scrollOffset.y, contentRect.width/2 - margin, 1.5f*fontSize }, valTextBox[i][2], 20, editValueBox[i][2])) + if (GuiTextBox((Rectangle){ contentRect.x, contentRect.y + contentRect.height + scrollOffset.y, contentRect.width/2 - margin, 1.5f*fontSize }, (char *)valTextBox[i][2], 20, editValueBox[i][2])) { editValueBox[i][2] = !editValueBox[i][2]; @@ -323,7 +323,7 @@ int main() } // Right tan - if (GuiTextBox((Rectangle){ contentRect.x + contentRect.width/2.0f, contentRect.y + contentRect.height + scrollOffset.y, contentRect.width/2.0f, 1.5f*fontSize }, valTextBox[i][3], 20, editValueBox[i][3])) + if (GuiTextBox((Rectangle){ contentRect.x + contentRect.width/2.0f, contentRect.y + contentRect.height + scrollOffset.y, contentRect.width/2.0f, 1.5f*fontSize }, (char *)valTextBox[i][3], 20, editValueBox[i][3])) { editValueBox[i][3] = !editValueBox[i][3]; diff --git a/examples/animation_curve/gui_curve_editor.h b/examples/animation_curve/gui_curve_editor.h index abe956c..8cf9c0c 100644 --- a/examples/animation_curve/gui_curve_editor.h +++ b/examples/animation_curve/gui_curve_editor.h @@ -256,7 +256,6 @@ void GuiCurveEditor(GuiCurveEditorState *state, Rectangle bounds) { // editRightTangent == true implies selectedIndex != -1 GuiCurveEditorPoint *p = &state->points[state->selectedIndex]; - const Vector2 screenPos = (Vector2){ p->position.x*innerBounds.width + innerBounds.x, innerBounds.y + innerBounds.height-p->position.y*innerBounds.height }; const Vector2 dir = (Vector2){ mouseLocal.x - p->position.x, mouseLocal.y - p->position.y}; // Calculate right tangent slope @@ -275,7 +274,6 @@ void GuiCurveEditor(GuiCurveEditorState *state, Rectangle bounds) { // editLeftTangent == true implies selectedIndex != -1 GuiCurveEditorPoint *p = &state->points[state->selectedIndex]; - const Vector2 screenPos = (Vector2){ p->position.x*innerBounds.width + innerBounds.x, innerBounds.y + innerBounds.height-p->position.y*innerBounds.height }; const Vector2 dir = (Vector2){ mouseLocal.x - p->position.x, mouseLocal.y - p->position.y }; // Calculate left tangent slope @@ -294,7 +292,6 @@ void GuiCurveEditor(GuiCurveEditorState *state, Rectangle bounds) { state->selectedIndex = hoveredPointIndex; const GuiCurveEditorPoint *p = &state->points[state->selectedIndex]; - const Vector2 screenPos = (Vector2){ p->position.x*innerBounds.width + innerBounds.x, innerBounds.y + innerBounds.height - p->position.y*innerBounds.height }; state->mouseOffset = (Vector2){ p->position.x - mouseLocal.x, p->position.y - mouseLocal.y }; } // Remove a point (check against bounds) @@ -430,22 +427,18 @@ void GuiCurveEditor(GuiCurveEditorState *state, Rectangle bounds) const Rectangle controlRect = (Rectangle){ control.x - handleSize/2.0f, control.y - handleSize/2.0f, handleSize, handleSize }; Color controlColor = { 0 }; - Color controlBorderColor = { 0 }; if (state->editLeftTangent) { controlColor = GetColor(GuiGetStyle(DEFAULT, BASE_COLOR_PRESSED)); - controlBorderColor = GetColor(GuiGetStyle(DEFAULT, BORDER_COLOR_NORMAL)); } else if (CheckCollisionPointRec(mouse, controlRect)) { controlColor = GetColor(GuiGetStyle(DEFAULT, BASE_COLOR_FOCUSED)); - controlBorderColor = GetColor(GuiGetStyle(DEFAULT, BORDER_COLOR_NORMAL)); } else { controlColor = GetColor(GuiGetStyle(BUTTON, BASE_COLOR_NORMAL)); - controlBorderColor = GetColor(GuiGetStyle(BUTTON, BORDER_COLOR_NORMAL)); } DrawLine(screenPos.x,screenPos.y, control.x, control.y, controlColor); @@ -463,22 +456,18 @@ void GuiCurveEditor(GuiCurveEditorState *state, Rectangle bounds) const Rectangle controlRect = (Rectangle){ control.x - handleSize/2.0f, control.y - handleSize/2.0f, handleSize, handleSize }; Color controlColor = { 0 }; - Color controlBorderColor = { 0 }; if (state->editRightTangent) { controlColor = GetColor(GuiGetStyle(DEFAULT, BASE_COLOR_PRESSED)); - controlBorderColor = GetColor(GuiGetStyle(DEFAULT, BORDER_COLOR_NORMAL)); } else if (CheckCollisionPointRec(mouse, controlRect)) { controlColor = GetColor(GuiGetStyle(DEFAULT, BASE_COLOR_FOCUSED)); - controlBorderColor = GetColor(GuiGetStyle(DEFAULT, BORDER_COLOR_NORMAL)); } else { controlColor = GetColor(GuiGetStyle(BUTTON, BASE_COLOR_NORMAL)); - controlBorderColor = GetColor(GuiGetStyle(BUTTON, BORDER_COLOR_NORMAL)); } DrawLine(screenPos.x,screenPos.y, control.x, control.y, controlColor); diff --git a/examples/controls_test_suite/controls_test_suite.c b/examples/controls_test_suite/controls_test_suite.c index 17c02c1..1f80954 100644 --- a/examples/controls_test_suite/controls_test_suite.c +++ b/examples/controls_test_suite/controls_test_suite.c @@ -93,8 +93,6 @@ int main() int listViewExFocus = -1; const char *listViewExList[8] = { "This", "is", "a", "list view", "with", "disable", "elements", "amazing!" }; - char multiTextBoxText[256] = "Multi text box"; - bool multiTextBoxEditMode = false; Color colorPickerValue = RED; float sliderValue = 50.0f; diff --git a/examples/custom_input_box/custom_input_box.c b/examples/custom_input_box/custom_input_box.c index f5d91d0..80b6352 100644 --- a/examples/custom_input_box/custom_input_box.c +++ b/examples/custom_input_box/custom_input_box.c @@ -106,7 +106,7 @@ int GuiFloatBox(Rectangle bounds, const char* text, float* value, int minValue, // Update control //-------------------------------------------------------------------- - if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging) + if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode) { Vector2 mousePoint = GetMousePosition(); diff --git a/examples/style_selector/style_selector.c b/examples/style_selector/style_selector.c index bea04db..b4afe66 100644 --- a/examples/style_selector/style_selector.c +++ b/examples/style_selector/style_selector.c @@ -59,11 +59,6 @@ int main() bool exitWindow = false; bool showMessageBox = false; - char textInput[256] = { 0 }; - bool showTextInputBox = false; - - char textInputFileName[256] = { 0 }; - // Load default style GuiLoadStyleBluish(); int visualStyleActive = 4; @@ -81,8 +76,6 @@ int main() if (IsKeyPressed(KEY_ESCAPE)) showMessageBox = !showMessageBox; - if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_S)) showTextInputBox = true; - if (IsFileDropped()) { FilePathList droppedFiles = LoadDroppedFiles();