2017-04-15 10:32:05 +00:00
|
|
|
/*
|
2016-10-08 16:57:59 +00:00
|
|
|
* rofi
|
|
|
|
*
|
|
|
|
* MIT/X11 License
|
2020-01-01 11:23:12 +00:00
|
|
|
* Copyright © 2013-2020 Qball Cow <qball@gmpclient.org>
|
2016-10-08 16:57:59 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2017-04-15 10:32:05 +00:00
|
|
|
*
|
2016-10-08 16:57:59 +00:00
|
|
|
*/
|
|
|
|
|
2018-06-12 09:45:42 +00:00
|
|
|
/** The log domain of this widget. */
|
2017-04-27 20:59:14 +00:00
|
|
|
#define G_LOG_DOMAIN "Widgets.Box"
|
2017-04-15 09:58:49 +00:00
|
|
|
|
2016-10-08 16:57:59 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include <stdio.h>
|
2016-10-09 08:13:15 +00:00
|
|
|
#include "widgets/widget.h"
|
|
|
|
#include "widgets/widget-internal.h"
|
2016-10-08 16:57:59 +00:00
|
|
|
#include "widgets/box.h"
|
2016-12-11 11:19:46 +00:00
|
|
|
#include "theme.h"
|
2016-10-08 16:57:59 +00:00
|
|
|
|
2017-01-01 17:08:49 +00:00
|
|
|
/** Default spacing used in the box*/
|
2017-01-08 20:36:06 +00:00
|
|
|
#define DEFAULT_SPACING 2
|
2017-01-01 14:39:02 +00:00
|
|
|
|
2016-10-08 16:57:59 +00:00
|
|
|
struct _box
|
|
|
|
{
|
2017-06-03 18:35:50 +00:00
|
|
|
widget widget;
|
2017-06-02 14:34:52 +00:00
|
|
|
RofiOrientation type;
|
2017-06-03 18:35:50 +00:00
|
|
|
int max_size;
|
2017-06-02 14:44:16 +00:00
|
|
|
// RofiPadding between elements
|
2017-06-03 18:35:50 +00:00
|
|
|
RofiDistance spacing;
|
2016-10-08 16:57:59 +00:00
|
|
|
|
2017-06-03 18:35:50 +00:00
|
|
|
GList *children;
|
2016-10-08 16:57:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void box_update ( widget *wid );
|
|
|
|
|
2017-05-28 14:10:11 +00:00
|
|
|
static int box_get_desired_width ( widget *wid )
|
|
|
|
{
|
|
|
|
box *b = (box *) wid;
|
2017-06-02 12:05:19 +00:00
|
|
|
int spacing = distance_get_pixel ( b->spacing, b->type );
|
2017-06-03 18:35:50 +00:00
|
|
|
int width = 0;
|
2017-12-08 09:48:22 +00:00
|
|
|
|
|
|
|
// Allow user to override.
|
2018-08-08 13:55:13 +00:00
|
|
|
RofiDistance w = rofi_theme_get_distance ( wid, "width", 0 );
|
2017-12-08 09:48:22 +00:00
|
|
|
width = distance_get_pixel ( w, ROFI_ORIENTATION_HORIZONTAL );
|
|
|
|
if ( width > 0 ) {
|
2018-08-08 13:55:13 +00:00
|
|
|
return width;
|
2017-12-08 09:48:22 +00:00
|
|
|
}
|
|
|
|
|
2017-06-02 14:34:52 +00:00
|
|
|
if ( b->type == ROFI_ORIENTATION_HORIZONTAL ) {
|
2017-05-28 14:10:11 +00:00
|
|
|
int active_widgets = 0;
|
|
|
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
|
|
|
if ( !child->enabled ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
active_widgets++;
|
|
|
|
if ( child->expand == TRUE ) {
|
|
|
|
width += widget_get_desired_width ( child );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
width += widget_get_desired_width ( child );
|
|
|
|
}
|
|
|
|
if ( active_widgets > 0 ) {
|
|
|
|
width += ( active_widgets - 1 ) * 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;
|
|
|
|
}
|
|
|
|
width = MAX ( widget_get_desired_width ( child ), width );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
width += widget_padding_get_padding_width ( wid );
|
|
|
|
return width;
|
|
|
|
}
|
2016-12-30 17:31:30 +00:00
|
|
|
static int box_get_desired_height ( widget *wid )
|
|
|
|
{
|
2017-03-04 18:41:06 +00:00
|
|
|
box *b = (box *) wid;
|
2017-06-02 12:05:19 +00:00
|
|
|
int spacing = distance_get_pixel ( b->spacing, b->type );
|
2017-03-04 18:41:06 +00:00
|
|
|
int height = 0;
|
2017-06-03 18:35:50 +00:00
|
|
|
if ( b->type == ROFI_ORIENTATION_VERTICAL ) {
|
2017-03-04 18:41:06 +00:00
|
|
|
int active_widgets = 0;
|
2016-12-30 18:59:45 +00:00
|
|
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
|
|
|
if ( !child->enabled ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
active_widgets++;
|
2016-12-30 17:31:30 +00:00
|
|
|
height += widget_get_desired_height ( child );
|
|
|
|
}
|
2017-01-08 20:36:06 +00:00
|
|
|
if ( active_widgets > 0 ) {
|
|
|
|
height += ( active_widgets - 1 ) * spacing;
|
2016-12-30 18:59:45 +00:00
|
|
|
}
|
2017-01-08 20:36:06 +00:00
|
|
|
}
|
|
|
|
else {
|
2016-12-30 18:59:45 +00:00
|
|
|
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 );
|
|
|
|
}
|
2016-12-30 17:31:30 +00:00
|
|
|
}
|
2016-12-30 18:59:45 +00:00
|
|
|
height += widget_padding_get_padding_height ( wid );
|
2016-12-30 17:31:30 +00:00
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
2016-10-08 16:57:59 +00:00
|
|
|
static void vert_calculate_size ( box *b )
|
|
|
|
{
|
2017-06-02 14:34:52 +00:00
|
|
|
int spacing = distance_get_pixel ( b->spacing, ROFI_ORIENTATION_VERTICAL );
|
2016-10-08 16:57:59 +00:00
|
|
|
int expanding_widgets = 0;
|
|
|
|
int active_widgets = 0;
|
2017-01-08 20:36:06 +00:00
|
|
|
int rem_width = widget_padding_get_remaining_width ( WIDGET ( b ) );
|
|
|
|
int rem_height = widget_padding_get_remaining_height ( WIDGET ( b ) );
|
2016-12-30 17:31:30 +00:00
|
|
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
2017-01-08 20:36:06 +00:00
|
|
|
if ( child->enabled && child->expand == FALSE ) {
|
|
|
|
widget_resize ( child, rem_width, widget_get_desired_height ( child ) );
|
2016-12-30 17:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-08 16:57:59 +00:00
|
|
|
b->max_size = 0;
|
|
|
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
|
|
|
if ( !child->enabled ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
active_widgets++;
|
|
|
|
if ( child->expand == TRUE ) {
|
|
|
|
expanding_widgets++;
|
|
|
|
continue;
|
|
|
|
}
|
2017-01-08 20:36:06 +00:00
|
|
|
if ( child->h > 0 ) {
|
2016-12-30 17:31:30 +00:00
|
|
|
b->max_size += child->h;
|
|
|
|
}
|
2016-10-08 16:57:59 +00:00
|
|
|
}
|
2017-01-08 20:36:06 +00:00
|
|
|
if ( active_widgets > 0 ) {
|
2017-01-03 13:25:24 +00:00
|
|
|
b->max_size += ( active_widgets - 1 ) * spacing;
|
2016-12-28 18:42:14 +00:00
|
|
|
}
|
2016-12-27 21:19:15 +00:00
|
|
|
if ( b->max_size > rem_height ) {
|
2016-12-30 17:31:30 +00:00
|
|
|
b->max_size = rem_height;
|
2017-04-15 09:37:50 +00:00
|
|
|
g_debug ( "Widgets to large (height) for box: %d %d", b->max_size, b->widget.h );
|
2016-10-08 16:57:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( active_widgets > 0 ) {
|
2017-01-08 20:36:06 +00:00
|
|
|
int top = widget_padding_get_top ( WIDGET ( b ) );
|
|
|
|
double rem = rem_height - b->max_size;
|
|
|
|
int index = 0;
|
2016-10-08 16:57:59 +00:00
|
|
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
|
|
|
if ( child->enabled == FALSE ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ( child->expand == TRUE ) {
|
|
|
|
// Re-calculate to avoid round issues leaving one pixel left.
|
|
|
|
int expanding_widgets_size = ( rem ) / ( expanding_widgets - index );
|
2017-01-06 15:41:23 +00:00
|
|
|
widget_move ( child, widget_padding_get_left ( WIDGET ( b ) ), top );
|
|
|
|
top += expanding_widgets_size;
|
|
|
|
widget_resize ( child, rem_width, expanding_widgets_size );
|
|
|
|
top += spacing;
|
2016-10-08 16:57:59 +00:00
|
|
|
rem -= expanding_widgets_size;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
else {
|
2016-12-29 16:25:24 +00:00
|
|
|
widget_move ( child, widget_padding_get_left ( WIDGET ( b ) ), top );
|
2016-10-08 16:57:59 +00:00
|
|
|
top += widget_get_height ( child );
|
2017-01-03 13:25:24 +00:00
|
|
|
top += spacing;
|
2016-10-08 16:57:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-08 20:36:06 +00:00
|
|
|
b->max_size += widget_padding_get_padding_height ( WIDGET ( b ) );
|
2016-10-08 16:57:59 +00:00
|
|
|
}
|
|
|
|
static void hori_calculate_size ( box *b )
|
|
|
|
{
|
2017-06-02 14:34:52 +00:00
|
|
|
int spacing = distance_get_pixel ( b->spacing, ROFI_ORIENTATION_HORIZONTAL );
|
2016-10-08 16:57:59 +00:00
|
|
|
int expanding_widgets = 0;
|
|
|
|
int active_widgets = 0;
|
2017-01-08 20:36:06 +00:00
|
|
|
int rem_width = widget_padding_get_remaining_width ( WIDGET ( b ) );
|
|
|
|
int rem_height = widget_padding_get_remaining_height ( WIDGET ( b ) );
|
2016-12-30 17:31:30 +00:00
|
|
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
2017-01-08 20:36:06 +00:00
|
|
|
if ( child->enabled && child->expand == FALSE ) {
|
2017-05-28 14:10:11 +00:00
|
|
|
widget_resize ( child,
|
2017-06-03 18:35:50 +00:00
|
|
|
widget_get_desired_width ( child ), //child->w,
|
|
|
|
rem_height );
|
2016-12-30 17:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-08 16:57:59 +00:00
|
|
|
b->max_size = 0;
|
|
|
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
|
|
|
if ( !child->enabled ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
active_widgets++;
|
|
|
|
if ( child->expand == TRUE ) {
|
|
|
|
expanding_widgets++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Size used by fixed width widgets.
|
2017-01-08 20:36:06 +00:00
|
|
|
if ( child->h > 0 ) {
|
|
|
|
b->max_size += child->w;
|
2016-12-30 17:31:30 +00:00
|
|
|
}
|
2016-10-08 16:57:59 +00:00
|
|
|
}
|
2017-01-03 13:25:24 +00:00
|
|
|
b->max_size += MAX ( 0, ( ( active_widgets - 1 ) * spacing ) );
|
2017-01-08 20:36:06 +00:00
|
|
|
if ( b->max_size > ( rem_width ) ) {
|
2016-12-30 17:31:30 +00:00
|
|
|
b->max_size = rem_width;
|
2017-04-15 09:37:50 +00:00
|
|
|
g_debug ( "Widgets to large (width) for box: %d %d", b->max_size, b->widget.w );
|
2020-05-13 15:17:15 +00:00
|
|
|
//return;
|
2016-10-08 16:57:59 +00:00
|
|
|
}
|
|
|
|
if ( active_widgets > 0 ) {
|
2017-01-08 20:36:06 +00:00
|
|
|
int left = widget_padding_get_left ( WIDGET ( b ) );
|
2016-12-27 21:19:15 +00:00
|
|
|
double rem = rem_width - b->max_size;
|
2016-10-08 16:57:59 +00:00
|
|
|
int index = 0;
|
2020-05-13 15:17:15 +00:00
|
|
|
if ( rem < 0 ) rem = 0;
|
2016-10-08 16:57:59 +00:00
|
|
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
|
|
|
if ( child->enabled == FALSE ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ( child->expand == TRUE ) {
|
|
|
|
// Re-calculate to avoid round issues leaving one pixel left.
|
|
|
|
int expanding_widgets_size = ( rem ) / ( expanding_widgets - index );
|
2017-01-06 15:41:23 +00:00
|
|
|
widget_move ( child, left, widget_padding_get_top ( WIDGET ( b ) ) );
|
|
|
|
left += expanding_widgets_size;
|
|
|
|
widget_resize ( child, expanding_widgets_size, rem_height );
|
|
|
|
left += spacing;
|
2017-01-08 20:36:06 +00:00
|
|
|
rem -= expanding_widgets_size;
|
2016-10-08 16:57:59 +00:00
|
|
|
index++;
|
|
|
|
}
|
|
|
|
else {
|
2016-12-29 16:25:24 +00:00
|
|
|
widget_move ( child, left, widget_padding_get_top ( WIDGET ( b ) ) );
|
2016-10-08 16:57:59 +00:00
|
|
|
left += widget_get_width ( child );
|
2017-01-03 13:25:24 +00:00
|
|
|
left += spacing;
|
2016-10-08 16:57:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-29 16:25:24 +00:00
|
|
|
b->max_size += widget_padding_get_padding_width ( WIDGET ( b ) );
|
2016-10-08 16:57:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void box_draw ( widget *wid, cairo_t *draw )
|
|
|
|
{
|
|
|
|
box *b = (box *) wid;
|
|
|
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
|
|
|
widget_draw ( child, draw );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void box_free ( widget *wid )
|
|
|
|
{
|
|
|
|
box *b = (box *) wid;
|
|
|
|
|
|
|
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
|
|
|
widget_free ( child );
|
|
|
|
}
|
2016-10-18 11:49:24 +00:00
|
|
|
g_list_free ( b->children );
|
2016-10-08 16:57:59 +00:00
|
|
|
g_free ( b );
|
|
|
|
}
|
|
|
|
|
2017-06-02 14:53:39 +00:00
|
|
|
void box_add ( box *box, widget *child, gboolean expand )
|
2016-10-08 16:57:59 +00:00
|
|
|
{
|
2016-10-18 11:49:24 +00:00
|
|
|
if ( box == NULL ) {
|
|
|
|
return;
|
|
|
|
}
|
2016-12-27 23:37:32 +00:00
|
|
|
// Make sure box is width/heigh enough.
|
2017-06-02 14:34:52 +00:00
|
|
|
if ( box->type == ROFI_ORIENTATION_VERTICAL ) {
|
2017-01-08 20:36:06 +00:00
|
|
|
int width = box->widget.w;
|
|
|
|
width = MAX ( width, child->w + widget_padding_get_padding_width ( WIDGET ( box ) ) );
|
2016-12-27 23:37:32 +00:00
|
|
|
box->widget.w = width;
|
2017-01-08 20:36:06 +00:00
|
|
|
}
|
|
|
|
else {
|
2016-12-27 23:37:32 +00:00
|
|
|
int height = box->widget.h;
|
2017-01-08 20:36:06 +00:00
|
|
|
height = MAX ( height, child->h + widget_padding_get_padding_height ( WIDGET ( box ) ) );
|
2016-12-27 23:37:32 +00:00
|
|
|
box->widget.h = height;
|
|
|
|
}
|
2017-01-08 20:36:06 +00:00
|
|
|
child->expand = rofi_theme_get_boolean ( child, "expand", expand );
|
2017-09-07 11:46:09 +00:00
|
|
|
g_assert ( child->parent == WIDGET ( box ) );
|
2016-11-27 15:02:37 +00:00
|
|
|
box->children = g_list_append ( box->children, (void *) child );
|
2016-10-08 16:57:59 +00:00
|
|
|
widget_update ( WIDGET ( box ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void box_resize ( widget *widget, short w, short h )
|
|
|
|
{
|
|
|
|
box *b = (box *) widget;
|
|
|
|
if ( b->widget.w != w || b->widget.h != h ) {
|
|
|
|
b->widget.w = w;
|
|
|
|
b->widget.h = h;
|
|
|
|
widget_update ( widget );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-30 10:37:11 +00:00
|
|
|
static widget *box_find_mouse_target ( widget *wid, WidgetType type, gint x, gint y )
|
2016-10-08 16:57:59 +00:00
|
|
|
{
|
|
|
|
box *b = (box *) wid;
|
|
|
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
|
|
|
if ( !child->enabled ) {
|
|
|
|
continue;
|
|
|
|
}
|
2017-05-30 10:37:11 +00:00
|
|
|
if ( widget_intersect ( child, x, y ) ) {
|
|
|
|
gint rx = x - child->x;
|
|
|
|
gint ry = y - child->y;
|
|
|
|
widget *target = widget_find_mouse_target ( child, type, rx, ry );
|
2017-05-28 00:18:09 +00:00
|
|
|
if ( target != NULL ) {
|
|
|
|
return target;
|
|
|
|
}
|
2016-10-25 19:19:39 +00:00
|
|
|
}
|
|
|
|
}
|
2017-05-28 00:18:09 +00:00
|
|
|
return NULL;
|
2016-10-25 19:19:39 +00:00
|
|
|
}
|
2016-10-08 16:57:59 +00:00
|
|
|
|
2020-05-13 14:25:12 +00:00
|
|
|
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 ) ) {
|
|
|
|
widget * child = (widget *) iter->data;
|
|
|
|
widget_set_state ( child, state );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-07 11:46:09 +00:00
|
|
|
box * box_create ( widget *parent, const char *name, RofiOrientation type )
|
2016-10-08 16:57:59 +00:00
|
|
|
{
|
|
|
|
box *b = g_malloc0 ( sizeof ( box ) );
|
2016-12-27 21:19:15 +00:00
|
|
|
// Initialize widget.
|
2017-09-07 11:46:09 +00:00
|
|
|
widget_init ( WIDGET ( b ), parent, WIDGET_TYPE_UNKNOWN, name );
|
2016-12-30 17:31:30 +00:00
|
|
|
b->type = type;
|
|
|
|
b->widget.draw = box_draw;
|
|
|
|
b->widget.free = box_free;
|
|
|
|
b->widget.resize = box_resize;
|
|
|
|
b->widget.update = box_update;
|
2017-05-28 00:18:09 +00:00
|
|
|
b->widget.find_mouse_target = box_find_mouse_target;
|
2016-12-30 17:31:30 +00:00
|
|
|
b->widget.get_desired_height = box_get_desired_height;
|
2017-05-28 14:10:11 +00:00
|
|
|
b->widget.get_desired_width = box_get_desired_width;
|
2020-05-13 14:25:12 +00:00
|
|
|
b->widget.set_state = box_set_state;
|
2016-10-08 16:57:59 +00:00
|
|
|
|
2017-06-03 18:35:50 +00:00
|
|
|
b->type = rofi_theme_get_orientation ( WIDGET ( b ), "orientation", b->type );
|
2017-05-26 18:23:46 +00:00
|
|
|
|
2017-01-08 20:36:06 +00:00
|
|
|
b->spacing = rofi_theme_get_distance ( WIDGET ( b ), "spacing", DEFAULT_SPACING );
|
2016-10-08 16:57:59 +00:00
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void box_update ( widget *wid )
|
|
|
|
{
|
|
|
|
box *b = (box *) wid;
|
|
|
|
switch ( b->type )
|
|
|
|
{
|
2017-06-02 14:34:52 +00:00
|
|
|
case ROFI_ORIENTATION_VERTICAL:
|
2016-10-08 16:57:59 +00:00
|
|
|
vert_calculate_size ( b );
|
|
|
|
break;
|
2017-06-02 14:34:52 +00:00
|
|
|
case ROFI_ORIENTATION_HORIZONTAL:
|
2016-10-08 16:57:59 +00:00
|
|
|
default:
|
|
|
|
hori_calculate_size ( b );
|
|
|
|
}
|
2019-11-07 11:44:20 +00:00
|
|
|
if ( wid->parent ) {
|
|
|
|
widget_update ( wid->parent );
|
|
|
|
}
|
2016-10-08 16:57:59 +00:00
|
|
|
}
|