Skip to content

Commit

Permalink
Modernize scrollbar look
Browse files Browse the repository at this point in the history
  • Loading branch information
x42 committed Dec 4, 2024
1 parent 3c8527c commit e59a5fc
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 90 deletions.
8 changes: 5 additions & 3 deletions gtk2_ardour/clearlooks.rc.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ style "default" = "medium_text"
GtkScrollbar :: arrow-scaling = 0.4 # [ 0.5 ] ( 0.1 ) The arrow size proportion relative to the scroll button size.
GtkScrollbar :: fixed-slider-length = 0 # [ 0 ] ( bool ) Don't change slider size, just lock it to the minimum length.
GtkScrollbar :: min-slider-length = 50 # [ 21 ] ( >= 0 ) Minimum length of scrollbar slider.
GtkScrollbar :: slider-width = 15 # [ 14 ] ( >= 0 ) Width of scrollbar or scale thumb.
GtkScrollbar :: slider-width = 10 # [ 14 ] ( >= 0 ) Width of scrollbar or scale thumb.
GtkScrollbar :: stepper-spacing = 0 # [ 0 ] ( >= 0 ) The spacing between the stepper buttons and thumb. Note that setting this value to anything > 0 will automatically set the trough-under-steppers style property to TRUE as well. Also, stepper-spacing won't have any effect if there are no steppers.
GtkScrollbar :: trough-border = 0 # [ 1 ] ( >= 0 ) Spacing between thumb/steppers and outer trough bevel.
GtkScrollbar :: focus-line-width = 0
GtkScrollbar :: focus-padding = 0
GtkScrollbar :: trough-side-details = 0 # [ 0 ] ( bool ) When TRUE, the parts of the trough on the two sides of the slider are drawn with different details.
GtkScrollbar :: trough-under-steppers = 1 # [ 1 ] ( bool ) Whether to draw the trough across the full length of the range or to exclude the steppers and their spacing. Note that setting the "stepper-spacing" style property to any value > 0 will automatically enable trough-under-steppers too.

GtkScrollbar :: has-backward-stepper = 1 # [ 1 ] ( bool ) Display the standard backward arrow button.
GtkScrollbar :: has-forward-stepper = 1 # [ 1 ] ( bool ) Display the standard forward arrow button.
GtkScrollbar :: has-backward-stepper = 0 # [ 1 ] ( bool ) Display the standard backward arrow button.
GtkScrollbar :: has-forward-stepper = 0 # [ 1 ] ( bool ) Display the standard forward arrow button.
GtkScrollbar :: has-secondary-backward-stepper = 0 # [ 0 ] ( bool ) Display a second backward arrow button on the opposite end of the scrollbar.
GtkScrollbar :: has-secondary-forward-stepper = 0 # [ 0 ] ( bool ) Display a second forward arrow button on the opposite end of the scrollbar.

Expand Down
130 changes: 44 additions & 86 deletions libs/clearlooks-newer/clearlooks_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1584,8 +1584,6 @@ clearlooks_draw_scrollbar_trough (cairo_t *cr,
{
const CairoColor *bg;
CairoColor bg_shade;
cairo_pattern_t *pattern;
const CairoColor *border = &colors->shade[5];

(void) widget;
bg = &colors->shade[2];
Expand All @@ -1604,6 +1602,9 @@ clearlooks_draw_scrollbar_trough (cairo_t *cr,
ge_cairo_set_color (cr, bg);
cairo_fill (cr);

#if 0
cairo_pattern_t *pattern;
const CairoColor *border = &colors->shade[5];
/* Draw shadow */
pattern = cairo_pattern_create_linear (1, 0, 3, 0);
cairo_pattern_add_color_stop_rgb (pattern, 0, bg_shade.r, bg_shade.g, bg_shade.b);
Expand All @@ -1616,6 +1617,7 @@ clearlooks_draw_scrollbar_trough (cairo_t *cr,
/* Draw border */
ge_cairo_set_color (cr, border);
ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
#endif
}

static void
Expand Down Expand Up @@ -1690,6 +1692,12 @@ clearlooks_draw_scrollbar_slider (cairo_t *cr,
const ScrollBarParameters *scrollbar,
int x, int y, int width, int height)
{
const CairoColor *border = &colors->shade[7];
CairoColor fill = scrollbar->color;
CairoColor hilight;
CairoColor shade1, shade2, shade3;
cairo_pattern_t *pattern;

if (scrollbar->junction & CL_JUNCTION_BEGIN)
{
if (scrollbar->horizontal)
Expand All @@ -1711,103 +1719,53 @@ clearlooks_draw_scrollbar_slider (cairo_t *cr,
height += 1;
}

double radius = MIN (widget->radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));

if (!scrollbar->horizontal)
ge_cairo_exchange_axis (cr, &x, &y, &width, &height);

cairo_translate (cr, x, y);

if (scrollbar->has_color)
{
const CairoColor *border = &colors->shade[7];
CairoColor fill = scrollbar->color;
CairoColor hilight;
CairoColor shade1, shade2, shade3;
cairo_pattern_t *pattern;
/* not have has-backward-stepper || has-forward-stepper : add padding */
if (width > 2) {
x += 2;
width -= 4;
}

if (widget->prelight)
ge_shade_color (&fill, 1.1, &fill);
cairo_translate (cr, x, y);

cairo_set_line_width (cr, 1);
if (widget->prelight)
ge_shade_color (&fill, 1.1, &fill);

ge_shade_color (&fill, 1.3, &hilight);
ge_shade_color (&fill, 1.1, &shade1);
ge_shade_color (&fill, 1.05, &shade2);
ge_shade_color (&fill, 0.98, &shade3);
cairo_set_line_width (cr, 1);

pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b);
cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade3.r, shade3.g, shade3.b);
cairo_pattern_add_color_stop_rgb (pattern, 1, fill.r, fill.g, fill.b);
cairo_rectangle (cr, 1, 1, width-2, height-2);
cairo_set_source (cr, pattern);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
ge_shade_color (&fill, 1.25, &hilight);
ge_shade_color (&fill, 1.16, &shade1);
ge_shade_color (&fill, 1.08, &shade2);
ge_shade_color (&fill, 1.08, &shade3);

pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b);
cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill.r, fill.g, fill.b);
cairo_pattern_add_color_stop_rgb (pattern, 1, shade3.r, shade3.g, shade3.b);
ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, widget->corners);
cairo_set_source (cr, pattern);
cairo_fill (cr);
cairo_pattern_destroy (pattern);

