rofi 1.7.5
widget
Collaboration diagram for widget:

Topics

 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 }
 

Functions

int widget_intersect (const widget *widget, int x, int y)
 
void widget_move (widget *widget, short x, short y)
 
void widget_set_type (widget *widget, WidgetType type)
 
gboolean widget_enabled (widget *widget)
 
void widget_set_enabled (widget *widget, gboolean enabled)
 
static void widget_disable (widget *widget)
 
static void widget_enable (widget *widget)
 
void widget_draw (widget *widget, cairo_t *d)
 
void widget_free (widget *wid)
 
void widget_resize (widget *widget, short w, short h)
 
int widget_get_height (widget *widget)
 
int widget_get_width (widget *widget)
 
int widget_get_y_pos (widget *widget)
 
int widget_get_x_pos (widget *widget)
 
void widget_xy_to_relative (widget *widget, gint *x, gint *y)
 
void widget_update (widget *widget)
 
void widget_queue_redraw (widget *wid)
 
gboolean widget_need_redraw (widget *wid)
 
widgetwidget_find_mouse_target (widget *wid, WidgetType type, gint x, gint y)
 
WidgetTriggerActionResult widget_check_action (widget *wid, guint action, gint x, gint y)
 
WidgetTriggerActionResult widget_trigger_action (widget *wid, guint action, gint x, gint y)
 
void widget_set_trigger_action_handler (widget *wid, widget_trigger_action_cb cb, void *cb_data)
 
gboolean widget_motion_notify (widget *wid, gint x, gint y)
 
int widget_get_desired_height (widget *wid, const int width)
 
int widget_get_desired_width (widget *wid, const int height)
 
int widget_get_absolute_xpos (widget *wid)
 
int widget_get_absolute_ypos (widget *wid)
 

Detailed Description

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.

Macro Definition Documentation

◆ WIDGET

#define WIDGET ( a)    ((widget *)(a))

Macro to get widget from an implementation (e.g. textbox/scrollbar)

Definition at line 119 of file widget.h.

Referenced by __create_window(), __textbox_update_pango_text(), barview_draw(), box_add(), box_create(), container_add(), container_create(), container_update(), hori_calculate_size(), icon_create(), icon_draw(), icon_set_surface(), listview_add_widget(), listview_create(), listview_create_row(), listview_draw(), listview_element_motion_notify(), listview_element_trigger_action(), listview_find_mouse_target(), listview_free(), listview_get_desired_height(), listview_nav_column_left_int(), listview_nav_column_right_int(), 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_recompute_elements(), listview_resize(), listview_set_num_elements(), listview_set_selected(), listview_set_show_scrollbar(), listview_set_state(), rofi_view_add_widget(), rofi_view_calculate_height(), rofi_view_calculate_window_position(), rofi_view_calculate_window_width(), rofi_view_check_action(), rofi_view_create(), rofi_view_error_dialog(), rofi_view_free(), rofi_view_handle_mouse_motion(), rofi_view_reload_message_bar(), rofi_view_resolve_cursor(), rofi_view_set_overlay(), rofi_view_setup_fake_transparency(), rofi_view_temp_configure_notify(), rofi_view_trigger_action(), rofi_view_update(), rofi_view_window_update_size(), scrollbar_create(), scrollbar_draw(), selection_changed_callback(), textbox_blink(), textbox_create(), textbox_cursor(), textbox_cursor_end(), textbox_draw(), textbox_font(), textbox_get_desired_height(), textbox_get_desired_width(), textbox_get_estimated_height(), textbox_get_height(), textbox_initialize_font(), textbox_moveresize(), textbox_set_ellipsize(), textbox_sidebar_modes_trigger_action(), textbox_tab_stops(), textbox_text(), update_callback(), and vert_calculate_size().

Typedef Documentation

◆ widget

typedef struct _widget widget

Abstract structure holding internal state of a widget. Structure is elaborated in widget-internal.h

Definition at line 51 of file widget.h.

◆ widget_find_mouse_target_cb

typedef widget *(* widget_find_mouse_target_cb) (widget *widget, WidgetType type, gint x, gint y)
Parameters
widgetThe container widget itself
typeThe widget type searched for
xThe X coordination of the mouse event relative to widget
yThe 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.

Returns
A child widget if found, NULL otherwise

Definition at line 98 of file widget.h.

◆ widget_trigger_action_cb

typedef WidgetTriggerActionResult(* widget_trigger_action_cb) (widget *widget, guint action, gint x, gint y, void *user_data)
Parameters
widgetThe target widget
actionThe action value (which enum it is depends on the widget type)
xThe X coordination of the mouse event relative to widget
yThe Y coordination of the mouse event relative to widget
user_dataThe data passed to widget_set_trigger_action_handler()

This callback should handle the action if relevant, and returns whether it did or not.

Returns
Whether the action was handled or not, see enum values for details

Definition at line 113 of file widget.h.

Enumeration Type Documentation

◆ WidgetTriggerActionResult

Whether and how the action was handled

Enumerator
WIDGET_TRIGGER_ACTION_RESULT_IGNORED 

The action was ignore and should bubble

WIDGET_TRIGGER_ACTION_RESULT_HANDLED 

The action was handled directly

WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN 

The action was handled and should start the grab for motion events

WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END 

The action was handled and should stop the grab for motion events

Definition at line 76 of file widget.h.

◆ WidgetType

enum WidgetType

Type of the widget. It is used to bubble events to the relevant widget.

Enumerator
WIDGET_TYPE_UNKNOWN 

Default type

WIDGET_TYPE_LISTVIEW 

The listview widget

WIDGET_TYPE_LISTVIEW_ELEMENT 

An element in the listview

WIDGET_TYPE_EDITBOX 

The input bar edit box

WIDGET_TYPE_SCROLLBAR 

The listview scrollbar

WIDGET_TYPE_MODE_SWITCHER 

A widget allowing user to swithc between modes

WIDGET_TYPE_TEXTBOX_TEXT 

Text-only textbox

Definition at line 56 of file widget.h.

Function Documentation

◆ widget_check_action()

WidgetTriggerActionResult widget_check_action ( widget * wid,
guint action,
gint x,
gint y )
Parameters
widThe widget handle
actionThe action to trigger
xA pointer to the x coordinate of the click
yA pointer to the y coordinate of the click

Trigger an action on widget. param x and param y are relative to param wid .

Returns
Whether the action would be handled or not

◆ widget_disable()

static void widget_disable ( widget * widget)
inlinestatic
Parameters
widgetHandle to widget

Disable the widget.

Definition at line 170 of file widget.h.

References widget_set_enabled().

Referenced by listview_set_show_scrollbar(), rofi_view_add_widget(), rofi_view_reload_message_bar(), and rofi_view_set_overlay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ widget_draw()

void widget_draw ( widget * widget,
cairo_t * d )
Parameters
widgetwidget Handle to the widget
dThe cairo object used to draw itself.

Render the textbox.

Definition at line 135 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(), rofi_theme_get_image(), RofiPadding::top, _widget::w, _widget::x, and _widget::y.

Referenced by barview_draw(), box_draw(), container_draw(), listview_draw(), and rofi_view_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ widget_enable()

static void widget_enable ( widget * widget)
inlinestatic
Parameters
widgetHandle to widget

Enable the widget.

Definition at line 178 of file widget.h.

References widget_set_enabled().

Referenced by listview_set_show_scrollbar(), rofi_view_reload_message_bar(), and rofi_view_set_overlay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ widget_enabled()

gboolean widget_enabled ( widget * widget)
Parameters
widgetHandle to widget

Check if widget is enabled.

Returns
TRUE when widget is enabled.

Definition at line 116 of file widget.c.

References _widget::enabled.

Referenced by listview_draw(), and listview_find_mouse_target().

Here is the caller graph for this function:

◆ widget_find_mouse_target()

widget * widget_find_mouse_target ( widget * wid,
WidgetType type,
gint x,
gint y )
Parameters
widThe widget handle
typeThe type of the wanted widget
xThe x coordinate of the mouse event
yThe y coordinate of the mouse event

Get the widget that should handle a mouse event.

Returns
returns the widget that should handle the mouse event.

Definition at line 510 of file widget.c.

References _widget::find_mouse_target, _widget::type, and WIDGET_TYPE_UNKNOWN.

Referenced by box_find_mouse_target(), container_find_mouse_target(), listview_find_mouse_target(), rofi_view_check_action(), rofi_view_handle_mouse_motion(), rofi_view_resolve_cursor(), and rofi_view_trigger_action().

Here is the caller graph for this function:

◆ widget_free()

void widget_free ( widget * wid)
Parameters
widHandle to the widget

Free the widget and all allocated memory.

Definition at line 425 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().

Here is the caller graph for this function:

◆ widget_get_absolute_xpos()

int widget_get_absolute_xpos ( widget * wid)
Parameters
widThe widget handle

Get the absolute x-position on the root widget..

Returns
the absolute x-position of widget of the widget in pixels.

Definition at line 663 of file widget.c.

References _widget::parent, widget_get_absolute_xpos(), and _widget::x.

Referenced by widget_get_absolute_xpos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ widget_get_absolute_ypos()

int widget_get_absolute_ypos ( widget * wid)
Parameters
widThe widget handle

Get the absolute y-position on the root widget..

Returns
the absolute y-position of widget of the widget in pixels.

Definition at line 673 of file widget.c.

References _widget::parent, widget_get_absolute_ypos(), and _widget::y.

Referenced by widget_get_absolute_ypos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ widget_get_desired_height()

int widget_get_desired_height ( widget * wid,
const int width )
Parameters
widThe widget handle
widthThe Widget width to get height for

Get the desired height of this widget recursively.

Returns
the desired height of the widget in pixels.

Definition at line 644 of file widget.c.

References _widget::get_desired_height, and _widget::h.

Referenced by box_get_desired_height(), container_get_desired_height(), listview_create(), rofi_view_calculate_height(), selection_changed_callback(), update_callback(), and vert_calculate_size().

Here is the caller graph for this function:

◆ widget_get_desired_width()

int widget_get_desired_width ( widget * wid,
const int height )
Parameters
widThe widget handle
heightThe Widget height to get height for

Get the desired width of this widget recursively.

Returns
the desired width of the widget in pixels.

Definition at line 653 of file widget.c.

References _widget::get_desired_width, and _widget::w.

Referenced by barview_draw(), box_get_desired_width(), and hori_calculate_size().

Here is the caller graph for this function:

◆ widget_get_height()

int widget_get_height ( widget * widget)
Parameters
widgetThe widget handle
Returns
the height of the widget.

Definition at line 437 of file widget.c.

References _widget::get_height, and _widget::h.

Referenced by vert_calculate_size().

Here is the caller graph for this function:

◆ widget_get_width()

int widget_get_width ( widget * widget)
Parameters
widgetThe widget handle
Returns
the width of the widget.

Definition at line 446 of file widget.c.

References _widget::get_width, and _widget::w.

Referenced by hori_calculate_size(), listview_draw(), and listview_resize().

Here is the caller graph for this function:

◆ widget_get_x_pos()

int widget_get_x_pos ( widget * widget)
Parameters
widgetThe widget handle
Returns
the x position of the widget relative to its parent.

Definition at line 455 of file widget.c.

References _widget::x.

Referenced by listview_find_mouse_target().

Here is the caller graph for this function:

◆ widget_get_y_pos()

int widget_get_y_pos ( widget * widget)
Parameters
widgetThe widget handle
Returns
the y position of the widget relative to its parent.

Definition at line 461 of file widget.c.

References _widget::y.

Referenced by listview_find_mouse_target().

Here is the caller graph for this function:

◆ widget_intersect()

int widget_intersect ( const widget * widget,
int x,
int y )
Parameters
widgetThe widget to check
xThe X position relative to parent window
ythe Y position relative to parent window

Check if x,y falls within the widget.

Returns
TRUE if x,y falls within the widget

Definition at line 75 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().

Here is the caller graph for this function:

◆ widget_motion_notify()

gboolean widget_motion_notify ( widget * wid,
gint x,
gint y )
Parameters
widThe widget handle
xThe x coordinate of the mouse event
yThe y coordinate of the mouse event

Motion notify.

Returns
TRUE when handled.

Definition at line 566 of file widget.c.

References _widget::motion_notify.

Referenced by rofi_view_handle_mouse_motion().

Here is the caller graph for this function:

◆ widget_move()

void widget_move ( widget * widget,
short x,
short y )
Parameters
widgetThe widget to move
xThe new X position relative to parent window
yThe new Y position relative to parent window

Moves the widget.

Definition at line 102 of file widget.c.

References _widget::x, and _widget::y.

Referenced by barview_draw(), container_update(), hori_calculate_size(), listview_draw(), listview_resize(), and vert_calculate_size().

Here is the caller graph for this function:

◆ widget_need_redraw()

gboolean widget_need_redraw ( widget * wid)
Parameters
widThe widget handle

Check the flag indicating the widget needs to be redrawn.

Definition at line 500 of file widget.c.

References _widget::enabled, and _widget::need_redraw.

Referenced by rofi_view_update().

Here is the caller graph for this function:

◆ widget_queue_redraw()

◆ widget_resize()

void widget_resize ( widget * widget,
short w,
short h )
Parameters
widgetThe widget toresize
wThe new width
hThe new height

Resizes the widget.

Definition at line 87 of file widget.c.

References _widget::h, _widget::resize, _widget::w, and widget_queue_redraw().

Referenced by barview_draw(), container_update(), hori_calculate_size(), listview_draw(), listview_resize(), rofi_view_temp_configure_notify(), rofi_view_window_update_size(), and vert_calculate_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ widget_set_enabled()

void widget_set_enabled ( widget * widget,
gboolean enabled )
Parameters
widgetHandle to widget
enabledThe new state

Disable the widget.

Definition at line 123 of file widget.c.

References _widget::enabled, _widget::parent, widget_queue_redraw(), and widget_update().

Referenced by widget_disable(), and widget_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ widget_set_trigger_action_handler()

void widget_set_trigger_action_handler ( widget * wid,
widget_trigger_action_cb cb,
void * cb_data )
Parameters
widThe widget handle
cbThe widget trigger action callback
cb_datathe user data to pass to callback

Override the widget trigger action handler on widget.

Definition at line 557 of file widget.c.

References _widget::trigger_action, and _widget::trigger_action_cb_data.

Referenced by listview_recompute_elements(), and rofi_view_add_widget().

Here is the caller graph for this function:

◆ widget_set_type()

void widget_set_type ( widget * widget,
WidgetType type )
Parameters
widgetHandle to widget
typeThe widget type.

Set the widget type.

Definition at line 109 of file widget.c.

References _widget::type.

Referenced by listview_create_row().

Here is the caller graph for this function:

◆ widget_trigger_action()

WidgetTriggerActionResult widget_trigger_action ( widget * wid,
guint action,
gint x,
gint y )
Parameters
widThe widget handle
actionThe action to trigger
xA pointer to the x coordinate of the click
yA pointer to the y coordinate of the click

Trigger an action on widget. param x and param y are relative to param wid .

Returns
Whether the action was handled or not

Definition at line 546 of file widget.c.

References _widget::trigger_action, and _widget::trigger_action_cb_data.

Referenced by rofi_view_trigger_action().

Here is the caller graph for this function:

◆ widget_update()

void widget_update ( widget * widget)
Parameters
widgetThe widget handle

Update the widget, and its parent recursively. This should be called when size of widget changes.

Definition at line 477 of file widget.c.

References _widget::update.

Referenced by box_add(), box_resize(), box_update(), container_add(), container_resize(), icon_resize(), textbox_text(), and widget_set_enabled().

Here is the caller graph for this function:

◆ widget_xy_to_relative()

void widget_xy_to_relative ( widget * widget,
gint * x,
gint * y )
Parameters
widgetThe widget handle
xA pointer to the absolute X coordinates
yA pointer to the absolute Y coordinates

Will modify param x and param y to make them relative to param widget .

Definition at line 468 of file widget.c.

References _widget::parent, widget_xy_to_relative(), _widget::x, and _widget::y.

Referenced by rofi_view_check_action(), rofi_view_handle_mouse_motion(), rofi_view_trigger_action(), and widget_xy_to_relative().

Here is the call graph for this function:
Here is the caller graph for this function: