Adrian C.
Fri, 16 Apr 2010 12:58:38 -0700
Hi, last month I wrote a quick offset solution for a user on IRC. Now this patch is sitting in my home for a month and it seems I can't find the time to review it. Maybe someone else can test and review (and decide/vote if we need this functionality at all). The commit message follows.
New method is available, set_offset, which takes a number as the offset argument. The progressbar will be drawn distanced from the border by as many pixels as the offset argument. Property is only taken into account when there actually is a border, it makes little sense otherwise (except to provide functionality simillar to margins, but widget margins are already available). -- Adrian C. (anrxc) | anrxc..sysphere.org | PGP ID: D20A0618 PGP FP: 02A5 628A D8EE 2A93 996E 929F D5CB 31B7 D20A 0618
signature.asc
Description: PGP signature
From 2b78444b75f74915bd45ce325a63921885f15e38 Mon Sep 17 00:00:00 2001
From: Adrian C. (anrxc) <an...@sysphere.org>
Date: Sun, 28 Mar 2010 20:26:55 +0200
Subject: [PATCH] awful.widget: add progressbar offset property
New method is available, set_offset, which takes a number as the
offset argument. The progressbar will be drawn distanced from the
border by as many pixels as the offset argument. Property is only
taken into account when there actually is a border, it makes little
sense otherwise (except to provide functionality simillar to margins,
but widget margins are already available).
Signed-off-by: Adrian C. (anrxc) <an...@sysphere.org>
---
lib/awful/widget/progressbar.lua.in | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/lib/awful/widget/progressbar.lua.in
b/lib/awful/widget/progressbar.lua.in
index 56e2733..480dc14 100644
--- a/lib/awful/widget/progressbar.lua.in
+++ b/lib/awful/widget/progressbar.lua.in
@@ -49,6 +49,12 @@ local data = setmetatable({}, { __mode = "k" })
-- @param progressbar The progressbar.
-- @param vertical A boolean value.
+--- Set the progressbar to draw with offset from the border.
+-- @name set_offset
+-- @class function
+-- @param progressbar The progressbar.
+-- @param value The value.
+
--- Set the progressbar to draw ticks. Default is false.
-- @name set_ticks
-- @class function
@@ -73,7 +79,7 @@ local data = setmetatable({}, { __mode = "k" })
-- @param progressbar The progressbar.
-- @param value The value.
-local properties = { "width", "height", "border_color",
+local properties = { "width", "height", "offset", "border_color",
"gradient_colors", "color", "background_color",
"vertical", "value", "max_value",
"ticks", "ticks_gap", "ticks_size" }
@@ -102,6 +108,12 @@ local function update(pbar)
over_drawn_width = width - 2 -- remove 2 for borders
over_drawn_height = height - 2 -- remove 2 for borders
border_width = 1
+
+ if data[pbar].offset then
+ border_width = border_width + data[pbar].offset
+ over_drawn_width = over_drawn_width - (data[pbar].offset * 2)
+ over_drawn_height = over_drawn_height - (data[pbar].offset * 2)
+ end
end
local angle = 270
--
1.7.0.3