mirror of
https://github.com/raysan5/raygui.git
synced 2026-02-01 11:49:18 -05:00
Code review and formatting
This commit is contained in:
@ -26,9 +26,8 @@
|
|||||||
#define RAYGUI_IMPLEMENTATION
|
#define RAYGUI_IMPLEMENTATION
|
||||||
#include "../src/raygui.h"
|
#include "../src/raygui.h"
|
||||||
|
|
||||||
bool contentArea = true;
|
|
||||||
Rectangle panelContentRec = {0, 0, 340, 340 };
|
static void DrawStyleEditControls(void); // Draw and process scroll bar style edition controls
|
||||||
void ChangeStyleUI(void);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
@ -42,8 +41,11 @@ int main()
|
|||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raygui - GuiScrollPanel()");
|
InitWindow(screenWidth, screenHeight, "raygui - GuiScrollPanel()");
|
||||||
|
|
||||||
Rectangle panelRec = {20, 40, 200, 150 };
|
Rectangle panelRec = { 20, 40, 200, 150 };
|
||||||
Vector2 panelScroll = {99, -20};
|
Rectangle panelContentRec = {0, 0, 340, 340 };
|
||||||
|
Vector2 panelScroll = { 99, -20 };
|
||||||
|
|
||||||
|
bool showContentArea = true;
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
@ -58,10 +60,10 @@ int main()
|
|||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawText(TextFormat("[%f, %f]", panelScroll.x, panelScroll.y), 4, 4, 20, RED);
|
DrawText(TextFormat("[%f, %f]", panelScroll.x, panelScroll.y), 4, 4, 20, RED);
|
||||||
|
|
||||||
Rectangle view = GuiScrollPanel(panelRec, panelContentRec, &panelScroll);
|
Rectangle view = GuiScrollPanel(panelRec, panelContentRec, &panelScroll);
|
||||||
@ -70,11 +72,16 @@ int main()
|
|||||||
GuiGrid((Rectangle){panelRec.x + panelScroll.x, panelRec.y + panelScroll.y, panelContentRec.width, panelContentRec.height}, 16, 3);
|
GuiGrid((Rectangle){panelRec.x + panelScroll.x, panelRec.y + panelScroll.y, panelContentRec.width, panelContentRec.height}, 16, 3);
|
||||||
EndScissorMode();
|
EndScissorMode();
|
||||||
|
|
||||||
if(contentArea)
|
if (showContentArea) DrawRectangle(panelRec.x + panelScroll.x, panelRec.y + panelScroll.y, panelContentRec.width, panelContentRec.height, Fade(RED, 0.1));
|
||||||
DrawRectangle(panelRec.x + panelScroll.x, panelRec.y + panelScroll.y, panelContentRec.width, panelContentRec.height, Fade(RED, 0.1));
|
|
||||||
|
|
||||||
ChangeStyleUI();
|
DrawStyleEditControls();
|
||||||
EndDrawing();
|
|
||||||
|
showContentArea = GuiCheckBox((Rectangle){ 565, 80, 20, 20 }, "SHOW CONTENT AREA", showContentArea);
|
||||||
|
|
||||||
|
panelContentRec.width = GuiSliderBar((Rectangle){ 590, 385, 145, 15}, "WIDTH", panelContentRec.width, 1, 600, true);
|
||||||
|
panelContentRec.height = GuiSliderBar((Rectangle){ 590, 410, 145, 15 }, "HEIGHT", panelContentRec.height, 1, 400, true);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,60 +93,58 @@ int main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeStyleUI()
|
// Draw and process scroll bar style edition controls
|
||||||
|
static void DrawStyleEditControls(void)
|
||||||
{
|
{
|
||||||
GuiGroupBox((Rectangle){550,170,220,205}, "SCROLLBAR STYLE");
|
// ScrollPanel style controls
|
||||||
|
//----------------------------------------------------------
|
||||||
|
GuiGroupBox((Rectangle){ 550, 170, 220, 205 }, "SCROLLBAR STYLE");
|
||||||
|
|
||||||
int style = GuiGetStyle(SCROLLBAR, BORDER_WIDTH);
|
int style = GuiGetStyle(SCROLLBAR, BORDER_WIDTH);
|
||||||
GuiLabel((Rectangle){555,195,110,10}, "BORDER_WIDTH");
|
GuiLabel((Rectangle){ 555, 195, 110, 10 }, "BORDER_WIDTH");
|
||||||
GuiSpinner((Rectangle){670,190,90,20}, &style, 0, 6, false);
|
GuiSpinner((Rectangle){ 670, 190, 90, 20 }, &style, 0, 6, false);
|
||||||
GuiSetStyle(SCROLLBAR, BORDER_WIDTH, style);
|
GuiSetStyle(SCROLLBAR, BORDER_WIDTH, style);
|
||||||
|
|
||||||
style = GuiGetStyle(SCROLLBAR, ARROWS_SIZE);
|
style = GuiGetStyle(SCROLLBAR, ARROWS_SIZE);
|
||||||
GuiLabel((Rectangle){555,220,110,10}, "ARROWS_SIZE");
|
GuiLabel((Rectangle){ 555, 220, 110, 10 }, "ARROWS_SIZE");
|
||||||
GuiSpinner((Rectangle){670,215,90,20}, &style, 4, 14, false);
|
GuiSpinner((Rectangle){ 670, 215, 90, 20 }, &style, 4, 14, false);
|
||||||
GuiSetStyle(SCROLLBAR, ARROWS_SIZE, style);
|
GuiSetStyle(SCROLLBAR, ARROWS_SIZE, style);
|
||||||
|
|
||||||
style = GuiGetStyle(SCROLLBAR, INNER_PADDING);
|
style = GuiGetStyle(SCROLLBAR, INNER_PADDING);
|
||||||
GuiLabel((Rectangle){555,245,110,10}, "INNER_PADDING");
|
GuiLabel((Rectangle){ 555, 245, 110, 10 }, "INNER_PADDING");
|
||||||
GuiSpinner((Rectangle){670,240,90,20}, &style, 0, 14, false);
|
GuiSpinner((Rectangle){ 670, 240, 90, 20 }, &style, 0, 14, false);
|
||||||
GuiSetStyle(SCROLLBAR, INNER_PADDING, style);
|
GuiSetStyle(SCROLLBAR, INNER_PADDING, style);
|
||||||
|
|
||||||
style = GuiCheckBox((Rectangle){565,280,20,20}, "SHOW_SPINNER_BUTTONS", GuiGetStyle(SCROLLBAR, SHOW_SPINNER_BUTTONS));
|
style = GuiCheckBox((Rectangle){ 565, 280, 20, 20 }, "SHOW_SPINNER_BUTTONS", GuiGetStyle(SCROLLBAR, SHOW_SPINNER_BUTTONS));
|
||||||
GuiSetStyle(SCROLLBAR, SHOW_SPINNER_BUTTONS, style);
|
GuiSetStyle(SCROLLBAR, SHOW_SPINNER_BUTTONS, style);
|
||||||
|
|
||||||
style = GuiGetStyle(SCROLLBAR, SLIDER_PADDING);
|
style = GuiGetStyle(SCROLLBAR, SLIDER_PADDING);
|
||||||
GuiLabel((Rectangle){555,325,110,10}, "SLIDER_PADDING");
|
GuiLabel((Rectangle){ 555, 325, 110, 10 }, "SLIDER_PADDING");
|
||||||
GuiSpinner((Rectangle){670,320,90,20}, &style, 0, 14, false);
|
GuiSpinner((Rectangle){ 670, 320, 90, 20 }, &style, 0, 14, false);
|
||||||
GuiSetStyle(SCROLLBAR, SLIDER_PADDING, style);
|
GuiSetStyle(SCROLLBAR, SLIDER_PADDING, style);
|
||||||
|
|
||||||
style = GuiGetStyle(SCROLLBAR, SLIDER_SIZE);
|
style = GuiGetStyle(SCROLLBAR, SLIDER_SIZE);
|
||||||
GuiLabel((Rectangle){555,350,110,10}, "SLIDER_SIZE");
|
GuiLabel((Rectangle){ 555, 350, 110, 10 }, "SLIDER_SIZE");
|
||||||
GuiSpinner((Rectangle){670,345,90,20}, &style, 2, 100, false);
|
GuiSpinner((Rectangle){ 670, 345, 90, 20 }, &style, 2, 100, false);
|
||||||
GuiSetStyle(SCROLLBAR, SLIDER_SIZE, style);
|
GuiSetStyle(SCROLLBAR, SLIDER_SIZE, style);
|
||||||
|
|
||||||
|
const char *text = GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE? "SCROLLBAR: LEFT" : "SCROLLBAR: RIGHT";
|
||||||
|
style = GuiToggle((Rectangle){ 560, 110, 200, 35 }, text, GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE));
|
||||||
|
GuiSetStyle(LISTVIEW, SCROLLBAR_SIDE, style);
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
|
|
||||||
GuiGroupBox((Rectangle){550,20,220,135}, "SCROLLPANEL STYLE");
|
// ScrollBar style controls
|
||||||
|
//----------------------------------------------------------
|
||||||
|
GuiGroupBox((Rectangle){ 550, 20, 220, 135 }, "SCROLLPANEL STYLE");
|
||||||
|
|
||||||
style = GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH);
|
style = GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH);
|
||||||
GuiLabel((Rectangle){555,35,110,10}, "SCROLLBAR_WIDTH");
|
GuiLabel((Rectangle){ 555, 35, 110, 10 }, "SCROLLBAR_WIDTH");
|
||||||
GuiSpinner((Rectangle){670,30,90,20}, &style, 6, 30, false);
|
GuiSpinner((Rectangle){ 670, 30, 90, 20 }, &style, 6, 30, false);
|
||||||
GuiSetStyle(LISTVIEW, SCROLLBAR_WIDTH, style);
|
GuiSetStyle(LISTVIEW, SCROLLBAR_WIDTH, style);
|
||||||
|
|
||||||
style = GuiGetStyle(DEFAULT, BORDER_WIDTH);
|
style = GuiGetStyle(DEFAULT, BORDER_WIDTH);
|
||||||
GuiLabel((Rectangle){555,60,110,10}, "BORDER_WIDTH");
|
GuiLabel((Rectangle){ 555, 60, 110, 10 }, "BORDER_WIDTH");
|
||||||
GuiSpinner((Rectangle){670,55,90,20}, &style, 0, 20, false);
|
GuiSpinner((Rectangle){ 670, 55, 90, 20 }, &style, 0, 20, false);
|
||||||
GuiSetStyle(DEFAULT, BORDER_WIDTH, style);
|
GuiSetStyle(DEFAULT, BORDER_WIDTH, style);
|
||||||
|
|
||||||
contentArea = GuiCheckBox((Rectangle){565,80,20,20}, "SHOW CONTENT AREA", contentArea);
|
|
||||||
|
|
||||||
const char* text = GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE ? "SCROLLBAR: LEFT" : "SCROLLBAR: RIGHT";
|
|
||||||
style = GuiToggle((Rectangle){560,110,200,35}, text, GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE));
|
|
||||||
GuiSetStyle(LISTVIEW, SCROLLBAR_SIDE, style);
|
|
||||||
|
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
|
|
||||||
panelContentRec.width = GuiSliderBar((Rectangle){590,385,145,15}, "WIDTH", panelContentRec.width, 1, 600, true);
|
|
||||||
panelContentRec.height = GuiSliderBar((Rectangle){590,410,145,15}, "HEIGHT", panelContentRec.height, 1, 400, true);
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user