Exemple #1
0
static int do_outline_imp(fz_outline *node, int end, int x0, int x1, int x, int y)
{
	int h = 0;
	int p = currentpage;
	int n = end;

	while (node)
	{
		if (node->dest.kind == FZ_LINK_GOTO)
		{
			p = node->dest.ld.gotor.page;

			if (ui.x >= x0 && ui.x < x1 && ui.y >= y + h && ui.y < y + h + ui.lineheight)
			{
				ui.hot = node;
				if (!ui.active && ui.down)
				{
					ui.active = node;
					jump_to_page(p);
					ui_needs_update = 1; /* we changed the current page, so force a redraw */
				}
			}

			n = end;
			if (node->next && node->next->dest.kind == FZ_LINK_GOTO)
			{
				n = node->next->dest.ld.gotor.page;
			}
			if (currentpage == p || (currentpage > p && currentpage < n))
			{
				glColor4f(0.9f, 0.9f, 0.9f, 1.0f);
				glRectf(x0, y + h, x1, y + h + ui.lineheight);
			}
		}

		glColor4f(0, 0, 0, 1);
		ui_draw_string(ctx, x, y + h + ui.baseline, node->title);
		h += ui.lineheight;
		if (node->down)
			h += do_outline_imp(node->down, n, x0, x1, x + ui.lineheight, y + h);

		node = node->next;
	}
	return h;
}
Exemple #2
0
static void do_outline(fz_outline *node, int outline_w)
{
    static char *id = "outline";
    static int outline_scroll_y = 0;
    static int saved_outline_scroll_y = 0;
    static int saved_ui_y = 0;

    int outline_h;
    int total_h;

    outline_w -= ui.lineheight;
    outline_h = window_h;
    total_h = measure_outline_height(outline);

    if (ui.x >= 0 && ui.x < outline_w && ui.y >= 0 && ui.y < outline_h)
    {
        ui.hot = id;
        if (!ui.active && ui.middle)
        {
            ui.active = id;
            saved_ui_y = ui.y;
            saved_outline_scroll_y = outline_scroll_y;
        }
    }

    if (ui.active == id)
        outline_scroll_y = saved_outline_scroll_y + (saved_ui_y - ui.y) * 5;

    if (ui.hot == id)
        outline_scroll_y -= ui.scroll_y * ui.lineheight * 3;

    ui_scrollbar(outline_w, 0, outline_w+ui.lineheight, outline_h, &outline_scroll_y, outline_h, total_h);

    glScissor(0, 0, outline_w, outline_h);
    glEnable(GL_SCISSOR_TEST);

    glColor4f(1, 1, 1, 1);
    glRectf(0, 0, outline_w, outline_h);

    do_outline_imp(outline, fz_count_pages(ctx, doc), 0, outline_w, 10, -outline_scroll_y);

    glDisable(GL_SCISSOR_TEST);
}