Commit 7a6b53a1 authored by William Jon McCann's avatar William Jon McCann Committed by Carlos Garcia Campos
Browse files

view: Use a rendered frame instead of custom border

So it can be styled with CSS.

https://bugzilla.gnome.org/show_bug.cgi?id=653294
parent f81d6e83
......@@ -104,6 +104,8 @@ typedef struct {
#define DEFAULT_PIXBUF_CACHE_SIZE 52428800 /* 50MB */
#define EV_STYLE_CLASS_DOCUMENT_PAGE "document-page"
/*** Scrolling ***/
static void view_update_range_and_current_page (EvView *view);
static void add_scroll_binding_keypad (GtkBindingSet *binding_set,
......@@ -116,8 +118,6 @@ static void ensure_rectangle_is_visible (EvView
/*** Geometry computations ***/
static void compute_border (EvView *view,
int width,
int height,
GtkBorder *border);
static void get_page_y_offset (EvView *view,
int page,
......@@ -1018,9 +1018,16 @@ ensure_rectangle_is_visible (EvView *view, GdkRectangle *rect)
/*** Geometry computations ***/
static void
compute_border (EvView *view, int width, int height, GtkBorder *border)
compute_border (EvView *view, GtkBorder *border)
{
ev_document_misc_get_page_border_size (width, height, border);
GtkWidget *widget = GTK_WIDGET (view);
GtkStyleContext *context = gtk_widget_get_style_context (widget);
GtkStateFlags state = gtk_widget_get_state_flags (widget);
gtk_style_context_save (context);
gtk_style_context_add_class (context, EV_STYLE_CLASS_DOCUMENT_PAGE);
gtk_style_context_get_border (context, state, border);
gtk_style_context_restore (context);
}
void
......@@ -1081,13 +1088,12 @@ ev_view_get_max_page_size (EvView *view,
static void
get_page_y_offset (EvView *view, int page, int *y_offset)
{
int max_width, offset;
int offset;
GtkBorder border;
g_return_if_fail (y_offset != NULL);
ev_view_get_max_page_size (view, &max_width, NULL);
compute_border (view, max_width, max_width, &border);
compute_border (view, &border);
if (view->dual_page) {
ev_view_get_height_to_page (view, page, NULL, &offset);
......@@ -1117,7 +1123,7 @@ ev_view_get_page_extents (EvView *view,
/* Get the size of the page */
ev_view_get_page_size (view, page, &width, &height);
compute_border (view, width, height, border);
compute_border (view, border);
page_area->width = width + border->left + border->right;
page_area->height = height + border->top + border->bottom;
......@@ -1163,7 +1169,7 @@ ev_view_get_page_extents (EvView *view,
if (height_2 > height)
max_height = height_2;
}
compute_border (view, max_width, max_height, &overall_border);
compute_border (view, &overall_border);
/* Find the offsets */
x = view->spacing;
......@@ -3041,7 +3047,7 @@ ev_view_size_request_continuous_dual_page (EvView *view,
GtkBorder border;
ev_view_get_max_page_size (view, &max_width, NULL);
compute_border (view, max_width, max_width, &border);
compute_border (view, &border);
requisition->width = (max_width + border.left + border.right) * 2 + (view->spacing * 3);
}
break;
......@@ -3070,7 +3076,7 @@ ev_view_size_request_continuous (EvView *view,
GtkBorder border;
ev_view_get_max_page_size (view, &max_width, NULL);
compute_border (view, max_width, max_width, &border);
compute_border (view, &border);
requisition->width = max_width + (view->spacing * 2) + border.left + border.right;
}
break;
......@@ -3107,7 +3113,7 @@ ev_view_size_request_dual_page (EvView *view,
height = height_2;
}
}
compute_border (view, width, height, &border);
compute_border (view, &border);
requisition->width = view->sizing_mode == EV_SIZING_FIT_WIDTH ? 1 :
((width + border.left + border.right) * 2) + (view->spacing * 3);
......@@ -3129,7 +3135,7 @@ ev_view_size_request_single_page (EvView *view,
}
ev_view_get_page_size (view, view->current_page, &width, &height);
compute_border (view, width, height, &border);
compute_border (view, &border);
requisition->width = view->sizing_mode == EV_SIZING_FIT_WIDTH ? 1 :
width + border.left + border.right + (2 * view->spacing);
......@@ -4350,10 +4356,10 @@ draw_one_page (EvView *view,
GdkRectangle *expose_area,
gboolean *page_ready)
{
GdkRectangle overlap;
GdkRectangle real_page_area;
gint current_page;
gboolean inverted_colors;
GtkStyleContext *context;
GdkRectangle overlap;
GdkRectangle real_page_area;
gint current_page;
g_assert (view->document);
......@@ -4369,13 +4375,17 @@ draw_one_page (EvView *view,
real_page_area.height -= (border->top + border->bottom);
*page_ready = TRUE;
context = gtk_widget_get_style_context (GTK_WIDGET (view));
current_page = ev_document_model_get_page (view->model);
inverted_colors = ev_document_model_get_inverted_colors (view->model);
ev_document_misc_paint_one_page (cr,
GTK_WIDGET (view),
page_area, border,
page == current_page,
inverted_colors);
gtk_style_context_save (context);
gtk_style_context_add_class (context, EV_STYLE_CLASS_DOCUMENT_PAGE);
if (view->continuous && page == current_page)
gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE);
gtk_render_frame (context, cr, page_area->x, page_area->y, page_area->width, page_area->height);
gtk_style_context_restore (context);
if (gdk_rectangle_intersect (&real_page_area, expose_area, &overlap)) {
gint width, height;
......@@ -5592,7 +5602,7 @@ ev_view_zoom_for_size_continuous_and_dual_page (EvView *view,
doc_height = tmp;
}
compute_border (view, doc_width, doc_height, &border);
compute_border (view, &border);
doc_width *= 2;
width -= (2 * (border.left + border.right) + 3 * view->spacing);
......@@ -5629,7 +5639,7 @@ ev_view_zoom_for_size_continuous (EvView *view,
doc_height = tmp;
}
compute_border (view, doc_width, doc_height, &border);
compute_border (view, &border);
width -= (border.left + border.right + 2 * view->spacing);
height -= (border.top + border.bottom + 2 * view->spacing);
......@@ -5669,7 +5679,7 @@ ev_view_zoom_for_size_dual_page (EvView *view,
if (height_2 > doc_height)
doc_height = height_2;
}
compute_border (view, width, height, &border);
compute_border (view, &border);
doc_width = doc_width * 2;
width -= ((border.left + border.right)* 2 + 3 * view->spacing);
......@@ -5700,7 +5710,7 @@ ev_view_zoom_for_size_single_page (EvView *view,
get_doc_page_size (view, view->current_page, &doc_width, &doc_height);
/* Get an approximate border */
compute_border (view, width, height, &border);
compute_border (view, &border);
width -= (border.left + border.right + 2 * view->spacing);
height -= (border.top + border.bottom + 2 * view->spacing);
......
......@@ -16,3 +16,21 @@ EvView {
EvView:selected {
background-color: @theme_selected_bg_color;
}
EvView.document-page {
border-color: black;
border-style: solid;
border-width: 1px;
border-radius: 0px;
border-image: none;
padding: 0;
}
EvView.document-page:active {
border-color: @theme_selected_bg_color;
border-style: solid;
border-width: 1px;
border-radius: 0px;
border-image: none;
padding: 0;
}
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