commit 38950329b35f33dd3bc8ccbe565cde6512ff2b51
parent 317ac4bf8168d5b1479ff4e0232704384e6e1df0
Author: lumidify <nobody@lumidify.org>
Date:   Wed,  4 Jan 2017 09:06:21 +0100
Add some more documentation
Diffstat:
5 files changed, 55 insertions(+), 23 deletions(-)
diff --git a/.window.c.swp b/.window.c.swp
Binary files differ.
diff --git a/README.md b/README.md
@@ -1,4 +1,4 @@
-# LTK - Lumidify Toolkit
+# LTK - Lumidify ToolKit
 
 This is work in progress.
 
diff --git a/button.c b/button.c
@@ -23,12 +23,6 @@
 
 #include "ltk.h"
 
-/*
- * Purpose: Extract style information for buttons.
- * Parameters:
- * button_json: A cJSON struct containing the JSON for the button style.
- * Returns: An LtkButtonTheme struct containing the style for a button.
- */
 LtkButtonTheme *ltk_parse_button_theme(cJSON *button_json)
 {
     LtkButtonTheme *button_theme = malloc(sizeof(LtkButtonTheme));
@@ -118,11 +112,6 @@ LtkButtonTheme *ltk_parse_button_theme(cJSON *button_json)
     return button_theme;
 }
 
-/*
- * Purpose: Draw a button in its current state.
- * Parameters:
- * button: Pointer to the button to draw.
- */
 void ltk_draw_button(LtkButton *button)
 {
     LtkButtonTheme *theme = ltk_global->theme->button;
@@ -170,15 +159,6 @@ void ltk_draw_button(LtkButton *button)
     XDrawRectangle(ltk_global->display, window->xwindow, window->gc, rect.x, rect.y, rect.w, rect.h);
 }
 
-/*
- * Purpose:    Create a button widget.
- * Parameters:
- * window:     The window the button will be shown on.
- * text:       The text to be shown on the button.
- * callback:   A function with no parameters or return
- *             type to be called when the button is clicked.
- * Returns:    A pointer to the newly created button.
- */
 LtkButton *ltk_create_button(LtkWindow *window, const char *text, void (*callback)(void))
 {
     LtkButton *button = malloc(sizeof(LtkButton));
@@ -209,6 +189,7 @@ void ltk_destroy_button(void *widget)
     free(button);
 }
 
+/* FIXME: ungrid button if gridded */
 void ltk_button_mouse_release(void *widget, XEvent event)
 {
     LtkButton *button = widget;
diff --git a/button.h b/button.h
@@ -26,6 +26,9 @@
 
 #include "widget.h"
 
+/*
+ * Struct to represent a button widget.
+ */
 typedef struct
 {
     LtkWidget widget;
@@ -33,6 +36,9 @@ typedef struct
     char *text;
 } LtkButton;
 
+/*
+ * Struct to contain all style information for buttons.
+ */
 typedef struct LtkButtonTheme
 {
     int border_width;
@@ -66,12 +72,39 @@ typedef struct LtkButtonTheme
 
 } LtkButtonTheme;
 
+/*
+ * Extract style information for buttons.
+ * button_json: A cJSON struct containing the JSON for the button style.
+ * Returns: An LtkButtonTheme struct containing the style for a button.
+ */
 LtkButtonTheme *ltk_parse_button_theme(cJSON *button_json);
+
+/*
+ * Draw a button in its current state.
+ * button: Pointer to the button to draw.
+ */
 void ltk_draw_button(LtkButton *button);
+
+/*
+ * Create a button widget.
+ * window: The window the button will be shown on.
+ * text: The text to be shown on the button.
+ * callback: The function to be called when the button is clicked.
+ * Returns: A pointer to the newly created button.
+ */
 LtkButton *ltk_create_button(LtkWindow *window, const char *text, void (*callback)(void));
-void ltk_button_key_event(void *widget, XEvent event);
-void ltk_button_mouse_event(void *widget, XEvent event);
+
+/*
+ * Destroy a button.
+ * widget: Pointer to the button.
+ */
 void ltk_destroy_button(void *widget);
+
+/*
+ * Default mouse button release handler for buttons.
+ * widget: Pointer to the button.
+ * event: The event to be handled.
+ */
 void ltk_button_mouse_release(void *widget, XEvent event);
 
 #endif
diff --git a/common.h b/common.h
@@ -27,6 +27,9 @@
 typedef void (*LTK_VOID_FUNC)(void *);
 typedef struct LtkWidget LtkWidget;
 
+/*
+ * An enumeration of all widget states.
+ */
 typedef enum
 {
     LTK_NORMAL,
@@ -37,6 +40,9 @@ typedef enum
     LTK_DISABLED
 } LtkWidgetState;
 
+/*
+ * Struct to represent a rectangle.
+ */
 typedef struct
 {
     int x;
@@ -45,8 +51,20 @@ typedef struct
     int h;
 } LtkRect;
 
+/*
+ * Check if a rectangle collides with a point.
+ * rect: The rectangle.
+ * x: The x coordinate of the point.
+ * y: The y coordinate of the point.
+ */
 int ltk_collide_rect(LtkRect rect, int x, int y);
+
+/*
+ * Read a file and return a null-terminated string with the contents.
+ * path: The path to the file.
+ */
 char *ltk_read_file(const char *path);
+
 void ltk_change_active_widget_state(void *widget, LtkWidgetState state);
 void ltk_remove_active_widget(void *widget);
 void ltk_remove_hover_widget(void *widget);