diff options
Diffstat (limited to 'src/ui_elements')
| -rw-r--r-- | src/ui_elements/UI.c | 28 | ||||
| -rw-r--r-- | src/ui_elements/UI.h | 6 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/ui_elements/UI.c b/src/ui_elements/UI.c index 502944c..e3a0048 100644 --- a/src/ui_elements/UI.c +++ b/src/ui_elements/UI.c @@ -78,3 +78,31 @@ void DrawTextInRec(Rectangle rec, char *text, Font *font, int height, Color colo } EndScissorMode(); } + +void GetPanesSplit(Rectangle *pane1, Rectangle *pane2, Rectangle body, float proportion_h, float proportion_v) { + if (body.height >= body.width) { + // vertical split + pane1->x = body.x; + pane1->y = body.y; + pane1->width = body.width; + pane1->height = (body.height - PADDING) * proportion_v; + + pane2->x = body.x; + pane2->y = body.y + pane1->height + PADDING; + pane2->width = body.width; + pane2->height = (body.height - PADDING) * (1 - proportion_v); + return; + } + + // horizontal split + pane1->x = body.x; + pane1->y = body.y; + pane1->height = body.height; + pane1->width = (body.width - PADDING) * proportion_h; + + pane2->y = body.y; + pane2->x = body.x + pane1->width + PADDING; + pane2->height = body.height; + pane2->width = (body.width - PADDING) * (1 - proportion_h); +} + diff --git a/src/ui_elements/UI.h b/src/ui_elements/UI.h index 532dd68..d3af014 100644 --- a/src/ui_elements/UI.h +++ b/src/ui_elements/UI.h @@ -7,6 +7,7 @@ static const float SCROLL_SENC = 10; static const float TAB_WIDTH = 4; +static const int PADDING = 10; // Sure about this value static const int MIN_FONT_SIZE = 10; @@ -78,4 +79,9 @@ void UpdateTextArea(TextArea *ta, Rectangle rec); char *GetText(TextArea *ta); void FreeTextArea(TextArea *ta); +/// Fills pane1 and pane2 with the panes location +/// proporion_h and proportion_v are the scale ratio of the panes in horizontal +/// and vertical orientation +void GetPanesSplit(Rectangle *pane1, Rectangle *pane2, Rectangle body, float proportion_h, float proportion_v); + #endif // UI_ELEMENTS_H |
