aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-11-28 01:48:36 +0100
committerFederico Angelilli <code@fedang.net>2024-11-28 01:48:36 +0100
commit32f4f9e071cb2a6966edaac512ae11598c5b1f7e (patch)
tree9000b12b72c67caa91bef9fdf228bf244d1f2d45
parent737167955e8347ce06718e7a8324c9d2ac89dfba (diff)
Fix line_radius
-rw-r--r--comet.conf2
-rw-r--r--src/blocks/slider.c17
-rw-r--r--src/layout.c2
3 files changed, 12 insertions, 9 deletions
diff --git a/comet.conf b/comet.conf
index 54f6000..27a25f3 100644
--- a/comet.conf
+++ b/comet.conf
@@ -98,7 +98,7 @@
bar-height = 8
bar-color = #f1baee, #CCCCFF
bar-line-color = #000
- bar-line-width = 2
+ bar-line-width = 10
bar-bg-color = #fff
seekable = true
knob = rectangle
diff --git a/src/blocks/slider.c b/src/blocks/slider.c
index 32ec3e6..8495ecf 100644
--- a/src/blocks/slider.c
+++ b/src/blocks/slider.c
@@ -69,7 +69,7 @@ static void block_slider_render(layout_t *layout, cairo_t *cr)
pattern = slider->bar_color.pattern;
if (pattern != NULL) {
- int current = (slider->width * slider->value) / 100;
+ int current = (slider->value * slider->width) / 100;
render_capsule(cr, bar_x, bar_y, current, radius, radius);
cairo_pattern_set_matrix(pattern, &matrix);
@@ -99,6 +99,7 @@ static void block_slider_render(layout_t *layout, cairo_t *cr)
double knob_rotation = slider->knob_rotation * degree;
int knob_rw = knob_width * cos(knob_rotation) + knob_height * sin(knob_rotation);
+ //int current = (slider->value * slider->width) / 100 - knob_rw / 2;
int current = (slider->value * (slider->width - knob_rw)) / 100;
int knob_x = bar_x + slider->line_width + slider->knob_x_offset + current - knob_rw / 2;
@@ -151,7 +152,7 @@ static void block_slider_render(layout_t *layout, cairo_t *cr)
switch (slider->knob) {
case KNOB_CAPSULE: {
- int line_radius = knob_radius - slider->knob_line_width / 2;
+ int line_radius = knob_radius + slider->knob_line_width / 2;
render_capsule(cr, knob_x, knob_y, knob_width, knob_radius, line_radius);
break;
}
@@ -181,11 +182,13 @@ static void block_slider_event(layout_t *layout, config_t *config, event_t event
int value = slider->value;
if (event_is_click(event)) {
- int bar_x = layout->x + (layout->width - slider->width) / 2 - slider->line_width;
- int bar_y = layout->y + (layout->height - slider->height) / 2 - slider->line_width;
+ // TODO: Adjust the size to account for line_width
+ //
+ int bar_x = layout->x + (layout->width - slider->width) / 2;
+ int bar_y = layout->y + (layout->height - slider->height) / 2;
- int bar_width = slider->width + 2 * slider->line_width;
- int bar_height = slider->height + 2 * slider->line_width;
+ int bar_width = slider->width;
+ int bar_height = slider->height;
bool clicked = check_capsule(event.x, event.y, bar_x, bar_y, bar_width, bar_height);
@@ -213,7 +216,7 @@ static void block_slider_event(layout_t *layout, config_t *config, event_t event
action_perform(action, layout->block, config);
if (slider->seekable && clicked)
- slider->value = 100 * (event.x - bar_x) / (double)(slider->width - 1);
+ slider->value = 100 * (event.x - bar_x) / (double)(bar_width - 1);
} else {
action_perform(layout->block->actions[event.type], layout->block, config);
diff --git a/src/layout.c b/src/layout.c
index 23b15ff..73243c5 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -119,7 +119,7 @@ void layout_render(layout_t *layout, cairo_t *cr)
// Render border
pattern = layout->block->line_color.pattern;
if (pattern != NULL) {
- int line_radius = radius - layout->line_width / 2;
+ int line_radius = radius + layout->line_width / 2;
render_capsule_fast(cr, block_x, block_y, layout->width - layout->x_padding, radius, line_radius);
cairo_pattern_set_matrix(pattern, &matrix);