#if 0
if (scrollbar->has_color)
{
cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);

ge_cairo_set_color (cr, border);
ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
}
else
{
const CairoColor *dark = &colors->shade[4];
const CairoColor *light = &colors->shade[0];
CairoColor border;
CairoColor s1, s2, s3, s4, s5;
cairo_pattern_t *pattern;
int bar_x, i;

ge_shade_color(&colors->shade[6], 1.05, &border);

s2 = colors->bg[widget->state_type];
ge_shade_color(&s2, 1.06, &s1);
ge_shade_color(&s2, 0.98, &s3);
ge_shade_color(&s2, 0.94, &s4);

pattern = cairo_pattern_create_linear(1, 1, 1, height-1);
cairo_pattern_add_color_stop_rgb(pattern, 0, s1.r, s1.g, s1.b);
cairo_pattern_add_color_stop_rgb(pattern, 0.5, s2.r, s2.g, s2.b);
cairo_pattern_add_color_stop_rgb(pattern, 0.7, s3.r, s3.g, s3.b);
cairo_pattern_add_color_stop_rgb(pattern, 1.0, s4.r, s4.g, s4.b);

cairo_rectangle (cr, 1, 1, width-2, height-2);
cairo_set_source(cr, pattern);
cairo_fill(cr);
cairo_pattern_destroy(pattern);

clearlooks_set_border_gradient (cr, &border, 1.2, 0, height);
ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);

cairo_move_to (cr, 1.5, height-1.5);
cairo_line_to (cr, 1.5, 1.5);
cairo_line_to (cr, width-1.5, 1.5);
ge_shade_color (&s2, 1.3, &s5);
cairo_set_source_rgba (cr, s5.r, s5.g, s5.b, 0.5);
cairo_stroke(cr);

/* draw handles */
cairo_set_line_width (cr, 1);

bar_x = width/2 - 4;
cairo_translate(cr, 0.5, 0.5);
for (i=0; i<3; i++)
{
cairo_move_to (cr, bar_x, 4);
cairo_line_to (cr, bar_x, height-5);
ge_cairo_set_color (cr, dark);
cairo_stroke (cr);

cairo_move_to (cr, bar_x+1, 4);
cairo_line_to (cr, bar_x+1, height-5);
ge_cairo_set_color (cr, light);
cairo_stroke (cr);
#endif

bar_x += 3;
}
}
CairoColor composite;
ge_mix_color (border, &fill, scrollbar->has_color? 0.4 : 0.2, &composite);
ge_cairo_set_color (cr, &composite);

ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, widget->corners);
cairo_stroke (cr);
}

static void
Expand Down
4 changes: 3 additions & 1 deletion libs/clearlooks-newer/clearlooks_style.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ clearlooks_style_draw_slider (DRAW_ARGS, GtkOrientation orientation)
ScrollBarParameters scrollbar;

clearlooks_set_widget_parameters (widget, style, state_type, &params);
params.corners = CR_CORNER_NONE;
//params.corners = CR_CORNER_NONE;

scrollbar.has_color = FALSE;
scrollbar.horizontal = (orientation == GTK_ORIENTATION_HORIZONTAL);
Expand All @@ -925,6 +925,8 @@ clearlooks_style_draw_slider (DRAW_ARGS, GtkOrientation orientation)
{
ge_gdk_color_to_cairo (&clearlooks_style->scrollbar_color, &scrollbar.color);
scrollbar.has_color = TRUE;
} else {
scrollbar.color = colors->bg[0];
}

STYLE_FUNCTION(draw_scrollbar_slider) (cr, colors, &params, &scrollbar,
Expand Down
22 changes: 22 additions & 0 deletions refactor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sed -f
s/strip_button_toggled/att_left_button_toggled/
s/list_button_toggled/att_right_button_toggled/
s/props_button_toggled/att_bottom_button_toggled/
s/showhide_sidebar_strip/showhide_att_left/
s/showhide_sidebar_list/showhide_att_right/
s/showhide_btm_props/showhide_att_bottom/
s/content_transport_ebox/content_app_bar/
s/content_strip_ebox/contents_att_left/
s/content_list_vbox/content_right_vbox/
s/content_list_ebox/content_att_right/
s/content_attachments_ebox/content_attachments/
s/content_tabbables_ebox/content_tabbables/
s/content_toolbar_ebox/content_toolbar/
s/content_list_pane/content_right_pane/
s/content_innermost_ebox/content_innermost_hbox/
s/content_props_ebox/content_att_bottom/
s/_transport_table/_table/g
s/TransportBar/ApplicationBar/g
s/strip_attachment_button/left_attachment_button/
s/list_attachment_button/right_attachment_button/
s/prop_attachment_button/bottom_attachment_button/

0 comments on commit e59a5fc

Please sign in to comment.