aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2014-07-07 22:58:25 +0200
committerThomas White <taw@bitwiz.org.uk>2014-07-07 22:58:25 +0200
commitdd688c7838fd63a6e4fc0b59ed4fdc0afe9a1ee9 (patch)
tree8bcc0c62af00bd46b813531a955cb97281d240df
parentb78321a41a1f8c6e75a8b9a1d774edc9ce7a5ed4 (diff)
New frame logic
-rw-r--r--src/mainwindow.c5
-rw-r--r--src/sc_parse.c14
-rw-r--r--src/sc_parse.h2
-rw-r--r--src/wrap.c2
4 files changed, 19 insertions, 4 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c
index e4986bc..46bdf7d 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -1594,7 +1594,10 @@ static struct frame *create_frame(struct presentation *p, double x, double y,
/* Add to SC */
snprintf(geom, 255, "%.1fux%.1fu+%.1f+%.1f", w, h, x, y);
fr->scblocks = sc_block_append_inside(p->cur_edit_slide->scblocks,
- "f", strdup(geom), strdup(""));
+ "f", strdup(geom), NULL);
+ sc_block_set_frame(fr->scblocks, fr);
+ sc_block_append_inside(fr->scblocks, NULL, NULL, strdup(""));
+ printf("new block is %p\n", fr->scblocks);
fr->x = x;
fr->y = y;
diff --git a/src/sc_parse.c b/src/sc_parse.c
index a3443a0..0696e15 100644
--- a/src/sc_parse.c
+++ b/src/sc_parse.c
@@ -147,8 +147,7 @@ SCBlock *sc_block_append_inside(SCBlock *parent,
while ( bl->next != NULL ) bl = bl->next;
ptr = &bl->next;
} else {
- ptr = &bl->child;
- bl = NULL;
+ ptr = &parent->child;
}
bln = sc_block_new();
@@ -454,6 +453,17 @@ SCBlock *sc_parse(const char *sc)
}
+SCBlock *find_last_child(SCBlock *bl)
+{
+ if ( bl == NULL ) return NULL;
+ if ( bl->child == NULL ) return NULL;
+
+ bl = bl->child;
+ while ( bl->next != NULL ) bl = bl->next;
+ return bl;
+}
+
+
void sc_insert_text(SCBlock *b1, int o1, const char *t)
{
size_t len = strlen(b1->contents)+1+strlen(t);
diff --git a/src/sc_parse.h b/src/sc_parse.h
index eb53893..549d2ab 100644
--- a/src/sc_parse.h
+++ b/src/sc_parse.h
@@ -51,6 +51,8 @@ extern SCBlock *sc_block_append_inside(SCBlock *bl,
extern struct frame *sc_block_frame(const SCBlock *bl);
extern void sc_block_set_frame(SCBlock *bl, struct frame *fr);
+extern SCBlock *find_last_child(SCBlock *bl);
+
extern void sc_insert_text(SCBlock *b1, int o1, const char *t);
extern void sc_delete_text(SCBlock *b1, int o1, SCBlock *b2, int o2);
diff --git a/src/wrap.c b/src/wrap.c
index 9406620..1163bda 100644
--- a/src/wrap.c
+++ b/src/wrap.c
@@ -922,7 +922,7 @@ int wrap_contents(struct frame *fr)
/* FIXME: Get ascent and descent from font metrics for
* whichever font will be used in this box */
} else {
- l->boxes[0].scblock = fr->scblocks;
+ l->boxes[0].scblock = find_last_child(fr->scblocks);
l->boxes[0].offs_char = 0;
l->boxes[0].ascent = 10000;
l->boxes[0].height = 10000;