diff options
author | Thomas White <taw@bitwiz.org.uk> | 2014-07-07 09:11:12 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2014-07-07 09:11:12 +0200 |
commit | b78321a41a1f8c6e75a8b9a1d774edc9ce7a5ed4 (patch) | |
tree | b97e551a6e7b9ec186ce35949bad4631ad652589 | |
parent | c04e68c97ab01b2196a0625bc5ab0df48b4b1124 (diff) |
Add frame creation
-rw-r--r-- | src/mainwindow.c | 7 | ||||
-rw-r--r-- | src/sc_parse.c | 40 | ||||
-rw-r--r-- | src/sc_parse.h | 7 |
3 files changed, 52 insertions, 2 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c index ed22a95..e4986bc 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -42,6 +42,7 @@ #include "notes.h" #include "pr_clock.h" #include "slide_sorter.h" +#include "sc_parse.h" /* Update a slide, once it's been edited in some way. */ @@ -1574,6 +1575,7 @@ static struct frame *create_frame(struct presentation *p, double x, double y, { struct frame *parent; struct frame *fr; + char geom[256]; parent = p->cur_edit_slide->top; @@ -1590,8 +1592,9 @@ static struct frame *create_frame(struct presentation *p, double x, double y, fr = add_subframe(parent); /* Add to SC */ - show_sc_blocks(parent->scblocks); - fr->scblocks = NULL; + 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("")); fr->x = x; fr->y = y; diff --git a/src/sc_parse.c b/src/sc_parse.c index 510f097..a3443a0 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -132,6 +132,46 @@ SCBlock *sc_block_append(SCBlock *bl, char *name, char *opt, char *contents, } +/* Append a new block to the chain inside "bl". + * "name", "options" and "contents" will not be copied. Returns the block just + * created, or NULL on error. */ +SCBlock *sc_block_append_inside(SCBlock *parent, + char *name, char *opt, char *contents) +{ + SCBlock *bln; + SCBlock *bl; + SCBlock **ptr; + + bl = parent->child; + if ( bl != NULL ) { + while ( bl->next != NULL ) bl = bl->next; + ptr = &bl->next; + } else { + ptr = &bl->child; + bl = NULL; + } + + bln = sc_block_new(); + if ( bln == NULL ) return NULL; + + bln->name = name; + bln->options = opt; + bln->contents = contents; + bln->child = NULL; + bln->next = NULL; + + if ( bl == NULL ) { + bln->prev = NULL; + } else { + bln->prev = bl; + } + *ptr = bln; + + return bln; +} + + + /* Frees "bl" and all its children */ void sc_block_free(SCBlock *bl) { diff --git a/src/sc_parse.h b/src/sc_parse.h index 44301df..eb53893 100644 --- a/src/sc_parse.h +++ b/src/sc_parse.h @@ -41,6 +41,13 @@ extern const char *sc_block_name(const SCBlock *bl); extern const char *sc_block_options(const SCBlock *bl); extern const char *sc_block_contents(const SCBlock *bl); +extern SCBlock *sc_block_append(SCBlock *bl, + char *name, char *opt, char *contents, + SCBlock **blfp); + +extern SCBlock *sc_block_append_inside(SCBlock *bl, + char *name, char *opt, char *contents); + extern struct frame *sc_block_frame(const SCBlock *bl); extern void sc_block_set_frame(SCBlock *bl, struct frame *fr); |