@@ -1113,7 +1113,7 @@ pub fn Element(comptime T: type) type {
11131113 );
11141114 }
11151115 }
1116- } else if (element .background .colour .a > 0 and element .type != .rectangle and element .type != .sprite ) {
1116+ } else if (element .background .colour .a > 0 and element .type != .rectangle and element .type != .sprite and element . type != .progress_bar ) {
11171117 // If there is no background image, but there is a background
11181118 // colour, draw the background as a simple rectangle (except for
11191119 // sprites and rectangles).
@@ -1135,7 +1135,7 @@ pub fn Element(comptime T: type) type {
11351135 .sprite = > element .draw_sprite (display , parent_scroll_offset , parent_clip , scroll_offset ),
11361136 .rectangle = > element .draw_rectangle_element (display , parent_scroll_offset , parent_clip , scroll_offset ),
11371137 .label = > element .draw_label (display , parent_scroll_offset , parent_clip ),
1138- .progress_bar = > element .draw_progress_bar (display , parent_scroll_offset , parent_clip ),
1138+ .progress_bar = > element .draw_progress_bar (display , parent_scroll_offset , parent_clip , scroll_offset ),
11391139 .expander = > {},
11401140 }
11411141
@@ -1733,17 +1733,22 @@ pub fn Element(comptime T: type) type {
17331733 }
17341734
17351735 /// Draw a radio box combined with a text label.
1736- inline fn draw_checkbox (element : * Self , display : * Display (T ), _ : Vector , _ : ? Clip , scroll_offset : Vector ) void {
1736+ inline fn draw_checkbox (
1737+ element : * Self ,
1738+ display : * Display (T ),
1739+ _ : Vector ,
1740+ _ : ? Clip ,
1741+ scroll_offset : Vector ,
1742+ ) void {
17371743 const checkbox = element .type .checkbox .checkbox_size ;
17381744 element .draw_label (display , scroll_offset , null );
1739- var dest : Rect = . {
1745+ var dest = Rect {
17401746 .x = element .rect .x + element .rect .width - checkbox .width - element .pad .left ,
17411747 .y = element .rect .y + (element .rect .height / 2 ) - (checkbox .height / 2 ),
17421748 .width = checkbox .width ,
17431749 .height = checkbox .height ,
17441750 };
1745- dest .x += scroll_offset .x ;
1746- dest .y += scroll_offset .y ;
1751+ dest = dest .move (& scroll_offset );
17471752 if (element .type .checkbox .checked ) {
17481753 if (element .type .checkbox .on_texture ) | texture | {
17491754 _ = sdl .SDL_RenderTexture (display .renderer , texture .texture , null , @ptrCast (& dest ));
@@ -1756,23 +1761,30 @@ pub fn Element(comptime T: type) type {
17561761 }
17571762
17581763 /// Draw a progress bar.
1759- inline fn draw_progress_bar (element : * Self , display : * Display (T ), _ : Vector , _ : ? Clip ) void {
1764+ inline fn draw_progress_bar (
1765+ element : * Self ,
1766+ display : * Display (T ),
1767+ _ : Vector ,
1768+ _ : ? Clip ,
1769+ scroll_offset : Vector ,
1770+ ) void {
17601771 // Draw the background matching the current button state
17611772 if (element .texture ) | texture | {
1762- // Progress bar background
1763- var tint = display .theme .progress_bar_background ;
1764- var dest : Rect = .{
1773+ var dest = Rect {
17651774 .x = element .rect .x + element .pad .left ,
17661775 .y = element .rect .y + element .pad .top ,
17671776 .width = element .rect .width - element .pad .left - element .pad .right ,
17681777 .height = element .rect .height - element .pad .top - element .pad .bottom ,
17691778 };
1770- _ = sdl .SDL_SetTextureAlphaMod (texture .texture , tint .a );
1771- _ = sdl .SDL_SetTextureColorMod (texture .texture , tint .r , tint .g , tint .b );
1779+ dest = dest .move (& scroll_offset );
17721780 var corner : f32 = element .background .corner_radius ;
17731781 if (corner * 2 > dest .height ) corner = dest .height / 2 ;
17741782
17751783 // Progress bar background
1784+ var tint = display .theme .progress_bar_background ;
1785+ if (element .style == .custom ) tint = element .background .colour ;
1786+ _ = sdl .SDL_SetTextureAlphaMod (texture .texture , tint .a );
1787+ _ = sdl .SDL_SetTextureColorMod (texture .texture , tint .r , tint .g , tint .b );
17761788 if (element .background .image_corner_radius == 0 ) {
17771789 _ = sdl .SDL_RenderTexture (display .renderer , texture .texture , null , @ptrCast (& dest ));
17781790 } else {
@@ -1792,6 +1804,8 @@ pub fn Element(comptime T: type) type {
17921804 // Progress bar foreground
17931805 if (element .type .progress_bar .progress > 0.01 ) {
17941806 tint = display .theme .progress_bar_foreground ;
1807+ if (element .style == .custom )
1808+ tint = element .colour ;
17951809 dest .width *= element .type .progress_bar .progress ;
17961810 _ = sdl .SDL_SetTextureAlphaMod (texture .texture , tint .a );
17971811 _ = sdl .SDL_SetTextureColorMod (texture .texture , tint .r , tint .g , tint .b );
@@ -1819,7 +1833,13 @@ pub fn Element(comptime T: type) type {
18191833 /// Draw a button with its text and/or icon. Mouse hover, mouse click
18201834 /// and the disabled status may change the picture or icon
18211835 /// displayed in the button.
1822- inline fn draw_button (element : * Self , display : * Display (T ), _ : Vector , _ : ? Clip , scroll_offset : Vector ) void {
1836+ inline fn draw_button (
1837+ element : * Self ,
1838+ display : * Display (T ),
1839+ _ : Vector ,
1840+ _ : ? Clip ,
1841+ scroll_offset : Vector ,
1842+ ) void {
18231843 // Draw the background matching the current button state
18241844 if (element .current_background ()) | background_image | {
18251845 var dest : Rect = .{
0 commit comments