Re: [Patch] Export :extents() to master and automagically resize naughtyfications

2009-05-07 Thread Julien Danjou
At 1241653923 time_t, koniu wrote:
 Also is there a way to have margins around imagebox?

Na, that would be handled by widget layouts.

-- 
Julien Danjou
// ᐰ jul...@danjou.info   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// And thinking so much differently.


signature.asc
Description: Digital signature


Re: [Patch] Export :extents() to master and automagically resize naughtyfications

2009-05-07 Thread Julien Danjou
At 1241678268 time_t, Julien Danjou wrote:
 At 1241653923 time_t, koniu wrote:
  Also is there a way to have margins around imagebox?
 
 Na, that would be handled by widget layouts.

So if you want to argue that textbox have margin, then I'll answer: we
should delete margin from textboxes and let widget's layouts handle
that.

-- 
Julien Danjou
// ᐰ jul...@danjou.info   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// Anna Molly! Anna Molly! Anna Molly!


signature.asc
Description: Digital signature


Re: [Patch] Export :extents() to master and automagically resize naughtyfications

2009-05-06 Thread koniu
 Good work Gregor, thank you very very much.

Ditto. Haven't had any issues with this so far.

 I'm glad to announce this 2 patches are inaugurating the next branch,
 for 3.4. :-)

And to celebrate, I would like to propose a couple more patches to
naughty which I pushed here:
http://git.mercenariesguild.net/?p=awesome.git;a=shortlog;h=refs/heads/naughty-fixes

I have something to report regarding the 1st one tho (add vertical margin):
http://git.mercenariesguild.net/?p=awesome.git;a=commitdiff;h=f5e2e1b560b8fdd8144455f2985c1e78790dc551;hp=a4de441d9bf3606d5cc5ae183e445bbf6082e741

If you look at the diff it's actually:
 textbox:margin({ ..., bottom = 2 * margin }).

For some reason if I do
 textbox:margin({ ..., top = margin, bottom = margin })

The widget gets the right size, but the text is, in vertical axis,
aligned to the bottom while the first one it's centered (as it should
with margin). I blame textbox?

The other two patches are cleanups and as far as I can tell, none of
them should break any configs but please briefly test.

And here's the candy (try repeating that without 3rd patch :P)
http://omploader.org/vMW13bw

Also is there a way to have margins around imagebox?

thanks,
koniu

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


[Patch] Export :extents() to master and automagically resize naughtyfications

2009-05-05 Thread Gregor Best
Hi people,

I finally found some time to hack around awesome again, so here i present a
backport of :extents() from the widget-layouts branch to the master branch and
a little addition to naughty which makes it behave much more friendly to screen
space by automagically resizing naughtyfications so they take exactly as much
space as they need.

The first patch export a function called :extents() for each widget which takes
a screen number as its argument. This is only used for systrays to correctly
calculate their geometries, for all other widgets it is ignored. If it's
omitted for a systray, 1 is assumed. It returns the geometry the widget wants
to be drawn at, which doesn't take later resizing into account (i.e. if you
have a square 64x64 imagebox with resize enabled on a wibox with 16 px
height, :extents().height will still be 64 although the widget is actually
drawn 16 pixels high).

The second patch adds support for resizing to naughty. See the commit message
for additional details on how it works.

-- 
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
From b3d219ee638f76f9ecd97b0eeb0cace437c0cf64 Mon Sep 17 00:00:00 2001
From: Gregor Best farha...@googlemail.com
Date: Tue, 5 May 2009 19:55:29 +0200
Subject: [PATCH 1/2] widgets: export extents() function

This commit adds a function called extents() to widgets. In the case of
a systray, it takes the systray's screen as its argument to correctly
calculate the width. By default, 1 is assumed. For all other widgets,
the argument can be ommitted.
The function doesn't return the geometry as drawn, instead it returns
the geometry the widget _wants_ to be drawn at, for example an imagebox
always has (image width, image height) as the return values even if it's
drawn with a smaller width and height on a smaller wibox.

Signed-off-by: Gregor Best farha...@googlemail.com
---
 widget.c  |   24 
 widget.h  |4 +++-
 widgets/graph.c   |   11 +++
 widgets/imagebox.c|   21 +
 widgets/progressbar.c |   29 +
 widgets/systray.c |   28 
 widgets/textbox.c |   25 +
 7 files changed, 141 insertions(+), 1 deletions(-)

diff --git a/widget.c b/widget.c
index f8c00e3..d6372bb 100644
--- a/widget.c
+++ b/widget.c
@@ -494,6 +494,29 @@ luaA_widget_newindex(lua_State *L)
 return 0;
 }
 
+static int
+luaA_widget_extents(lua_State *L)
+{
+widget_t *widget = luaL_checkudata(L, 1, widget);
+area_t g = {
+.x = 0,
+.y = 0,
+.width = 0,
+.height = 0
+};
+
+if(widget-extents)
+g = widget-extents(L, widget);
+
+lua_newtable(L);
+lua_pushnumber(L, g.width);
+lua_setfield(L, -2, width);
+lua_pushnumber(L, g.height);
+lua_setfield(L, -2, height);
+
+return 1;
+}
+
 const struct luaL_reg awesome_widget_methods[] =
 {
 { __call, luaA_widget_new },
@@ -502,6 +525,7 @@ const struct luaL_reg awesome_widget_methods[] =
 const struct luaL_reg awesome_widget_meta[] =
 {
 { buttons, luaA_widget_buttons },
+{ extents, luaA_widget_extents },
 { __index, luaA_widget_index },
 { __newindex, luaA_widget_newindex },
 { __gc, luaA_widget_gc },
diff --git a/widget.h b/widget.h
index 97c792e..02fbc9a 100644
--- a/widget.h
+++ b/widget.h
@@ -37,8 +37,10 @@ struct widget_t
 widget_constructor_t *type;
 /** Widget destructor */
 widget_destructor_t *destructor;
-/** Geometry function */
+/** Geometry function for drawing */
 area_t (*geometry)(widget_t *, screen_t *, int, int);
+/** Extents function */
+area_t (*extents)(lua_State *, widget_t *);
 /** Draw function */
 void (*draw)(widget_t *, draw_context_t *, area_t, wibox_t *);
 /** Index function */
diff --git a/widgets/graph.c b/widgets/graph.c
index 675239b..44f8f0e 100644
--- a/widgets/graph.c
+++ b/widgets/graph.c
@@ -159,6 +159,16 @@ graph_geometry(widget_t *widget, screen_t *screen, int height, int width)
 return geometry;
 }
 
+static area_t
+graph_extents(lua_State *L, widget_t *widget)
+{
+area_t geometry;
+graph_data_t *d = widget-data;
+geometry.width = geometry.height = d-width;
+
+return geometry;
+}
+
 /** Draw a graph widget.
  * \param ctx The draw context.
  * \param w The widget node we are called from.
@@ -592,6 +602,7 @@ widget_graph(widget_t *w)
 w-newindex = luaA_graph_newindex;
 w-destructor = graph_destructor;
 w-geometry = graph_geometry;
+w-extents = graph_extents;
 
 graph_data_t *d = w-data = p_new(graph_data_t, 1);
 
diff --git a/widgets/imagebox.c b/widgets/imagebox.c
index de8b5f0..ddcd131 100644
--- a/widgets/imagebox.c
+++ b/widgets/imagebox.c
@@ -72,6 +72,26 @@ imagebox_geometry(widget_t *widget, screen_t *screen, int height, int width)
 return 

Re: [Patch] Export :extents() to master and automagically resize naughtyfications

2009-05-05 Thread Frank Blendinger
Hi.

On Tue 2009-05-05 20:45, Gregor Best farha...@googlemail.com
proclaimed:
 I finally found some time to hack around awesome again, so here i present a
 backport of :extents() from the widget-layouts branch to the master branch and
 a little addition to naughty which makes it behave much more friendly to 
 screen
 space by automagically resizing naughtyfications so they take exactly as much
 space as they need.

That is great to hear, I was hoping that this would be done at some
point of time. Seems like I can finally remove some ugly manual naughty
size settings from my rc.lua.

Thanks for the work.


Greetings,
Frank

-- 
Frank Blendinger | fb(at)intoxicatedmind.net | GPG: 0x0BF2FE7A
Fingerprint: BB64 F2B8 DFD8 BF90 0F2E 892B 72CF 7A41 0BF2 FE7A


signature.asc
Description: Digital signature