diff options
Diffstat (limited to 'deck.c')
-rw-r--r-- | deck.c | 94 |
1 files changed, 78 insertions, 16 deletions
@@ -8,6 +8,9 @@ struct Deck { DeckChangeNotify notify; /* Called on slide add/delete/reorder */ gpointer data; + + int view_width; + int thumb_width; }; Deck * @@ -22,23 +25,41 @@ deck_new (DeckChangeNotify notify, return deck; } -int -deck_get_slide_height (Deck *deck, int view_width) +void +deck_set_main_width (Deck *deck, int view_width) +{ + deck->view_width = view_width; +} + +static int +get_slide_height (int view_width) { return (view_width - 2 * MARGIN) / RATIO; } -void -deck_paint (Deck *deck, - cairo_t *cr, - int orig_x, - int orig_y, - int width) +int +deck_get_main_slide_height (Deck *deck) +{ + return get_slide_height (deck->view_width); +} + +int +deck_get_thumb_slide_height (Deck *deck) +{ + return get_slide_height (deck->thumb_width); +} + +static void +deck_paint (Deck *deck, + cairo_t *cr, + int orig_x, + int orig_y, + int width) { int height; int i; - height = deck_get_slide_height (deck, width); + height = get_slide_height (width); width -= 2 * MARGIN; @@ -68,6 +89,24 @@ deck_paint (Deck *deck, } } +void +deck_paint_main (Deck *deck, + cairo_t *cr, + int orig_x, + int orig_y) +{ + deck_paint (deck, cr, orig_x, orig_y, deck->view_width); +} + +void +deck_paint_thumbs (Deck *deck, + cairo_t *cr, + int x, + int y) +{ + deck_paint (deck, cr, x, y, deck->thumb_width); +} + /* Returns the slide the user is likely looking * at, given the viewport. */ @@ -75,7 +114,7 @@ int deck_get_view_slide (Deck *deck, GdkRectangle *viewport) { - int slide_height = deck_get_slide_height (deck, viewport->width); + int slide_height = deck_get_main_slide_height (deck); /* Compute the y-coordinate of the first visible top edge of a slide */ return (viewport->y - MARGIN) / (MARGIN + slide_height) + 1; @@ -85,19 +124,42 @@ deck_get_view_slide (Deck *deck, * the viewport */ int -deck_get_slide_location (Deck *deck, - int view_width, - int nth_slide) +deck_get_main_slide_location (Deck *deck, + int nth_slide) { - int slide_height = deck_get_slide_height (deck, view_width); + int slide_height = deck_get_main_slide_height (deck); return nth_slide * (MARGIN + slide_height) + MARGIN; } int -deck_get_height (Deck *deck, int view_width) +deck_get_thumb_slide_location (Deck *deck, + int nth_slide) +{ + int slide_height = deck_get_thumb_slide_height (deck); + + return nth_slide * (MARGIN + slide_height) + MARGIN; +} + +int +deck_get_main_height (Deck *deck) { - int slide_height = deck_get_slide_height (deck, view_width); + int slide_height = deck_get_main_slide_height (deck); return N_SLIDES * slide_height + (N_SLIDES + 1) * MARGIN; } + + +void +deck_set_thumb_width (Deck *deck, int thumb_width) +{ + deck->thumb_width = thumb_width; +} + +int +deck_get_thumb_height (Deck *deck) +{ + int thumb_height = deck_get_thumb_slide_height (deck); + + return N_SLIDES * thumb_height + (N_SLIDES + 1) * MARGIN; +} |