Some more tweaks
This commit is contained in:
parent
f79e30dd5c
commit
f53867175e
|
@ -35,6 +35,17 @@ local slider = {mt={}}
|
||||||
-- @propbeautiful
|
-- @propbeautiful
|
||||||
-- @see gears.shape
|
-- @see gears.shape
|
||||||
|
|
||||||
|
-- The slider handle widget
|
||||||
|
|
||||||
|
--@DOC_wibox_widget_slider_handle_widget_EXAMPLE@
|
||||||
|
|
||||||
|
-- @property handle_widget
|
||||||
|
-- @tparam widget|nil handle_widget
|
||||||
|
-- @propemits true false
|
||||||
|
-- @propbeautiful
|
||||||
|
-- @see wibox.widget
|
||||||
|
|
||||||
|
|
||||||
--- The slider handle color.
|
--- The slider handle color.
|
||||||
--
|
--
|
||||||
--@DOC_wibox_widget_slider_handle_color_EXAMPLE@
|
--@DOC_wibox_widget_slider_handle_color_EXAMPLE@
|
||||||
|
@ -99,6 +110,16 @@ local slider = {mt={}}
|
||||||
-- @propbeautiful
|
-- @propbeautiful
|
||||||
-- @see gears.shape
|
-- @see gears.shape
|
||||||
|
|
||||||
|
-- The bar widget
|
||||||
|
|
||||||
|
--@DOC_wibox_widget_slider_bar_widget_EXAMPLE@
|
||||||
|
--
|
||||||
|
-- @property bar_widget
|
||||||
|
-- @tparam widget|nil bar_widget
|
||||||
|
-- @propemits true false
|
||||||
|
-- @propbeautiful
|
||||||
|
-- @see wibox.widget
|
||||||
|
|
||||||
--- The bar (background) height.
|
--- The bar (background) height.
|
||||||
--
|
--
|
||||||
--@DOC_wibox_widget_slider_bar_height_EXAMPLE@
|
--@DOC_wibox_widget_slider_bar_height_EXAMPLE@
|
||||||
|
@ -320,9 +341,7 @@ function slider:set_value(value)
|
||||||
if changed then
|
if changed then
|
||||||
self:emit_signal( "property::value", value)
|
self:emit_signal( "property::value", value)
|
||||||
self:emit_signal( "widget::redraw_needed" )
|
self:emit_signal( "widget::redraw_needed" )
|
||||||
if self._private.handle_widget then
|
if self._private.handle_widget or self._private.bar_widget then
|
||||||
self:emit_signal("widget::layout_changed")
|
|
||||||
elseif self._private.bar_widget then
|
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -412,7 +431,8 @@ function slider:draw(_, cr, width, height)
|
||||||
bar_height = bar_height or (
|
bar_height = bar_height or (
|
||||||
height - (margins.top or 0) - (margins.bottom or 0)
|
height - (margins.top or 0) - (margins.bottom or 0)
|
||||||
)
|
)
|
||||||
x_offset, y_offset = margins.left or 0, margins.top or 0
|
x_offset, y_offset = margins.left or 0,
|
||||||
|
margins.top or 0
|
||||||
right_margin = margins.right or 0
|
right_margin = margins.right or 0
|
||||||
else
|
else
|
||||||
bar_height = bar_height or beautiful.slider_bar_height or height
|
bar_height = bar_height or beautiful.slider_bar_height or height
|
||||||
|
@ -493,7 +513,8 @@ function slider:draw(_, cr, width, height)
|
||||||
x_offset, y_offset = 0, 0
|
x_offset, y_offset = 0, 0
|
||||||
|
|
||||||
if margins then
|
if margins then
|
||||||
x_offset, y_offset = margins.left or 0, margins.top or 0
|
x_offset, y_offset = margins.left or 0,
|
||||||
|
margins.top or 0
|
||||||
handle_width = handle_width -
|
handle_width = handle_width -
|
||||||
(margins.left or 0) - (margins.right or 0)
|
(margins.left or 0) - (margins.right or 0)
|
||||||
handle_height = handle_height -
|
handle_height = handle_height -
|
||||||
|
@ -534,11 +555,6 @@ function slider:fit(_, width, height)
|
||||||
return width, height
|
return width, height
|
||||||
end
|
end
|
||||||
|
|
||||||
-- @property handle_widget
|
|
||||||
-- @tparam widget|nil handle_widget
|
|
||||||
|
|
||||||
-- @property bar_widget
|
|
||||||
-- @tparam widget|nil bar_widget
|
|
||||||
function slider:layout(context, width, height)
|
function slider:layout(context, width, height)
|
||||||
local result = {}
|
local result = {}
|
||||||
local handle_widget = self._private.handle_widget
|
local handle_widget = self._private.handle_widget
|
||||||
|
@ -555,7 +571,7 @@ function slider:layout(context, width, height)
|
||||||
local bar_height, bar_width = self._private.bar_height or height, width
|
local bar_height, bar_width = self._private.bar_height or height, width
|
||||||
local handle_height, handle_width = height, self._private.handle_width
|
local handle_height, handle_width = height, self._private.handle_width
|
||||||
or beautiful.slider_handle_width
|
or beautiful.slider_handle_width
|
||||||
or math.floor(height / 2)
|
or width
|
||||||
|
|
||||||
if bar_widget then
|
if bar_widget then
|
||||||
bar_width = (((value - min) / interval) * width + handle_width / 2 - ((value - min) / interval ) * handle_width)
|
bar_width = (((value - min) / interval) * width + handle_width / 2 - ((value - min) / interval ) * handle_width)
|
||||||
|
|
Loading…
Reference in New Issue