Position the overlay in the top right corner of the listview.
This commit is contained in:
@@ -306,5 +306,21 @@ int widget_get_desired_height ( widget *wid );
|
||||
* @returns the desired width of the widget in pixels.
|
||||
*/
|
||||
int widget_get_desired_width ( widget *wid );
|
||||
/**
|
||||
* @param wid The widget handle
|
||||
*
|
||||
* Get the absolute x-position on the root widget..
|
||||
*
|
||||
* @returns the absolute x-position of widget of the widget in pixels.
|
||||
*/
|
||||
int widget_get_absolute_xpos ( widget *wid );
|
||||
/**
|
||||
* @param wid The widget handle
|
||||
*
|
||||
* Get the absolute y-position on the root widget..
|
||||
*
|
||||
* @returns the absolute y-position of widget of the widget in pixels.
|
||||
*/
|
||||
int widget_get_absolute_ypos ( widget *wid );
|
||||
/*@}*/
|
||||
#endif // ROFI_WIDGET_H
|
||||
|
@@ -1811,7 +1811,7 @@ Mode * rofi_view_get_mode ( RofiViewState *state )
|
||||
|
||||
void rofi_view_set_overlay ( RofiViewState *state, const char *text )
|
||||
{
|
||||
if ( state->overlay == NULL ) {
|
||||
if ( state->overlay == NULL || state->list_view == NULL ) {
|
||||
return;
|
||||
}
|
||||
if ( text == NULL ) {
|
||||
@@ -1820,16 +1820,12 @@ void rofi_view_set_overlay ( RofiViewState *state, const char *text )
|
||||
}
|
||||
widget_enable ( WIDGET ( state->overlay ) );
|
||||
textbox_text ( state->overlay, text );
|
||||
int x_offset = widget_get_width ( WIDGET ( state->main_window ) );
|
||||
int x_offset = widget_get_width ( WIDGET ( state->list_view ) );
|
||||
// Within padding of window.
|
||||
x_offset -= widget_padding_get_right ( WIDGET ( state->main_window ) );
|
||||
// Within the border of widget.
|
||||
//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_absolute_xpos ( WIDGET ( state->list_view ) );
|
||||
x_offset -= widget_get_width ( WIDGET ( state->overlay ) );
|
||||
int top_offset = widget_padding_get_top ( WIDGET ( state->main_window ) );
|
||||
//top_offset += widget_padding_get_top ( WIDGET ( state->main_box ) );
|
||||
// Within the border of widget.
|
||||
int top_offset = widget_get_absolute_ypos ( WIDGET ( state->list_view ) );
|
||||
widget_move ( WIDGET ( state->overlay ), x_offset, top_offset );
|
||||
// We want to queue a repaint.
|
||||
rofi_view_queue_redraw ( );
|
||||
|
@@ -569,3 +569,26 @@ int widget_get_desired_width ( widget *wid )
|
||||
}
|
||||
return wid->w;
|
||||
}
|
||||
|
||||
int widget_get_absolute_xpos ( widget *wid )
|
||||
{
|
||||
int retv = 0;
|
||||
if ( wid ) {
|
||||
retv += wid->x;
|
||||
if ( wid->parent ) {
|
||||
retv += widget_get_absolute_xpos ( wid->parent );
|
||||
}
|
||||
}
|
||||
return retv;
|
||||
}
|
||||
int widget_get_absolute_ypos ( widget *wid )
|
||||
{
|
||||
int retv = 0;
|
||||
if ( wid ) {
|
||||
retv += wid->y;
|
||||
if ( wid->parent ) {
|
||||
retv += widget_get_absolute_ypos ( wid->parent );
|
||||
}
|
||||
}
|
||||
return retv;
|
||||
}
|
||||
|
Reference in New Issue
Block a user