Commit 50c00218 authored by Cedric Roux's avatar Cedric Roux
Browse files

space widget, to add some space in the gui

parent 25546ae9
......@@ -3,7 +3,7 @@ CFLAGS=-Wall -g -pthread
OBJS=init.o loop.o toplevel_window.o x.o container.o widget.o \
gui.o label.o event.o xy_plot.o textlist.o notify.o positioner.o \
timeline.o
timeline.o space.o
gui.a: $(OBJS)
ar cr gui.a $(OBJS)
......
......@@ -33,6 +33,7 @@ widget *new_xy_plot(gui *gui, int width, int height, char *label,
widget *new_textlist(gui *gui, int width, int nlines, int background_color);
widget *new_timeline(gui *gui, int width, int number_of_sublines,
int subline_height);
widget *new_space(gui *gui, int width, int height);
void label_set_clickable(gui *gui, widget *label, int clickable);
......
......@@ -31,7 +31,7 @@ extern int volatile gui_logd;
enum widget_type {
TOPLEVEL_WINDOW, CONTAINER, POSITIONER, TEXT_LIST, XY_PLOT, BUTTON, LABEL,
TIMELINE
TIMELINE, SPACE
};
struct widget_list;
......@@ -148,6 +148,12 @@ struct label_widget {
int baseline; /* as given by the graphic's backend */
};
struct space_widget {
struct widget common;
int wanted_width;
int wanted_height;
};
/*************************************************************************/
/* events */
/*************************************************************************/
......
#include "gui.h"
#include "gui_defs.h"
#include <stdio.h>
static void paint(gui *_gui, widget *_w)
{
/* nothing */
}
static void hints(gui *_gui, widget *_w, int *width, int *height)
{
struct space_widget *w = _w;
LOGD("HINTS space %p\n", w);
*width = w->wanted_width;
*height = w->wanted_height;
}
widget *new_space(gui *_gui, int width, int height)
{
struct gui *g = _gui;
struct space_widget *w;
glock(g);
w = new_widget(g, SPACE, sizeof(struct space_widget));
w->wanted_width = width;
w->wanted_height = height;
w->common.paint = paint;
w->common.hints = hints;
gunlock(g);
return w;
}
......@@ -265,12 +265,11 @@ void widget_dirty(gui *_gui, widget *_this)
static const char *names[] = {
"TOPLEVEL_WINDOW", "CONTAINER", "POSITIONER", "TEXT_LIST",
"XY_PLOT", "BUTTON", "LABEL", "TIMELINE"
"XY_PLOT", "BUTTON", "LABEL", "TIMELINE", "SPACE"
};
const char *widget_name(enum widget_type type)
{
switch (type) {
default: break;
case TOPLEVEL_WINDOW:
case CONTAINER:
case POSITIONER:
......@@ -279,6 +278,7 @@ const char *widget_name(enum widget_type type)
case BUTTON:
case LABEL:
case TIMELINE:
case SPACE:
return names[type];
}
return "UNKNOWN (error)";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment