progressbar: Remove vertical/width/height code

The deprecation message should be enough. This doesn't remove
the functionalities themselves.
This commit is contained in:
Emmanuel Lepage Vallee 2016-07-23 19:21:15 -04:00
parent e28b79944f
commit e5d4c188f1
1 changed files with 28 additions and 59 deletions

View File

@ -1,6 +1,10 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
--- A progressbar widget. --- A progressbar widget.
-- --
-- By default, this widget will take all the available size. To prevent this,
-- a `wibox.container.constraint` widget or the `forced_width`/`forced_height`
-- properties have to be used.
--
--@DOC_wibox_widget_defaults_progressbar_EXAMPLE@ --@DOC_wibox_widget_defaults_progressbar_EXAMPLE@
-- @author Julien Danjou <julien@danjou.info> -- @author Julien Danjou <julien@danjou.info>
-- @copyright 2009 Julien Danjou -- @copyright 2009 Julien Danjou
@ -34,8 +38,8 @@ local progressbar = { mt = {} }
-- @property background_color -- @property background_color
-- @tparam gears.color color The progressbar background color. -- @tparam gears.color color The progressbar background color.
--- Set the progressbar to draw vertically. Default is false. --- Set the progressbar to draw vertically.
-- -- This doesn't do anything anymore, use a `wibox.container.rotate` widget.
-- @deprecated set_vertical -- @deprecated set_vertical
-- @tparam boolean vertical -- @tparam boolean vertical
@ -68,10 +72,9 @@ local progressbar = { mt = {} }
--- The progressbar border color. --- The progressbar border color.
-- @beautiful beautiful.progressbar_border_color -- @beautiful beautiful.progressbar_border_color
local properties = { "width", "height", "border_color", local properties = { "border_color", "color" , "background_color",
"color", "background_color", "value" , "max_value", "ticks",
"vertical", "value", "max_value", "ticks_gap" , "ticks_size" }
"ticks", "ticks_gap", "ticks_size" }
function progressbar.draw(pbar, _, cr, width, height) function progressbar.draw(pbar, _, cr, width, height)
local ticks_gap = pbar._private.ticks_gap or 1 local ticks_gap = pbar._private.ticks_gap or 1
@ -107,58 +110,32 @@ function progressbar.draw(pbar, _, cr, width, height)
cr:fill() cr:fill()
-- Cover the part that is not set with a rectangle -- Cover the part that is not set with a rectangle
if pbar._private.vertical then local rel_x = over_drawn_width * value
local rel_height = over_drawn_height * (1 - value) cr:rectangle(border_width + rel_x,
cr:rectangle(border_width, border_width,
border_width, over_drawn_width - rel_x,
over_drawn_width, over_drawn_height)
rel_height) cr:set_source(color(pbar._private.background_color or "#000000aa"))
cr:set_source(color(pbar._private.background_color or beautiful.progressbar_bg or "#000000aa")) cr:fill()
cr:fill()
-- Place smaller pieces over the gradient if ticks are enabled if pbar._private.ticks then
if pbar._private.ticks then for i=0, width / (ticks_size+ticks_gap)-border_width do
for i=0, height / (ticks_size+ticks_gap)-border_width do local rel_offset = over_drawn_width / 1 - (ticks_size+ticks_gap) * i
local rel_offset = over_drawn_height / 1 - (ticks_size+ticks_gap) * i
if rel_offset >= rel_height then if rel_offset <= rel_x then
cr:rectangle(border_width, cr:rectangle(rel_offset,
rel_offset, border_width,
over_drawn_width, ticks_gap,
ticks_gap) over_drawn_height)
end
end end
cr:set_source(color(pbar._private.background_color or beautiful.progressbar_bg or "#000000aa"))
cr:fill()
end end
else
local rel_x = over_drawn_width * value
cr:rectangle(border_width + rel_x,
border_width,
over_drawn_width - rel_x,
over_drawn_height)
cr:set_source(color(pbar._private.background_color or "#000000aa")) cr:set_source(color(pbar._private.background_color or "#000000aa"))
cr:fill() cr:fill()
if pbar._private.ticks then
for i=0, width / (ticks_size+ticks_gap)-border_width do
local rel_offset = over_drawn_width / 1 - (ticks_size+ticks_gap) * i
if rel_offset <= rel_x then
cr:rectangle(rel_offset,
border_width,
ticks_gap,
over_drawn_height)
end
end
cr:set_source(color(pbar._private.background_color or "#000000aa"))
cr:fill()
end
end end
end end
function progressbar.fit(pbar) function progressbar:fit(_, width, height)
return pbar._private.width, pbar._private.height return width, height
end end
--- Set the progressbar value. --- Set the progressbar value.
@ -172,27 +149,21 @@ function progressbar:set_value(value)
end end
--- Set the progressbar height. --- Set the progressbar height.
-- This method is deprecated. -- This method is deprecated, it no longer do anything.
-- Use a `wibox.container.constraint` widget or `forced_height`. -- Use a `wibox.container.constraint` widget or `forced_height`.
-- @param height The height to set. -- @param height The height to set.
-- @deprecated set_height -- @deprecated set_height
function progressbar:set_height(height) --luacheck: no unused_args function progressbar:set_height(height) --luacheck: no unused_args
util.deprecate("Use a `wibox.container.constraint` widget or forced_height") util.deprecate("Use a `wibox.container.constraint` widget or forced_height")
self._private.height = height
self:emit_signal("widget::layout_changed")
return self
end end
--- Set the progressbar width. --- Set the progressbar width.
-- This method is deprecated. -- This method is deprecated, it no longer do anything.
-- Use a `wibox.container.constraint` widget or `forced_width`. -- Use a `wibox.container.constraint` widget or `forced_width`.
-- @param width The width to set. -- @param width The width to set.
-- @deprecated set_width -- @deprecated set_width
function progressbar:set_width(width) --luacheck: no unused_args function progressbar:set_width(width) --luacheck: no unused_args
util.deprecate("Use a `wibox.container.constraint` widget or forced_width") util.deprecate("Use a `wibox.container.constraint` widget or forced_width")
self._private.width = width
self:emit_signal("widget::layout_changed")
return self
end end
-- Build properties function -- Build properties function
@ -206,10 +177,8 @@ for _, prop in ipairs(properties) do
end end
end end
local set_vertical = progressbar.set_vertical
function progressbar:set_vertical(value) --luacheck: no unused_args function progressbar:set_vertical(value) --luacheck: no unused_args
util.deprecate("Use a `wibox.container.rotate` widget") util.deprecate("Use a `wibox.container.rotate` widget")
set_vertical(self, value)
end end