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

Make separator work in both directions ( hori/vert ).

This commit is contained in:
Dave Davenport 2016-10-09 10:07:32 +02:00
parent ad02f8f0b7
commit f10bc5004f
6 changed files with 73 additions and 43 deletions

View file

@ -45,7 +45,7 @@ box * box_create ( boxType type, short x, short y, short w, short h );
* @param end If the child widget should be packed at the end.
*
* Add a widget to the box.
*/
*/
void box_add ( box *box, widget *child, gboolean expand, gboolean end );
/**
@ -53,7 +53,7 @@ void box_add ( box *box, widget *child, gboolean expand, gboolean end );
*
* Obtains the minimal size required to display all widgets. (expanding widgets are not counted, except for their
* padding)
*
*
* @returns the minimum size in pixels.
*/
int box_get_fixed_pixels ( box *box );

View file

@ -14,13 +14,24 @@
typedef struct _separator separator;
/**
* @param h The height of the separator.
* Direction of the separator.
*/
typedef enum
{
S_HORIZONTAL = 0,
S_VERTICAL = 1
} separator_type;
/**
* @param type The type of separator.
* @param sw The thickness of the separator.
*
* Create a horizontal separator with height h.
*
* @returns a new separator, free with ::widget_free
*/
separator *separator_create ( short h );
separator *separator_create ( separator_type type, short sw );
/*@}*/
#endif // ROFI_SEPARATOR_H

View file

@ -38,16 +38,16 @@ typedef struct
typedef enum
{
TB_AUTOHEIGHT = 1 << 0,
TB_AUTOWIDTH = 1 << 1,
TB_LEFT = 1 << 16,
TB_RIGHT = 1 << 17,
TB_CENTER = 1 << 18,
TB_EDITABLE = 1 << 19,
TB_MARKUP = 1 << 20,
TB_WRAP = 1 << 21,
TB_PASSWORD = 1 << 22,
TB_INDICATOR = 1 << 23,
TB_AUTOHEIGHT = 1 << 0,
TB_AUTOWIDTH = 1 << 1,
TB_LEFT = 1 << 16,
TB_RIGHT = 1 << 17,
TB_CENTER = 1 << 18,
TB_EDITABLE = 1 << 19,
TB_MARKUP = 1 << 20,
TB_WRAP = 1 << 21,
TB_PASSWORD = 1 << 22,
TB_INDICATOR = 1 << 23,
} TextboxFlags;
typedef enum

View file

@ -73,9 +73,9 @@ struct xkb_stuff xkb = {
.keymap = NULL,
.state = NULL,
.compose = {
.table = NULL,
.state = NULL
}
.table = NULL,
.state = NULL
}
};
char *config_path = NULL;
// Array of modi.
@ -456,22 +456,22 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
break;
case XCB_XKB_STATE_NOTIFY:
{
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
guint modmask;
xkb_state_update_mask ( xkb.state,
ksne->baseMods,
ksne->latchedMods,
ksne->lockedMods,
ksne->baseGroup,
ksne->latchedGroup,
ksne->lockedGroup );
modmask = x11_get_current_mask ( &xkb );
if ( modmask == 0 ) {
abe_trigger_release ( );
}
break;
{
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
guint modmask;
xkb_state_update_mask ( xkb.state,
ksne->baseMods,
ksne->latchedMods,
ksne->lockedMods,
ksne->baseGroup,
ksne->latchedGroup,
ksne->lockedGroup );
modmask = x11_get_current_mask ( &xkb );
if ( modmask == 0 ) {
abe_trigger_release ( );
}
break;
}
}
return G_SOURCE_CONTINUE;
}

View file

