aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2012-08-12 14:54:45 +0200
committerThomas White <taw@bitwiz.org.uk>2012-08-12 14:54:45 +0200
commit3795b390e6923670d5510acc37315dc9e3668b09 (patch)
tree6cb236860acd89907516f645965435887bd006cd /src
parentf8d5a4d3c2eed0fde67371159a0ffc3c7d3849c3 (diff)
Basic structure for frames
Diffstat (limited to 'src')
-rw-r--r--src/colloquium.c2
-rw-r--r--src/layout.c59
-rw-r--r--src/layout.h44
-rw-r--r--src/presentation.h13
-rw-r--r--src/render.c27
-rw-r--r--src/render.h2
-rw-r--r--src/storycode.c17
7 files changed, 147 insertions, 17 deletions
diff --git a/src/colloquium.c b/src/colloquium.c
index 15836be..93d2c4e 100644
--- a/src/colloquium.c
+++ b/src/colloquium.c
@@ -43,7 +43,7 @@ static void show_help(const char *s)
int main(int argc, char *argv[])
{
int c;
- struct presentation *p;
+// struct presentation *p;
/* Long options */
const struct option longopts[] = {
diff --git a/src/layout.c b/src/layout.c
new file mode 100644
index 0000000..6bcb37c
--- /dev/null
+++ b/src/layout.c
@@ -0,0 +1,59 @@
+/*
+ * layout.c
+ *
+ * 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/>.
+ *
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "presentation.h"
+#include "layout.h"
+
+
+/* Calculate layout for frame (and all its children) based on size */
+void layout_frame(struct frame *fr, double w, double h)
+{
+ fr->w = w;
+ fr->h = h;
+
+ int i;
+
+ for ( i=0; i<fr->num_ro; i++ ) {
+
+ struct frame *child;
+ double child_w, child_h;
+
+ child = fr->rendering_order[i];
+
+ if ( child == fr ) continue;
+
+ child->x = fr->lop.margin_l;
+ child->y = fr->lop.margin_t;
+ child_w = w - (fr->lop.margin_l + fr->lop.margin_r);
+ child_h = h - (fr->lop.margin_t + fr->lop.margin_b);
+ layout_frame(child, child_w, child_h);
+
+ }
+}
diff --git a/src/layout.h b/src/layout.h
new file mode 100644
index 0000000..9e76896
--- /dev/null
+++ b/src/layout.h
@@ -0,0 +1,44 @@
+/*
+ * 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 layout_parameters
+{
+ double margin_l;
+ double margin_r;
+ double margin_t;
+ double margin_b;
+};
+
+
+/* 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/presentation.h b/src/presentation.h
index 8707151..50d3831 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -30,6 +30,9 @@
#include <cairo.h>
#include <pango/pango.h>
+struct frame;
+#include "layout.h"
+
struct slide
{
struct presentation *parent;
@@ -50,7 +53,7 @@ struct slide
struct frame
{
- struct frame_class *cl;
+ //struct frame_class *cl;
PangoContext *pc;
struct frame **rendering_order;
@@ -58,6 +61,14 @@ struct frame
char *sc; /* Storycode */
+ struct layout_parameters lop;
+
+ /* Location relative to parent, calculated from alignment parameters */
+ double x;
+ double y;
+ double w;
+ double h;
+
int empty;
};
diff --git a/src/render.c b/src/render.c
index 1e8a697..f05044e 100644
--- a/src/render.c
+++ b/src/render.c
@@ -108,6 +108,11 @@ int render_sc(const char *sc, cairo_t *cr, double w, double h, PangoContext *pc)
PangoFontDescription *fontdesc;
GdkColor col;
+ cairo_rectangle(cr, 0.0, 0.0, w, h);
+ cairo_set_line_width(cr, 0.1);
+ cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
+ cairo_stroke(cr);
+
/* FIXME: Check for Level 1 markup e.g. image */
layout = pango_layout_new(pc);
@@ -115,6 +120,8 @@ int render_sc(const char *sc, cairo_t *cr, double w, double h, PangoContext *pc)
pango_cairo_update_layout(cr, layout);
pango_layout_set_width(layout, w*PANGO_SCALE);
pango_layout_set_height(layout, h*PANGO_SCALE);
+ pango_layout_set_justify(layout, 1);
+ pango_layout_set_ellipsize(layout, 1);
pango_layout_set_text(layout, sc, -1);
fontdesc = pango_font_description_from_string("Sans 12");
@@ -136,7 +143,7 @@ int render_sc(const char *sc, cairo_t *cr, double w, double h, PangoContext *pc)
}
-static int render_frame(struct frame *fr, cairo_t *cr, double w, double h)
+int render_frame(struct frame *fr, cairo_t *cr, PangoContext *pc)
{
int i;
@@ -146,24 +153,16 @@ static int render_frame(struct frame *fr, cairo_t *cr, double w, double h)
* children. */
for ( i=0; i<fr->num_ro; i++ ) {
- double nw, nh;
-
if ( fr->rendering_order[i] == fr ) {
- render_sc(fr->sc, cr, w, h, fr->pc);
+ render_sc(fr->sc, cr, fr->w, fr->h, pc);
continue;
}
/* Sort out the transformation for the margins */
- cairo_translate(cr, fr->rendering_order[i]->cl->margin_left,
- fr->rendering_order[i]->cl->margin_top);
-
- nw = w - fr->rendering_order[i]->cl->margin_left;
- nw -= fr->rendering_order[i]->cl->margin_right;
-
- nh = h - fr->rendering_order[i]->cl->margin_top;
- nh -= fr->rendering_order[i]->cl->margin_bottom;
+ cairo_translate(cr, fr->rendering_order[i]->x,
+ fr->rendering_order[i]->y);
- render_frame(fr->rendering_order[i], cr, nw, nh);
+ render_frame(fr->rendering_order[i], cr, pc);
}
@@ -193,7 +192,7 @@ cairo_surface_t *render_slide(struct slide *s, int w, int h)
render_bgblock(cr, s->st->bgblocks[i]);
}
- render_frame(s->top, cr, w, h);
+ render_frame(s->top, cr, NULL); /* FIXME: pc */
cairo_font_options_destroy(fopts);
cairo_destroy(cr);
diff --git a/src/render.h b/src/render.h
index d5054cd..2fbaa22 100644
--- a/src/render.h
+++ b/src/render.h
@@ -34,4 +34,6 @@ extern cairo_surface_t *render_slide(struct slide *s, int w, int h);
extern int render_sc(const char *sc, cairo_t *cr, double w, double h,
PangoContext *pc);
+extern int render_frame(struct frame *fr, cairo_t *cr, PangoContext *pc);
+
#endif /* RENDER_H */
diff --git a/src/storycode.c b/src/storycode.c
index f3c2e27..446d277 100644
--- a/src/storycode.c
+++ b/src/storycode.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
@@ -26,5 +26,20 @@
#endif
#include <assert.h>
+#include <stdlib.h>
#include "storycode.h"
+#include "presentation.h"
+
+
+struct frame *unpack_storycode(const char *sc)
+{
+ struct frame *fr;
+
+ fr = calloc(1, sizeof(struct frame));
+ if ( fr == NULL ) return NULL;
+
+
+
+ return fr;
+}