diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2015-02-24 12:00:44 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2015-10-06 11:21:22 +0200 |
commit | 2b134a88de6a941e122043e33e8de43513c7a742 (patch) | |
tree | d845e505b035d139fb2d8fce257b8bdc89b676e7 /platform | |
parent | 96116587d8e216fd7a72c784bb1af62fdb640de4 (diff) | |
download | mupdf-2b134a88de6a941e122043e33e8de43513c7a742.tar.xz |
glut: Center page on canvas.
Conflicts:
platform/glut/glut-main.c
Diffstat (limited to 'platform')
-rw-r--r-- | platform/glut/glut-main.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/platform/glut/glut-main.c b/platform/glut/glut-main.c index 429cab3e..37448a64 100644 --- a/platform/glut/glut-main.c +++ b/platform/glut/glut-main.c @@ -286,9 +286,8 @@ static int draw_outline_imp(fz_outline *node, int end, int x0, int x1, int x, in return h; } -static void draw_outline(fz_outline *node) +static void draw_outline(fz_outline *node, int w) { - static int w = 300; static int y = 0; int h; @@ -360,6 +359,7 @@ static void display(void) { fz_rect r; float x, y; + int canvas_x, canvas_w; glViewport(0, 0, screen_w, screen_h); glClearColor(0.3, 0.3, 0.4, 1.0); @@ -374,6 +374,14 @@ static void display(void) ui_begin(); + if (showoutline) + { + if (!outline) + outline = fz_load_outline(ctx, doc); + if (!outline) + showoutline = 0; + } + if (oldpage != currentpage || oldzoom != currentzoom || oldrotate != currentrotate) { render_page(currentpage, currentzoom, currentrotate); @@ -382,7 +390,18 @@ static void display(void) oldrotate = currentrotate; } - x = (screen_w - page_w) / 2; + if (showoutline) + { + canvas_x = 300; + canvas_w = screen_w - canvas_x; + } + else + { + canvas_x = 0; + canvas_w = screen_w; + } + + x = canvas_x + (canvas_w - page_w) / 2; y = (screen_h - page_h) / 2; r.x0 = x; @@ -394,10 +413,7 @@ static void display(void) if (showoutline) { - if (!outline) - outline = fz_load_outline(ctx, doc); - if (outline) - draw_outline(outline); + draw_outline(outline, canvas_x); } ui_end(); |