@@ -997,15 +997,13 @@ pub fn Element(comptime T: type) type {
997997 }
998998
999999 switch (element .type ) {
1000- .button = > | b | b .draw (element , display , parent_scroll_offset , parent_clip , scroll_offset ),
1001- .checkbox = > | c | c .draw (element , display , parent_scroll_offset , parent_clip , scroll_offset ),
1002- .expander = > | e | e .draw (),
1003- .label = > | l | l .draw (element , display , parent_scroll_offset , parent_clip , scroll_offset ),
1004- .panel = > element .draw_panel (display , parent_scroll_offset , parent_clip , scroll_offset ),
1005- .progress_bar = > | d | d .draw (element , display , parent_scroll_offset , parent_clip , scroll_offset ),
1006- .rectangle = > element .draw_rectangle_element (display , parent_scroll_offset , parent_clip , scroll_offset ),
1007- .sprite = > | s | s .draw (element , display , parent_scroll_offset , parent_clip , scroll_offset ),
1008- .text_input = > | ti | ti .draw (element , display , parent_scroll_offset , parent_clip , scroll_offset ),
1000+ inline else = > | o | o .draw (
1001+ element ,
1002+ display ,
1003+ parent_scroll_offset ,
1004+ parent_clip ,
1005+ scroll_offset ,
1006+ ),
10091007 }
10101008
10111009 // Draw a border around an element if a border is specified, or
@@ -1107,54 +1105,6 @@ pub fn Element(comptime T: type) type {
11071105 }
11081106 }
11091107
1110- /// Draw the contents of a panel.
1111- inline fn draw_panel (
1112- element : * Self ,
1113- display : * Display (T ),
1114- _ : Vector ,
1115- parent_clip : ? Clip ,
1116- scroll_offset : Vector ,
1117- ) void {
1118- if (parent_clip ) | clip | {
1119- for (element .type .panel .children .items ) | child | {
1120- child .draw (display , scroll_offset , clip );
1121- }
1122- } else if (element .type .panel .scrollable .scroll .x or element .type .panel .scrollable .scroll .y ) {
1123- for (element .type .panel .children .items ) | child | {
1124- child .draw (display , scroll_offset , Clip {
1125- .top = element .rect .y ,
1126- .left = element .rect .x ,
1127- .bottom = element .rect .y + element .rect .height ,
1128- .right = element .rect .x + element .rect .width ,
1129- });
1130- }
1131- } else {
1132- for (element .type .panel .children .items ) | child | {
1133- child .draw (display , scroll_offset , null );
1134- }
1135- }
1136- }
1137-
1138- /// Draw a basic rectangle.
1139- inline fn draw_rectangle_element (
1140- element : * Self ,
1141- display : * Display (T ),
1142- _ : Vector ,
1143- _ : ? Clip ,
1144- scroll_offset : Vector ,
1145- ) void {
1146- const colour = element .style .panel (display .theme , element .background .colour );
1147- _ = sdl .SDL_SetRenderDrawColor (
1148- display .renderer ,
1149- colour .r ,
1150- colour .g ,
1151- colour .b ,
1152- colour .a ,
1153- );
1154- var dest = element .rect .move (& scroll_offset );
1155- _ = sdl .SDL_RenderFillRect (display .renderer , @ptrCast (& dest ));
1156- }
1157-
11581108 /// Calculate the layout of all elements, and optionally render every element.
11591109 ///
11601110 /// Normally text is converted to an image and rendered left to right, starting
0 commit comments