mirror of
https://github.com/davatorium/rofi.git
synced 2025-01-27 15:25:24 -05:00
cleanup some of sizing logic.
This commit is contained in:
parent
df74540624
commit
37d99378dd
3 changed files with 41 additions and 23 deletions
|
@ -168,6 +168,21 @@ void listview_set_mouse_activated_cb ( listview *lv, listview_mouse_activated_cb
|
|||
* Enable,disable multi-select.
|
||||
*/
|
||||
void listview_set_multi_select ( listview *lv, gboolean enable );
|
||||
/**
|
||||
* @param lv Handler to the listview object.
|
||||
* @param num_lines the maximum number of lines to display.
|
||||
*
|
||||
* Set the maximum number of lines to display.
|
||||
*/
|
||||
void listview_set_num_lines ( listview *lv, unsigned int num_lines );
|
||||
|
||||
/**
|
||||
* @param lv Handler to the listview object.
|
||||
* @param max_lines the maximum number of lines to display.
|
||||
*
|
||||
* Set the maximum number of lines to display.
|
||||
*/
|
||||
void listview_set_max_lines ( listview *lv, unsigned int max_lines );
|
||||
/* @} */
|
||||
|
||||
#endif // ROFI_LISTVIEW_H
|
||||
|
|
|
@ -308,6 +308,7 @@ static void rofi_view_window_update_size ( RofiViewState * state )
|
|||
CacheState.edit_surf = cairo_xcb_surface_create ( xcb->connection, CacheState.edit_pixmap, visual, state->width, state->height );
|
||||
CacheState.edit_draw = cairo_create ( CacheState.edit_surf );
|
||||
|
||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Re-size window based internal request: %dx%d.", state->width, state->height );
|
||||
// Should wrap main window in a widget.
|
||||
widget_resize ( WIDGET ( state->main_window ), state->width, state->height );
|
||||
}
|
||||
|
@ -888,6 +889,7 @@ static void _rofi_view_reload_row ( RofiViewState *state )
|
|||
state->num_lines = mode_get_num_entries ( state->sw );
|
||||
state->line_map = g_malloc0_n ( state->num_lines, sizeof ( unsigned int ) );
|
||||
state->distance = g_malloc0_n ( state->num_lines, sizeof ( int ) );
|
||||
listview_set_max_lines ( state->list_view, state->num_lines );
|
||||
}
|
||||
|
||||
static void rofi_view_refilter ( RofiViewState *state )
|
||||
|
@ -971,7 +973,9 @@ static void rofi_view_refilter ( RofiViewState *state )
|
|||
state->retv = MENU_OK;
|
||||
state->quit = TRUE;
|
||||
}
|
||||
if ( config.fixed_num_lines == FALSE && ( CacheState.flags & MENU_NORMAL_WINDOW ) == 0 ) {
|
||||
|
||||
// Make sure we enable fixed num lines when in normal window mode.
|
||||
if ( (CacheState.flags&MENU_NORMAL_WINDOW) == 0 ){
|
||||
int height = rofi_view_calculate_height ( state );
|
||||
if ( height != state->height ) {
|
||||
state->height = height;
|
||||
|
@ -1269,6 +1273,7 @@ void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *ev, xkb_st
|
|||
|
||||
CacheState.edit_surf = cairo_xcb_surface_create ( xcb->connection, CacheState.edit_pixmap, visual, state->width, state->height );
|
||||
CacheState.edit_draw = cairo_create ( CacheState.edit_surf );
|
||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Re-size window based external request: %d %d\n", state->width, state->height);
|
||||
widget_resize ( WIDGET ( state->main_window ), state->width, state->height );
|
||||
}
|
||||
}
|
||||
|
@ -1494,40 +1499,26 @@ RofiViewState *rofi_view_create ( Mode *sw,
|
|||
listview_set_multi_select ( state->list_view, ( state->menu_flags & MENU_INDICATOR ) == MENU_INDICATOR );
|
||||
listview_set_scroll_type ( state->list_view, config.scroll_method );
|
||||
listview_set_mouse_activated_cb ( state->list_view, rofi_view_listview_mouse_activated_cb, state );
|
||||
listview_set_num_lines ( state->list_view, config.menu_lines );
|
||||
listview_set_max_lines ( state->list_view, state->num_lines );
|
||||
|
||||
box_add ( state->main_box, WIDGET ( state->list_view ), TRUE, FALSE );
|
||||
|
||||
|
||||
|
||||
// Height of a row.
|
||||
if ( config.menu_lines == 0 || config.fullscreen ) {
|
||||
state->height = CacheState.mon.h;
|
||||
// Autosize it.
|
||||
config.fixed_num_lines = TRUE;
|
||||
}
|
||||
|
||||
// filtered list
|
||||
state->line_map = g_malloc0_n ( state->num_lines, sizeof ( unsigned int ) );
|
||||
state->distance = (int *) g_malloc0_n ( state->num_lines, sizeof ( int ) );
|
||||
|
||||
// Make sure we enable fixed num lines when in normal window mode.
|
||||
if ( (CacheState.flags&MENU_NORMAL_WINDOW) == MENU_NORMAL_WINDOW){
|
||||
config.fixed_num_lines = TRUE;
|
||||
}
|
||||
|
||||
rofi_view_calculate_window_width ( state );
|
||||
state->height = rofi_view_calculate_height ( state );
|
||||
|
||||
// Only needed when window is fixed size.
|
||||
if (( CacheState.flags & MENU_NORMAL_WINDOW ) == MENU_NORMAL_WINDOW ) {
|
||||
config.fixed_num_lines = TRUE;
|
||||
rofi_view_window_update_size ( state );
|
||||
}
|
||||
// Move the window to the correct x,y position.
|
||||
rofi_view_calculate_window_position ( state );
|
||||
|
||||
rofi_view_window_update_size ( state );
|
||||
// Update.
|
||||
//state->selected = 0;
|
||||
|
||||
state->quit = FALSE;
|
||||
rofi_view_refilter ( state );
|
||||
|
||||
rofi_view_update ( state, TRUE );
|
||||
xcb_map_window ( xcb->connection, CacheState.main_window );
|
||||
widget_queue_redraw ( WIDGET ( state->main_window ) );
|
||||
|
|
|
@ -58,6 +58,7 @@ struct _listview
|
|||
|
||||
unsigned int spacing;
|
||||
unsigned int menu_lines;
|
||||
unsigned int max_displayed_lines;
|
||||
unsigned int menu_columns;
|
||||
unsigned int fixed_num_lines;
|
||||
unsigned int eh;
|
||||
|
@ -352,7 +353,6 @@ listview *listview_create ( const char *name, listview_update_callback cb, void
|
|||
|
||||
// Some settings.
|
||||
lv->spacing = distance_get_pixel (rofi_theme_get_distance (lv->widget.class_name, lv->widget.name, NULL, "spacing", DEFAULT_SPACING ));
|
||||
lv->menu_lines = rofi_theme_get_integer (lv->widget.class_name, lv->widget.name, NULL, "lines", config.menu_lines );
|
||||
lv->menu_columns = rofi_theme_get_integer (lv->widget.class_name, lv->widget.name, NULL, "columns", config.menu_columns);
|
||||
lv->fixed_num_lines = rofi_theme_get_boolean (lv->widget.class_name, lv->widget.name, NULL, "fixed-height", config.fixed_num_lines );
|
||||
listview_set_show_scrollbar ( lv, rofi_theme_get_boolean ( lv->widget.class_name, lv->widget.name, NULL, "scrollbar", !config.hide_scrollbar ));
|
||||
|
@ -511,3 +511,15 @@ void listview_set_multi_select ( listview *lv, gboolean enable )
|
|||
lv->multi_select = enable;
|
||||
}
|
||||
}
|
||||
void listview_set_num_lines ( listview *lv, unsigned int num_lines )
|
||||
{
|
||||
if ( lv ) {
|
||||
lv->menu_lines = num_lines;
|
||||
}
|
||||
}
|
||||
void listview_set_max_lines ( listview *lv, unsigned int max_lines )
|
||||
{
|
||||
if ( lv ) {
|
||||
lv->max_displayed_lines = max_lines;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue