Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wibox.widget.slider: handle shape is misslocated when setting a manual height for a shape #3759

Open
Crylia opened this issue Jan 1, 2023 · 1 comment

Comments

@Crylia
Copy link
Contributor

Crylia commented Jan 1, 2023

Output of awesome --version:

awesome v4.3-1581-gc8016f0c (Too long)

How to reproduce the issue:

bar_shape = function(cr, width, height)
  gshape.rounded_rect(cr, width, height, dpi(5))
end,
bar_height = dpi(5),
bar_color = Theme_config.volume_controller.border_color,
bar_active_color = Theme_config.volume_controller.volume_fg,
handle_color = Theme_config.volume_controller.volume_fg,
handle_shape = function(cr, width, height)
  gshape.partially_rounded_rect(cr, width, dpi(5), false, true, true, false)
 end,
 handle_border_color = Theme_config.volume_controller.volume_fg,
handle_width = dpi(5),
handle_cursor = 'left_ptr',
maximum = 100,
forced_height = dpi(5),
value = 50,
widget = wibox.widget.slider,

When I create a slider with the code above the handle is placed above the slider.

The problem "goes away" when I just use the provided height but then I can't limit the height.

I can see this getting fixed in two ways, maybe both would be good.

  • add a handle_height variable
  • properly place the surface so its placed as expected

It looks like the widget uses all its *available space for the shape, even when wrapping the slider in a wibox.container.constraint or using forced_height = dpi(5)

*The space that the entire widget and its partent(a constraint with height = dpi(5) and strategy = 'exact') have in this layout

@kosorin
Copy link
Contributor

kosorin commented Jan 10, 2023

handle_shape = function(cr, width, height)
  gshape.partially_rounded_rect(cr, width, dpi(5) --[[ here ]] , false, true, true, false)
end,

This is not how you use shape. You only clipped what is drawn and the handle is still there in its full size, you didn't magically changed its height.

You mentioned wibox.container.constraint. I'm also having trouble getting it to work, I almost think there must be some bugs or the doc is not clear and I'm missing something.

However you can use other layouts. I tried wibox.layout.align and it works:

{
    widget = wibox.layout.align.vertical,
    expand = "outside",
    nil,
    {
        bar_shape = function(cr, width, height)
            gshape.rounded_rect(cr, width, height, dpi(5))
        end,
        bar_height = dpi(5),
        bar_color = "#000044",
        bar_active_color = "#0000cc",
        handle_color = "#cc0000",
        handle_shape = function(cr, width, height)
            gshape.partially_rounded_rect(cr, width, height, false, true, true, false)
        end,
        handle_border_color = "#00cc00",
        handle_width = dpi(5),
        handle_cursor = 'left_ptr',
        maximum = 100,
        forced_height = dpi(5),
        value = 50,
        widget = wibox.widget.slider,
    },
    nil,
}

image

Edit:
I just noticed this is not the best solution as it kind of hard to grab the slider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants