Module giblets.widgets.progressbar
Progressbar widget.
This progressbar is very similar to the one you get with awful.widget.progressbar,
except that it is always drawn with segments, or ticks. In addition, rather than being
drawn with a solid border and ticks inside the border, each tick is drawn as
though it is its own entity. So if a border is used, all four sides of each tick
will have a border.
All the functions implemented by awful.widget.progressbar are also implemented
here. So a giblets.widgets.progressbar can be a drop-in replacement for any
awful.widget.progressbars that are in use. Keep in mind though that
giblets.widgets.progressbar does have additional functions so the reverse isn't
true.
Info:
- Copyright: 2015 Nathan Lundquist
- Author: Nathan Lundquist (atatsu)
Functions
| Progressbar.new ([opts]) | Create a new progressbar widget. |
| Progressbar:get_value () | Get the current value of the progressbar (not compatible with awful.widget.progressbar). |
| Progressbar:set_background_color ([color="#484874"]) | Set the background color of the progressbar. |
| Progressbar:set_border_color ([color="#8585ac"]) | Set the progressbar's border color. |
| Progressbar:set_border_width ([width=1]) | Set the border width of the progressbar (not compatible with awful.widget.progressbar). |
| Progressbar:set_color ([color="#8585ac"]) | Set the foreground color of the progressbar. |
| Progressbar:set_height ([height=12]) | Sets the height of the progressbar. |
| Progressbar:set_max_value ([value=1]) | Sets the maximum value the progressbar can handle. |
| Progressbar:set_ticks ([ticks=true]) | Set the progressbar to draw ticks (non-functional). |
| Progressbar:set_ticks_align ([align="center"]) | Set the alignment of the ticks (not compatible with awful.widget.progressbar). |
| Progressbar:set_ticks_gap ([gap=3]) | Set the pixel spacing between each tick. |
| Progressbar:set_ticks_size ([size=8]) | Set the tick size of the progressbar. |
| Progressbar:set_tooltip ([enabled=true[, fmt_func]]) | Enable or disable the progressbar tooltip (not compatible with awful.widget.progressbar). |
| Progressbar:set_value ([value=0]) | Set the value of the progressbar. |
| Progressbar:set_vertical ([vertical=false]) | Instructs the progressbar to be drawn vertically. |
| Progressbar:set_width ([width=100]) | Sets the width of the progressbar. |
Tables
| opts | Progressbar options. |
Functions
- Progressbar.new ([opts])
-
Create a new progressbar widget.
Parameters:
- opts table Options for controlling the dimensions and look of the progressbar. For a break down of all available options and their default values see opts. (optional)
Returns:
-
Progressbar
A new Progressbar instance.
See also:
Usage:
local giblets = require("giblets") local pbar = giblets.widgets.progressbar()
- Progressbar:get_value ()
-
Get the current value of the progressbar (not compatible with
awful.widget.progressbar).Returns:
-
number
The current progressbar value.
Usage:
local val = pbar:get_value() - Progressbar:set_background_color ([color="#484874"])
-
Set the background color of the progressbar.
Or in other words, the empty color of ticks.
Signals:
-
widget::updated
Parameters:
- color string Background color. (default "#484874")
Returns:
-
The progressbar instance.
Usage:
pbar:set_background_color("#484874") - Progressbar:set_border_color ([color="#8585ac"])
-
Set the progressbar's border color.
Remember this only has an effect if
border_widthis non-zero.Signals:
-
widget::updated
Parameters:
- color string Color of the border. (default "#8585ac")
Returns:
-
The progressbar instance.
Usage:
pbar:set_border_color("#8585ac") - Progressbar:set_border_width ([width=1])
-
Set the border width of the progressbar (not compatible with
awful.widget.progressbar).Signals:
-
widget::updated
Parameters:
- width int Pixel width of the border. (default 1)
Returns:
-
The progressbar instance.
Usage:
pbar:set_border_width(2) - Progressbar:set_color ([color="#8585ac"])
-
Set the foreground color of the progressbar.
In other words, the filled color of ticks.
Signals:
-
widget::updated
Parameters:
- color string Foreground color. (default "#8585ac")
Returns:
-
The progressbar instance.
Usage:
pbar:set_color("#8585ac") - Progressbar:set_height ([height=12])
-
Sets the height of the progressbar.
Signals:
-
widget::updated
Parameters:
- height int Height of the progressbar. (default 12)
Returns:
-
The progressbar instance.
Usage:
pbar:set_height(12) - Progressbar:set_max_value ([value=1])
-
Sets the maximum value the progressbar can handle.
Signals:
-
widget::updated
Parameters:
- value number Max value of the progressbar. (default 1)
Returns:
-
The progressbar instance.
Usage:
pbar:set_max_value(2) - Progressbar:set_ticks ([ticks=true])
-
Set the progressbar to draw ticks (non-functional).
This function doesn't do anything. It merely exists for compatibility with
awful.widget.progressbar. A giblets' progressbar is always drawn with ticks, therefor they are not optional and cannot be turned off.Signals:
-
widget::updated
Parameters:
- ticks
bool
This will always be
true. (default true)
Returns:
-
The progressbar instance.
- ticks
bool
This will always be
- Progressbar:set_ticks_align ([align="center"])
-
Set the alignment of the ticks (not compatible with
awful.widget.progressbar). Can be one ofcenter,top, orbottom.Signals:
-
widget::updated
Parameters:
- align string Alignment of the ticks. (default "center")
Returns:
-
The progressbar instance.
Usage:
pbar:set_ticks_align("top") - Progressbar:set_ticks_gap ([gap=3])
-
Set the pixel spacing between each tick.
Signals:
-
widget::updated
Parameters:
- gap int Pixel space between each tick. (default 3)
Returns:
-
The progressbar instance.
Usage:
pbar:set_ticks_gap(3) - Progressbar:set_ticks_size ([size=8])
-
Set the tick size of the progressbar.
Can be a number representing both width and height or a table with separate width
and height dimentions with the keys
widthandheight. For best results use even numbers.Signals:
-
widget::updated
Parameters:
- size int or table Size of each tick. (default 8)
Returns:
-
The progressbar instance.
Usage:
pbar:set_ticks_size(8)pbar:set_ticks_size({width = 8, height = 4})
- Progressbar:set_tooltip ([enabled=true[, fmt_func]])
-
Enable or disable the progressbar tooltip (not compatible with
awful.widget.progressbar).
Iftruea tooltip will be displayed when the progressbar is hovered over displaying the current % value.Signals:
-
widget::updated
Parameters:
- enabled bool Enable or disable the tooltip. (default true)
- fmt_func
func
An optional function that receives the current progressbar
value and should return a string to be used as the tooltip text. The default format
function is:
function(value) return value * 100 .. "%" end. (optional)
Returns:
-
The progressbar instance.
Usage:
pbar:set_tooltip(true, function(value) return "I'm " .. value * 100 .. "%!" end )
- Progressbar:set_value ([value=0])
-
Set the value of the progressbar.
Signals:
-
widget::updated
Parameters:
- value
number
The value between
0andmax_valueas set with opts or set_max_value. (default 0)
Returns:
-
The progressbar instance.
Usage:
pbar:set_value(0.4) - value
number
The value between
- Progressbar:set_vertical ([vertical=false])
-
Instructs the progressbar to be drawn vertically.
Signals:
-
widget::updated
Parameters:
- vertical bool Draw vertical or not. (default false)
Returns:
-
The progressbar instance.
Usage:
pbar:set_vertical(true) - Progressbar:set_width ([width=100])
-
Sets the width of the progressbar.
Signals:
-
widget::updated
Parameters:
- width int Width of the progressbar. (default 100)
Returns:
-
The progressbar instance.
Usage:
pbar:set_width(100)
Tables
- opts
-
Progressbar options.
If an option is available via your beautiful theme it is listed immediately
following the field description. Take note that the theme overrides default options,
but any options supplied here will override those found in the theme.
Fields:
- width
int
Width of the progressbar.
theme.giblets.widgets.progressbar.width(default 100) - height
int
Height of the progressbar.
theme.giblets.widgets.progressbar.height(default 12) - vertical bool Draw the progressbar vertically. (default false)
- max_value number Maximum value the progressbar should support. (default 1)
- foreground_color
string
Foreground color of the progressbar. Or in other
words, the filled color of ticks.
theme.giblets.widgets.progressbar.foreground_color(default "#8585ac") - background_color
string
Background color of the progressbar. Or in other
words, the empty color of ticks.
theme.giblets.widgets.progressbar.background_color(default "#484874") - border_color
string
Border color (if
border_widthis non-zero) of the progressbar. Again, affects the border surrounding each tick.theme.giblets.widgets.progressbar.border_color(default "#8585ac") - border_width
int
Pixel width of the border surrounding each tick.
theme.giblets.widgets.progressbar.border_width(default 1) - ticks_gap
int
Spacing between each tick.
theme.giblets.widgets.progressbar.ticks_gap(default 3) - ticks_size
int or table
Size of each tick. Can be a number
representing both width and height or a table with separate width and height
dimentions with the keys
widthandheight({width = 10, height = 5}).theme.giblets.widgets.progressbar.ticks_size(default 8) - ticks_align
string
Set the alignment of the ticks. Can be one of
center,top,bottom.theme.giblets.widgets.progressbar.ticks_align(default "center") - tooltip
bool
If
truea tooltip will be displayed when the progressbar is hovered over displaying the current % value.theme.giblets.widgets.progressbar.tooltip(default true) - tooltip_fmt_func
func
An optional function that receives the current progressbar
value and should return a string to be used as the tooltip text. The default format
function is:
function(value) return value * 100 .. "%" end. (optional)
- width
int
Width of the progressbar.