rofi
1.5.4
|
Generic abstract widget class. Widgets should 'inherit' from this class (first structure in there structure should be widget). The generic widget implements generic functions like get_width, get_height, draw, resize, update, free and clicked. It also holds information about how the widget should be packed. More...
Modules | |
box | |
container | |
icon | |
listview | |
Scrollbar | |
Textbox | |
Macros | |
#define | WIDGET(a) ( (widget *) ( a ) ) |
Typedefs | |
typedef struct _widget | widget |
typedef widget *(* | widget_find_mouse_target_cb) (widget *widget, WidgetType type, gint x, gint y) |
typedef WidgetTriggerActionResult(* | widget_trigger_action_cb) (widget *widget, guint action, gint x, gint y, void *user_data) |
Enumerations | |
enum | WidgetType { WIDGET_TYPE_UNKNOWN, WIDGET_TYPE_LISTVIEW = SCOPE_MOUSE_LISTVIEW, WIDGET_TYPE_LISTVIEW_ELEMENT = SCOPE_MOUSE_LISTVIEW_ELEMENT, WIDGET_TYPE_EDITBOX = SCOPE_MOUSE_EDITBOX, WIDGET_TYPE_SCROLLBAR = SCOPE_MOUSE_SCROLLBAR, WIDGET_TYPE_MODE_SWITCHER = SCOPE_MOUSE_MODE_SWITCHER, WIDGET_TYPE_TEXTBOX_TEXT } |
enum | WidgetTriggerActionResult { WIDGET_TRIGGER_ACTION_RESULT_IGNORED, WIDGET_TRIGGER_ACTION_RESULT_HANDLED, WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN, WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END } |
Generic abstract widget class. Widgets should 'inherit' from this class (first structure in there structure should be widget). The generic widget implements generic functions like get_width, get_height, draw, resize, update, free and clicked. It also holds information about how the widget should be packed.
#define WIDGET | ( | a | ) | ( (widget *) ( a ) ) |
Abstract structure holding internal state of a widget. Structure is elaborated in widget-internal.h
typedef widget*( * widget_find_mouse_target_cb) (widget *widget, WidgetType type, gint x, gint y) |
widget | The container widget itself |
type | The widget type searched for |
x | The X coordination of the mouse event relative to |
widget | |
y | The Y coordination of the mouse event relative to |
widget | This callback must only iterate over the children of a Widget, and return NULL if none of them is relevant. |
typedef WidgetTriggerActionResult( * widget_trigger_action_cb) (widget *widget, guint action, gint x, gint y, void *user_data) |
widget | The target widget |
action | The action value (which enum it is depends on the widget type) |
x | The X coordination of the mouse event relative to |
widget | |
y | The Y coordination of the mouse event relative to |
widget | |
user_data | The data passed to widget_set_trigger_action_handler() |
This callback should handle the action if relevant, and returns whether it did or not.
Whether and how the action was handled
enum WidgetType |
Type of the widget. It is used to bubble events to the relevant widget.
void widget_disable | ( | widget * | widget | ) |
widget | Handle to widget |
Disable the widget.
Definition at line 133 of file widget.c.
References _widget::enabled, _widget::parent, widget_queue_redraw(), and widget_update().
Referenced by listview_set_show_scrollbar(), rofi_view_add_widget(), rofi_view_reload_message_bar(), and rofi_view_set_overlay().
void widget_draw | ( | widget * | widget, |
cairo_t * | d | ||
) |
widget | widget Handle to the widget |
d | The cairo object used to draw itself. |
Render the textbox.
Definition at line 142 of file widget.c.
References _widget::border, _widget::border_radius, RofiPadding::bottom, distance_get_linestyle(), distance_get_pixel(), _widget::draw, _widget::enabled, _widget::h, RofiPadding::left, _widget::margin, _widget::need_redraw, RofiPadding::right, ROFI_ORIENTATION_HORIZONTAL, ROFI_ORIENTATION_VERTICAL, rofi_theme_get_color(), RofiPadding::top, _widget::w, _widget::x, and _widget::y.
Referenced by barview_draw(), box_draw(), container_draw(), listview_draw(), and rofi_view_update().
void widget_enable | ( | widget * | widget | ) |
widget | Handle to widget |
Enable the widget.
Definition at line 124 of file widget.c.
References _widget::enabled, _widget::parent, widget_queue_redraw(), and widget_update().
Referenced by listview_set_show_scrollbar(), rofi_view_reload_message_bar(), and rofi_view_set_overlay().
gboolean widget_enabled | ( | widget * | widget | ) |
widget | Handle to widget |
Check if widget is enabled.
Definition at line 116 of file widget.c.
References _widget::enabled.
Referenced by listview_draw(), and listview_find_mouse_target().
widget* widget_find_mouse_target | ( | widget * | wid, |
WidgetType | type, | ||
gint | x, | ||
gint | y | ||
) |
wid | The widget handle |
type | The type of the wanted widget |
x | The x coordinate of the mouse event |
y | The y coordinate of the mouse event |
Get the widget that should handle a mouse event.
Definition at line 453 of file widget.c.
References _widget::find_mouse_target, and _widget::type.
Referenced by box_find_mouse_target(), container_find_mouse_target(), listview_find_mouse_target(), and rofi_view_trigger_action().
void widget_free | ( | widget * | wid | ) |
wid | Handle to the widget |
Free the widget and all allocated memory.
Definition at line 365 of file widget.c.
References _widget::free, and _widget::name.
Referenced by __create_window(), box_free(), container_free(), listview_create(), listview_free(), listview_recompute_elements(), and rofi_view_free().
int widget_get_absolute_xpos | ( | widget * | wid | ) |
wid | The widget handle |
Get the absolute x-position on the root widget..
Definition at line 588 of file widget.c.
References _widget::parent, widget_get_absolute_xpos(), and _widget::x.
Referenced by widget_get_absolute_xpos().
int widget_get_absolute_ypos | ( | widget * | wid | ) |
wid | The widget handle |
Get the absolute y-position on the root widget..
Definition at line 599 of file widget.c.
References _widget::parent, widget_get_absolute_ypos(), and _widget::y.
Referenced by widget_get_absolute_ypos().
int widget_get_desired_height | ( | widget * | wid | ) |
wid | The widget handle |
Get the desired height of this widget recursively.
Definition at line 567 of file widget.c.
References _widget::get_desired_height, and _widget::h.
Referenced by box_get_desired_height(), container_get_desired_height(), rofi_view_calculate_height(), rofi_view_error_dialog(), and vert_calculate_size().
int widget_get_desired_width | ( | widget * | wid | ) |
wid | The widget handle |
Get the desired width of this widget recursively.
Definition at line 577 of file widget.c.
References _widget::get_desired_width, and _widget::w.
Referenced by box_get_desired_width(), and hori_calculate_size().
int widget_get_height | ( | widget * | widget | ) |
widget | The widget handle |
Definition at line 378 of file widget.c.
References _widget::get_height, and _widget::h.
Referenced by vert_calculate_size().
int widget_get_width | ( | widget * | widget | ) |
widget | The widget handle |
Definition at line 388 of file widget.c.
References _widget::get_width, and _widget::w.
Referenced by hori_calculate_size(), listview_draw(), and listview_resize().
int widget_get_x_pos | ( | widget * | widget | ) |
widget | The widget handle |
Definition at line 398 of file widget.c.
References _widget::x.
Referenced by listview_find_mouse_target().
int widget_get_y_pos | ( | widget * | widget | ) |
widget | The widget handle |
Definition at line 405 of file widget.c.
References _widget::y.
Referenced by listview_find_mouse_target().
int widget_intersect | ( | const widget * | widget, |
int | x, | ||
int | y | ||
) |
widget | The widget to check |
x | The X position relative to parent window |
y | the Y position relative to parent window |
Check if x,y falls within the widget.
Definition at line 70 of file widget.c.
References _widget::h, _widget::w, _widget::x, and _widget::y.
Referenced by box_find_mouse_target(), container_find_mouse_target(), and listview_find_mouse_target().
gboolean widget_motion_notify | ( | widget * | wid, |
gint | x, | ||
gint | y | ||
) |
wid | The widget handle |
x | The x coordinate of the mouse event |
y | The y coordinate of the mouse event |
Motion notify.
Definition at line 488 of file widget.c.
References _widget::motion_notify.
Referenced by rofi_view_handle_mouse_motion().
void widget_move | ( | widget * | widget, |
short | x, | ||
short | y | ||
) |
widget | The widget to move |
x | The new X position relative to parent window |
y | The new Y position relative to parent window |
Moves the widget.
Definition at line 100 of file widget.c.
References _widget::x, and _widget::y.
Referenced by container_update(), hori_calculate_size(), listview_resize(), and vert_calculate_size().
gboolean widget_need_redraw | ( | widget * | wid | ) |
wid | The widget handle |
Check the flag indicating the widget needs to be redrawn.
Definition at line 445 of file widget.c.
References _widget::enabled, and _widget::need_redraw.
Referenced by rofi_view_update().
void widget_queue_redraw | ( | widget * | wid | ) |
wid | The widget handle |
Indicate that the widget needs to be redrawn. This is done by setting the redraw flag on the toplevel widget.
Definition at line 432 of file widget.c.
References _widget::need_redraw, and _widget::parent.
Referenced by icon_set_surface(), listview_nav_down_int(), listview_nav_left(), listview_nav_page_next_int(), listview_nav_page_prev_int(), listview_nav_right(), listview_nav_up_int(), listview_resize(), listview_set_num_elements(), listview_set_selected(), rofi_view_create(), rofi_view_error_dialog(), rofi_view_temp_configure_notify(), textbox_blink(), textbox_cursor(), textbox_cursor_end(), textbox_font(), textbox_icon(), textbox_moveresize(), textbox_set_ellipsize(), textbox_text(), widget_disable(), widget_enable(), widget_resize(), and widget_set_state().
void widget_resize | ( | widget * | widget, |
short | w, | ||
short | h | ||
) |
widget | The widget toresize |
w | The new width |
h | The new height |
Resizes the widget.
Definition at line 84 of file widget.c.
References _widget::h, _widget::resize, _widget::w, and widget_queue_redraw().
Referenced by container_update(), hori_calculate_size(), listview_resize(), rofi_view_create(), rofi_view_error_dialog(), rofi_view_temp_configure_notify(), rofi_view_window_update_size(), and vert_calculate_size().
void widget_set_trigger_action_handler | ( | widget * | wid, |
widget_trigger_action_cb | cb, | ||
void * | cb_data | ||
) |
wid | The widget handle |
cb | The widget trigger action callback |
cb_data | the user data to pass to callback |
Override the widget trigger action handler on widget.
Definition at line 479 of file widget.c.
References _widget::trigger_action, and _widget::trigger_action_cb_data.
Referenced by listview_recompute_elements(), and rofi_view_add_widget().
WidgetTriggerActionResult widget_trigger_action | ( | widget * | wid, |
guint | action, | ||
gint | x, | ||
gint | y | ||
) |
wid | The widget handle |
action | The action to trigger |
x | A pointer to the x coordinate of the click |
y | A pointer to the y coordinate of the click |
Trigger an action on widget.
x | and |
y | are relative to |
wid | . |
Definition at line 471 of file widget.c.
References _widget::trigger_action, and _widget::trigger_action_cb_data.
Referenced by rofi_view_trigger_action().
WidgetType widget_type | ( | widget * | widget | ) |
widget | Handle to widget |
Get the type of the widget.
Definition at line 108 of file widget.c.
References _widget::type, and WIDGET_TYPE_UNKNOWN.
void widget_update | ( | widget * | widget | ) |
widget | The widget handle |
Update the widget, and its parent recursively. This should be called when size of widget changes.
Definition at line 422 of file widget.c.
References _widget::update.
Referenced by box_add(), box_resize(), container_add(), container_resize(), icon_resize(), textbox_text(), widget_disable(), and widget_enable().
void widget_xy_to_relative | ( | widget * | widget, |
gint * | x, | ||
gint * | y | ||
) |
widget | The widget handle |
x | A pointer to the absolute X coordinates |
y | A pointer to the absolute Y coordinates |
Will modify
x | and |
y | to make them relative to |
widget | . |
Definition at line 413 of file widget.c.
References _widget::parent, widget_xy_to_relative(), _widget::x, and _widget::y.
Referenced by rofi_view_handle_mouse_motion(), rofi_view_trigger_action(), and widget_xy_to_relative().