TTK as a library

This commit is contained in:
Kevin Lange 2013-02-12 00:04:31 -08:00
parent afa3750144
commit a8020854e4
4 changed files with 67 additions and 31 deletions

View File

@ -41,6 +41,7 @@ class CCompiler(object):
'"lib/shmemfonts.h"': (None, 'lib/shmemfonts.o', ['"lib/graphics.h"', '<ft2build.h>']),
'"lib/wcwidth.h"': (None, 'lib/wcwidth.o', []),
'"lib/window.h"': (None, 'lib/window.o', ['"lib/pthread.h"', '"lib/list.h"']),
'"gui/ttk/ttk.h"': (None, 'gui/ttk/lib/ttk-core.o', ['"lib/decorations.h"', '<cairo.h>', '<math.h>']),
}
def __init__(self, filename):

View File

@ -6,15 +6,8 @@
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <cairo.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_CACHE_H
#include "lib/window.h"
#include "lib/graphics.h"
#include "lib/decorations.h"
#include "lib/shmemfonts.h"
#include "gui/ttk/ttk.h"
/* TTK {{{ */
@ -29,21 +22,6 @@ void cairo_rounded_rectangle(cairo_t * cr, double x, double y, double width, dou
cairo_close_path(cr);
}
typedef struct ttk_window {
window_t * core_window;
gfx_context_t * core_context;
char * title;
cairo_surface_t * cairo_surface;
uint16_t width; /* internal space */
uint16_t height;
uint16_t off_x; /* decor_left_width */
uint16_t off_y; /* decor_top_height */
} ttk_window_t;
#define TTK_BACKGROUND_DEFAULT 204,204,204
#define TTK_DEFAULT_X 300
#define TTK_DEFAULT_Y 300
list_t * ttk_window_list;
void ttk_redraw_borders(ttk_window_t * window) {
@ -447,11 +425,3 @@ done:
}
/* }}} end TTK */
int main (int argc, char ** argv) {
ttk_initialize();
ttk_window_t * main_window = ttk_window_new("TTK Demo", 500, 500);
return ttk_run(main_window);
}

View File

@ -0,0 +1,17 @@
/*
*
* Toolkit Demo and Development Application
*
*/
#include <stdlib.h>
#include <assert.h>
#include "gui/ttk/ttk.h"
int main (int argc, char ** argv) {
ttk_initialize();
ttk_window_t * main_window = ttk_window_new("TTK Demo", 500, 500);
return ttk_run(main_window);
}

48
userspace/gui/ttk/ttk.h Normal file
View File

@ -0,0 +1,48 @@
#ifndef _TTK_H
#define _TTK_H
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <cairo.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_CACHE_H
#include "lib/window.h"
#include "lib/graphics.h"
#include "lib/decorations.h"
#include "lib/shmemfonts.h"
typedef struct ttk_window {
window_t * core_window;
gfx_context_t * core_context;
char * title;
cairo_surface_t * cairo_surface;
uint16_t width; /* internal space */
uint16_t height;
uint16_t off_x; /* decor_left_width */
uint16_t off_y; /* decor_top_height */
} ttk_window_t;
#define TTK_BACKGROUND_DEFAULT 204,204,204
#define TTK_DEFAULT_X 300
#define TTK_DEFAULT_Y 300
void cairo_rounded_rectangle(cairo_t * cr, double x, double y, double width, double height, double radius);
void ttk_redraw_borders(ttk_window_t * window);
void _ttk_draw_button(cairo_t * cr, int x, int y, int width, int height);
void _ttk_draw_button_hover(cairo_t * cr, int x, int y, int width, int height);
void _ttk_draw_button_select(cairo_t * cr, int x, int y, int width, int height);
void _ttk_draw_button_disabled(cairo_t * cr, int x, int y, int width, int height);
void _ttk_draw_menu(cairo_t * cr, int x, int y, int width);
void ttk_window_draw(ttk_window_t * window);
void ttk_resize_callback(window_t * window);
void ttk_focus_callback(window_t * window);
void ttk_initialize();
ttk_window_t * ttk_window_new(char * title, uint16_t width, uint16_t height);
void ttk_quit();
int ttk_run(ttk_window_t * window);
#endif