Re: [RFC + PATCH] awful.widget: add progressbar ticks property

2010-03-23 Thread Julien Danjou
Adrian C. an...@sysphere.org writes:

Pushed. :-)
Thanks a lot for this very nice work, Adrian.

Cheers,
-- 
Julien Danjou
// ᐰ jul...@danjou.info   http://julien.danjou.info

--
To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.


Re: [RFC + PATCH] awful.widget: add progressbar ticks property

2010-03-23 Thread Adrian C.
On Tue, 23 Mar 2010, Gwenhael Le Moine wrote:

  - Calling set_ticks(true) enables ticks for a progressbar
 
 and the casual suicidal lurker that I am instantly copied this to one
 of my progressbar, which not-so-nicely crashed awesome instantly as
 well...

I forgot to CC the second version to the users mailing list, I apologise 
for your trouble. The first one from which you tried to figure out how 
it works was just a porposal, a Request For Comments.

 Now there's not much harm done, and I _could_ dive into the code 
 itself and absorb its wisdom but just to be friendly a little bit of 
 documentation wouldn't have hurt

Functionality of all awful functions is actually documented, as comments 
in the modules. From these comments documentation is automatically 
generated at build time with Luadoc (which ends up in /usr/share/doc).

-- 
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


Re: [RFC + PATCH] awful.widget: add progressbar ticks property

2010-03-22 Thread Andrei Thorp
I think the ticks look _very_ nice -- especially with the gradients.

On Sun, Mar 21, 2010 at 5:41 PM, Adrian C. an...@sysphere.org wrote:
 Hello,
 sticking to the same principles from my last e-mail, the simple is
 better than complex and so on, here is the second version of ticks.

 My biggest dilemma in the last e-mail was ticks and gaps sizes.
 Considering possible implementations I settled on the following; being
 that the awful.widget.progressbar has a default size (100px wide) why
 not have a default tick and gap size (4px and 1px respectively). If a
 user goes trough the trouble of changing progressbar properties, and
 also enables ticks, why wouldn't he choose his own tick size, one that
 is more appropriate to his chosen progressbar dimensions.


 Three methods are available: set_ticks (false by default),
 set_ticks_size (width or height if horizontal or vertical) and
 set_ticks_gap. The gaps are drawn only over the gradient, the same color
 as the progressbar background.

 But (unlike the previous version) the number of ticks for the whole
 progressbar is calculated, so the gaps could be drawn in advance (by
 removing rel_offset comparison to rel_height/rel_x). But in that case
 the gaps should be of a different color (like wibox background), to get
 the effect of empty ticks.


 Demonstration of progressbars, with usage examples:
  - http://bljak.org/~anrxc/images/progressbars.png


 --
 Adrian C. (anrxc) | anrxc..sysphere.org | PGP ID: D20A0618
 PGP FP: 02A5 628A D8EE 2A93 996E  929F D5CB 31B7 D20A 0618


--
To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.


Re: [RFC + PATCH] awful.widget: add progressbar ticks property

2010-03-22 Thread Gregor Best
+1 from me for the patch :)

-- 
GCS/IT/M d- s+:- a-- C++ UL+++ US UB++ P+++ L+++ E--- W+ N+ o--
K- w--- ?O M-- ?V PS++ PE- Y++ PGP+++ t+ 5 X+ R tv b+++ DI+++
D+++ G+ e h! r y+

Gregor Best


pgpQVs5pcxdsW.pgp
Description: PGP signature


Re: [RFC + PATCH] awful.widget: add progressbar ticks property

2010-03-22 Thread Adrian C.
On Mon, 22 Mar 2010, Andrei Thorp wrote:

 I think the ticks look _very_ nice -- especially with the gradients.

That's great, I also like ticks :) and these do look nice if a user sets 
on to make them look nice.

That right there is my biggest problem. I got the ball rolling, but am I 
not sure about the finishing touches (setting aside that there are 
many other possible implementations of ticks).

In the demonstration I knew that 8 ticks of 2px and 1px gaps fit perfect 
into a 24px high progressbar. But what to do with a 23px high 
progressbar? My first e-mail was on the side of calculating the best 
relative size. My second was let the user do the work.

-- 
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


Re: [RFC + PATCH] awful.widget: add progressbar ticks property

2010-03-22 Thread lukash
Hi,
I also like ticks, ++ from me too :)

And I'm still of the opinion to let the user tune the params. No
algorithm would be perfect and a lot of users would end up setting their
own values anyway, IMHO.

Thanks!

lukash


On Mon, 22 Mar 2010 19:11:24 +0100 (CET) Adrian C. an...@sysphere.org
wrote:

 On Mon, 22 Mar 2010, Andrei Thorp wrote:
 
  I think the ticks look _very_ nice -- especially with the gradients.
 
 That's great, I also like ticks :) and these do look nice if a user sets 
 on to make them look nice.
 
 That right there is my biggest problem. I got the ball rolling, but am I 
 not sure about the finishing touches (setting aside that there are 
 many other possible implementations of ticks).
 
 In the demonstration I knew that 8 ticks of 2px and 1px gaps fit perfect 
 into a 24px high progressbar. But what to do with a 23px high 
 progressbar? My first e-mail was on the side of calculating the best 
 relative size. My second was let the user do the work.
 
 -- 
 Adrian C. (anrxc) | anrxc..sysphere.org | PGP ID: D20A0618
 PGP FP: 02A5 628A D8EE 2A93 996E  929F D5CB 31B7 D20A 0618

-- 
To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.


Re: [RFC + PATCH] awful.widget: add progressbar ticks property

2010-03-21 Thread Adrian C.
Hello, 
sticking to the same principles from my last e-mail, the simple is 
better than complex and so on, here is the second version of ticks.

My biggest dilemma in the last e-mail was ticks and gaps sizes. 
Considering possible implementations I settled on the following; being 
that the awful.widget.progressbar has a default size (100px wide) why 
not have a default tick and gap size (4px and 1px respectively). If a 
user goes trough the trouble of changing progressbar properties, and 
also enables ticks, why wouldn't he choose his own tick size, one that 
is more appropriate to his chosen progressbar dimensions.


Three methods are available: set_ticks (false by default), 
set_ticks_size (width or height if horizontal or vertical) and 
set_ticks_gap. The gaps are drawn only over the gradient, the same color 
as the progressbar background.

But (unlike the previous version) the number of ticks for the whole 
progressbar is calculated, so the gaps could be drawn in advance (by 
removing rel_offset comparison to rel_height/rel_x). But in that case 
the gaps should be of a different color (like wibox background), to get 
the effect of empty ticks.


Demonstration of progressbars, with usage examples:
  - http://bljak.org/~anrxc/images/progressbars.png


-- 
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 ab7763df65a8b68aeba611985128e4efac42df0d Mon Sep 17 00:00:00 2001
From: Adrian C. (anrxc) an...@sysphere.org
Date: Sun, 21 Mar 2010 18:42:21 +0100
Subject: [PATCH] awful.widget: add progressbar ticks property

Second implementation of the progressbar ticks. Adds set_ticks,
set_ticks_gap and set_ticks_size methods. Default gap is 1, size 4 in
respect to the default progressbar width of 100px.

Signed-off-by: Adrian C. (anrxc) an...@sysphere.org
---
 lib/awful/widget/progressbar.lua.in |   56 +--
 1 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/lib/awful/widget/progressbar.lua.in 
b/lib/awful/widget/progressbar.lua.in
index c457d8b..56e2733 100644
--- a/lib/awful/widget/progressbar.lua.in
+++ b/lib/awful/widget/progressbar.lua.in
@@ -49,6 +49,24 @@ local data = setmetatable({}, { __mode = k })
 -- @param progressbar The progressbar.
 -- @param vertical A boolean value.
 
+--- Set the progressbar to draw ticks. Default is false.
+-- @name set_ticks
+-- @class function
+-- @param progressbar The progressbar.
+-- @param ticks A boolean value.
+
+--- Set the progressbar ticks gap.
+-- @name set_ticks_gap
+-- @class function
+-- @param progressbar The progressbar.
+-- @param value The value.
+
+--- Set the progressbar ticks size.
+-- @name set_ticks_size
+-- @class function
+-- @param progressbar The progressbar.
+-- @param value The value.
+
 --- Set the maximum value the progressbar should handle.
 -- @name set_max_value
 -- @class function
@@ -57,11 +75,14 @@ local data = setmetatable({}, { __mode = k })
 
 local properties = { width, height, border_color,
  gradient_colors, color, background_color,
- vertical, value, max_value }
+ vertical, value, max_value,
+ ticks, ticks_gap, ticks_size }
 
 local function update(pbar)
 local width = data[pbar].width or 100
-local height  = data[pbar].height or 20
+local height = data[pbar].height or 20
+local ticks_gap = data[pbar].ticks_gap or 1
+local ticks_size = data[pbar].ticks_size or 4
 
 -- Create new empty image
 local img = capi.image.argb32(width, height, nil)
@@ -107,13 +128,42 @@ local function update(pbar)
over_drawn_width,
rel_height,
true, data[pbar].background_color or #00aa)
+
+-- Place smaller pieces over the gradient if ticks are enabled
+if data[pbar].ticks then
+for i=0, height / (ticks_size+ticks_gap)-border_width do
+local rel_offset = over_drawn_height / 1 - 
(ticks_size+ticks_gap) * i
+
+if rel_offset = rel_height then
+img:draw_rectangle(border_width,
+   rel_offset,
+   over_drawn_width,
+   ticks_gap,
+   true, data[pbar].background_color or 
#00aa)
+end
+end
+end
 else
-local rel_x = math.floor((over_drawn_width * value) + 0.5)
+local rel_x = math.ceil(over_drawn_width * value)
 img:draw_rectangle(border_width + rel_x,
border_width,
over_drawn_width - rel_x,
over_drawn_height,
true, data[pbar].background_color or #00aa)
+
+if data[pbar].ticks then
+for i=0, width /