From 50c00218c7ca785c2ff50c2d1446541c113c26fb Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Mon, 23 May 2016 16:18:00 +0200
Subject: [PATCH] space widget, to add some space in the gui

---
 common/utils/T/tracer/gui/Makefile   |  2 +-
 common/utils/T/tracer/gui/gui.h      |  1 +
 common/utils/T/tracer/gui/gui_defs.h |  8 ++++++-
 common/utils/T/tracer/gui/space.c    | 36 ++++++++++++++++++++++++++++
 common/utils/T/tracer/gui/widget.c   |  4 ++--
 5 files changed, 47 insertions(+), 4 deletions(-)
 create mode 100644 common/utils/T/tracer/gui/space.c

diff --git a/common/utils/T/tracer/gui/Makefile b/common/utils/T/tracer/gui/Makefile
index 7129d390b9..fb3a9486d8 100644
--- a/common/utils/T/tracer/gui/Makefile
+++ b/common/utils/T/tracer/gui/Makefile
@@ -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)
diff --git a/common/utils/T/tracer/gui/gui.h b/common/utils/T/tracer/gui/gui.h
index 6d36cddfd6..208a3c2a54 100644
--- a/common/utils/T/tracer/gui/gui.h
+++ b/common/utils/T/tracer/gui/gui.h
@@ -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);
 
diff --git a/common/utils/T/tracer/gui/gui_defs.h b/common/utils/T/tracer/gui/gui_defs.h
index 5b8469ad9a..dc3559c82c 100644
--- a/common/utils/T/tracer/gui/gui_defs.h
+++ b/common/utils/T/tracer/gui/gui_defs.h
@@ -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                                    */
 /*************************************************************************/
diff --git a/common/utils/T/tracer/gui/space.c b/common/utils/T/tracer/gui/space.c
new file mode 100644
index 0000000000..c98600b88d
--- /dev/null
+++ b/common/utils/T/tracer/gui/space.c
@@ -0,0 +1,36 @@
+#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;
+}
diff --git a/common/utils/T/tracer/gui/widget.c b/common/utils/T/tracer/gui/widget.c
index 1d2b03a25f..149f4be7f5 100644
--- a/common/utils/T/tracer/gui/widget.c
+++ b/common/utils/T/tracer/gui/widget.c
@@ -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)";
-- 
GitLab