Commit Graph

221 Commits

Author SHA1 Message Date
Uli Schlachter 267ab282b2 Sanitize argument handling for wibox.layout.stack constructor
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-16 19:42:35 +01:00
Uli Schlachter 9db539fbf2 Fix wibox.layout.mirror
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-14 14:42:34 +01:00
Uli Schlachter 15e72fb037 Fix luacheck warnings in lib/wibox
Warnings pointing out actual problems are left.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-12 09:15:55 +01:00
Daniel Hahler 58954f7f08 Merge pull request #675 from psychon/remove-gears.sort
Remove gears.sort
2016-02-11 21:51:44 +01:00
Emmanuel Lepage Vallee cb896ca87f wibox.widget: Add method to create declarative widgets directly 2016-02-11 03:58:54 -05:00
Emmanuel Lepage Vallee 0a39d196c7 wibox.layout: Add the new 'ratio' layout
This layout allow each widgets to take 'r' percent of the total
space, where 'r' is configurable.

It re-implement the 'wfact' system used by `awful.layout.suit.tile`
2016-02-10 21:40:40 -05:00
Emmanuel Lepage Vallee 20030e6f93 wibox.layout: Add new 'stack' layout
This layout display the widgets on top of each other. It can also optionally
display only the first one.

The most common use case is to create a composited widget. Other use case
include the creation of a "paged" stack to only display the most
relevant widget without adding extra complexity to the parent layout.
2016-02-10 21:40:40 -05:00
Emmanuel Lepage Vallée ff8f2aef27 Merge pull request #678 from Elv13/bgimage
Extend bgimage support
2016-02-10 03:59:06 -05:00
Emmanuel Lepage Vallee b1e69dba8c doc: Move the new widget documentation to a new file
This will help with discoverability
2016-02-10 01:25:41 -05:00
Emmanuel Lepage Vallee 7842f92f08 wibox: Support the declarative container syntax
Also support it for titlebars
2016-02-10 01:25:31 -05:00
Emmanuel Lepage Vallee 6a68173ccb widget: Add a new container declaration syntax
This new syntax is inspired by the Awesome widget 3.2-3.4 API. It
allow cleaner widgets declaration. The produced code is usually much
shorted and easier to read than wibox.widget imperative syntax.
2016-02-10 01:09:50 -05:00
Emmanuel Lepage Vallee e36f23171b wibox.widget: Add `set_children` method
Provide a generic method to set the widget content
2016-02-10 01:09:50 -05:00
Emmanuel Lepage Vallee c957b3d5a8 wibox: Support bg_image 2016-02-10 00:15:14 -05:00
Emmanuel Lepage Vallee 7666976538 drawable: Add background image support
Copy what's done in `widget.background`
2016-02-10 00:15:09 -05:00
Emmanuel Lepage Vallee cbea82f1c8 widget.background: Allow function as background image
There is already a hack into `awful.widget.common`. This system aim
to make the hack obselete while preserving the useful part.

I think this is also necessary to properly support SVG (with DPI
and resize).

Finally, Qt handle this using the QBrush concept, where you can have
programmatic patterns. Cairo doesn't have this concept, so there is no
"clean" way to have programmatic brushes.
2016-02-10 00:15:00 -05:00
Uli Schlachter 94e9a030c1 Remove gears.sort
It's unused since commit 0aa4304bda. Before this was a stable sorting
algorithm since table.sort is allowed to be unstable. Apparently we don't need a
stable sorting algorithm anymore.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-07 12:24:35 +01:00
Emmanuel Lepage Vallee 33c943d9b8 widget.background: Add shape border support 2016-02-06 03:43:42 -05:00
Emmanuel Lepage Vallee e615173552 layout.fixed: Add methods to manipulate the layout after creation
Until now, this layout was "append only". There was no official
APIs to remove, replace, insert and swap widgets. This is fine
for the usual wibox + sensors widget used by the majority of
users, but lack flexibility necessary to use the layout system
to place dynamic elements such as clients.

The methods introduced by this commit are also recursive. This
allow widgets to be decorated, wrapped and splitted without
having to add boilerplate code everywhere.
2016-02-03 04:01:38 -05:00
Emmanuel Lepage Vallee 330c8d97e1 layout.flex: Base on layout.fixed rather than widget.base
This remove duplicated code and will allow more "collection"
style layouts to be implemented without logic duplication.

This commit also do some small cleanup to remove duplicated
code now present in `awful.util`.

Fixes https://github.com/awesomeWM/awesome/issues/617
2016-02-03 04:00:56 -05:00
Emmanuel Lepage Vallee b2d121aa18 widget.base: Add ':index(w, r)' method
This function is optionally recursive. This allow to manipulate
abstract layouts without really having to care about the exact
hierarchy.
2016-02-03 04:00:56 -05:00
Emmanuel Lepage Vallee 8da5c79bb8 wibox.widget: Add new `get_children(recursive)` method to all widgets 2016-02-03 04:00:42 -05:00
Emmanuel Lepage Vallee 1d1e487d19 wibox.imagebox: Add a `clip` method based on the `gears.shape` API 2016-02-02 00:21:42 -05:00
Emmanuel Lepage Vallee dc432eb7a6 widget.background: Fix error introduced in d01c1d2d6
Fix a copy/paste mistake.
2016-01-21 22:53:21 -05:00
Daniel Hahler cb267e56d5 Merge pull request #637 from psychon/set_markup
Make wibox.widget.textbox:set_markup() throw Lua errors less often
2016-01-20 00:01:09 +01:00
Emmanuel Lepage Vallee d01c1d2d6d widget.background: Allow background to have a shape 2016-01-18 17:22:49 -05:00
Emmanuel Lepage Vallee b74b8ea0cd margin: Add an option to :fit() -> 0,0 when the content is empty
Make it easier to write "optional" widgets, like empty textbox
that can be filled only in certain scenarios.
2016-01-18 03:38:46 -05:00
Uli Schlachter de6d9334d8 wibox.drawable: Handle gears.surface's new error handling
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-01-17 17:39:32 +01:00
Uli Schlachter 178204449c Textbox:set_markup(): Print errors to stderr
Instead of throwing a Lua error, the code now just prints an error message to
stderr on invalid markup. For callers which want to handle this case specially,
we add :set_markup_silently() which returns error messages.

Fixes: https://github.com/awesomeWM/awesome/issues/546
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-01-17 16:47:27 +01:00
Uli Schlachter 76b1d348a1 imagebox: Remove dead code
Since some commits, surface.load() handles printing an error message for us.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-01-15 18:53:09 +01:00
Emmanuel Lepage Vallee bd8e2d2ca8 typo: replace 'wibox' with 'context' where relevant
Closes https://github.com/awesomeWM/awesome/pull/613.
2015-12-31 15:33:22 +01:00
Daniel Hahler ae5d4b5512 Merge pull request #571 from psychon/scrolling_layout
Add a scroll layout
2015-12-12 20:01:32 +01:00
Daniel Hahler 981987764e Merge pull request #586 from psychon/widget_funcs
Widgets: set_width / set_height
2015-12-12 19:13:28 +01:00
Daniel Hahler e39504a30f Make textbox widget respect the current theme
Without this fix `wibox.widget.textbox` ignores current theme font
setting and resets it to the initial one.
It becomes handy when the initial theme is tweaked during runtime, ie.
in `rc.lua`. Other AwesomeWM components like `awful` (taglist,
tasklist, menu) are aware and do respect the actual theme settings.

Closes https://github.com/awesomeWM/awesome/pull/89.
2015-12-11 00:55:33 +01:00
Uli Schlachter f4077def8e Add :set_{width,height} to widgets (#291)
This adds new functions to all widgets that allow to force a specific
width/height. These values override the result from :fit().

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-12-05 12:31:33 +01:00
Uli Schlachter c2be60fb54 wibox.widget.base: Factor out functions available on all widgets
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-12-05 12:25:25 +01:00
Uli Schlachter c02969bb0e wibox.widget.systray: Also emit redraw_needed
When emitting layout_changed, the widget is relayouted. If this doesn't actually
change anything, nothing will be redrawn. Thus, this also emits redraw_needed to
force redraws.

This fixes a race condition with some weird tray icons. A new tray icon is
created and the systray is updated. Then this new icon is destroyed immediately
again and at the same time another icon is created. Then, the systray isn't
updated since the number of icons (=the layout) did not actually change.
However, it needs to be updated and so we ended up with broken/missing icons.

Fixes: https://github.com/awesomeWM/awesome/issues/487
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-11-29 12:33:13 +01:00
Uli Schlachter 1c8aa0f5f4 Add a scroll layout
This allows scrolling a widget if there is too few space available. There are
several different modes available for how the scrolling "looks like".

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-11-22 18:19:53 +01:00
Uli Schlachter f7bbcf1263 wibox.drawable: Make screen_getbycoord() local
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-11-15 19:36:15 +01:00
Daniel Hahler 2bca03cb87 doc: fix format for wibox.widget.base.make_widget
Closes https://github.com/awesomeWM/awesome/pull/548.
2015-11-05 23:05:42 +01:00
Daniel Hahler 1222b5b5fd Merge pull request #535 from psychon/textbox_preferred_size
Add functions for querying a textbox's preferred size

Closes https://github.com/awesomeWM/awesome/pull/535.
2015-10-30 20:31:17 +01:00
Uli Schlachter cdd8d2ed5f Textbox: Add API for queriying preferred size (#466)
This adds :get_preferred_size() and :get_preferred_size_at_dpi() which return
the size (=width, height) that the textbox would need if unlimited space is
available.

This also adds :get_height_for_width() and :get_height_for_width_at_dpi() which
return the height that the textbox would need if the given width is available.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-17 19:13:26 +02:00
Uli Schlachter dc0afe9f59 Add some constructor arguments to some layouts
This adds new constructor arguments to align, fixed and flex which allows adding
widgets directly while creating the layout.

Idea originally by actionless:
https://github.com/awesomeWM/awesome/pull/486#issuecomment-143606301

Closes https://github.com/awesomeWM/awesome/pull/490.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-17 14:50:46 +02:00
Daniel Hahler 4bffa7e47e doc: fix unintentional rendering as code due to indent 2015-10-14 00:22:26 +02:00
Uli Schlachter d03762c322 systray: Make sure the widget is only placed in a wibox
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-10 20:30:08 +02:00
Uli Schlachter a3e690d191 imagebox: Redraw in :set_image()
If someone modifies a cairo surface and then sets the resulting object as the
image of an imagebox, the imagebox needs to redraw. Thus, since surfaces are
modifiable, we cannot assume that nothing changed when the same image is set
multiple times on an imagebox.

However, the dimensions of a surface cannot be changed and thus this does not
need to emit widget::layout_changed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-29 00:28:26 +02:00
Uli Schlachter bd47edb4ef leak test: Make the layoutbox test pass
This commit does two things: It gets rid of the reference to the layoutbox that
the default config created and it changes the widget dependency cache to not
keep widgets alive unnecessarily.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-27 14:42:39 +02:00
Daniel Hahler 4e22cf02e6 Merge pull request #384 from blueyed/more-robust-errors
More robust errors: make sure errors are strings

Closes https://github.com/awesomeWM/awesome/pull/384.
2015-09-23 20:59:35 +02:00
Uli Schlachter dfcbf20d81 Add and use wibox.hierarchy:update()
This function updates a hierarchy if the layout of some widgets changed. It does
nothing on the parts that did not change. This should be more efficient than
recomputing the whole hierarchy whenever something changes.

Once again, this has some positive results on the "benchmark test":

Before:
        create wibox: 0.083016   sec/iter ( 13 iters, 1.161 sec for benchmark)
    update textclock: 0.00391091 sec/iter (271 iters, 3.219 sec for benchmark)
  relayout textclock: 0.00273234 sec/iter (397 iters, 1.087 sec for benchmark)
    redraw textclock: 0.0010191  sec/iter (989 iters, 1.745 sec for benchmark)

After:
        create wibox: 0.083146   sec/iter ( 13 iters, 1.163 sec for benchmark)
    update textclock: 0.00170519 sec/iter (647 iters, 2.201 sec for benchmark)
  relayout textclock: 0.000581637 sec/iter (1880 iters, 1.094 sec for benchmark)
    redraw textclock: 0.0010167  sec/iter (997 iters, 1.773 sec for benchmark)

So again no difference for creating wiboxes (100.16% compared to before). This
time we also have no real difference for creating wiboxes (99.76%). Update (44%)
and relayout (21%) are improved a lot.

Closes https://github.com/awesomeWM/awesome/pull/463.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-23 20:57:41 +02:00
Daniel Hahler 28ffdb050e Merge pull request #454 from psychon/remove_gears.debug.assert
Remove gears.debug.assert

Closes https://github.com/awesomeWM/awesome/pull/454.

Conflicts:
	lib/gears/matrix.lua
2015-09-21 21:16:36 +02:00
Uli Schlachter 8d6030819b textbox: Honor per-screen DPI
This makes the textbox' :draw() and :fit() callbacks use the DPI that is
specified in the given drawing context. With this, the textbox now scales
correctly if different screens have different DPI values.

Idea originally from Daniel.

Closes https://github.com/awesomeWM/awesome/pull/457.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-21 21:13:21 +02:00