Remove border-width property from window.

This commit is contained in:
Dave Davenport 2017-01-03 15:57:40 +01:00
parent 861b52a523
commit b60ca07f1f
4 changed files with 15 additions and 44 deletions

View file

@ -30,14 +30,5 @@ window * window_create ( const char *name );
* Add a widget to the window.
*/
void window_add ( window *window, widget *child );
/**
* @param window Handle to the window widget.
*
* Get the border width of the widget.
*
* @returns the border width (times 2) of the widget.
*/
int window_get_border_width ( const window *window );
/*@}*/
#endif // ROFI_WINDOW_H

View file

@ -432,17 +432,18 @@ void rofi_theme_convert_old_theme ( void )
}
{
// Border width.
ThemeWidget *window_widget = rofi_theme_find_or_create_class ( rofi_theme , "@window" );
ThemeWidget *window_widget = rofi_theme_find_or_create_class ( rofi_theme , "window" );
window_widget->properties = rofi_theme_convert_create_property_ht ( );
Property *p = rofi_theme_property_create ( P_INTEGER );
p->name = g_strdup("border-width");
p->value.i = config.menu_bw;
g_hash_table_replace ( window_widget->properties, p->name, p );
// Padding
p = rofi_theme_property_create ( P_INTEGER );
Property *p = rofi_theme_property_create ( P_INTEGER );
p->name = g_strdup("padding");
p->value.i = config.padding;
g_hash_table_replace ( window_widget->properties, p->name, p );
p = rofi_theme_property_create ( P_INTEGER );
p->name = g_strdup("border");
p->value.i = config.menu_bw;
g_hash_table_replace ( window_widget->properties, p->name, p );
}
{
gchar **vals = g_strsplit ( config.color_window, ",", 3 );

View file

@ -666,7 +666,7 @@ static void rofi_view_calculate_window_width ( RofiViewState *state )
else if ( config.menu_width < 0 ) {
double fw = textbox_get_estimated_char_width ( );
state->width = -( fw * config.menu_width );
state->width += window_get_border_width ( state->main_window );
state->width += widget_padding_get_padding_width ( WIDGET ( state->main_window ) );
}
else{
// Calculate as float to stop silly, big rounding down errors.
@ -1556,8 +1556,7 @@ int rofi_view_error_dialog ( const char *msg, int markup )
widget_resize ( WIDGET ( state->main_window ), state->width, 100);
unsigned int line_height = textbox_get_height ( state->text );
// resize window vertically to suit
state->height = line_height + window_get_border_width ( state->main_window);
state->height = widget_padding_get_padding_height ( WIDGET(state->main_window) );
state->height = line_height + widget_padding_get_padding_height ( WIDGET(state->main_window) );
// Calculte window position.
rofi_view_calculate_window_position ( state );
@ -1678,13 +1677,11 @@ void rofi_view_set_overlay ( RofiViewState *state, const char *text )
// Within padding of window.
x_offset -= widget_padding_get_right ( WIDGET (state->main_window) );
// Within the border of widget.
x_offset -= window_get_border_width ( state->main_window );
x_offset -= widget_padding_get_right ( WIDGET (state->main_box ) );
x_offset -= widget_padding_get_right ( WIDGET (state->input_bar ) );
x_offset -= widget_get_width ( WIDGET ( state->case_indicator ) );
x_offset -= widget_get_width ( WIDGET ( state->overlay ) );
int top_offset = window_get_border_width ( state->main_window );
top_offset += widget_padding_get_top ( WIDGET (state->main_window) );
int top_offset = widget_padding_get_top ( WIDGET (state->main_window) );
top_offset += widget_padding_get_top ( WIDGET (state->main_box ) );
widget_move ( WIDGET ( state->overlay ), x_offset, top_offset );
// We want to queue a repaint.

View file

@ -50,7 +50,6 @@ struct _window
{
widget widget;
widget *child;
int border_width;
};
static void window_update ( widget *wid );
@ -59,7 +58,7 @@ static void window_update ( widget *wid );
static int window_get_desired_height ( widget *widget )
{
window *b = (window *) widget;
int height = b->border_width*2;
int height = 0;
if ( b->child ) {
height += widget_get_desired_height ( b->child );
}
@ -72,16 +71,6 @@ static void window_draw ( widget *wid, cairo_t *draw )
{
window *b = (window *) wid;
cairo_save ( draw );
rofi_theme_get_color ( "@window", "window" , NULL, "foreground", draw );
cairo_set_line_width ( draw, b->border_width );
cairo_rectangle ( draw,
b->border_width / 2.0,
b->border_width / 2.0,
wid->w - b->border_width,
wid->h - b->border_width );
cairo_stroke ( draw );
cairo_restore ( draw );
widget_draw ( b->child, draw );
}
@ -149,9 +138,6 @@ window * window_create ( const char *name )
b->widget.motion_notify = window_motion_notify;
b->widget.get_desired_height = window_get_desired_height;
b->widget.enabled = TRUE;
b->border_width = rofi_theme_get_integer (
b->widget.class_name, b->widget.name, NULL, "border-width" , DEFAULT_BORDER_WIDTH);
return b;
}
@ -160,17 +146,13 @@ static void window_update ( widget *wid )
window *b = (window *) wid;
if ( b->child && b->child->enabled ){
widget_resize ( WIDGET ( b->child ),
widget_padding_get_remaining_width (WIDGET(b))-2*b->border_width,
widget_padding_get_remaining_height (WIDGET(b))-2*b->border_width
widget_padding_get_remaining_width (WIDGET(b)),
widget_padding_get_remaining_height (WIDGET(b))
);
widget_move ( WIDGET ( b->child ),
b->border_width+widget_padding_get_left (WIDGET(b)),
b->border_width+widget_padding_get_top (WIDGET(b))
widget_padding_get_left (WIDGET(b)),
widget_padding_get_top (WIDGET(b))
);
}
}
int window_get_border_width ( const window *window )
{
return window->border_width*2;
}