summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2008-06-07 17:52:24 -0400
committerSøren Sandmann <sandmann@redhat.com>2008-06-07 17:52:24 -0400
commit7d738b3680bcb36a6b245615dddff2d2d37dec24 (patch)
tree92e590e7b9dfd9abec39004e6c5851c29350f9cc
parent7b9a2aa438c2eed48c81846750a02ba8be5cd1db (diff)
Move more stuff to deck.[ch]
-rw-r--r--deck.c8
-rw-r--r--deck.h2
-rw-r--r--main.c32
3 files changed, 20 insertions, 22 deletions
diff --git a/deck.c b/deck.c
index c2d462f..be2558a 100644
--- a/deck.c
+++ b/deck.c
@@ -89,3 +89,11 @@ deck_get_slide_location (Deck *deck,
return nth_slide * (MARGIN + slide_height) + MARGIN;
}
+
+int
+deck_get_height (Deck *deck, GdkRectangle *viewport)
+{
+ int slide_height = get_slide_height (deck, viewport);
+
+ return N_SLIDES * slide_height + (N_SLIDES + 1) * MARGIN;
+}
diff --git a/deck.h b/deck.h
index b13eb89..5b01599 100644
--- a/deck.h
+++ b/deck.h
@@ -23,3 +23,5 @@ int
deck_get_slide_location (Deck *deck,
GdkRectangle *viewport,
int nth_slide);
+int
+deck_get_height (Deck *deck, GdkRectangle *viewport);
diff --git a/main.c b/main.c
index 15739cd..f289edb 100644
--- a/main.c
+++ b/main.c
@@ -66,30 +66,18 @@ on_main_paint (FooScrollArea *scroll_area,
static void
on_main_viewport_size_changed (FooScrollArea *scroll_area,
- GdkRectangle *viewport,
- GdkRectangle *old_viewport)
+ GdkRectangle *new_viewport,
+ GdkRectangle *old_viewport,
+ gpointer data)
{
- int total_height;
- int nth_slide;
- double old_y;
- double new_y;
-
- /* Compute the y-coordinate of the first visible top edge of a slide */
- nth_slide =
- (old_viewport->y - MARGIN) / (MARGIN + (double)slide_height) + 1;
-
- old_y = nth_slide * (MARGIN + (double)slide_height) + MARGIN;
-
- slide_width = viewport->width - 2 * MARGIN;
- slide_height = slide_width / RATIO;
-
- new_y = nth_slide * (MARGIN + (double)slide_height) + MARGIN;
-
- total_height = N_SLIDES * slide_height + (N_SLIDES + 1) * MARGIN;
+ App *app = data;
+ int nth_slide = deck_get_view_slide (app->deck, old_viewport);
+ int old_location = deck_get_slide_location (app->deck, old_viewport, nth_slide);
+ int new_location = deck_get_slide_location (app->deck, new_viewport, nth_slide);
+ int height = deck_get_height (app->deck, new_viewport);
- foo_scroll_area_set_size_fixed_y (scroll_area, viewport->width,
- total_height,
- old_y + 0.5, new_y + 0.5);
+ foo_scroll_area_set_size_fixed_y (scroll_area, new_viewport->width,
+ height, old_location, new_location);
foo_scroll_area_invalidate (scroll_area);
}