mirror of
https://github.com/raysan5/raygui.git
synced 2026-02-05 13:49:17 -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
|
||||||
@ -43,8 +42,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 };
|
||||||
|
Rectangle panelContentRec = {0, 0, 340, 340 };
|
||||||
Vector2 panelScroll = { 99, -20 };
|
Vector2 panelScroll = { 99, -20 };
|
||||||
|
|
||||||
|
bool showContentArea = true;
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -70,10 +72,15 @@ 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));
|
|
||||||
|
DrawStyleEditControls();
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
ChangeStyleUI();
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
@ -86,8 +93,11 @@ int main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeStyleUI()
|
// Draw and process scroll bar style edition controls
|
||||||
|
static void DrawStyleEditControls(void)
|
||||||
{
|
{
|
||||||
|
// ScrollPanel style controls
|
||||||
|
//----------------------------------------------------------
|
||||||
GuiGroupBox((Rectangle){ 550, 170, 220, 205 }, "SCROLLBAR STYLE");
|
GuiGroupBox((Rectangle){ 550, 170, 220, 205 }, "SCROLLBAR STYLE");
|
||||||
|
|
||||||
int style = GuiGetStyle(SCROLLBAR, BORDER_WIDTH);
|
int style = GuiGetStyle(SCROLLBAR, BORDER_WIDTH);
|
||||||
@ -118,8 +128,13 @@ void ChangeStyleUI()
|
|||||||
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);
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
|
|
||||||
|
// ScrollBar style controls
|
||||||
|
//----------------------------------------------------------
|
||||||
GuiGroupBox((Rectangle){ 550, 20, 220, 135 }, "SCROLLPANEL STYLE");
|
GuiGroupBox((Rectangle){ 550, 20, 220, 135 }, "SCROLLPANEL STYLE");
|
||||||
|
|
||||||
style = GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH);
|
style = GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH);
|
||||||
@ -131,15 +146,5 @@ void ChangeStyleUI()
|
|||||||
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