summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-01-09 16:22:09 +0100
committerDave Davenport <qball@gmpclient.org>2016-01-09 16:22:09 +0100
commitd7dab65e5b89f2a223fba00c62accee2d5313609 (patch)
treeb1eb366a352f7ff07672c09d351fb98986fe367a /include
parent06c7f30b7e39775698ab241583adb0b23d4ac4bd (diff)
Making widget class, moving stuff around
Diffstat (limited to 'include')
-rw-r--r--include/rofi.h8
-rw-r--r--include/scrollbar.h12
-rw-r--r--include/textbox.h12
-rw-r--r--include/widget.h47
-rw-r--r--include/x11-helper.h1
5 files changed, 53 insertions, 27 deletions
diff --git a/include/rofi.h b/include/rofi.h
index 424f483e..316d4cb5 100644
--- a/include/rofi.h
+++ b/include/rofi.h
@@ -1,21 +1,15 @@
#ifndef ROFI_MAIN_H
#define ROFI_MAIN_H
#include <X11/X.h>
+#include <X11/Xlib.h>
#include <glib.h>
#include <string.h>
#include <stdlib.h>
-#include "textbox.h"
-#include <cairo.h>
-#include <cairo-xlib.h>
#include "timings.h"
#include "keyb.h"
#include "mode.h"
/**
- * @defgroup Widgets Widgets
- */
-
-/**
* @defgroup Main Main
* @{
*/
diff --git a/include/scrollbar.h b/include/scrollbar.h
index e3312854..960d241c 100644
--- a/include/scrollbar.h
+++ b/include/scrollbar.h
@@ -1,6 +1,7 @@
#ifndef ROFI_SCROLLBAR_H
#define ROFI_SCROLLBAR_H
#include <cairo.h>
+#include "widget.h"
/**
* @defgroup Scrollbar Scrollbar
@@ -13,7 +14,7 @@
*/
typedef struct _scrollbar
{
- short x, y, w, h;
+ Widget widget;
unsigned int length;
unsigned int pos;
unsigned int pos_length;
@@ -89,14 +90,5 @@ unsigned int scrollbar_clicked ( scrollbar *sb, int y );
*/
void scrollbar_resize ( scrollbar *sb, int w, int h );
-/**
- * @param sb scrollbar object
- * @param x x pos in pixels
- * @param y y pos in pixels
- *
- * Move the scrollbar.
- */
-void scrollbar_move ( scrollbar *sb, int x, int y );
-
/*@}*/
#endif // ROFI_SCROLLBAR_H
diff --git a/include/textbox.h b/include/textbox.h
index daa57aff..94fdcb7b 100644
--- a/include/textbox.h
+++ b/include/textbox.h
@@ -6,6 +6,7 @@
#include <pango/pango-fontmap.h>
#include <pango/pangocairo.h>
#include <cairo.h>
+#include "widget.h"
/**
* @defgroup Textbox Textbox
@@ -21,8 +22,8 @@ typedef struct
typedef struct
{
+ Widget widget;
unsigned long flags;
- short x, y, w, h;
short cursor;
Color color_fg, color_bg;
char *text;
@@ -127,15 +128,6 @@ void textbox_cursor_end ( textbox *tb );
void textbox_cursor ( textbox *tb, int pos );
/**
- * @param tb Handle to the textbox
- * @param x The new x coordinate to move the window to
- * @param y The new y coordinate to move the window to
- *
- * Move the window to x,y position.
- */
-void textbox_move ( textbox *tb, int x, int y );
-
-/**
* @param tb Handle to the textbox
* @param pos The position to insert the string at
* @param str The string to insert.
diff --git a/include/widget.h b/include/widget.h
new file mode 100644
index 00000000..5540260a
--- /dev/null
+++ b/include/widget.h
@@ -0,0 +1,47 @@
+#ifndef ROFI_WIDGET_H
+#define ROFI_WIDGET_H
+
+/**
+ * @defgroup Widgets Widgets
+ *
+ * Generic Widget class
+ *
+ * @{
+ */
+typedef struct _Widget
+{
+ /** X position relative to parent */
+ short x;
+ /** Y position relative to parent */
+ short y;
+ /** Width of the widget */
+ short w;
+ /** Height of the widget */
+ short h;
+} Widget;
+
+/** Macro to get widget from an implementation (e.g. textbox/scrollbar) */
+#define WIDGET(a) (a != NULL?&(a->widget):NULL)
+
+/**
+ * @param widget The widget to check
+ * @param x The X position relative to parent window
+ * @param y the Y position relative to parent window
+ *
+ * Check if x,y falls within the widget.
+ *
+ * @return TRUE if x,y falls within the widget
+ */
+int widget_intersect ( const Widget *widget, int x, int y);
+
+/**
+ * @param widget The widget to move
+ * @param x The new X position relative to parent window
+ * @param y The new Y position relative to parent window
+ *
+ * Moves the widget.
+ */
+void widget_move(Widget *widget, short x, short y);
+
+/*@}*/
+#endif // ROFI_WIDGET_H
diff --git a/include/x11-helper.h b/include/x11-helper.h
index d8a7ecbc..b075feeb 100644
--- a/include/x11-helper.h
+++ b/include/x11-helper.h
@@ -1,5 +1,6 @@
#ifndef X11_ROFI_HELPER_H
#define X11_ROFI_HELPER_H
+#include <cairo.h>
/**
* @defgroup X11Helper X11Helper