rofi  1.5.1
widget.c File Reference
#include <glib.h>
#include <math.h>
#include "widgets/widget.h"
#include "widgets/widget-internal.h"
#include "theme.h"
Include dependency graph for widget.c:

Go to the source code of this file.

Macros

#define WIDGET_DEFAULT_PADDING   0
 

Functions

void widget_init (widget *wid, widget *parent, WidgetType type, const char *name)
 
void widget_set_state (widget *widget, const char *state)
 
int widget_intersect (const widget *widget, int x, int y)
 
void widget_resize (widget *widget, short w, short h)
 
void widget_move (widget *widget, short x, short y)
 
WidgetType widget_type (widget *widget)
 
gboolean widget_enabled (widget *widget)
 
void widget_enable (widget *widget)
 
void widget_disable (widget *widget)
 
void widget_draw (widget *widget, cairo_t *d)
 
void widget_free (widget *wid)
 
int widget_get_height (widget *widget)
 
int widget_get_width (widget *widget)
 
int widget_get_x_pos (widget *widget)
 
int widget_get_y_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_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_padding_get_left (const widget *wid)
 
int widget_padding_get_right (const widget *wid)
 
int widget_padding_get_top (const widget *wid)
 
int widget_padding_get_bottom (const widget *wid)
 
int widget_padding_get_remaining_width (const widget *wid)
 
int widget_padding_get_remaining_height (const widget *wid)
 
int widget_padding_get_padding_height (const widget *wid)
 
int widget_padding_get_padding_width (const widget *wid)
 
int widget_get_desired_height (widget *wid)
 
int widget_get_desired_width (widget *wid)
 
int widget_get_absolute_xpos (widget *wid)
 
int widget_get_absolute_ypos (widget *wid)
 

Macro Definition Documentation

◆ WIDGET_DEFAULT_PADDING

#define WIDGET_DEFAULT_PADDING   0

Default padding.

Definition at line 35 of file widget.c.

Referenced by widget_init().

Function Documentation

◆ widget_init()

void widget_init ( widget wid,
widget parent,
WidgetType  type,
const char *  name 
)
Parameters
widThe widget to initialize.
parentThe widget's parent.
typeThe type of the widget.
nameThe name of the widget.

Initializes the widget structure.

Definition at line 37 of file widget.c.

References _widget::border, _widget::border_radius, _widget::def_border, _widget::def_border_radius, _widget::def_margin, _widget::def_padding, _widget::enabled, _widget::margin, _widget::name, _widget::padding, _widget::parent, ROFI_HL_SOLID, ROFI_PU_PX, rofi_theme_get_boolean(), rofi_theme_get_padding(), _widget::type, and WIDGET_DEFAULT_PADDING.

Referenced by box_create(), container_create(), listview_create(), scrollbar_create(), and textbox_create().

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

◆ widget_padding_get_bottom()

int widget_padding_get_bottom ( const widget wid)
Parameters
widThe widget handle.

Get the bottom padding of the widget.

Returns
the bottom padding in pixels.

Definition at line 516 of file widget.c.

References _widget::border, RofiPadding::bottom, distance_get_pixel(), _widget::margin, _widget::padding, and ROFI_ORIENTATION_VERTICAL.

Referenced by listview_draw(), textbox_draw(), widget_padding_get_padding_height(), and widget_padding_get_remaining_height().

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

◆ widget_padding_get_left()

int widget_padding_get_left ( const widget wid)
Parameters
widThe widget handle.

Get the left padding of the widget.

Returns
the left padding in pixels.

Definition at line 486 of file widget.c.

References _widget::border, distance_get_pixel(), RofiPadding::left, _widget::margin, _widget::padding, and ROFI_ORIENTATION_HORIZONTAL.

Referenced by barview_draw(), container_update(), hori_calculate_size(), listview_draw(), listview_resize(), scrollbar_draw(), textbox_draw(), textbox_editable_trigger_action(), textbox_get_desired_width(), vert_calculate_size(), widget_padding_get_padding_width(), and widget_padding_get_remaining_width().

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

◆ widget_padding_get_padding_height()

int widget_padding_get_padding_height ( const widget wid)
Parameters
widThe widget handle.

Get the combined top and bottom padding.

Returns
the top and bottom padding of the widget in pixels.

Definition at line 541 of file widget.c.

References widget_padding_get_bottom(), and widget_padding_get_top().

Referenced by box_add(), box_get_desired_height(), container_get_desired_height(), listview_get_desired_height(), listview_resize(), scrollbar_create(), textbox_get_estimated_height(), textbox_get_height(), and vert_calculate_size().

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

◆ widget_padding_get_padding_width()

int widget_padding_get_padding_width ( const widget wid)
Parameters
widThe widget handle.

Get the combined left and right padding.

Returns
the left and right padding of the widget in pixels.

Definition at line 548 of file widget.c.

References widget_padding_get_left(), and widget_padding_get_right().

Referenced by barview_draw(), box_add(), box_get_desired_width(), hori_calculate_size(), listview_draw(), rofi_view_calculate_window_width(), scrollbar_create(), textbox_draw(), textbox_get_desired_width(), textbox_get_width(), and textbox_moveresize().

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

◆ widget_padding_get_remaining_height()

int widget_padding_get_remaining_height ( const widget wid)
Parameters
widThe widget handle.

Get height of the content of the widget

Returns
the widget height, excluding padding.

Definition at line 534 of file widget.c.

References _widget::h, widget_padding_get_bottom(), and widget_padding_get_top().

Referenced by container_update(), hori_calculate_size(), scrollbar_draw(), and vert_calculate_size().

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

◆ widget_padding_get_remaining_width()

int widget_padding_get_remaining_width ( const widget wid)
Parameters
widThe widget handle.

Get width of the content of the widget

Returns
the widget width, excluding padding.

Definition at line 527 of file widget.c.

References _widget::w, widget_padding_get_left(), and widget_padding_get_right().

Referenced by container_update(), hori_calculate_size(), scrollbar_draw(), and vert_calculate_size().

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

◆ widget_padding_get_right()

int widget_padding_get_right ( const widget wid)
Parameters
widThe widget handle.

Get the right padding of the widget.

Returns
the right padding in pixels.

Definition at line 496 of file widget.c.

References _widget::border, distance_get_pixel(), _widget::margin, _widget::padding, RofiPadding::right, and ROFI_ORIENTATION_HORIZONTAL.

Referenced by barview_draw(), listview_resize(), textbox_get_desired_width(), widget_padding_get_padding_width(), and widget_padding_get_remaining_width().

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

◆ widget_padding_get_top()

int widget_padding_get_top ( const widget wid)
Parameters
widThe widget handle.

Get the top padding of the widget.

Returns
the top padding in pixels.

Definition at line 506 of file widget.c.

References _widget::border, distance_get_pixel(), _widget::margin, _widget::padding, ROFI_ORIENTATION_VERTICAL, and RofiPadding::top.

Referenced by barview_draw(), container_update(), hori_calculate_size(), listview_draw(), listview_resize(), scrollbar_draw(), textbox_draw(), vert_calculate_size(), widget_padding_get_padding_height(), and widget_padding_get_remaining_height().

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

◆ widget_set_state()

void widget_set_state ( widget widget,
const char *  state 
)
Parameters
widgetThe widget handle.
stateThe state of the widget.

Set the state of the widget.

Definition at line 56 of file widget.c.

References _widget::border, _widget::border_radius, _widget::def_border, _widget::def_border_radius, rofi_theme_get_padding(), _widget::state, and widget_queue_redraw().

Referenced by textbox_font().

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