Code review and formatting

This commit is contained in:
Ray 2019-04-30 18:46:44 +02:00
parent c45e7ee524
commit a2a3af31de

View File

@ -26,9 +26,8 @@
#define RAYGUI_IMPLEMENTATION
#include "../src/raygui.h"
bool contentArea = true;
Rectangle panelContentRec = {0, 0, 340, 340 };
void ChangeStyleUI(void);
static void DrawStyleEditControls(void); // Draw and process scroll bar style edition controls
//------------------------------------------------------------------------------------
// Program main entry point
@ -43,8 +42,11 @@ int main()
InitWindow(screenWidth, screenHeight, "raygui - GuiScrollPanel()");
Rectangle panelRec = { 20, 40, 200, 150 };
Rectangle panelContentRec = {0, 0, 340, 340 };
Vector2 panelScroll = { 99, -20 };
bool showContentArea = true;
SetTargetFPS(60);
//---------------------------------------------------------------------------------------
@ -70,10 +72,15 @@ int main()
GuiGrid((Rectangle){panelRec.x + panelScroll.x, panelRec.y + panelScroll.y, panelContentRec.width, panelContentRec.height}, 16, 3);
EndScissorMode();
if(contentArea)
DrawRectangle(panelRec.x + panelScroll.x, panelRec.y + panelScroll.y, panelContentRec.width, panelContentRec.height, Fade(RED, 0.1));
if (showContentArea) 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();
//----------------------------------------------------------------------------------
}
@ -86,8 +93,11 @@ int main()
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");
int style = GuiGetStyle(SCROLLBAR, BORDER_WIDTH);
@ -118,8 +128,13 @@ void ChangeStyleUI()
GuiSpinner((Rectangle){ 670, 345, 90, 20 }, &style, 2, 100, false);
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");
style = GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH);
@ -131,15 +146,5 @@ void ChangeStyleUI()
GuiLabel((Rectangle){ 555, 60, 110, 10 }, "BORDER_WIDTH");
GuiSpinner((Rectangle){ 670, 55, 90, 20 }, &style, 0, 20, false);
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);
}