Add ability to render part of a local history window.
This is achieved through new function history_redraw_rectangle. It takes the co-ordinates of the history area to plot as parameters 2-5 and the co-ordinates of the top-left position to draw this area as params 6,7 Added local history scrolling to Amiga port using the above function. svn path=/trunk/netsurf/; revision=6740
This commit is contained in:
parent
0bdcf4b8e2
commit
2014dac36d
|
@ -36,12 +36,16 @@
|
|||
#include "amiga/history_local.h"
|
||||
#include <proto/exec.h>
|
||||
#include <proto/graphics.h>
|
||||
#include <intuition/icclass.h>
|
||||
#include <proto/utility.h>
|
||||
#include "utils/messages.h"
|
||||
|
||||
#include <proto/window.h>
|
||||
#include <proto/space.h>
|
||||
#include <proto/layout.h>
|
||||
#include <classes/window.h>
|
||||
#include <gadgets/space.h>
|
||||
#include <gadgets/scroller.h>
|
||||
#include <reaction/reaction.h>
|
||||
#include <reaction/reaction_macros.h>
|
||||
|
||||
|
@ -52,6 +56,10 @@ static int mouse_x = 0;
|
|||
static int mouse_y = 0;
|
||||
static struct history_window *hwindow;
|
||||
|
||||
void ami_history_update_extent(struct history_window *hw);
|
||||
void ami_history_redraw(struct history_window *hw);
|
||||
static void ami_history_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg);
|
||||
|
||||
/**
|
||||
* Open history window.
|
||||
*
|
||||
|
@ -63,6 +71,7 @@ static struct history_window *hwindow;
|
|||
void ami_history_open(struct browser_window *bw, struct history *history)
|
||||
{
|
||||
int width, height;
|
||||
struct IBox *bbox;
|
||||
|
||||
assert(history);
|
||||
|
||||
|
@ -75,6 +84,9 @@ void ami_history_open(struct browser_window *bw, struct history *history)
|
|||
hwindow->bw = bw;
|
||||
history_size(history, &width, &height);
|
||||
|
||||
hwindow->scrollerhook.h_Entry = (void *)ami_history_scroller_hook;
|
||||
hwindow->scrollerhook.h_Data = hwindow;
|
||||
|
||||
hwindow->objects[OID_MAIN] = WindowObject,
|
||||
WA_ScreenTitle,nsscreentitle,
|
||||
WA_Title,messages_get("History"),
|
||||
|
@ -90,9 +102,13 @@ void ami_history_open(struct browser_window *bw, struct history *history)
|
|||
WINDOW_UserData,hwindow,
|
||||
WINDOW_IconifyGadget, FALSE,
|
||||
WINDOW_Position, WPOS_CENTERSCREEN,
|
||||
WA_ReportMouse,TRUE,
|
||||
WINDOW_HorizProp,1,
|
||||
WINDOW_VertProp,1,
|
||||
WINDOW_IDCMPHook,&hwindow->scrollerhook,
|
||||
WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE,
|
||||
// WA_ReportMouse,TRUE,
|
||||
WA_IDCMP,IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE, // | IDCMP_MOUSEMOVE,
|
||||
WINDOW_ParentGroup, VGroupObject,
|
||||
WINDOW_ParentGroup, hwindow->gadgets[GID_MAIN] = VGroupObject,
|
||||
LAYOUT_AddChild, hwindow->gadgets[GID_BROWSER] = SpaceObject,
|
||||
GA_ID,GID_BROWSER,
|
||||
// SPACE_MinWidth,width,
|
||||
|
@ -105,6 +121,21 @@ void ami_history_open(struct browser_window *bw, struct history *history)
|
|||
// hwindow->bw->window = hwindow;
|
||||
hwindow->node = AddObject(window_list,AMINS_HISTORYWINDOW);
|
||||
hwindow->node->objstruct = hwindow;
|
||||
|
||||
GetAttr(WINDOW_HorizObject,hwindow->objects[OID_MAIN],(ULONG *)&hwindow->objects[OID_HSCROLL]);
|
||||
GetAttr(WINDOW_VertObject,hwindow->objects[OID_MAIN],(ULONG *)&hwindow->objects[OID_VSCROLL]);
|
||||
|
||||
RefreshSetGadgetAttrs((APTR)hwindow->objects[OID_VSCROLL],hwindow->win,NULL,
|
||||
GA_ID,OID_VSCROLL,
|
||||
SCROLLER_Top,0,
|
||||
ICA_TARGET,ICTARGET_IDCMP,
|
||||
TAG_DONE);
|
||||
|
||||
RefreshSetGadgetAttrs((APTR)hwindow->objects[OID_HSCROLL],hwindow->win,NULL,
|
||||
GA_ID,OID_HSCROLL,
|
||||
SCROLLER_Top,0,
|
||||
ICA_TARGET,ICTARGET_IDCMP,
|
||||
TAG_DONE);
|
||||
}
|
||||
|
||||
hwindow->bw = bw;
|
||||
|
@ -119,14 +150,26 @@ void ami_history_open(struct browser_window *bw, struct history *history)
|
|||
void ami_history_redraw(struct history_window *hw)
|
||||
{
|
||||
struct IBox *bbox;
|
||||
ULONG xs,ys;
|
||||
|
||||
GetAttr(SPACE_AreaBox,hw->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
ami_clg(0xffffff);
|
||||
GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
|
||||
GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);
|
||||
|
||||
history_redraw(history_current);
|
||||
//ami_clg(0xffffff);
|
||||
|
||||
RefreshGadgets(hw->gadgets[GID_MAIN],hw->win,NULL);
|
||||
currp = hw->win->RPort;
|
||||
history_redraw_rectangle(history_current, xs, ys,
|
||||
bbox->Width + xs, bbox->Height + ys,
|
||||
bbox->Left, bbox->Top);
|
||||
|
||||
currp = &glob.rp;
|
||||
|
||||
ami_clearclipreg(currp);
|
||||
BltBitMapRastPort(glob.bm,0,0,hw->win->RPort,bbox->Left,bbox->Top,bbox->Width,bbox->Height,0x0C0);
|
||||
ami_history_update_extent(hw);
|
||||
|
||||
// BltBitMapRastPort(glob.bm,0,0,hw->win->RPort,bbox->Left,bbox->Top,bbox->Width,bbox->Height,0x0C0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,14 +182,14 @@ bool ami_history_click(struct history_window *hw,uint16 code)
|
|||
{
|
||||
int x, y;
|
||||
struct IBox *bbox;
|
||||
ULONG width,height;
|
||||
ULONG width,height,xs,ys;
|
||||
|
||||
GetAttr(SPACE_AreaBox,hw->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
|
||||
// GetAttr(SCROLLER_Top,gwin->objects[OID_HSCROLL],(ULONG *)&xs);
|
||||
x = hw->win->MouseX - bbox->Left; // +xs;
|
||||
// GetAttr(SCROLLER_Top,gwin->objects[OID_VSCROLL],(ULONG *)&ys);
|
||||
y = hw->win->MouseY - bbox->Top; // + ys;
|
||||
GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
|
||||
x = hw->win->MouseX - bbox->Left +xs;
|
||||
GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);
|
||||
y = hw->win->MouseY - bbox->Top + ys;
|
||||
|
||||
width=bbox->Width;
|
||||
height=bbox->Height;
|
||||
|
@ -218,3 +261,48 @@ BOOL ami_history_event(struct history_window *hw)
|
|||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void ami_history_update_extent(struct history_window *hw)
|
||||
{
|
||||
struct IBox *bbox;
|
||||
int width, height;
|
||||
|
||||
history_size(hw->bw->history, &width, &height);
|
||||
GetAttr(SPACE_AreaBox,hw->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
|
||||
RefreshSetGadgetAttrs((APTR)hw->objects[OID_VSCROLL],hw->win,NULL,
|
||||
GA_ID,OID_VSCROLL,
|
||||
SCROLLER_Total,height,
|
||||
SCROLLER_Visible,bbox->Height,
|
||||
// SCROLLER_Top,0,
|
||||
ICA_TARGET,ICTARGET_IDCMP,
|
||||
TAG_DONE);
|
||||
|
||||
RefreshSetGadgetAttrs((APTR)hw->objects[OID_HSCROLL],hw->win,NULL,
|
||||
GA_ID,OID_HSCROLL,
|
||||
SCROLLER_Total,width,
|
||||
SCROLLER_Visible,bbox->Width,
|
||||
// SCROLLER_Top,0,
|
||||
ICA_TARGET,ICTARGET_IDCMP,
|
||||
TAG_DONE);
|
||||
}
|
||||
|
||||
void ami_history_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg)
|
||||
{
|
||||
ULONG gid,x,y;
|
||||
struct history_window *hw = hook->h_Data;
|
||||
|
||||
if (msg->Class == IDCMP_IDCMPUPDATE)
|
||||
{
|
||||
gid = GetTagData( GA_ID, 0, msg->IAddress );
|
||||
|
||||
switch( gid )
|
||||
{
|
||||
case OID_HSCROLL:
|
||||
case OID_VSCROLL:
|
||||
ami_history_redraw(hw);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// ReplyMsg((struct Message *)msg);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ struct history_window {
|
|||
struct nsObject *node;
|
||||
struct browser_window *bw;
|
||||
ULONG pad[4];
|
||||
|
||||
struct Hook scrollerhook;
|
||||
};
|
||||
|
||||
void ami_history_open(struct browser_window *bw, struct history *history);
|
||||
|
|
|
@ -86,7 +86,9 @@ static void history_layout(struct history *history);
|
|||
static int history_layout_subtree(struct history *history,
|
||||
struct history_entry *entry, int x, int y, bool shuffle);
|
||||
static bool history_redraw_entry(struct history *history,
|
||||
struct history_entry *entry);
|
||||
struct history_entry *entry,
|
||||
int x0, int y0, int x1, int y1,
|
||||
int x, int y, bool clip);
|
||||
static struct history_entry *history_find_position(struct history_entry *entry,
|
||||
int x, int y);
|
||||
|
||||
|
@ -580,9 +582,32 @@ bool history_redraw(struct history *history)
|
|||
{
|
||||
if (!history->start)
|
||||
return true;
|
||||
return history_redraw_entry(history, history->start);
|
||||
return history_redraw_entry(history, history->start, 0, 0, 0, 0, 0, 0, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redraw part of a history.
|
||||
*
|
||||
* \param history history to render
|
||||
* \param x0 left X co-ordinate of redraw area
|
||||
* \param y0 top Y co-ordinate of redraw area
|
||||
* \param x1 right X co-ordinate of redraw area
|
||||
* \param y1 lower Y co-ordinate of redraw area
|
||||
* \param x start X co-ordinate on plot canvas
|
||||
* \param y start Y co-ordinate on plot canvas
|
||||
*
|
||||
* The current plotter is used.
|
||||
*/
|
||||
|
||||
bool history_redraw_rectangle(struct history *history,
|
||||
int x0, int y0, int x1, int y1,
|
||||
int x, int y)
|
||||
{
|
||||
if (!history->start)
|
||||
return true;
|
||||
return history_redraw_entry(history, history->start,
|
||||
x0, y0, x1, y1, x, y, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively redraw a history_entry.
|
||||
|
@ -592,18 +617,28 @@ bool history_redraw(struct history *history)
|
|||
*/
|
||||
|
||||
bool history_redraw_entry(struct history *history,
|
||||
struct history_entry *entry)
|
||||
struct history_entry *entry,
|
||||
int x0, int y0, int x1, int y1,
|
||||
int x, int y, bool clip)
|
||||
{
|
||||
size_t char_offset;
|
||||
int actual_x;
|
||||
struct history_entry *child;
|
||||
colour c = entry == history->current ? 0x0000ff : 0x333333;
|
||||
int tailsize = 5;
|
||||
int xoffset = x - x0;
|
||||
int yoffset = y - y0;
|
||||
|
||||
if (!plot.bitmap(entry->x, entry->y, WIDTH, HEIGHT,
|
||||
if (clip) {
|
||||
if(!plot.clip(x0 + xoffset, y0 + yoffset, x1 + xoffset, y1 + yoffset))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!plot.bitmap(entry->x + xoffset, entry->y + yoffset, WIDTH, HEIGHT,
|
||||
entry->bitmap, 0xffffff, NULL))
|
||||
return false;
|
||||
if (!plot.rectangle(entry->x - 1, entry->y - 1, WIDTH + 1, HEIGHT + 1,
|
||||
if (!plot.rectangle(entry->x - 1 + xoffset, entry->y - 1 + yoffset,
|
||||
WIDTH + 1, HEIGHT + 1,
|
||||
entry == history->current ? 2 : 1, c, false, false))
|
||||
return false;
|
||||
|
||||
|
@ -611,26 +646,29 @@ bool history_redraw_entry(struct history *history,
|
|||
strlen(entry->page.title), WIDTH,
|
||||
&char_offset, &actual_x))
|
||||
return false;
|
||||
if (!plot.text(entry->x, entry->y + HEIGHT + 12, &css_base_style,
|
||||
entry->page.title, char_offset, 0xffffff, c))
|
||||
if (!plot.text(entry->x + xoffset, entry->y + HEIGHT + 12 + yoffset,
|
||||
&css_base_style, entry->page.title, char_offset, 0xffffff, c))
|
||||
return false;
|
||||
|
||||
for (child = entry->forward; child; child = child->next) {
|
||||
if (!plot.line(entry->x + WIDTH, entry->y + HEIGHT / 2,
|
||||
entry->x + WIDTH + tailsize,
|
||||
entry->y + HEIGHT / 2, 1,
|
||||
if (!plot.line(entry->x + WIDTH + xoffset,
|
||||
entry->y + HEIGHT / 2 + yoffset,
|
||||
entry->x + WIDTH + tailsize + xoffset,
|
||||
entry->y + HEIGHT / 2 + yoffset, 1,
|
||||
0x333333, false, false))
|
||||
return false;
|
||||
if (!plot.line(entry->x + WIDTH + tailsize,
|
||||
entry->y + HEIGHT / 2,
|
||||
child->x - tailsize, child->y + HEIGHT / 2, 1,
|
||||
if (!plot.line(entry->x + WIDTH + tailsize + xoffset,
|
||||
entry->y + HEIGHT / 2 + yoffset,
|
||||
child->x - tailsize +xoffset,
|
||||
child->y + HEIGHT / 2 + yoffset, 1,
|
||||
0x333333, false, false))
|
||||
return false;
|
||||
if (!plot.line(child->x - tailsize, child->y + HEIGHT / 2,
|
||||
child->x, child->y + HEIGHT / 2, 1,
|
||||
if (!plot.line(child->x - tailsize + xoffset,
|
||||
child->y + HEIGHT / 2 + yoffset,
|
||||
child->x + xoffset, child->y + HEIGHT / 2 + yoffset, 1,
|
||||
0x333333, false, false))
|
||||
return false;
|
||||
if (!history_redraw_entry(history, child))
|
||||
if (!history_redraw_entry(history, child, x0, y0, x1, y1, x, y, clip))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ bool history_back_available(struct history *history);
|
|||
bool history_forward_available(struct history *history);
|
||||
void history_size(struct history *history, int *width, int *height);
|
||||
bool history_redraw(struct history *history);
|
||||
bool history_redraw_rectangle(struct history *history,
|
||||
int x0, int y0, int x1, int y1, int x, int y);
|
||||
bool history_click(struct browser_window *bw, struct history *history,
|
||||
int x, int y, bool new_window);
|
||||
const char *history_position_url(struct history *history, int x, int y);
|
||||
|
|
Loading…
Reference in New Issue