2019-09-01 21:40:08 +00:00
|
|
|
#include "LandscapePageLayout.hpp"
|
|
|
|
#include "common.h"
|
|
|
|
#include <algorithm>
|
|
|
|
|
2019-09-03 22:17:53 +00:00
|
|
|
LandscapePageLayout::LandscapePageLayout(fz_document *doc, int current_page):PageLayout(doc, current_page) {
|
2019-09-01 21:40:08 +00:00
|
|
|
int w = viewport.w;
|
|
|
|
viewport.w = viewport.h;
|
|
|
|
viewport.h = w;
|
|
|
|
|
|
|
|
render_page_to_texture(_current_page, true);
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
2019-09-03 22:17:53 +00:00
|
|
|
void LandscapePageLayout::reset() {
|
2019-09-01 21:40:08 +00:00
|
|
|
page_center = fz_make_point(viewport.h / 2, viewport.w / 2);
|
|
|
|
set_zoom(min_zoom);
|
|
|
|
};
|
|
|
|
|
2019-09-03 22:17:53 +00:00
|
|
|
void LandscapePageLayout::draw_page() {
|
2019-09-01 21:40:08 +00:00
|
|
|
float w = page_bounds.x1 * zoom, h = page_bounds.y1 * zoom;
|
|
|
|
|
|
|
|
SDL_Rect rect;
|
|
|
|
rect.y = page_center.y - h / 2;
|
|
|
|
rect.x = page_center.x - w / 2;
|
|
|
|
rect.w = w;
|
|
|
|
rect.h = h;
|
|
|
|
|
|
|
|
SDL_RenderCopyEx(RENDERER, page_texture, NULL, &rect, 90, NULL, SDL_FLIP_NONE);
|
|
|
|
}
|
|
|
|
|
2019-09-03 22:17:53 +00:00
|
|
|
void LandscapePageLayout::move_page(float x, float y) {
|
2019-09-01 21:40:08 +00:00
|
|
|
float w = page_bounds.x1 * zoom, h = page_bounds.y1 * zoom;
|
|
|
|
|
|
|
|
page_center.x = fmin(fmax(page_center.x + y, h / 2), viewport.h - h / 2);
|
|
|
|
page_center.y = fmin(fmax(page_center.y + x, viewport.w - w / 2), w / 2);
|
|
|
|
}
|