mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 04:02:34 +03:00
Local history: Consolidate thumbnail dimensions.
This commit is contained in:
parent
ab03b204ba
commit
813a284e9e
@ -42,12 +42,6 @@
|
||||
#include "desktop/browser_private.h"
|
||||
#include "desktop/browser_history.h"
|
||||
|
||||
#define WIDTH 100
|
||||
#define HEIGHT 86
|
||||
#define RIGHT_MARGIN 50
|
||||
#define BOTTOM_MARGIN 30
|
||||
|
||||
|
||||
/**
|
||||
* Clone a history entry
|
||||
*
|
||||
@ -107,8 +101,10 @@ browser_window_history__clone_entry(struct history *history,
|
||||
unsigned char *bmdst_data;
|
||||
size_t bmsize;
|
||||
|
||||
new_entry->page.bitmap = guit->bitmap->create(WIDTH, HEIGHT,
|
||||
BITMAP_NEW | BITMAP_OPAQUE);
|
||||
new_entry->page.bitmap = guit->bitmap->create(
|
||||
LOCAL_HISTORY_WIDTH,
|
||||
LOCAL_HISTORY_HEIGHT,
|
||||
BITMAP_NEW | BITMAP_OPAQUE);
|
||||
|
||||
if (new_entry->page.bitmap != NULL) {
|
||||
bmsrc_data = guit->bitmap->get_buffer(entry->page.bitmap);
|
||||
@ -202,26 +198,26 @@ static int browser_window_history__layout_subtree(struct history *history,
|
||||
struct history_entry *child;
|
||||
int y1 = y;
|
||||
|
||||
if (history->width < x + WIDTH)
|
||||
history->width = x + WIDTH;
|
||||
if (history->width < x + LOCAL_HISTORY_WIDTH)
|
||||
history->width = x + LOCAL_HISTORY_WIDTH;
|
||||
|
||||
if (!entry->forward) {
|
||||
entry->x = x;
|
||||
entry->y = y;
|
||||
return y + HEIGHT;
|
||||
return y + LOCAL_HISTORY_HEIGHT;
|
||||
}
|
||||
|
||||
/* layout child subtrees below each other */
|
||||
for (child = entry->forward; child; child = child->next) {
|
||||
y1 = browser_window_history__layout_subtree(history, child,
|
||||
x + WIDTH + RIGHT_MARGIN, y1);
|
||||
x + LOCAL_HISTORY_WIDTH + LOCAL_HISTORY_RIGHT_MARGIN, y1);
|
||||
if (child->next)
|
||||
y1 += BOTTOM_MARGIN;
|
||||
y1 += LOCAL_HISTORY_BOTTOM_MARGIN;
|
||||
}
|
||||
|
||||
/* place ourselves in the middle */
|
||||
entry->x = x;
|
||||
entry->y = (y + y1) / 2 - HEIGHT / 2;
|
||||
entry->y = (y + y1) / 2 - LOCAL_HISTORY_HEIGHT / 2;
|
||||
|
||||
return y1;
|
||||
}
|
||||
@ -244,12 +240,13 @@ static void browser_window_history__layout(struct history *history)
|
||||
if (history->start)
|
||||
history->height = browser_window_history__layout_subtree(
|
||||
history, history->start,
|
||||
RIGHT_MARGIN / 2, BOTTOM_MARGIN / 2);
|
||||
LOCAL_HISTORY_RIGHT_MARGIN / 2,
|
||||
LOCAL_HISTORY_BOTTOM_MARGIN / 2);
|
||||
else
|
||||
history->height = 0;
|
||||
|
||||
history->width += RIGHT_MARGIN / 2;
|
||||
history->height += BOTTOM_MARGIN / 2;
|
||||
history->width += LOCAL_HISTORY_RIGHT_MARGIN / 2;
|
||||
history->height += LOCAL_HISTORY_BOTTOM_MARGIN / 2;
|
||||
}
|
||||
|
||||
|
||||
@ -275,7 +272,8 @@ static bool browser_window_history__enumerate_entry(
|
||||
const struct history_entry *child;
|
||||
|
||||
if (!cb(bw, entry->x, entry->y,
|
||||
entry->x + WIDTH, entry->y + HEIGHT,
|
||||
entry->x + LOCAL_HISTORY_WIDTH,
|
||||
entry->y + LOCAL_HISTORY_HEIGHT,
|
||||
entry, ud))
|
||||
return false;
|
||||
|
||||
@ -304,8 +302,8 @@ nserror browser_window_history_create(struct browser_window *bw)
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
history->width = RIGHT_MARGIN / 2;
|
||||
history->height = BOTTOM_MARGIN / 2;
|
||||
history->width = LOCAL_HISTORY_RIGHT_MARGIN / 2;
|
||||
history->height = LOCAL_HISTORY_BOTTOM_MARGIN / 2;
|
||||
|
||||
bw->history = history;
|
||||
|
||||
@ -386,7 +384,8 @@ browser_window_history_add(struct browser_window *bw,
|
||||
NSLOG(netsurf, DEBUG,
|
||||
"Creating thumbnail for %s", nsurl_access(entry->page.url));
|
||||
|
||||
entry->page.bitmap = guit->bitmap->create(WIDTH, HEIGHT,
|
||||
entry->page.bitmap = guit->bitmap->create(
|
||||
LOCAL_HISTORY_WIDTH, LOCAL_HISTORY_HEIGHT,
|
||||
BITMAP_NEW | BITMAP_CLEAR_MEMORY | BITMAP_OPAQUE);
|
||||
if (entry->page.bitmap != NULL) {
|
||||
ret = guit->bitmap->render(entry->page.bitmap, content);
|
||||
@ -637,7 +636,8 @@ void browser_window_history_enumerate_forward(const struct browser_window *bw,
|
||||
|
||||
e = bw->history->current->forward_pref;
|
||||
for (; e != NULL; e = e->forward_pref) {
|
||||
if (!cb(bw, e->x, e->y, e->x + WIDTH, e->y + HEIGHT,
|
||||
if (!cb(bw, e->x, e->y, e->x + LOCAL_HISTORY_WIDTH,
|
||||
e->y + LOCAL_HISTORY_HEIGHT,
|
||||
e, user_data))
|
||||
break;
|
||||
}
|
||||
@ -654,7 +654,8 @@ void browser_window_history_enumerate_back(const struct browser_window *bw,
|
||||
return;
|
||||
|
||||
for (e = bw->history->current->back; e != NULL; e = e->back) {
|
||||
if (!cb(bw, e->x, e->y, e->x + WIDTH, e->y + HEIGHT,
|
||||
if (!cb(bw, e->x, e->y, e->x + LOCAL_HISTORY_WIDTH,
|
||||
e->y + LOCAL_HISTORY_HEIGHT,
|
||||
e, user_data))
|
||||
break;
|
||||
}
|
||||
|
@ -35,6 +35,17 @@
|
||||
|
||||
#include "utils/errors.h"
|
||||
|
||||
#include "content/handlers/css/utils.h"
|
||||
|
||||
#define LOCAL_HISTORY_WIDTH \
|
||||
(FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(116))))
|
||||
#define LOCAL_HISTORY_HEIGHT \
|
||||
(FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(100))))
|
||||
#define LOCAL_HISTORY_RIGHT_MARGIN \
|
||||
(FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(50))))
|
||||
#define LOCAL_HISTORY_BOTTOM_MARGIN \
|
||||
(FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(30))))
|
||||
|
||||
struct browser_window;
|
||||
struct history_entry;
|
||||
struct bitmap;
|
||||
|
@ -39,13 +39,6 @@
|
||||
#include "desktop/browser_history.h"
|
||||
#include "desktop/local_history.h"
|
||||
|
||||
#include "content/handlers/css/utils.h"
|
||||
|
||||
#define WIDTH (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(116))))
|
||||
#define HEIGHT (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(100))))
|
||||
#define RIGHT_MARGIN (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(50))))
|
||||
#define BOTTOM_MARGIN (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(30))))
|
||||
|
||||
/**
|
||||
* local history viewer context
|
||||
*/
|
||||
@ -166,7 +159,8 @@ redraw_entry(struct history *history,
|
||||
entry->page.bitmap,
|
||||
entry->x + x,
|
||||
entry->y + y,
|
||||
WIDTH, HEIGHT,
|
||||
LOCAL_HISTORY_WIDTH,
|
||||
LOCAL_HISTORY_HEIGHT,
|
||||
0xffffff,
|
||||
0);
|
||||
if (res != NSERROR_OK) {
|
||||
@ -176,8 +170,8 @@ redraw_entry(struct history *history,
|
||||
|
||||
rect.x0 = entry->x - 1 + x;
|
||||
rect.y0 = entry->y - 1 + y;
|
||||
rect.x1 = entry->x + x + WIDTH;
|
||||
rect.y1 = entry->y + y + HEIGHT;
|
||||
rect.x1 = entry->x + x + LOCAL_HISTORY_WIDTH;
|
||||
rect.y1 = entry->y + y + LOCAL_HISTORY_HEIGHT;
|
||||
res = ctx->plot->rectangle(ctx, pstyle, &rect);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
@ -193,7 +187,7 @@ redraw_entry(struct history *history,
|
||||
}
|
||||
|
||||
res = guit->layout->position(plot_style_font, entry->page.title,
|
||||
strlen(entry->page.title), WIDTH,
|
||||
strlen(entry->page.title), LOCAL_HISTORY_WIDTH,
|
||||
&char_offset, &actual_x);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
@ -202,7 +196,7 @@ redraw_entry(struct history *history,
|
||||
res = ctx->plot->text(ctx,
|
||||
pfstyle,
|
||||
entry->x + x,
|
||||
entry->y + HEIGHT + 12 + y,
|
||||
entry->y + LOCAL_HISTORY_HEIGHT + 12 + y,
|
||||
entry->page.title,
|
||||
char_offset);
|
||||
if (res != NSERROR_OK) {
|
||||
@ -211,28 +205,28 @@ redraw_entry(struct history *history,
|
||||
|
||||
/* for each child node draw a line and recurse redraw into it */
|
||||
for (child = entry->forward; child; child = child->next) {
|
||||
rect.x0 = entry->x + WIDTH + x;
|
||||
rect.y0 = entry->y + HEIGHT / 2 + y;
|
||||
rect.x1 = entry->x + WIDTH + tailsize + x;
|
||||
rect.y1 = entry->y + HEIGHT / 2 + y;
|
||||
rect.x0 = entry->x + LOCAL_HISTORY_WIDTH + x;
|
||||
rect.y0 = entry->y + LOCAL_HISTORY_HEIGHT / 2 + y;
|
||||
rect.x1 = entry->x + LOCAL_HISTORY_WIDTH + tailsize + x;
|
||||
rect.y1 = entry->y + LOCAL_HISTORY_HEIGHT / 2 + y;
|
||||
res = ctx->plot->line(ctx, &pstyle_line, &rect);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
rect.x0 = entry->x + WIDTH + tailsize + x;
|
||||
rect.y0 = entry->y + HEIGHT / 2 + y;
|
||||
rect.x0 = entry->x + LOCAL_HISTORY_WIDTH + tailsize + x;
|
||||
rect.y0 = entry->y + LOCAL_HISTORY_HEIGHT / 2 + y;
|
||||
rect.x1 = child->x - tailsize + x;
|
||||
rect.y1 = child->y + HEIGHT / 2 + y;
|
||||
rect.y1 = child->y + LOCAL_HISTORY_HEIGHT / 2 + y;
|
||||
res = ctx->plot->line(ctx, &pstyle_line, &rect);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
rect.x0 = child->x - tailsize + x;
|
||||
rect.y0 = child->y + HEIGHT / 2 + y;
|
||||
rect.y0 = child->y + LOCAL_HISTORY_HEIGHT / 2 + y;
|
||||
rect.x1 = child->x + x;
|
||||
rect.y1 = child->y + HEIGHT / 2 + y;
|
||||
rect.y1 = child->y + LOCAL_HISTORY_HEIGHT / 2 + y;
|
||||
res = ctx->plot->line(ctx, &pstyle_line, &rect);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
@ -267,9 +261,9 @@ find_entry_position(struct history_entry *entry, int x, int y)
|
||||
}
|
||||
|
||||
if ((entry->x <= x) &&
|
||||
(x <= entry->x + WIDTH) &&
|
||||
(x <= entry->x + LOCAL_HISTORY_WIDTH) &&
|
||||
(entry->y <= y) &&
|
||||
(y <= entry->y + HEIGHT)) {
|
||||
(y <= entry->y + LOCAL_HISTORY_HEIGHT)) {
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -293,10 +287,12 @@ local_history_scroll_to_cursor(struct local_history_session *session)
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
cursor.x0 = session->cursor->x - RIGHT_MARGIN / 2;
|
||||
cursor.y0 = session->cursor->y - BOTTOM_MARGIN / 2;
|
||||
cursor.x1 = cursor.x0 + WIDTH + RIGHT_MARGIN / 2;
|
||||
cursor.y1 = cursor.y0 + HEIGHT + BOTTOM_MARGIN / 2;
|
||||
cursor.x0 = session->cursor->x - LOCAL_HISTORY_RIGHT_MARGIN / 2;
|
||||
cursor.y0 = session->cursor->y - LOCAL_HISTORY_BOTTOM_MARGIN / 2;
|
||||
cursor.x1 = cursor.x0 + LOCAL_HISTORY_WIDTH +
|
||||
LOCAL_HISTORY_RIGHT_MARGIN / 2;
|
||||
cursor.y1 = cursor.y0 + LOCAL_HISTORY_HEIGHT +
|
||||
LOCAL_HISTORY_BOTTOM_MARGIN / 2;
|
||||
|
||||
session->cw_t->scroll_visible(session->core_window_handle, &cursor);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user