Skip to content

Commit

Permalink
Narrative rendering machinery
Browse files Browse the repository at this point in the history
  • Loading branch information
taw10 committed Feb 28, 2019
1 parent fcdd596 commit 4104a6f
Show file tree
Hide file tree
Showing 11 changed files with 405 additions and 44 deletions.
42 changes: 8 additions & 34 deletions libstorycode/gtk/gtknarrativeview.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <math.h>

#include <presentation.h>
#include <narrative_render_cairo.h>

//#include "slide_window.h"
#include "gtknarrativeview.h"
Expand Down Expand Up @@ -121,24 +122,6 @@ static void set_vertical_params(GtkNarrativeView *e)
}


static void update_size(GtkNarrativeView *e)
{
// double total = total_height(e->top);
//
// e->w = e->top->w;
// e->h = total + e->top->pad_t + e->top->pad_b;
//
// e->top->h = e->h;
//
// if ( e->top->h < e->visible_height ) {
// e->top->h = e->visible_height;
// }
//
// set_vertical_params(e);
// set_horizontal_params(e);
}


static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
GtkNarrativeView *e)
{
Expand All @@ -149,23 +132,13 @@ static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
e->visible_height = event->height;
e->visible_width = event->width;

/* Wrap everything with the current width, to get the total height */
//e->top = interp_and_shape(e->scblocks, e->stylesheet, e->cbl,
// e->is, e->slidenum, pc,
// w, h, e->lang);
// e->top->scblocks = e->scblocks;
// recursive_wrap(e->top, pc);
// }
//
// /* Wrap using current width */
// e->top->w = event->width;
// e->top->h = 0.0; /* To be updated in a moment */
// e->top->x = 0.0;
// e->top->y = 0.0;
// /* Only the top level needs to be wrapped */
// wrap_frame(e->top, pc);
e->w = e->visible_width;
e->h = narrative_get_height(presentation_get_narrative(e->p));

update_size(e);
/* Wrap everything with the current width, to get the total height */
narrative_wrap(presentation_get_narrative(e->p),
presentation_get_stylesheet(e->p),
pango_language_get_default(), pc, e->w);

g_object_unref(pc);

Expand Down Expand Up @@ -1045,6 +1018,7 @@ GtkNarrativeView *gtk_narrative_view_new(Presentation *p, PangoLanguage *lang,
nview->h = 100;
nview->scroll_pos = 0;
nview->lang = lang;
nview->p = p;

nview->para_highlight = 0;

Expand Down
1 change: 1 addition & 0 deletions libstorycode/gtk/gtknarrativeview.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ struct _gtknarrativeview
GtkDrawingArea parent_instance;

/*< private >*/
Presentation *p;
GtkIMContext *im_context;
PangoContext *pc;
PangoLanguage *lang;
Expand Down
8 changes: 1 addition & 7 deletions libstorycode/narrative.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@
#include <string.h>

#include "narrative.h"

struct _narrative
{
int n_items;
struct narrative_item *items;
};

#include "narrative_priv.h"

Narrative *narrative_new()
{
Expand Down
70 changes: 70 additions & 0 deletions libstorycode/narrative_priv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* narrative_priv.h
*
* Copyright © 2019 Thomas White <[email protected]>
*
* This file is part of Colloquium.
*
* Colloquium 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 NARRATIVE_PRIV_H
#define NARRATIVE_PRIV_H

#ifdef HAVE_PANGO
#include <pango/pangocairo.h>
#endif

#include "storycode.h"


enum narrative_item_type
{
NARRATIVE_ITEM_TEXT,
NARRATIVE_ITEM_SLIDE,
NARRATIVE_ITEM_BP,
};


struct narrative_item
{
enum narrative_item_type type;

/* For TEXT, SLIDETITLE, PRESTITLE */
char **paragraphs;
int n_paras;
enum alignment align;
#ifdef HAVE_PANGO
PangoLayout **layouts;
#endif

/* For IMAGE */
char *filename;

/* For TEXT and IMAGE */
struct frame_geom geom;
};


struct _narrative
{
int n_items;
struct narrative_item *items;
double w;
double total_h;
};


#endif /* NARRATIVE_PRIV_H */
Loading

0 comments on commit 4104a6f

Please sign in to comment.