mirror of
https://github.com/davatorium/rofi.git
synced 2025-02-03 15:34:54 -05:00
Fix more sizing issues
This commit is contained in:
parent
eafd4697a2
commit
2bfbb464e6
6 changed files with 57 additions and 14 deletions
|
@ -60,22 +60,33 @@ static int box_get_desired_height ( widget *wid )
|
||||||
{
|
{
|
||||||
box *b = (box *)wid;
|
box *b = (box *)wid;
|
||||||
int active_widgets = 0;
|
int active_widgets = 0;
|
||||||
int height = widget_padding_get_padding_height ( wid );
|
int height = 0;
|
||||||
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
if ( b->type == BOX_VERTICAL ){
|
||||||
widget * child = (widget *) iter->data;
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
||||||
if ( !child->enabled ) {
|
widget * child = (widget *) iter->data;
|
||||||
continue;
|
if ( !child->enabled ) {
|
||||||
}
|
continue;
|
||||||
active_widgets++;
|
}
|
||||||
if ( child->expand == TRUE ) {
|
active_widgets++;
|
||||||
|
if ( child->expand == TRUE ) {
|
||||||
|
height += widget_get_desired_height ( child );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
height += widget_get_desired_height ( child );
|
height += widget_get_desired_height ( child );
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
height += child->h;
|
if ( active_widgets > 0 ){
|
||||||
}
|
height += (active_widgets - 1)*b->spacing;
|
||||||
if ( active_widgets > 0 ){
|
}
|
||||||
height += (active_widgets - 1)*b->spacing;
|
} else {
|
||||||
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
||||||
|
widget * child = (widget *) iter->data;
|
||||||
|
if ( !child->enabled ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
height = MAX ( widget_get_desired_height ( child ), height );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
height += widget_padding_get_padding_height ( wid );
|
||||||
|
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,13 @@ static void scrollbar_draw ( widget *, cairo_t * );
|
||||||
static void scrollbar_free ( widget * );
|
static void scrollbar_free ( widget * );
|
||||||
static gboolean scrollbar_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme );
|
static gboolean scrollbar_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme );
|
||||||
|
|
||||||
|
|
||||||
|
static int scrollbar_get_desired_height ( widget *wid )
|
||||||
|
{
|
||||||
|
// Want height we are.
|
||||||
|
return wid->h;
|
||||||
|
}
|
||||||
|
|
||||||
scrollbar *scrollbar_create ( const char *name, int width )
|
scrollbar *scrollbar_create ( const char *name, int width )
|
||||||
{
|
{
|
||||||
scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
|
scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
|
||||||
|
@ -47,6 +54,7 @@ scrollbar *scrollbar_create ( const char *name, int width )
|
||||||
sb->widget.draw = scrollbar_draw;
|
sb->widget.draw = scrollbar_draw;
|
||||||
sb->widget.free = scrollbar_free;
|
sb->widget.free = scrollbar_free;
|
||||||
sb->widget.motion_notify = scrollbar_motion_notify;
|
sb->widget.motion_notify = scrollbar_motion_notify;
|
||||||
|
sb->widget.get_desired_height = scrollbar_get_desired_height;
|
||||||
|
|
||||||
sb->length = 10;
|
sb->length = 10;
|
||||||
sb->pos = 0;
|
sb->pos = 0;
|
||||||
|
|
|
@ -58,6 +58,7 @@ struct _separator
|
||||||
widget widget;
|
widget widget;
|
||||||
separator_type type;
|
separator_type type;
|
||||||
separator_line_style line_style;
|
separator_line_style line_style;
|
||||||
|
int separator_width;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Configuration value for separator style indicating no line */
|
/** Configuration value for separator style indicating no line */
|
||||||
|
@ -67,11 +68,20 @@ const char *const _separator_style_dash = "dash";
|
||||||
static void separator_draw ( widget *, cairo_t * );
|
static void separator_draw ( widget *, cairo_t * );
|
||||||
static void separator_free ( widget * );
|
static void separator_free ( widget * );
|
||||||
|
|
||||||
|
static int separator_get_desired_height ( widget *wid )
|
||||||
|
{
|
||||||
|
separator *sb = (separator *)wid;
|
||||||
|
int height = sb->separator_width;
|
||||||
|
height += widget_padding_get_padding_height ( WIDGET (sb) );
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
separator *separator_create ( const char *name, separator_type type, short sw )
|
separator *separator_create ( const char *name, separator_type type, short sw )
|
||||||
{
|
{
|
||||||
separator *sb = g_malloc0 ( sizeof ( separator ) );
|
separator *sb = g_malloc0 ( sizeof ( separator ) );
|
||||||
widget_init ( WIDGET (sb), name, SEPARATOR_CLASS_NAME );
|
widget_init ( WIDGET (sb), name, SEPARATOR_CLASS_NAME );
|
||||||
sb->type = type;
|
sb->type = type;
|
||||||
|
sb->separator_width = sw;
|
||||||
sb->widget.x = 0;
|
sb->widget.x = 0;
|
||||||
sb->widget.y = 0;
|
sb->widget.y = 0;
|
||||||
if ( sb->type == S_HORIZONTAL ) {
|
if ( sb->type == S_HORIZONTAL ) {
|
||||||
|
@ -85,6 +95,7 @@ separator *separator_create ( const char *name, separator_type type, short sw )
|
||||||
|
|
||||||
sb->widget.draw = separator_draw;
|
sb->widget.draw = separator_draw;
|
||||||
sb->widget.free = separator_free;
|
sb->widget.free = separator_free;
|
||||||
|
sb->widget.get_desired_height = separator_get_desired_height;
|
||||||
|
|
||||||
// Enabled by default
|
// Enabled by default
|
||||||
sb->widget.enabled = TRUE;
|
sb->widget.enabled = TRUE;
|
||||||
|
|
|
@ -77,6 +77,15 @@ static void textbox_resize ( widget *wid, short w, short h )
|
||||||
textbox *tb = (textbox *) wid;
|
textbox *tb = (textbox *) wid;
|
||||||
textbox_moveresize ( tb, tb->widget.x, tb->widget.y, w, h );
|
textbox_moveresize ( tb, tb->widget.x, tb->widget.y, w, h );
|
||||||
}
|
}
|
||||||
|
static int textbox_get_desired_height ( widget *wid )
|
||||||
|
{
|
||||||
|
textbox *tb = (textbox *)wid;
|
||||||
|
if ( tb->flags & TB_AUTOHEIGHT )
|
||||||
|
{
|
||||||
|
return tb->widget.h;
|
||||||
|
}
|
||||||
|
return textbox_get_height (tb);
|
||||||
|
}
|
||||||
|
|
||||||
textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text )
|
textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text )
|
||||||
{
|
{
|
||||||
|
@ -89,6 +98,7 @@ textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType
|
||||||
tb->widget.resize = textbox_resize;
|
tb->widget.resize = textbox_resize;
|
||||||
tb->widget.get_width = textbox_get_width;
|
tb->widget.get_width = textbox_get_width;
|
||||||
tb->widget.get_height = _textbox_get_height;
|
tb->widget.get_height = _textbox_get_height;
|
||||||
|
tb->widget.get_desired_height = textbox_get_desired_height;
|
||||||
tb->flags = flags;
|
tb->flags = flags;
|
||||||
|
|
||||||
tb->changed = FALSE;
|
tb->changed = FALSE;
|
||||||
|
|
|
@ -66,6 +66,7 @@ void widget_enable ( widget *widget )
|
||||||
if ( widget && !widget->enabled ) {
|
if ( widget && !widget->enabled ) {
|
||||||
widget->enabled = TRUE;
|
widget->enabled = TRUE;
|
||||||
widget_update ( widget );
|
widget_update ( widget );
|
||||||
|
widget_update ( widget->parent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void widget_disable ( widget *widget )
|
void widget_disable ( widget *widget )
|
||||||
|
@ -73,6 +74,7 @@ void widget_disable ( widget *widget )
|
||||||
if ( widget && widget->enabled ) {
|
if ( widget && widget->enabled ) {
|
||||||
widget->enabled = FALSE;
|
widget->enabled = FALSE;
|
||||||
widget_update ( widget );
|
widget_update ( widget );
|
||||||
|
widget_update ( widget->parent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void widget_draw ( widget *widget, cairo_t *d )
|
void widget_draw ( widget *widget, cairo_t *d )
|
||||||
|
@ -269,7 +271,7 @@ int widget_padding_get_padding_width ( const widget *wid )
|
||||||
|
|
||||||
int widget_get_desired_height ( widget *wid )
|
int widget_get_desired_height ( widget *wid )
|
||||||
{
|
{
|
||||||
if ( wid->get_desired_height )
|
if ( wid && wid->get_desired_height )
|
||||||
{
|
{
|
||||||
return wid->get_desired_height ( wid );
|
return wid->get_desired_height ( wid );
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ static int window_get_desired_height ( widget *widget )
|
||||||
if ( b->child ) {
|
if ( b->child ) {
|
||||||
height += widget_get_desired_height ( b->child );
|
height += widget_get_desired_height ( b->child );
|
||||||
}
|
}
|
||||||
|
height += widget_padding_get_padding_height ( widget );
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue