Class wibox.widget.base
Info:
- Copyright: 2010 Uli Schlachter
- Author: Uli Schlachter
Functions
Tables
wibox.widget.base.widget | Functions available on all widgets. |
Methods
Functions
Methods- wibox.widget.base.rect_to_device_geometry ()
-
Figure out the geometry in the device coordinate space.
This gives only tight bounds if no rotations by non-multiples of 90° are used.
- wibox.widget.base.fit_widget (parent, context, widget, width, height)
-
Fit a widget for the given available width and height.
This calls the widget’s
:fit
callback and caches the result for later use. Never call:fit
directly, but always through this function!- parent widget The parent widget which requests this information.
- context table The context in which we are fit.
- widget
widget
The widget to fit (this uses
widget:fit(context, width, height)
). - width number The available width for the widget.
- height number The available height for the widget.
Returns:
- number The width that the widget wants to use.
- number The height that the widget wants to use.
- wibox.widget.base.layout_widget (parent, context, widget, width, height)
-
Lay out a widget for the given available width and height.
This calls the widget’s
:layout
callback and caches the result for later use. Never call:layout
directly, but always through this function! However, normally there shouldn’t be any reason why you need to use this function.- parent widget The parent widget which requests this information.
- context table The context in which we are laid out.
- widget
widget
The widget to layout (this uses
widget:layout(context, width, height)
). - width number The available width for the widget.
- height number The available height for the widget.
Returns:
-
table
The result from the widget’s
:layout
callback. - wibox.widget.base.handle_button ()
-
Handle a button event on a widget.
This is used internally and should not be called directly.
- wibox.widget.base.place_widget_via_matrix (widget, mat, width, height)
-
Create widget placement information. This should be used in a widget’s
:layout()
callback.- widget widget The widget that should be placed.
- mat A matrix transforming from the parent widget’s coordinate system. For example, use matrix.create_translate(1, 2) to draw a widget at position (1, 2) relative to the parent widget.
- width number The width of the widget in its own coordinate system. That is, after applying the transformation matrix.
- height number The height of the widget in its own coordinate system. That is, after applying the transformation matrix.
Returns:
-
table
An opaque object that can be returned from
:layout()
. - wibox.widget.base.place_widget_at (widget, x, y, width, height)
-
Create widget placement information. This should be used for a widget’s
:layout()
callback.- widget widget The widget that should be placed.
- x number The x coordinate for the widget.
- y number The y coordinate for the widget.
- width number The width of the widget in its own coordinate system. That is, after applying the transformation matrix.
- height number The height of the widget in its own coordinate system. That is, after applying the transformation matrix.
Returns:
-
table
An opaque object that can be returned from
:layout()
. - wibox.widget.base.make_widget_declarative (args)
-
Create a widget from a declarative description.
See The declarative layout system.
- args table A table containing the widgets disposition.
- wibox.widget.base.make_widget ([proxy[, widget_name[, args={}]]])
-
Create an empty widget skeleton.
See Creating new widgets.
- proxy widget If this is set, the returned widget will be a proxy for this widget. It will be equivalent to this widget. This means it looks the same on the screen. (optional)
- widget_name string Name of the widget. If not set, it will be set automatically via gears.object.modulename. (optional)
- args Widget settings
- enable_properties boolean Enable automatic getter and setter methods. (default false)
- class table The widget class (default nil)
See also:
- wibox.widget.base.empty_widget ()
- Generate an empty widget which takes no space and displays nothing.
- wibox.widget.base.check_widget ()
-
Do some sanity checking on a widget.
This function raises an error if the widget is not valid.
Tables
Methods
- wibox.widget.base:buttons (_buttons)
-
Set/get a widget’s buttons.
- _buttons table The table of buttons that is bound to the widget.
- wibox.widget.base:set_visible (b)
-
Set a widget’s visibility.
- b boolean Whether the widget is visible.
- wibox.widget.base:get_visible ()
-
Is the widget visible?
Returns:
-
boolean
- wibox.widget.base:set_opacity (o)
-
Set a widget’s opacity.
- o number The opacity to use (a number from 0 (transparent) to 1 (opaque)).
- wibox.widget.base:get_opacity ()
-
Get the widget’s opacity.
Returns:
-
number
The opacity (between 0 (transparent) and 1 (opaque)).
- wibox.widget.base:set_forced_width ([width])
-
Set the widget’s forced width.
- width
number
With
nil
the default mechanism of calling the:fit
method is used. (optional)
See also:
- width
number
With
- wibox.widget.base:get_forced_width ()
-
Get the widget’s forced width.
Note that widget instances can be used in different places simultaneously, and therefore can have multiple dimensions. If there is no forced width/height, then the only way to get the widget’s actual size is during a
mouse::enter
,mouse::leave
or button event.Returns:
-
number
The forced width (nil if automatic).
See also:
- wibox.widget.base:set_height ([height])
-
Set the widget’s forced height.
- height
number
With
nil
the default mechanism of calling the:fit
method is used. (optional)
See also:
- height
number
With
- wibox.widget.base:get_forced_height ()
-
Get the widget’s forced height.
Note that widget instances can be used in different places simultaneously, and therefore can have multiple dimensions. If there is no forced width/height, then the only way to get the widget’s actual size is during a
mouse::enter
,mouse::leave
or button event.Returns:
-
number
The forced height (nil if automatic).
- wibox.widget.base:get_children ()
-
Get the widget’s direct children widgets.
This method should be re-implemented by the relevant widgets.
Returns:
-
table
The children
- wibox.widget.base:set_children (children)
-
Replace the layout children.
The default implementation does nothing, this must be re-implemented by all layout and container widgets.
- children table A table composed of valid widgets.
- wibox.widget.base:get_all_children ()
-
Get all direct and indirect children widgets.
This will scan all containers recursively to find widgets.
Warning: This method it prone to stack overflow if the widget, or any of its children, contains (directly or indirectly) itself.
Returns:
-
table
The children
- wibox.widget.base:emit_signal_recursive (signal_name, ...)
-
Emit a signal and ensure all parent widgets in the hierarchies also forward the signal. This is useful to track signals when there is a dynamic set of containers and layouts wrapping the widget.
Note that this function has some flaws:
- The signal is only forwarded once the widget tree has been built. This happens after all currently scheduled functions have been executed. Therefore, it will not start to work right away.
- In case the widget is present multiple times in a single widget tree, this function will also forward the signal multiple times (once per upward tree path).
- If the widget is removed from the widget tree, the signal is still forwarded for some time, similar to the first case.
- signal_name string
- ... Other arguments
- wibox.widget.base:index (widget[, recursive[, ...]])
-
Get the index of a widget.
- widget widget The widget to look for.
- recursive boolean Also check sub-widgets? (optional)
- ... widget Additional widgets to add at the end of the “path” (optional)
Returns:
- wibox.widget.base:setup (args)
-
Set a declarative widget hierarchy description.
See The declarative layout system.
- args table A table containing the widget’s disposition.
- wibox.widget.base:make_widget_from_value (wdg[, ...=nil])
-
Create a widget from an undetermined value.
The value can be:
- A widget (in which case nothing new is created)
- A declarative construct
- A constructor function
- A metaobject
- wdg The value.
- ... Arguments passed to the contructor (if any). (default nil)
Returns:
-
The
new widget.