aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2012-11-30 09:49:01 +0100
committerThomas White <taw@bitwiz.org.uk>2012-11-30 09:49:01 +0100
commitf6fefa99ea3a9a71d5803931cec403db845f767a (patch)
tree1331f00024cbede9245b993efa9e501dbca42405
parent1392eda7d12dc4ad6a75c794fcb21e494c12c0aa (diff)
WIP on rendering
-rw-r--r--Makefile.am9
-rw-r--r--src/frame.h33
-rw-r--r--src/layout.h70
-rw-r--r--src/mainwindow.c1
-rw-r--r--src/presentation.h2
-rw-r--r--src/render.c3
-rw-r--r--src/render.h2
-rw-r--r--src/stylesheet.h3
-rw-r--r--tests/render_test.c9
-rw-r--r--tests/render_test_sc1.c9
10 files changed, 42 insertions, 99 deletions
diff --git a/Makefile.am b/Makefile.am
index 8b1fde6..369f443 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,12 +11,12 @@ LDADD = $(top_builddir)/lib/libgnu.la @IGNORE_UNUSED_LIBRARIES_CFLAGS@ \
libstorycode/src/libstorycode.la harfatum/src/libharfatum.la
src_colloquium_SOURCES = src/colloquium.c src/render.c \
- src/layout.c src/mainwindow.c src/presentation.c \
+ src/mainwindow.c src/presentation.c \
src/stylesheet.c src/loadsave.c src/frame.c
INCLUDES = -Ilibstorycode/src -Iharfatum/src
-EXTRA_DIST += src/layout.h src/presentation.h src/render.h \
+EXTRA_DIST += src/presentation.h src/render.h \
src/stylesheet.h src/loadsave.h
colloquiumdir = $(datadir)/colloquium
@@ -31,8 +31,7 @@ EXTRA_DIST += $(colloquium_DATA)
noinst_PROGRAMS = tests/render_test tests/render_test_sc1
TESTS = tests/render_test tests/render_test_sc1
-tests_render_test_SOURCES = tests/render_test.c src/render.c \
- src/layout.c src/frame.c
+tests_render_test_SOURCES = tests/render_test.c src/render.c src/frame.c
tests_render_test_sc1_SOURCES = tests/render_test_sc1.c \
- src/render.c src/layout.c src/frame.c
+ src/render.c src/frame.c
diff --git a/src/frame.h b/src/frame.h
index 8c1797f..80072a2 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -29,7 +29,38 @@
#include <pango/pango.h>
-#include "layout.h"
+
+typedef enum
+{
+ DIR_NONE,
+ DIR_UL,
+ DIR_U,
+ DIR_UR,
+ DIR_R,
+ DIR_DR,
+ DIR_D,
+ DIR_DL,
+ DIR_L
+} Direction;
+
+
+struct layout_parameters
+{
+ double margin_l;
+ double margin_r;
+ double margin_t;
+ double margin_b;
+
+ double pad_l;
+ double pad_r;
+ double pad_t;
+ double pad_b;
+
+ Direction grav;
+
+ double min_w;
+ double min_h;
+};
struct frame
diff --git a/src/layout.h b/src/layout.h
deleted file mode 100644
index d037157..0000000
--- a/src/layout.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * layout.h
- *
- * Colloquium - A tiny presentation program
- *
- * Copyright (c) 2012 Thomas White <taw@bitwiz.org.uk>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef LAYOUT_H
-#define LAYOUT_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-struct frame;
-
-
-typedef enum
-{
- DIR_NONE,
- DIR_UL,
- DIR_U,
- DIR_UR,
- DIR_R,
- DIR_DR,
- DIR_D,
- DIR_DL,
- DIR_L
-} Direction;
-
-
-struct layout_parameters
-{
- double margin_l;
- double margin_r;
- double margin_t;
- double margin_b;
-
- double pad_l;
- double pad_r;
- double pad_t;
- double pad_b;
-
- Direction grav;
-
- double min_w;
- double min_h;
-};
-
-
-/* Calculate layout for frame (and all its children) based on size */
-extern void layout_frame(struct frame *fr, double w, double h);
-
-#endif /* LAYOUT_H */
diff --git a/src/mainwindow.c b/src/mainwindow.c
index e36be11..a97dd29 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -535,7 +535,6 @@ static gint add_furniture(GtkWidget *widget, struct presentation *p)
fr->style = sty;
set_edit(p, p->cur_edit_slide);
fr->sc = "Hello";
- layout_frame(p->cur_edit_slide->top, p->slide_width, p->slide_height);
set_selection(p, fr);
rerender_slide(p, p->pc);
redraw(p);
diff --git a/src/presentation.h b/src/presentation.h
index 415147f..c43cb9a 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -30,8 +30,6 @@
#include <cairo.h>
#include <gtk/gtk.h>
-struct frame;
-#include "layout.h"
#include "stylesheet.h"
struct slide
diff --git a/src/render.c b/src/render.c
index d7b46ec..6cd1f05 100644
--- a/src/render.c
+++ b/src/render.c
@@ -3,7 +3,7 @@
*
* Colloquium - A tiny presentation program
*
- * Copyright (c) 2011 Thomas White <taw@bitwiz.org.uk>
+ * Copyright (c) 2012 Thomas White <taw@bitwiz.org.uk>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,6 +37,7 @@
#include "stylesheet.h"
#include "presentation.h"
#include "frame.h"
+#include "render.h"
struct renderstuff
diff --git a/src/render.h b/src/render.h
index 4bc47f2..d2f8388 100644
--- a/src/render.h
+++ b/src/render.h
@@ -29,7 +29,7 @@
#include "presentation.h"
-extern int render_sc(const char *sc, cairo_t *cr, double w, double h);
+extern int render_sc(struct frame *fr, cairo_t *cr, double w, double h);
extern int render_frame(struct frame *fr, cairo_t *cr);
diff --git a/src/stylesheet.h b/src/stylesheet.h
index 82f198d..deb1b08 100644
--- a/src/stylesheet.h
+++ b/src/stylesheet.h
@@ -28,9 +28,8 @@
#endif
-struct frame;
-#include "layout.h"
#include "loadsave.h"
+#include "frame.h"
struct style
diff --git a/tests/render_test.c b/tests/render_test.c
index c800cdb..ab2bfc9 100644
--- a/tests/render_test.c
+++ b/tests/render_test.c
@@ -32,7 +32,6 @@
#include "../src/storycode.h"
#include "../src/render.h"
-#include "../src/layout.h"
#include "../src/stylesheet.h"
#include "../src/frame.h"
@@ -44,8 +43,6 @@ static gint mw_destroy(GtkWidget *w, void *p)
static gboolean draw_sig(GtkWidget *da, cairo_t *cr, struct frame *fr)
{
- PangoContext *pc;
- GtkAllocation allocation;
gint w, h;
w = gtk_widget_get_allocated_width(da);
@@ -56,11 +53,7 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, struct frame *fr)
cairo_set_source_rgb(cr, 0.9, 0.9, 0.9);
cairo_fill(cr);
- pc = gtk_widget_get_pango_context(da);
-
- gtk_widget_get_allocation(da, &allocation);
-
- layout_frame(fr, allocation.width, allocation.height);
+ fr->w = w; fr->h = h;
render_frame(fr, cr);
return FALSE;
diff --git a/tests/render_test_sc1.c b/tests/render_test_sc1.c
index 154a08f..e32674d 100644
--- a/tests/render_test_sc1.c
+++ b/tests/render_test_sc1.c
@@ -33,7 +33,6 @@
#include "../src/storycode.h"
#include "../src/render.h"
-#include "../src/layout.h"
#include "../src/stylesheet.h"
#include "../src/frame.h"
@@ -45,8 +44,6 @@ static gint mw_destroy(GtkWidget *w, void *p)
static gboolean draw_sig(GtkWidget *da, cairo_t *cr, struct frame *fr)
{
- PangoContext *pc;
- GtkAllocation allocation;
gint w, h;
w = gtk_widget_get_allocated_width(da);
@@ -57,11 +54,7 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, struct frame *fr)
cairo_set_source_rgb(cr, 0.9, 0.9, 0.9);
cairo_fill(cr);
- pc = gtk_widget_get_pango_context(da);
-
- gtk_widget_get_allocation(da, &allocation);
-
- layout_frame(fr, allocation.width, allocation.height);
+ fr->w = w; fr->h = h;
render_frame(fr, cr);
return FALSE;