@ -1388,7 +1388,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
state->input_bar = box_create ( BOX_HORIZONTAL, 0, 0, state->width - state->border, line_height );
box_set_padding ( state->input_bar, config.line_margin );
state->input_bar_separator = separator_create ( 2 );
state->input_bar_separator = separator_create ( S_HORIZONTAL, 2 );
if ( ( config.location == WL_EAST_SOUTH || config.location == WL_SOUTH || config.location == WL_SOUTH_WEST ) ) {
box_add ( state->main_box, WIDGET ( state->input_bar_separator ), FALSE, TRUE );
@ -1400,6 +1400,8 @@ RofiViewState *rofi_view_create ( Mode *sw,
}
state->case_indicator = textbox_create ( TB_AUTOWIDTH, 0, 0, 0, line_height, NORMAL, "*" );
// Add small separator between case indicator and text box.
/* box_add ( state->input_bar, WIDGET( separator_create ( S_VERTICAL, 2 ) ), FALSE, TRUE );*/
box_add ( state->input_bar, WIDGET ( state->case_indicator ), FALSE, TRUE );
// Prompt box.
@ -1419,7 +1421,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
textbox *message_tb = textbox_create ( TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, 0, 0,
state->width - ( 2 * ( state->border ) ), -1, NORMAL, message );
box_add ( state->main_box, WIDGET ( message_tb ), FALSE, FALSE );
box_add ( state->main_box, WIDGET ( separator_create ( 2 ) ), FALSE, FALSE );
box_add ( state->main_box, WIDGET ( separator_create ( S_HORIZONTAL, 2 ) ), FALSE, FALSE );
}
state->overlay = textbox_create ( TB_AUTOWIDTH, 0, 0, 20, line_height, URGENT, "blaat" );
@ -1444,7 +1446,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
if ( config.sidebar_mode ) {
state->sidebar_bar = box_create ( BOX_HORIZONTAL, 0, 0, state->width - 2 * state->border, line_height );
box_set_padding ( state->sidebar_bar, config.line_margin );
box_add ( state->main_box, WIDGET ( separator_create ( 2 ) ), FALSE, TRUE );
box_add ( state->main_box, WIDGET ( separator_create ( S_HORIZONTAL, 2 ) ), FALSE, TRUE );
box_add ( state->main_box, WIDGET ( state->sidebar_bar ), FALSE, TRUE );
state->num_modi = rofi_get_num_enabled_modi ();
state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) );

View file

@ -35,7 +35,8 @@
*/
struct _separator
{
widget widget;
widget widget;
separator_type type;
};
const char *const _separator_style_none = "none";
@ -43,14 +44,21 @@ const char *const _separator_style_dash = "dash";
static void separator_draw ( widget *, cairo_t * );
static void separator_free ( widget * );
separator *separator_create ( short h )
separator *separator_create ( separator_type type, short sw )
{
separator *sb = g_malloc0 ( sizeof ( separator ) );
sb->type = type;
sb->widget.x = 0;
sb->widget.y = 0;
sb->widget.w = 1;
sb->widget.h = MAX ( 1, h );
if ( sb->type == S_HORIZONTAL ) {
sb->widget.w = 1;
sb->widget.h = MAX ( 1, sw );
}
else {
sb->widget.h = 1;
sb->widget.w = MAX ( 1, sw );
}
sb->widget.draw = separator_draw;
sb->widget.free = separator_free;
@ -68,16 +76,25 @@ static void separator_free ( widget *wid )
static void separator_draw ( widget *wid, cairo_t *draw )
{
separator *sep = (separator *) wid;
if ( strcmp ( config.separator_style, _separator_style_none ) ) {
cairo_set_line_width ( draw, wid->h );
color_separator ( draw );
if ( strcmp ( config.separator_style, _separator_style_dash ) == 0 ) {
const double dashes[1] = { 4 };
cairo_set_dash ( draw, dashes, 1, 0.0 );
}
double half = wid->h / 2.0;
cairo_move_to ( draw, wid->x, wid->y + half );
cairo_line_to ( draw, wid->x + wid->w, wid->y + half );
if ( sep->type == S_HORIZONTAL ) {
cairo_set_line_width ( draw, wid->h );
double half = wid->h / 2.0;
cairo_move_to ( draw, wid->x, wid->y + half );
cairo_line_to ( draw, wid->x + wid->w, wid->y + half );
}
else {
cairo_set_line_width ( draw, wid->w );
double half = wid->w / 2.0;
cairo_move_to ( draw, wid->x + half, wid->y );
cairo_line_to ( draw, wid->x + half, wid->y + wid->h );
}
cairo_stroke ( draw );
}
}