Remove separator

This commit is contained in:
Dave Davenport 2017-01-05 22:07:50 +01:00
parent fb59be5d72
commit f2a4049991
6 changed files with 0 additions and 223 deletions

View File

@ -43,7 +43,6 @@ rofi_SOURCES=\
source/widgets/textbox.c\
source/widgets/listview.c\
source/widgets/scrollbar.c\
source/widgets/separator.c\
source/xrmoptions.c\
source/x11-helper.c\
source/dialogs/run.c\
@ -76,7 +75,6 @@ rofi_SOURCES=\
include/widgets/textbox.h\
include/widgets/listview.h\
include/widgets/scrollbar.h\
include/widgets/separator.h\
include/xrmoptions.h\
include/x11-helper.h\
include/dialogs/ssh.h\

View File

@ -20,7 +20,6 @@ List of names in **rofi**:
* `#window.mainbox.box`: The main vertical @box
* `#window.mainbox.inputbar`
* `#window.mainbox.inputbar.box`: The horizontal @box packing the widgets.
* `#window.mainbox.inputbar.separator`: The separator under/above the inputbar.
* `#window.mainbox.inputbar.case-indicator`: The case/sort indicator @textbox
* `#window.mainbox.inputbar.prompt`: The prompt @textbox
* `#window.mainbox.inputbar.entry`: The main entry @textbox
@ -30,10 +29,8 @@ List of names in **rofi**:
* `#window.mainbox.sidebar`
* `#window.mainbox.sidebar.box`: The main horizontal @box packing the buttons.
* `#window.mainbox.sidebar.button`: The buttons @textbox for each mode.
* `#window.mainbox.sidebar.separator`: The separator under/above the sidebar.
* `#window.mainbox.message`
* `#window.mainbox.message.textbox`: The message textbox.
* `#window.mainbox.message.separator`: The separator under/above the sidebar.
* `#window.mainbox.message.box`: The box containing the message.
## State

View File

@ -3,7 +3,6 @@
#include "widgets/container.h"
#include "widgets/widget.h"
#include "widgets/textbox.h"
#include "widgets/separator.h"
#include "widgets/listview.h"
#include "widgets/box.h"
#include "keyb.h"
@ -36,8 +35,6 @@ struct RofiViewState
textbox *text;
/** #textbox showing the state of the case sensitive and sortng. */
textbox *case_indicator;
/** #separator widget below the input bar. */
separator *input_bar_separator;
/** #listview holding the displayed elements. */
listview *list_view;

View File

@ -1,51 +0,0 @@
#ifndef ROFI_SEPARATOR_H
#define ROFI_SEPARATOR_H
#include <cairo.h>
#include "widget.h"
/**
* @defgroup separator separator
* @ingroup widget
*
* Displays a horizontal separator line. The height of the widget determines the line width.
*
* @{
*/
/**
* Abstract handle to the separator widget internal state.
*/
typedef struct _separator separator;
/**
* Direction of the separator.
*/
typedef enum
{
S_HORIZONTAL = 0,
S_VERTICAL = 1
} separator_type;
/**
* The style of the separator line.
*/
typedef enum
{
S_LINE_NONE,
S_LINE_SOLID,
S_LINE_DASH
} separator_line_style;
/**
* @param name The name of the widget.
* @param type The type of separator.
* @param sw The thickness of the separator.
*
* Create a horizontal separator with height h.
*
* @returns a new separator, free with ::widget_free
*/
separator *separator_create ( const char *name, separator_type type, short sw );
/*@}*/
#endif // ROFI_SEPARATOR_H

View File

@ -1382,11 +1382,9 @@ static int rofi_view_calculate_height ( RofiViewState *state )
return height;
}
if ( state->filtered_lines == 0 && !config.fixed_num_lines ) {
widget_disable ( WIDGET ( state->input_bar_separator ) );
widget_disable ( WIDGET ( state->list_view) );
}
else {
widget_enable ( WIDGET ( state->input_bar_separator ) );
widget_enable ( WIDGET ( state->list_view) );
}

View File

@ -1,162 +0,0 @@
/**
* MIT/X11 License
* Modified (c) 2016-2017 Qball Cow <qball@gmpclient.org>
*
* 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.
*/
#include <config.h>
#include <xkbcommon/xkbcommon.h>
#include <glib.h>
#include <string.h>
#include "widgets/widget.h"
#include "widgets/widget-internal.h"
#include "widgets/separator.h"
#include "x11-helper.h"
#include "theme.h"
/**
* @param sp The separator widget handle.
* @param style_str String representation of the style.
*
* Sets the line style based on the string style_str
*/
void separator_set_line_style_from_string ( separator *sp, const char *style_str );
/**
* @param sp The separator widget handle.
* @param style The new style.
*
* Sets the line style.
*/
void separator_set_line_style ( separator *sp, separator_line_style style );
/**
* Internal structure for the separator.
*/
struct _separator
{
widget widget;
separator_type type;
separator_line_style line_style;
int separator_width;
};
/** Configuration value for separator style indicating no line */
const char *const _separator_style_none = "none";
/** Configuration value for separator style indicating dashed line. */
const char *const _separator_style_dash = "dash";
static void separator_draw ( widget *, cairo_t * );
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 *sb = g_malloc0 ( sizeof ( separator ) );
widget_init ( WIDGET (sb), name );
sb->type = type;
sb->separator_width = sw;
sb->widget.x = 0;
sb->widget.y = 0;
if ( sb->type == S_HORIZONTAL ) {
sb->widget.w = 1;
sb->widget.h = MAX ( 1, sw )+widget_padding_get_padding_height ( WIDGET (sb) );
}
else {
sb->widget.h = 1;
sb->widget.w = MAX ( 1, sw )+widget_padding_get_padding_width ( WIDGET ( sb ) );
}
sb->widget.draw = separator_draw;
sb->widget.free = separator_free;
sb->widget.get_desired_height = separator_get_desired_height;
// Enabled by default
sb->widget.enabled = TRUE;
const char *line_style = rofi_theme_get_string ( WIDGET (sb), "line-style", "solid");
separator_set_line_style_from_string ( sb, line_style );
return sb;
}
static void separator_free ( widget *wid )
{
separator *sb = (separator *) wid;
g_free ( sb );
}
void separator_set_line_style ( separator *sp, separator_line_style style )
{
if ( sp ) {
sp->line_style = style;
widget_need_redraw ( WIDGET ( sp ) );
}
}
void separator_set_line_style_from_string ( separator *sp, const char *style_str )
{
if ( !sp ) {
return;
}
separator_line_style style = S_LINE_SOLID;
if ( g_strcmp0 ( style_str, _separator_style_none ) == 0 ) {
style = S_LINE_NONE;
}
else if ( g_strcmp0 ( style_str, _separator_style_dash ) == 0 ) {
style = S_LINE_DASH;
}
separator_set_line_style ( sp, style );
}
static void separator_draw ( widget *wid, cairo_t *draw )
{
separator *sep = (separator *) wid;
if ( sep->line_style == S_LINE_NONE ) {
// Nothing to draw.
return;
}
color_separator ( draw );
rofi_theme_get_color ( wid, "foreground", draw );
if ( sep->line_style == S_LINE_DASH ) {
const double dashes[1] = { 4 };
cairo_set_dash ( draw, dashes, 1, 0.0 );
}
if ( sep->type == S_HORIZONTAL ) {
int height= widget_padding_get_remaining_height ( wid );
cairo_set_line_width ( draw, height );
double half = height / 2.0;
cairo_move_to ( draw, widget_padding_get_left ( wid ), widget_padding_get_top ( wid ) + half );
cairo_line_to ( draw, wid->w-widget_padding_get_right ( wid ), widget_padding_get_top ( wid ) + half );
}
else {
int width = widget_padding_get_remaining_width ( wid );
cairo_set_line_width ( draw, width);
double half = width / 2.0;
cairo_move_to ( draw, widget_padding_get_left ( wid ) + half, widget_padding_get_top ( wid ));
cairo_line_to ( draw, widget_padding_get_left ( wid ) + half, wid->h-widget_padding_get_bottom ( wid ) );
}
cairo_stroke ( draw );
}