1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00

Change Orientation enum to RofiOrientation.

This commit is contained in:
Dave Davenport 2017-06-02 16:34:52 +02:00
parent 9915857a2e
commit ea7d20d150
11 changed files with 66 additions and 66 deletions

View file

@ -83,7 +83,7 @@ typedef struct
double distance;
/** Unit type of the distance */
RofiPixelUnit type;
/** Style of the line */
/** Style of the line (optional)*/
RofiLineStyle style;
} RofiDistance;
@ -92,9 +92,9 @@ typedef struct
*/
typedef enum
{
ORIENTATION_VERTICAL,
ORIENTATION_HORIZONTAL
} Orientation;
ROFI_ORIENTATION_VERTICAL,
ROFI_ORIENTATION_HORIZONTAL
} RofiOrientation;
/**
* Type of property
*/
@ -365,7 +365,7 @@ int rofi_theme_get_boolean ( const widget *widget, const char *property, int
*
* @returns The orientation of this property for this widget or %def not found.
*/
Orientation rofi_theme_get_orientation ( const widget *widget, const char *property, Orientation def );
RofiOrientation rofi_theme_get_orientation ( const widget *widget, const char *property, RofiOrientation def );
/**
* @param widget The widget to query
* @param property The property to query.
@ -427,7 +427,7 @@ ThemeHighlight rofi_theme_get_highlight ( widget *widget, const char *property,
* Convert RofiDistance into pixels.
* @returns the number of pixels this distance represents.
*/
int distance_get_pixel ( RofiDistance d, Orientation ori );
int distance_get_pixel ( RofiDistance d, RofiOrientation ori );
/**
* @param d The distance handle.
* @param draw The cairo drawable.

View file

@ -53,7 +53,7 @@ typedef struct _box box;
*
* @returns a newly created box, free with #widget_free
*/
box * box_create ( const char *name, Orientation type );
box * box_create ( const char *name, RofiOrientation type );
/**
* @param box Handle to the box widget.

View file

@ -579,8 +579,8 @@ t_property_color_value
;
t_property_orientation
: ORIENTATION_HORI { $$ = ORIENTATION_HORIZONTAL; }
| ORIENTATION_VERT { $$ = ORIENTATION_VERTICAL; }
: ORIENTATION_HORI { $$ = ROFI_ORIENTATION_HORIZONTAL; }
| ORIENTATION_VERT { $$ = ROFI_ORIENTATION_VERTICAL; }
;
/** Property name */

View file

@ -541,7 +541,7 @@ int rofi_theme_get_boolean ( const widget *widget, const char *property, int def
g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property );
return def;
}
Orientation rofi_theme_get_orientation ( const widget *widget, const char *property, Orientation def )
RofiOrientation rofi_theme_get_orientation ( const widget *widget, const char *property, RofiOrientation def )
{
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state, FALSE );
Property *p = rofi_theme_find_property ( wid, P_ORIENTATION, property, FALSE );
@ -637,13 +637,13 @@ ThemeHighlight rofi_theme_get_highlight ( widget *widget, const char *property,
return th;
}
int distance_get_pixel ( RofiDistance d, Orientation ori )
int distance_get_pixel ( RofiDistance d, RofiOrientation ori )
{
if ( d.type == ROFI_PU_EM ) {
return d.distance * textbox_get_estimated_char_height ();
}
else if ( d.type == ROFI_PU_PERCENT ) {
if ( ori == ORIENTATION_VERTICAL ) {
if ( ori == ROFI_ORIENTATION_VERTICAL ) {
int height = 0;
rofi_view_get_current_monitor ( NULL, &height );
return ( d.distance * height ) / ( 100.0 );

View file

@ -348,8 +348,8 @@ static void rofi_view_calculate_window_position ( RofiViewState *state )
// Apply offset.
RofiDistance x = rofi_theme_get_distance ( WIDGET ( state->main_window ), "x-offset", config.x_offset );
RofiDistance y = rofi_theme_get_distance ( WIDGET ( state->main_window ), "y-offset", config.y_offset );
state->x += distance_get_pixel ( x, ORIENTATION_HORIZONTAL );
state->y += distance_get_pixel ( y, ORIENTATION_VERTICAL );
state->x += distance_get_pixel ( x, ROFI_ORIENTATION_HORIZONTAL );
state->y += distance_get_pixel ( y, ROFI_ORIENTATION_VERTICAL );
}
static void rofi_view_window_update_size ( RofiViewState * state )
@ -709,7 +709,7 @@ void __create_window ( MenuFlags menu_flags )
}
// Setup font.
// Dummy widget.
box *win = box_create ( "window.box_window", ORIENTATION_HORIZONTAL);
box *win = box_create ( "window.box_window", ROFI_ORIENTATION_HORIZONTAL);
const char *font = rofi_theme_get_string ( WIDGET ( win ), "font", config.menu_font );
if ( font ) {
PangoFontDescription *pfd = pango_font_description_from_string ( font );
@ -808,7 +808,7 @@ static void rofi_view_calculate_window_width ( RofiViewState *state )
}
// Use theme configured width, if set.
RofiDistance width = rofi_theme_get_distance ( WIDGET ( state->main_window ), "width", state->width );
state->width = distance_get_pixel ( width, ORIENTATION_HORIZONTAL );
state->width = distance_get_pixel ( width, ROFI_ORIENTATION_HORIZONTAL );
}
/**
@ -1497,7 +1497,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
* MAINBOX
*/
if ( strcmp ( name, "mainbox") == 0 ){
wid = (widget *)box_create ( strbox, ORIENTATION_VERTICAL );
wid = (widget *)box_create ( strbox, ROFI_ORIENTATION_VERTICAL );
box_add ( (box *)parent_widget, WIDGET ( wid ), TRUE, 0 );
defaults = "inputbar,message,listview";
}
@ -1505,7 +1505,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
* INPUTBAR
*/
else if ( strcmp ( name, "inputbar" ) == 0 ){
wid = (widget *)box_create ( strbox, ORIENTATION_HORIZONTAL );
wid = (widget *)box_create ( strbox, ROFI_ORIENTATION_HORIZONTAL );
defaults = "prompt,entry,case-indicator";
box_add ( (box *)parent_widget, WIDGET ( wid ), FALSE, 0 );
@ -1571,7 +1571,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
*/
else if ( strcmp( name, "sidebar" ) == 0 ) {
if ( config.sidebar_mode ){
state->sidebar_bar = box_create ( strbox, ORIENTATION_HORIZONTAL );
state->sidebar_bar = box_create ( strbox, ROFI_ORIENTATION_HORIZONTAL );
box_add ( (box*)parent_widget, WIDGET ( state->sidebar_bar ), FALSE, 10 );
state->num_modi = rofi_get_num_enabled_modi ();
state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) );
@ -1589,7 +1589,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
textbox *t = textbox_create ( str, TB_WRAP, NORMAL, "");
box_add ( (box *)parent_widget, WIDGET(t), TRUE, 0);
} else {
wid = box_create ( strbox, ORIENTATION_VERTICAL );
wid = box_create ( strbox, ROFI_ORIENTATION_VERTICAL );
box_add ( (box *)parent_widget, WIDGET ( wid ), TRUE, 0 );
//g_error("The widget %s does not exists. Invalid layout.", name);
}
@ -1632,7 +1632,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
TICK_N ( "Get active monitor" );
state->main_window = box_create ( "window.box", ORIENTATION_VERTICAL );
state->main_window = box_create ( "window.box", ROFI_ORIENTATION_VERTICAL );
// Get children.
GList *list = rofi_theme_get_list ( WIDGET(state->main_window), "children", "mainbox");
for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter )){
@ -1683,8 +1683,8 @@ int rofi_view_error_dialog ( const char *msg, int markup )
state->menu_flags = MENU_ERROR_DIALOG;
state->finalize = process_result;
state->main_window = box_create ( "window.box", ORIENTATION_VERTICAL );
box *box = box_create ( "window.mainbox.message.box", ORIENTATION_VERTICAL );
state->main_window = box_create ( "window.box", ROFI_ORIENTATION_VERTICAL );
box *box = box_create ( "window.mainbox.message.box", ROFI_ORIENTATION_VERTICAL );
box_add ( state->main_window, WIDGET ( box ), TRUE, 0 );
state->text = textbox_create ( "window.mainbox.message.textbox", ( TB_AUTOHEIGHT | TB_WRAP ) + ( ( markup ) ? TB_MARKUP : 0 ),
NORMAL, ( msg != NULL ) ? msg : "" );

View file

@ -40,7 +40,7 @@
struct _box
{
widget widget;
Orientation type;
RofiOrientation type;
int max_size;
// Padding between elements
RofiDistance spacing;
@ -56,7 +56,7 @@ static int box_get_desired_width ( widget *wid )
box *b = (box *) wid;
int spacing = distance_get_pixel ( b->spacing, b->type );
int width = 0;
if ( b->type == ORIENTATION_HORIZONTAL ) {
if ( b->type == ROFI_ORIENTATION_HORIZONTAL ) {
int active_widgets = 0;
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
widget * child = (widget *) iter->data;
@ -91,7 +91,7 @@ static int box_get_desired_height ( widget *wid )
box *b = (box *) wid;
int spacing = distance_get_pixel ( b->spacing, b->type );
int height = 0;
if ( b->type == ORIENTATION_VERTICAL) {
if ( b->type == ROFI_ORIENTATION_VERTICAL) {
int active_widgets = 0;
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
widget * child = (widget *) iter->data;
@ -124,7 +124,7 @@ static int box_get_desired_height ( widget *wid )
static void vert_calculate_size ( box *b )
{
int spacing = distance_get_pixel ( b->spacing, ORIENTATION_VERTICAL );
int spacing = distance_get_pixel ( b->spacing, ROFI_ORIENTATION_VERTICAL );
int expanding_widgets = 0;
int active_widgets = 0;
int rem_width = widget_padding_get_remaining_width ( WIDGET ( b ) );
@ -188,7 +188,7 @@ static void vert_calculate_size ( box *b )
}
static void hori_calculate_size ( box *b )
{
int spacing = distance_get_pixel ( b->spacing, ORIENTATION_HORIZONTAL );
int spacing = distance_get_pixel ( b->spacing, ROFI_ORIENTATION_HORIZONTAL );
int expanding_widgets = 0;
int active_widgets = 0;
int rem_width = widget_padding_get_remaining_width ( WIDGET ( b ) );
@ -287,7 +287,7 @@ void box_add ( box *box, widget *child, gboolean expand, int index )
return;
}
// Make sure box is width/heigh enough.
if ( box->type == ORIENTATION_VERTICAL ) {
if ( box->type == ROFI_ORIENTATION_VERTICAL ) {
int width = box->widget.w;
width = MAX ( width, child->w + widget_padding_get_padding_width ( WIDGET ( box ) ) );
box->widget.w = width;
@ -335,7 +335,7 @@ static widget *box_find_mouse_target ( widget *wid, WidgetType type, gint x, gin
return NULL;
}
box * box_create ( const char *name, Orientation type )
box * box_create ( const char *name, RofiOrientation type )
{
box *b = g_malloc0 ( sizeof ( box ) );
// Initialize widget.
@ -361,10 +361,10 @@ static void box_update ( widget *wid )
box *b = (box *) wid;
switch ( b->type )
{
case ORIENTATION_VERTICAL:
case ROFI_ORIENTATION_VERTICAL:
vert_calculate_size ( b );
break;
case ORIENTATION_HORIZONTAL:
case ROFI_ORIENTATION_HORIZONTAL:
default:
hori_calculate_size ( b );
}

View file

@ -197,7 +197,7 @@ static void barview_draw ( widget *wid, cairo_t *draw )
listview *lv = (listview *) wid;
offset = scroll_per_page_barview ( lv );
lv->last_offset = offset;
int spacing_hori = distance_get_pixel ( lv->spacing, ORIENTATION_HORIZONTAL );
int spacing_hori = distance_get_pixel ( lv->spacing, ROFI_ORIENTATION_HORIZONTAL );
int left_offset = widget_padding_get_left ( wid );
int right_offset = lv->widget.w - widget_padding_get_right( wid );
@ -289,8 +289,8 @@ static void listview_draw ( widget *wid, cairo_t *draw )
scrollbar_set_handle ( lv->scrollbar, lv->selected );
}
lv->last_offset = offset;
int spacing_vert = distance_get_pixel ( lv->spacing, ORIENTATION_VERTICAL );
int spacing_hori = distance_get_pixel ( lv->spacing, ORIENTATION_HORIZONTAL );
int spacing_vert = distance_get_pixel ( lv->spacing, ROFI_ORIENTATION_VERTICAL );
int spacing_hori = distance_get_pixel ( lv->spacing, ROFI_ORIENTATION_HORIZONTAL );
int left_offset = widget_padding_get_left ( wid );
int top_offset = widget_padding_get_top ( wid );
@ -411,7 +411,7 @@ static void listview_resize ( widget *wid, short w, short h )
lv->widget.w = MAX ( 0, w );
lv->widget.h = MAX ( 0, h );
int height = lv->widget.h - widget_padding_get_padding_height ( WIDGET ( lv ) );
int spacing_vert = distance_get_pixel ( lv->spacing, ORIENTATION_VERTICAL );
int spacing_vert = distance_get_pixel ( lv->spacing, ROFI_ORIENTATION_VERTICAL );
lv->max_rows = ( spacing_vert + height ) / ( lv->element_height + spacing_vert );
lv->max_elements = lv->max_rows * lv->menu_columns;
@ -736,7 +736,7 @@ static int listview_get_desired_height ( widget *wid )
if ( lv == NULL || lv->widget.enabled == FALSE ) {
return 0;
}
int spacing = distance_get_pixel ( lv->spacing, ORIENTATION_VERTICAL );
int spacing = distance_get_pixel ( lv->spacing, ROFI_ORIENTATION_VERTICAL );
int h = lv->menu_lines;
if ( !( lv->fixed_num_lines ) ) {
if ( lv->dynamic ) {

View file

@ -105,7 +105,7 @@ scrollbar *scrollbar_create ( const char *name )
sb->widget.x = 0;
sb->widget.y = 0;
sb->width = rofi_theme_get_distance ( WIDGET ( sb ), "handle-width", DEFAULT_SCROLLBAR_WIDTH );
int width = distance_get_pixel ( sb->width, ORIENTATION_HORIZONTAL );
int width = distance_get_pixel ( sb->width, ROFI_ORIENTATION_HORIZONTAL );
sb->widget.w = widget_padding_get_padding_width ( WIDGET ( sb ) ) + width;
sb->widget.h = widget_padding_get_padding_height ( WIDGET ( sb ) );

View file

@ -902,7 +902,7 @@ int textbox_get_desired_width ( widget *wid )
return textbox_get_font_width ( tb ) + widget_padding_get_padding_width ( wid ) + offset;
}
RofiDistance w = rofi_theme_get_distance ( WIDGET ( tb ), "width", 0 );
int wi = distance_get_pixel ( w, ORIENTATION_HORIZONTAL );
int wi = distance_get_pixel ( w, ROFI_ORIENTATION_HORIZONTAL );
if ( wi > 0 )
{
return wi;

View file

@ -144,18 +144,18 @@ void widget_draw ( widget *widget, cairo_t *d )
}
// Store current state.
cairo_save ( d );
const int margin_left = distance_get_pixel ( widget->margin.left, ORIENTATION_HORIZONTAL );
const int margin_top = distance_get_pixel ( widget->margin.top, ORIENTATION_VERTICAL );
const int margin_right = distance_get_pixel ( widget->margin.right, ORIENTATION_HORIZONTAL );
const int margin_bottom = distance_get_pixel ( widget->margin.bottom, ORIENTATION_VERTICAL );
const int left = distance_get_pixel ( widget->border.left, ORIENTATION_HORIZONTAL );
const int right = distance_get_pixel ( widget->border.right, ORIENTATION_HORIZONTAL );
const int top = distance_get_pixel ( widget->border.top, ORIENTATION_VERTICAL );
const int bottom = distance_get_pixel ( widget->border.bottom, ORIENTATION_VERTICAL );
int radius_bl = distance_get_pixel ( widget->border_radius.left, ORIENTATION_HORIZONTAL );
int radius_tr = distance_get_pixel ( widget->border_radius.right, ORIENTATION_HORIZONTAL );
int radius_tl = distance_get_pixel ( widget->border_radius.top, ORIENTATION_VERTICAL );
int radius_br = distance_get_pixel ( widget->border_radius.bottom, ORIENTATION_VERTICAL );
const int margin_left = distance_get_pixel ( widget->margin.left, ROFI_ORIENTATION_HORIZONTAL );
const int margin_top = distance_get_pixel ( widget->margin.top, ROFI_ORIENTATION_VERTICAL );
const int margin_right = distance_get_pixel ( widget->margin.right, ROFI_ORIENTATION_HORIZONTAL );
const int margin_bottom = distance_get_pixel ( widget->margin.bottom, ROFI_ORIENTATION_VERTICAL );
const int left = distance_get_pixel ( widget->border.left, ROFI_ORIENTATION_HORIZONTAL );
const int right = distance_get_pixel ( widget->border.right, ROFI_ORIENTATION_HORIZONTAL );
const int top = distance_get_pixel ( widget->border.top, ROFI_ORIENTATION_VERTICAL );
const int bottom = distance_get_pixel ( widget->border.bottom, ROFI_ORIENTATION_VERTICAL );
int radius_bl = distance_get_pixel ( widget->border_radius.left, ROFI_ORIENTATION_HORIZONTAL );
int radius_tr = distance_get_pixel ( widget->border_radius.right, ROFI_ORIENTATION_HORIZONTAL );
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 vspace = widget->h - margin_top - margin_bottom - top / 2.0 - bottom / 2.0;
double hspace = widget->w - margin_left - margin_right - left / 2.0 - right / 2.0;
@ -484,9 +484,9 @@ int widget_padding_get_left ( const widget *wid )
if ( wid == NULL ) {
return 0;
}
int distance = distance_get_pixel ( wid->padding.left, ORIENTATION_HORIZONTAL );
distance += distance_get_pixel ( wid->border.left, ORIENTATION_HORIZONTAL );
distance += distance_get_pixel ( wid->margin.left, ORIENTATION_HORIZONTAL );
int distance = distance_get_pixel ( wid->padding.left, ROFI_ORIENTATION_HORIZONTAL );
distance += distance_get_pixel ( wid->border.left, ROFI_ORIENTATION_HORIZONTAL );
distance += distance_get_pixel ( wid->margin.left, ROFI_ORIENTATION_HORIZONTAL );
return distance;
}
int widget_padding_get_right ( const widget *wid )
@ -494,9 +494,9 @@ int widget_padding_get_right ( const widget *wid )
if ( wid == NULL ) {
return 0;
}
int distance = distance_get_pixel ( wid->padding.right, ORIENTATION_HORIZONTAL );
distance += distance_get_pixel ( wid->border.right, ORIENTATION_HORIZONTAL );
distance += distance_get_pixel ( wid->margin.right, ORIENTATION_HORIZONTAL );
int distance = distance_get_pixel ( wid->padding.right, ROFI_ORIENTATION_HORIZONTAL );
distance += distance_get_pixel ( wid->border.right, ROFI_ORIENTATION_HORIZONTAL );
distance += distance_get_pixel ( wid->margin.right, ROFI_ORIENTATION_HORIZONTAL );
return distance;
}
int widget_padding_get_top ( const widget *wid )
@ -504,9 +504,9 @@ int widget_padding_get_top ( const widget *wid )
if ( wid == NULL ) {
return 0;
}
int distance = distance_get_pixel ( wid->padding.top, ORIENTATION_VERTICAL );
distance += distance_get_pixel ( wid->border.top, ORIENTATION_VERTICAL );
distance += distance_get_pixel ( wid->margin.top, ORIENTATION_VERTICAL );
int distance = distance_get_pixel ( wid->padding.top, ROFI_ORIENTATION_VERTICAL );
distance += distance_get_pixel ( wid->border.top, ROFI_ORIENTATION_VERTICAL );
distance += distance_get_pixel ( wid->margin.top, ROFI_ORIENTATION_VERTICAL );
return distance;
}
int widget_padding_get_bottom ( const widget *wid )
@ -514,9 +514,9 @@ int widget_padding_get_bottom ( const widget *wid )
if ( wid == NULL ) {
return 0;
}
int distance = distance_get_pixel ( wid->padding.bottom, ORIENTATION_VERTICAL );
distance += distance_get_pixel ( wid->border.bottom, ORIENTATION_VERTICAL );
distance += distance_get_pixel ( wid->margin.bottom, ORIENTATION_VERTICAL );
int distance = distance_get_pixel ( wid->padding.bottom, ROFI_ORIENTATION_VERTICAL );
distance += distance_get_pixel ( wid->border.bottom, ROFI_ORIENTATION_VERTICAL );
distance += distance_get_pixel ( wid->margin.bottom, ROFI_ORIENTATION_VERTICAL );
return distance;
}

View file

@ -92,7 +92,7 @@ void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
{
box *b = box_create ( "box", ORIENTATION_HORIZONTAL );
box *b = box_create ( "box", ROFI_ORIENTATION_HORIZONTAL );
//box_set_padding ( b, 5 );
widget_resize ( WIDGET (b), 100, 20);
@ -154,7 +154,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
widget_free ( WIDGET ( b ) );
}
{
box *b = box_create ( "box", ORIENTATION_VERTICAL );
box *b = box_create ( "box", ROFI_ORIENTATION_VERTICAL );
widget_resize ( WIDGET (b), 20, 100);
//box_set_padding ( b, 5 );
@ -215,7 +215,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
widget_free ( WIDGET ( b ) );
}
{
box *b = box_create ( "box", ORIENTATION_VERTICAL );
box *b = box_create ( "box", ROFI_ORIENTATION_VERTICAL );
widget_resize ( WIDGET (b), 20, 90);
//box_set_padding ( b, 5 );
widget *wid1 = g_malloc0(sizeof(widget));