Commit 0408e03f authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

[libview] Move get_dual_even_left from EvPageCache to EvView

parent ea39d52d
......@@ -209,14 +209,6 @@ ev_page_cache_get_max_height (EvPageCache *page_cache,
*height = (rotation == 0 || rotation == 180) ? h * scale : w * scale;
}
gboolean
ev_page_cache_get_dual_even_left (EvPageCache *page_cache)
{
g_return_val_if_fail (EV_IS_PAGE_CACHE (page_cache), 0);
return (ev_document_get_n_pages (page_cache->document) > 2);
}
#define PAGE_CACHE_STRING "ev-page-cache"
EvPageCache *
......
......@@ -49,8 +49,6 @@ void ev_page_cache_get_max_height (EvPageCache *page_cache,
gint rotation,
gfloat scale,
gint *height);
gboolean ev_page_cache_get_dual_even_left (EvPageCache *page_cache);
/* Navigation */
gint ev_page_cache_get_current_page (EvPageCache *page_cache);
void ev_page_cache_set_current_page (EvPageCache *page_cache,
......
......@@ -129,6 +129,7 @@ static void doc_rect_to_view_rect (EvView
int page,
EvRectangle *doc_rect,
GdkRectangle *view_rect);
static gboolean get_dual_even_left (EvView *view);
static void find_page_at_location (EvView *view,
gdouble x,
gdouble y,
......@@ -653,7 +654,7 @@ view_update_range_and_current_page (EvView *view)
}
} else if (view->dual_page) {
if (view->current_page % 2 == ev_page_cache_get_dual_even_left (view->page_cache)) {
if (view->current_page % 2 == get_dual_even_left (view)) {
view->start_page = view->current_page;
if (view->current_page + 1 < ev_document_get_n_pages (view->document))
view->end_page = view->start_page + 1;
......@@ -917,7 +918,8 @@ get_page_y_offset (EvView *view, int page, int *y_offset)
if (view->dual_page) {
ev_view_get_height_to_page (view, page, NULL, &offset);
offset += ((page + ev_page_cache_get_dual_even_left (view->page_cache)) / 2 + 1) * view->spacing + ((page + ev_page_cache_get_dual_even_left (view->page_cache)) / 2 ) * (border.top + border.bottom);
offset += ((page + get_dual_even_left (view)) / 2 + 1) * view->spacing +
((page + get_dual_even_left (view)) / 2 ) * (border.top + border.bottom);
} else {
ev_view_get_height_to_page (view, page, &offset, NULL);
offset += (page + 1) * view->spacing + page * (border.top + border.bottom);
......@@ -959,9 +961,9 @@ get_page_extents (EvView *view,
max_width = max_width + border->left + border->right;
/* Get the location of the bounding box */
if (view->dual_page) {
x = view->spacing + ((page % 2 == ev_page_cache_get_dual_even_left (view->page_cache)) ? 0 : 1) * (max_width + view->spacing);
x = view->spacing + ((page % 2 == get_dual_even_left (view)) ? 0 : 1) * (max_width + view->spacing);
x = x + MAX (0, widget->allocation.width - (max_width * 2 + view->spacing * 3)) / 2;
if (page % 2 == ev_page_cache_get_dual_even_left (view->page_cache))
if (page % 2 == get_dual_even_left (view))
x = x + (max_width - width - border->left - border->right);
} else {
x = view->spacing;
......@@ -981,7 +983,7 @@ get_page_extents (EvView *view,
GtkBorder overall_border;
gint other_page;
other_page = (page % 2 == ev_page_cache_get_dual_even_left (view->page_cache)) ? page + 1: page - 1;
other_page = (page % 2 == get_dual_even_left (view)) ? page + 1: page - 1;
/* First, we get the bounding box of the two pages */
if (other_page < ev_document_get_n_pages (view->document)
......@@ -1003,7 +1005,7 @@ get_page_extents (EvView *view,
y = view->spacing;
/* Adjust for being the left or right page */
if (page % 2 == ev_page_cache_get_dual_even_left (view->page_cache))
if (page % 2 == get_dual_even_left (view))
x = x + max_width - width;
else
x = x + (max_width + overall_border.left + overall_border.right) + view->spacing;
......@@ -1156,6 +1158,12 @@ doc_rect_to_view_rect (EvView *view,
view_rect->height = h * view->scale;
}
static gboolean
get_dual_even_left (EvView *view)
{
return (ev_document_get_n_pages (view->document) > 2);
}
static void
find_page_at_location (EvView *view,
gdouble x,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment