summaryrefslogtreecommitdiffstats
path: root/source/widgets
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2020-08-28 16:41:59 +0200
committerDave Davenport <qball@gmpclient.org>2020-08-28 16:41:59 +0200
commit30735791b4ad900f7ae5ebb6321c9302bee9ab7c (patch)
tree66360b3cde71070b25307eff33dcbcd7b3098ac6 /source/widgets
parent5bec191d2ef3f7083573a99b4f9dd4fcc4a68208 (diff)
Run indenter.
Diffstat (limited to 'source/widgets')
-rw-r--r--source/widgets/box.c6
-rw-r--r--source/widgets/listview.c47
-rw-r--r--source/widgets/textbox.c2
-rw-r--r--source/widgets/widget.c90
4 files changed, 79 insertions, 66 deletions
diff --git a/source/widgets/box.c b/source/widgets/box.c
index 8bf531c9..4f7a2a9d 100644
--- a/source/widgets/box.c
+++ b/source/widgets/box.c
@@ -231,7 +231,9 @@ static void hori_calculate_size ( box *b )
int left = widget_padding_get_left ( WIDGET ( b ) );
double rem = rem_width - b->max_size;
int index = 0;
- if ( rem < 0 ) rem = 0;
+ if ( rem < 0 ) {
+ rem = 0;
+ }
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
widget * child = (widget *) iter->data;
if ( child->enabled == FALSE ) {
@@ -332,7 +334,7 @@ static widget *box_find_mouse_target ( widget *wid, WidgetType type, gint x, gin
static void box_set_state ( widget *wid, const char *state )
{
- for ( GList *iter = g_list_first ( ((box*)wid)->children ); iter != NULL; iter = g_list_next ( iter ) ) {
+ for ( GList *iter = g_list_first ( ( (box *) wid )->children ); iter != NULL; iter = g_list_next ( iter ) ) {
widget * child = (widget *) iter->data;
widget_set_state ( child, state );
}
diff --git a/source/widgets/listview.c b/source/widgets/listview.c
index 863e2b77..1a537de1 100644
--- a/source/widgets/listview.c
+++ b/source/widgets/listview.c
@@ -45,10 +45,10 @@
/**
* Orientation of the listview
*/
- /** Vertical (classical) list */
-#define LISTVIEW ROFI_ORIENTATION_VERTICAL
- /** Horizontal list. (barview) */
-#define BARVIEW ROFI_ORIENTATION_HORIZONTAL
+/** Vertical (classical) list */
+#define LISTVIEW ROFI_ORIENTATION_VERTICAL
+/** Horizontal list. (barview) */
+#define BARVIEW ROFI_ORIENTATION_HORIZONTAL
/**
* The moving direction of the selection, this (in barview) affects the scrolling.
@@ -69,7 +69,7 @@ typedef struct
struct _listview
{
- widget widget;
+ widget widget;
RofiOrientation type;
@@ -143,8 +143,8 @@ const char *const listview_theme_prop_names[][3] = {
static void listview_set_state ( _listview_row r, TextBoxFontType tbft )
{
- widget *w = WIDGET(r.box);
- TextBoxFontType t = tbft & STATE_MASK;
+ widget *w = WIDGET ( r.box );
+ TextBoxFontType t = tbft & STATE_MASK;
if ( w == NULL ) {
return;
}
@@ -171,25 +171,25 @@ static void listview_add_widget ( listview *lv, _listview_row *row, widget *wid,
if ( strcasecmp ( label, "element-icon" ) == 0 ) {
if ( config.show_icons ) {
row->icon = icon_create ( WIDGET ( wid ), "element-icon" );
- box_add ( (box *)wid, WIDGET ( row->icon ), FALSE );
+ box_add ( (box *) wid, WIDGET ( row->icon ), FALSE );
}
}
else if ( strcasecmp ( label, "element-text" ) == 0 ) {
row->textbox = textbox_create ( WIDGET ( wid ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT | flags, NORMAL, "DDD", 0, 0 );
- box_add ( (box *)wid, WIDGET ( row->textbox ), TRUE );
+ box_add ( (box *) wid, WIDGET ( row->textbox ), TRUE );
}
else if ( strcasecmp ( label, "element-index" ) == 0 ) {
row->index = textbox_create ( WIDGET ( wid ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT, NORMAL, " ", 0, 0 );
- box_add ( (box *)wid, WIDGET ( row->index ), FALSE );
- } else {
+ box_add ( (box *) wid, WIDGET ( row->index ), FALSE );
+ }
+ else {
widget *wid2 = (widget *) box_create ( wid, label, ROFI_ORIENTATION_VERTICAL );
box_add ( (box *) wid, WIDGET ( wid2 ), TRUE );
- GList *list = rofi_theme_get_list ( WIDGET ( wid2 ), "children", "" );
+ GList *list = rofi_theme_get_list ( WIDGET ( wid2 ), "children", "" );
for ( GList *iter = g_list_first ( list ); iter != NULL; iter = g_list_next ( iter ) ) {
- listview_add_widget ( lv,row, wid2, (const char *)iter->data );
+ listview_add_widget ( lv, row, wid2, (const char *) iter->data );
}
}
-
}
static void listview_create_row ( listview *lv, _listview_row *row )
@@ -203,7 +203,7 @@ static void listview_create_row ( listview *lv, _listview_row *row )
row->index = NULL;
for ( GList *iter = g_list_first ( list ); iter != NULL; iter = g_list_next ( iter ) ) {
- listview_add_widget ( lv,row, WIDGET(row->box), (const char *)iter->data );
+ listview_add_widget ( lv, row, WIDGET ( row->box ), (const char *) iter->data );
}
g_list_free_full ( list, g_free );
}
@@ -348,7 +348,7 @@ static void barview_draw ( widget *wid, cairo_t *draw )
else {
for ( unsigned int i = 0; i < lv->cur_elements && width > 0 && i <= offset; i++ ) {
update_element ( lv, i, offset - i, TRUE );
- int twidth = widget_get_desired_width ( WIDGET ( lv->boxes[i].box ) );
+ int twidth = widget_get_desired_width ( WIDGET ( lv->boxes[i].box ) );
if ( twidth >= width ) {
if ( !first ) {
break;
@@ -553,8 +553,8 @@ static void listview_resize ( widget *wid, short w, short h )
lv->max_elements = lv->max_rows * lv->menu_columns;
widget_move ( WIDGET ( lv->scrollbar ),
- lv->widget.w - widget_padding_get_right ( WIDGET ( lv ) ) - widget_get_width ( WIDGET ( lv->scrollbar ) ),
- widget_padding_get_top ( WIDGET ( lv ) ) );
+ lv->widget.w - widget_padding_get_right ( WIDGET ( lv ) ) - widget_get_width ( WIDGET ( lv->scrollbar ) ),
+ widget_padding_get_top ( WIDGET ( lv ) ) );
widget_resize ( WIDGET ( lv->scrollbar ), widget_get_width ( WIDGET ( lv->scrollbar ) ), height );
@@ -661,10 +661,13 @@ listview *listview_create ( widget *parent, const char *name, listview_update_ca
listview_create_row ( lv, &row );
// FIXME: hack to scale hight correctly.
if ( lv->eh > 1 && row.textbox ) {
- char buff[lv->eh*2+1] ;
- memset( buff, '\0', lv->eh*2+1);
- for ( unsigned int i = 0; i < (lv->eh-1); i++) { buff[i*2] = 'a'; buff[i*2+1] ='\n'; };
- textbox_text( row.textbox, buff);
+ char buff[lv->eh * 2 + 1];
+ memset ( buff, '\0', lv->eh * 2 + 1 );
+ for ( unsigned int i = 0; i < ( lv->eh - 1 ); i++ ) {
+ buff[i * 2] = 'a'; buff[i * 2 + 1] = '\n';
+ }
+ ;
+ textbox_text ( row.textbox, buff );
}
lv->element_height = widget_get_desired_height ( WIDGET ( row.box ) );
widget_free ( WIDGET ( row.box ) );
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index 79db938b..3f5d0633 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -914,7 +914,7 @@ double textbox_get_estimated_ch ( void )
int textbox_get_estimated_height ( const textbox *tb, int eh )
{
int height = pango_font_metrics_get_ascent ( tb->metrics ) + pango_font_metrics_get_descent ( tb->metrics );
- return ceil(( eh * height ) / (double)PANGO_SCALE) + widget_padding_get_padding_height ( WIDGET ( tb ) );
+ return ceil ( ( eh * height ) / (double) PANGO_SCALE ) + widget_padding_get_padding_height ( WIDGET ( tb ) );
}
int textbox_get_desired_width ( widget *wid )
{
diff --git a/source/widgets/widget.c b/source/widgets/widget.c
index 8fc3b758..550eead5 100644
--- a/source/widgets/widget.c
+++ b/source/widgets/widget.c
@@ -33,7 +33,7 @@
/** Default padding. */
#define WIDGET_DEFAULT_PADDING 0
-#define WIDGET_PADDING_INIT { { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL }, ROFI_HL_SOLID }
+#define WIDGET_PADDING_INIT { { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL }, ROFI_HL_SOLID }
/* Corner radius - tl, tr, br, bl */
static void draw_rounded_rect ( cairo_t * d,
@@ -41,27 +41,31 @@ static void draw_rounded_rect ( cairo_t * d,
double r0, double r1, double r2, double r3 )
{
if ( r0 > 0 ) {
- cairo_move_to ( d, x1, y1+r0 );
- cairo_arc ( d, x1+r0, y1+r0, r0, -G_PI, -G_PI_2 );
- } else {
+ cairo_move_to ( d, x1, y1 + r0 );
+ cairo_arc ( d, x1 + r0, y1 + r0, r0, -G_PI, -G_PI_2 );
+ }
+ else {
cairo_move_to ( d, x1, y1 );
}
if ( r1 > 0 ) {
- cairo_line_to ( d, x2-r1, y1 );
- cairo_arc ( d, x2-r1, y1+r1, r1, -G_PI_2, 0.0 );
- } else {
+ cairo_line_to ( d, x2 - r1, y1 );
+ cairo_arc ( d, x2 - r1, y1 + r1, r1, -G_PI_2, 0.0 );
+ }
+ else {
cairo_line_to ( d, x2, y1 );
}
if ( r2 > 0 ) {
- cairo_line_to ( d, x2, y2-r2 );
- cairo_arc ( d, x2-r2, y2-r2, r2, 0.0, G_PI_2 );
- } else {
+ cairo_line_to ( d, x2, y2 - r2 );
+ cairo_arc ( d, x2 - r2, y2 - r2, r2, 0.0, G_PI_2 );
+ }
+ else {
cairo_line_to ( d, x2, y2 );
}
if ( r3 > 0 ) {
- cairo_line_to ( d, x1+r3, y2 );
- cairo_arc ( d, x1+r3, y2-r3, r3, G_PI_2, G_PI );
- } else {
+ cairo_line_to ( d, x1 + r3, y2 );
+ cairo_arc ( d, x1 + r3, y2 - r3, r3, G_PI_2, G_PI );
+ }
+ else {
cairo_line_to ( d, x1, y2 );
}
cairo_close_path ( d );
@@ -69,9 +73,9 @@ static void draw_rounded_rect ( cairo_t * d,
void widget_init ( widget *wid, widget *parent, WidgetType type, const char *name )
{
- wid->type = type;
- wid->parent = parent;
- wid->name = g_strdup ( name );
+ wid->type = type;
+ wid->parent = parent;
+ wid->name = g_strdup ( name );
wid->def_padding = (RofiPadding) { WIDGET_PADDING_INIT, WIDGET_PADDING_INIT, WIDGET_PADDING_INIT, WIDGET_PADDING_INIT };
wid->def_border = (RofiPadding) { WIDGET_PADDING_INIT, WIDGET_PADDING_INIT, WIDGET_PADDING_INIT, WIDGET_PADDING_INIT };
wid->def_border_radius = (RofiPadding) { WIDGET_PADDING_INIT, WIDGET_PADDING_INIT, WIDGET_PADDING_INIT, WIDGET_PADDING_INIT };
@@ -205,23 +209,23 @@ void widget_draw ( widget *widget, cairo_t *d )
int radius_tl = distance_get_pixel ( widget->border_radius.top, ROFI_ORIENTATION_VERTICAL );
int radius_br = distance_get_pixel ( widget->border_radius.bottom, ROFI_ORIENTATION_VERTICAL );
- double minof_tl, minof_tr, minof_br, minof_bl;
+ double minof_tl, minof_tr, minof_br, minof_bl;
{
- double left_2 = (double) left / 2;
- double top_2 = (double) top / 2;
- double right_2 = (double) right / 2;
+ double left_2 = (double) left / 2;
+ double top_2 = (double) top / 2;
+ double right_2 = (double) right / 2;
double bottom_2 = (double) bottom / 2;
// Calculate the different offsets for the corners.
- minof_tl = MIN ( left_2, top_2 );
+ minof_tl = MIN ( left_2, top_2 );
minof_tr = MIN ( right_2, top_2 );
minof_br = MIN ( right_2, bottom_2 );
- minof_bl = MIN ( left_2, bottom_2 );
+ minof_bl = MIN ( left_2, bottom_2 );
// Contain border radius in widget space
double vspace, vspace_2, hspace, hspace_2;
- vspace = widget->h - ( margin_top + margin_bottom ) - ( top_2 + bottom_2 );
- hspace = widget->w - ( margin_left + margin_right ) - ( left_2 + right_2 );
+ vspace = widget->h - ( margin_top + margin_bottom ) - ( top_2 + bottom_2 );
+ hspace = widget->w - ( margin_left + margin_right ) - ( left_2 + right_2 );
vspace_2 = vspace / 2;
hspace_2 = hspace / 2;
@@ -249,9 +253,9 @@ void widget_draw ( widget *widget, cairo_t *d )
cairo_set_line_width ( d, 0 );
draw_rounded_rect ( d,
- margin_left + ( left > 2 ? left - 1 : left == 1 ? 0.5 : 0 ),
- margin_top + ( top > 2 ? top - 1 : top == 1 ? 0.5 : 0 ),
- widget->w - margin_right - ( right > 2 ? right - 1 : right == 1 ? 0.5 : 0 ),
+ margin_left + ( left > 2 ? left - 1 : left == 1 ? 0.5 : 0 ),
+ margin_top + ( top > 2 ? top - 1 : top == 1 ? 0.5 : 0 ),
+ widget->w - margin_right - ( right > 2 ? right - 1 : right == 1 ? 0.5 : 0 ),
widget->h - margin_bottom - ( bottom > 2 ? bottom - 1 : bottom == 1 ? 0.5 : 0 ),
radius_tl - ( minof_tl > 1 ? minof_tl - 1 : 0 ),
radius_tr - ( minof_tr > 1 ? minof_tr - 1 : 0 ),
@@ -277,28 +281,32 @@ void widget_draw ( widget *widget, cairo_t *d )
double radius_int_tl, radius_int_tr, radius_int_br, radius_int_bl;
double radius_out_tl, radius_out_tr, radius_out_br, radius_out_bl;
- if (radius_tl > 0) {
- radius_out_tl = radius_tl + minof_tl ,
+ if ( radius_tl > 0 ) {
+ radius_out_tl = radius_tl + minof_tl,
radius_int_tl = radius_tl - minof_tl;
- } else {
+ }
+ else {
radius_out_tl = radius_int_tl = 0;
}
- if (radius_tr > 0) {
- radius_out_tr = radius_tr + minof_tr ,
+ if ( radius_tr > 0 ) {
+ radius_out_tr = radius_tr + minof_tr,
radius_int_tr = radius_tr - minof_tr;
- } else {
+ }
+ else {
radius_out_tr = radius_int_tr = 0;
}
- if (radius_br > 0) {
- radius_out_br = radius_br + minof_br ,
+ if ( radius_br > 0 ) {
+ radius_out_br = radius_br + minof_br,
radius_int_br = radius_br - minof_br;
- } else {
+ }
+ else {
radius_out_br = radius_int_br = 0;
}
- if (radius_bl > 0) {
- radius_out_bl = radius_bl + minof_bl ,
+ if ( radius_bl > 0 ) {
+ radius_out_bl = radius_bl + minof_bl,
radius_int_bl = radius_bl - minof_bl;
- } else {
+ }
+ else {
radius_out_bl = radius_int_bl = 0;
}
@@ -314,7 +322,7 @@ void widget_draw ( widget *widget, cairo_t *d )
cairo_new_sub_path ( d );
draw_rounded_rect ( d,
margin_left + left,
- margin_top + top,
+ margin_top + top,
widget->w - margin_right - right,
widget->h - margin_bottom - bottom,
radius_int_tl,
@@ -416,7 +424,7 @@ gboolean widget_need_redraw ( widget *wid )
if ( wid == NULL ) {
return FALSE;
}
- if ( ! wid->enabled ) {
+ if ( !wid->enabled ) {
return FALSE;
}
return wid->need_redraw;