1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-03 04:23:42 -05:00
rofi/source/widgets/separator.c
Dave Davenport 3c64507f02 Qtk widgets (#478)
* Initial support for using boxes for packing widgets.

* Make CapiTalIzation more consistent

* Move widgets to subdirectory

* Removed nolonger needed resize function.

* Small cleanup

* When switching mode, reuse view, don't rebuild it. Reduces artifacts.

* Needs cleaning up.

* Remove separate prompt argument, use display_name

* Simplify run-switcher code.

* Add notion of parents, and trigger parent update on resize.

* Use widget_get_height wrapper, avoid crash

* Size separator width based on height. (indent)

 * TODO add margin to box.

* First draft version of listview.

* Add scrollbar to listview widget

* Add padding option to box

* Move access to global config out of widget. (1/2 done)

*  Remove printf

* Make listview not access global config

* Add click support, implement on mode buttons.

* Re-introduce mouse handling on list-view.

* TODO draggin on scrollbar.

* Fix multi-select

* Fix warnings

* Fix include
2016-10-08 18:57:59 +02:00

84 lines
2.6 KiB
C

/**
* MIT/X11 License
* Modified (c) 2016 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/separator.h"
#include "x11-helper.h"
#include "settings.h"
/**
* Internal structure for the separator.
*/
struct _separator
{
widget widget;
};
const char *const _separator_style_none = "none";
const char *const _separator_style_dash = "dash";
static void separator_draw ( widget *, cairo_t * );
static void separator_free ( widget * );
separator *separator_create ( short h )
{
separator *sb = g_malloc0 ( sizeof ( separator ) );
sb->widget.x = 0;
sb->widget.y = 0;
sb->widget.w = 1;
sb->widget.h = MAX ( 1, h );
sb->widget.draw = separator_draw;
sb->widget.free = separator_free;
// Enabled by default
sb->widget.enabled = TRUE;
return sb;
}
static void separator_free ( widget *wid )
{
separator *sb = (separator *) wid;
g_free ( sb );
}
static void separator_draw ( widget *wid, cairo_t *draw )
{
if ( strcmp ( config.separator_style, _separator_style_none ) ) {
cairo_set_line_width ( draw, wid->h );
color_separator ( draw );
if ( strcmp ( config.separator_style, _separator_style_dash ) == 0 ) {
const double dashes[1] = { 4 };
cairo_set_dash ( draw, dashes, 1, 0.0 );
}
double half = wid->h / 2.0;
cairo_move_to ( draw, wid->x, wid->y + half );
cairo_line_to ( draw, wid->x + wid->w, wid->y + half );
cairo_stroke ( draw );
}
}