From 5d40458ad550d3a35694167b26f130deae3188e6 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Tue, 19 Oct 2010 22:22:03 +0000 Subject: Auto-scroll on drags beyond window boundaries svn path=/trunk/netsurf/; revision=10894 --- amiga/download.c | 40 +++++++++++++++++----------------------- amiga/download.h | 5 +++-- amiga/gui.c | 29 ++++++++++++++++++++++++++--- amiga/tree.c | 23 +++++++++++++++++++++-- 4 files changed, 67 insertions(+), 30 deletions(-) (limited to 'amiga') diff --git a/amiga/download.c b/amiga/download.c index e6302a842..dd5755310 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -56,12 +56,10 @@ #include +struct Window *drag_icon = NULL; ULONG drag_icon_width; ULONG drag_icon_height; -struct Window *ami_drag_icon_show(struct gui_window *g, char *type, ULONG *x, ULONG *y); -void ami_drag_icon_close(struct Window *win); - struct gui_download_window *gui_download_window_create(download_context *ctx, struct gui_window *gui) { @@ -360,7 +358,7 @@ void gui_drag_save_object(gui_save_type type, hlcache_handle *c, break; } - drag_icon = ami_drag_icon_show(g, filetype, &drag_icon_width, &drag_icon_height); + ami_drag_icon_show(g->shared->win, filetype); drag_save_data = c; drag_save_gui = g; @@ -369,7 +367,7 @@ void gui_drag_save_object(gui_save_type type, hlcache_handle *c, void gui_drag_save_selection(struct selection *s, struct gui_window *g) { - drag_icon = ami_drag_icon_show(g, "ascii", &drag_icon_width, &drag_icon_height); + ami_drag_icon_show(g->shared->win, "ascii"); drag_save_data = s; drag_save = GUI_SAVE_TEXT_SELECTION; @@ -382,7 +380,7 @@ void ami_drag_save(struct Window *win) char *source_data; ULONG source_size; - if(drag_icon) ami_drag_icon_close(drag_icon); + if(drag_icon) ami_drag_icon_close(); if(strcmp(option_use_pubscreen,"Workbench") == 0) { @@ -493,9 +491,8 @@ void ami_drag_save(struct Window *win) ami_update_pointer(win,GUI_POINTER_DEFAULT); } -struct Window *ami_drag_icon_show(struct gui_window *g, char *type, ULONG *x, ULONG *y) +void ami_drag_icon_show(struct Window *win, char *type) { - struct Window *win; struct DiskObject *dobj = NULL; ULONG *icondata1; ULONG width, height; @@ -505,12 +502,12 @@ struct Window *ami_drag_icon_show(struct gui_window *g, char *type, ULONG *x, UL if(option_drag_save_icons == false) { - gui_window_set_pointer(g, AMI_GUI_POINTER_DRAG); - return NULL; + ami_update_pointer(win, AMI_GUI_POINTER_DRAG); + return; } else { - gui_window_set_pointer(g, GUI_POINTER_DEFAULT); + ami_update_pointer(win, GUI_POINTER_DEFAULT); } if(type == "drawer") deftype = WBDRAWER; @@ -524,10 +521,10 @@ struct Window *ami_drag_icon_show(struct gui_window *g, char *type, ULONG *x, UL ICONCTRLA_GetHeight,&height, TAG_DONE); - *x = width; - *y = height; + drag_icon_width = width; + drag_icon_height = height; - win = OpenWindowTags(NULL, + drag_icon = OpenWindowTags(NULL, WA_Left, scrn->MouseX - (width/2), WA_Top, scrn->MouseY - (height/2), WA_Width, width, @@ -542,27 +539,24 @@ struct Window *ami_drag_icon_show(struct gui_window *g, char *type, ULONG *x, UL /* probably need layouticon and drawinfo stuff too */ - DrawIconState(win->RPort, dobj, NULL, 0, 0, IDS_NORMAL, + DrawIconState(drag_icon->RPort, dobj, NULL, 0, 0, IDS_NORMAL, ICONDRAWA_Frameless, TRUE, ICONDRAWA_Borderless, TRUE, -// ICONDRAWA_Transparency, 128, TAG_DONE); - - return win; } -void ami_drag_icon_move(struct Window *win) +void ami_drag_icon_move(void) { - if(win == NULL) return; + if(drag_icon == NULL) return; - ChangeWindowBox(win, scrn->MouseX - (drag_icon_width / 2), + ChangeWindowBox(drag_icon, scrn->MouseX - (drag_icon_width / 2), scrn->MouseY - (drag_icon_height / 2), drag_icon_width, drag_icon_height); } -void ami_drag_icon_close(struct Window *win) +void ami_drag_icon_close(void) { - if(win) CloseWindow(win); + if(drag_icon) CloseWindow(drag_icon); drag_icon = NULL; } diff --git a/amiga/download.h b/amiga/download.h index ebf0c4b6d..782a414c8 100755 --- a/amiga/download.h +++ b/amiga/download.h @@ -45,12 +45,13 @@ struct gui_download_window { int drag_save; void *drag_save_data; struct gui_window *drag_save_gui; -struct Window *drag_icon; void ami_download_window_abort(struct gui_download_window *dw); BOOL ami_download_window_event(struct gui_download_window *dw); void ami_drag_save(struct Window *win); -void ami_drag_icon_move(struct Window *win); +void ami_drag_icon_show(struct Window *win, char *type); +void ami_drag_icon_close(void); +void ami_drag_icon_move(void); void ami_free_download_list(struct List *dllist); void ami_superimpose_favicon(STRPTR path, struct hlcache_handle *icon, STRPTR type); diff --git a/amiga/gui.c b/amiga/gui.c index 759b4f932..bcd0c0365 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -1012,9 +1012,6 @@ void ami_handle_msg(void) switch(result & WMHI_CLASSMASK) // class { case WMHI_MOUSEMOVE: - if(drag_icon) - ami_drag_icon_move(drag_icon); - GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER], (ULONG *)&bbox); @@ -1030,6 +1027,32 @@ void ami_handle_msg(void) width=bbox->Width; height=bbox->Height; + if(gwin->mouse_state & BROWSER_MOUSE_DRAG_ON) + { + int drag_x_move = 0, drag_y_move = 0; + + ami_drag_icon_move(); + + if(gwin->win->MouseX < bbox->Left) + drag_x_move = gwin->win->MouseX - bbox->Left; + if(gwin->win->MouseX > (bbox->Left + bbox->Width)) + drag_x_move = gwin->win->MouseX - (bbox->Left + bbox->Width); + if(gwin->win->MouseY < bbox->Top) + drag_y_move = gwin->win->MouseY - bbox->Top; + if(gwin->win->MouseY > (bbox->Top + bbox->Height)) + drag_y_move = gwin->win->MouseY - (bbox->Top + bbox->Height); + + if(drag_x_move || drag_y_move) + { + gui_window_get_scroll(gwin->bw->window, + &gwin->bw->window->scrollx, &gwin->bw->window->scrolly); + + gui_window_set_scroll(gwin->bw->window, + gwin->bw->window->scrollx + drag_x_move, + gwin->bw->window->scrolly + drag_y_move); + } + } + if((x>=xs) && (y>=ys) && (xobjects[OID_HSCROLL], (ULONG *)&x); GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&y); @@ -678,6 +676,27 @@ BOOL ami_tree_event(struct treeview_window *twin) GetAttr(SCROLLER_Top, twin->objects[OID_VSCROLL], (ULONG *)&ys); y = twin->win->MouseY - bbox->Top + ys; + if(twin->mouse_state & BROWSER_MOUSE_DRAG_ON) + { + int drag_x_move = 0, drag_y_move = 0; + + /* TODO: Show drag icons on TREE_MOVE_DRAG start. + * Until then, the below line does nothing. */ + ami_drag_icon_move(); + + if(twin->win->MouseX < bbox->Left) + drag_x_move = twin->win->MouseX - bbox->Left; + if(twin->win->MouseX > (bbox->Left + bbox->Width)) + drag_x_move = twin->win->MouseX - (bbox->Left + bbox->Width); + if(twin->win->MouseY < bbox->Top) + drag_y_move = twin->win->MouseY - bbox->Top; + if(twin->win->MouseY > (bbox->Top + bbox->Height)) + drag_y_move = twin->win->MouseY - (bbox->Top + bbox->Height); + + if(drag_x_move || drag_y_move) + ami_tree_scroll(twin, drag_x_move, drag_y_move); + } + if((x >= xs) && (y >= ys) && (x < bbox->Width + xs) && (y < bbox->Height + ys)) { -- cgit v1.2.3