diff options
-rwxr-xr-x | atari/browser.c | 114 | ||||
-rwxr-xr-x | atari/browser_win.c | 162 | ||||
-rwxr-xr-x | atari/global_evnt.c | 1 | ||||
-rwxr-xr-x | atari/global_evnt.h | 3 | ||||
-rwxr-xr-x | atari/gui.c | 88 | ||||
-rwxr-xr-x | atari/gui.h | 10 | ||||
-rwxr-xr-x | atari/treeview.c | 100 | ||||
-rwxr-xr-x | atari/treeview.h | 2 |
8 files changed, 202 insertions, 278 deletions
diff --git a/atari/browser.c b/atari/browser.c index 0c6d394a8..98602835d 100755 --- a/atari/browser.c +++ b/atari/browser.c @@ -58,13 +58,8 @@ #include "atari/ctxmenu.h" #include "cflib.h"
-extern browser_mouse_state bmstate;
-extern int mouse_click_time[3];
-extern int mouse_hold_start[3];
extern GEM_PLOTTER plotter;
extern struct gui_window *input_window;
-extern short last_drag_x;
-extern short last_drag_y; static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect ); static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff, @@ -156,18 +151,17 @@ void browser_get_rect( struct gui_window * gw, enum browser_rect type, LGRECT * LGRECT cur; /* Query component for it's current size: */ - mt_CompGetLGrect(&app, gw->browser->comp, WF_WORKXYWH, &cur); - /* And extract the different widget dimensions: */ - /* Redraw area of html content: */
+ /* And extract the different widget dimensions: */ if( type == BR_CONTENT ){
out->g_w = cur.g_w;
out->g_h = cur.g_h;
out->g_x = cur.g_x;
out->g_y = cur.g_y;
- return;
}
+ + return; }
/* Report an resize to the COMPONENT interface */
@@ -216,22 +210,24 @@ static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * da /* Mouse Button handler for browser component. */ -
+ static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * data)
{ short mx, my, dummy, mbut;
- uint32_t tnow = clock()*1000 / CLOCKS_PER_SEC;
- LGRECT cwork;
+ LGRECT cwork; + browser_mouse_state bmstate = 0;
struct gui_window * gw = data;
if( input_window != gw ) {
return;
- }
+ } + window_set_focus( gw, BROWSER, (void*)gw->browser );
- browser_get_rect( gw, BR_CONTENT, &cwork );
+ browser_get_rect( gw, BR_CONTENT, &cwork ); + + /* convert screen coords to component coords: */
mx = evnt.mx - cwork.g_x;
- my = evnt.my - cwork.g_y;
- LOG(("mevent (%d) within %s at %d / %d\n", evnt.nb_click, gw->browser->bw->name, mx, my ));
+ my = evnt.my - cwork.g_y; /* Translate GEM key state to netsurf mouse modifier */
if( evnt.mkstate & (K_RSHIFT | K_LSHIFT) ){
@@ -248,49 +244,57 @@ static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * da bmstate |= BROWSER_MOUSE_MOD_3;
} else {
bmstate &= ~(BROWSER_MOUSE_MOD_3);
- }
- int sx = (mx + gw->browser->scroll.current.x);
- int sy = (my + gw->browser->scroll.current.y);
+ } + + /* convert component coords to scrolled content coords: */
+ int sx_origin = (mx + gw->browser->scroll.current.x);
+ int sy_origin = (my + gw->browser->scroll.current.y); + + short rel_cur_x, rel_cur_y; + short prev_x=sx_origin, prev_y=sy_origin; /* Detect left mouse button state and compare with event state: */
- graf_mkstate(&dummy, &dummy, &mbut, &dummy);
- if( (mbut & 1) && (evnt.mbut & 1) ) {
- if( mouse_hold_start[0] == 0 ) {
- mouse_hold_start[0] = tnow;
- LOG(("Drag starts at %d,%d\n", sx, sy));
- browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_PRESS_1,sx,sy);
- bmstate |= BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON;
- } else {
- bmstate |= BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_ON;
- }
- if( (abs(mx-last_drag_x)>5) || (abs(mx-last_drag_y)>5) ){
- browser_window_mouse_track(
- gw->browser->bw,
- bmstate,
- sx, sy
- );
- last_drag_x = mx;
- last_drag_y = my;
- }
-
- } else if( (evnt.mbut & 1) ) {
- mouse_click_time[0] = tnow; /* clock in ms */
- /* check if this event was during an drag op, only handle if it wasn't: */
- if( mouse_hold_start[0] == 0 ) {
- LOG(("Click within %s at %d / %d\n", gw->browser->bw->name, sx, sy ));
- browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_PRESS_1,sx,sy);
- browser_window_mouse_click(gw->browser->bw,BROWSER_MOUSE_CLICK_1,sx,sy);
- bmstate &= ~( BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_CLICK_1);
- }
- mouse_hold_start[0] = 0;
- } + graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy); + if( (mbut & 1) && (evnt.mbut & 1) ){ + /* Mouse still pressed, report drag */ + rel_cur_x = (rel_cur_x - cwork.g_x) + gw->browser->scroll.current.x;
+ rel_cur_y = (rel_cur_y - cwork.g_y) + gw->browser->scroll.current.y; + browser_window_mouse_click( gw->browser->bw, + BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_DRAG_1, + sx_origin, sy_origin);
+ do{ + if( abs(prev_x-rel_cur_x) > 5 || abs(prev_y-rel_cur_y) > 5 ){ + browser_window_mouse_track( gw->browser->bw, + BROWSER_MOUSE_DRAG_ON|BROWSER_MOUSE_HOLDING_1, + rel_cur_x, rel_cur_y); + prev_x = rel_cur_x; + prev_y = rel_cur_y; + if( browser_redraw_required( gw ) ){ + browser_redraw( gw ); + } + } + graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy); + rel_cur_x = (rel_cur_x - cwork.g_x) + gw->browser->scroll.current.x;
+ rel_cur_y = (rel_cur_y - cwork.g_y) + gw->browser->scroll.current.y; + } while( mbut & 1 ); + browser_window_mouse_track(gw->browser->bw, 0, rel_cur_x,rel_cur_y); + } else { + /* Right button pressed? */ + if( (evnt.mbut & 2 ) ) { + context_popup( gw, evnt.mx, evnt.my ); + } else { + browser_window_mouse_click(gw->browser->bw, + bmstate|BROWSER_MOUSE_PRESS_1, + sx_origin,sy_origin);
+ browser_window_mouse_click(gw->browser->bw, + bmstate|BROWSER_MOUSE_CLICK_1, + sx_origin,sy_origin); + } + }
- /* Right button pressed? */ - if( (evnt.mbut & 2 ) ) { - context_popup( gw, evnt.mx, evnt.my ); - } + +} -}
/* Report scroll event to the browser component. diff --git a/atari/browser_win.c b/atari/browser_win.c index 92744bba4..5f2938c67 100755 --- a/atari/browser_win.c +++ b/atari/browser_win.c @@ -62,11 +62,6 @@ extern void * h_gem_rsrc;
extern struct gui_window *input_window;
extern GEM_PLOTTER plotter;
-extern int mouse_click_time[3];
-extern int mouse_hold_start[3];
-extern browser_mouse_state bmstate;
-extern short last_drag_x;
-extern short last_drag_y;
void __CDECL std_szd( WINDOW * win, short buff[8], void * );
void __CDECL std_mvd( WINDOW * win, short buff[8], void * ); @@ -92,77 +87,6 @@ static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data /* -------------------------------------------------------------------------- */
-/*
- track the mouse state and
- finally checks for released buttons.
- */
-static void window_track_mouse_state( LGRECT * bwrect, bool within, short mx, short my, short mbut, short mkstate ){
- int i = 0;
- int nx, ny;
- struct gui_window * gw = input_window;
-
- if( !gw ) {
- bmstate = 0;
- mouse_hold_start[0] = 0;
- mouse_hold_start[1] = 0;
- return;
- }
-
- /* todo: creat function find_browser_window( mx, my ) */
- nx = (mx - bwrect->g_x + gw->browser->scroll.current.x);
- ny = (my - bwrect->g_y + gw->browser->scroll.current.y);
-
- if( mkstate & (K_RSHIFT | K_LSHIFT) ){
- bmstate |= BROWSER_MOUSE_MOD_1;
- } else {
- bmstate &= ~(BROWSER_MOUSE_MOD_1);
- }
- if( (mkstate & K_CTRL) ){
- bmstate |= BROWSER_MOUSE_MOD_2;
- } else {
- bmstate &= ~(BROWSER_MOUSE_MOD_2);
- }
- if( (mkstate & K_ALT) ){
- bmstate |= BROWSER_MOUSE_MOD_3;
- } else {
- bmstate &= ~(BROWSER_MOUSE_MOD_3);
- }
-
- if( !(mbut&1) && !(mbut&2) ) {
- if(bmstate & BROWSER_MOUSE_DRAG_ON )
- bmstate &= ~( BROWSER_MOUSE_DRAG_ON );
- }
-
- /* todo: if we need right button click, increase loop count */
- for( i = 1; i<2; i++ ) {
- if( !(mbut & i) ) {
- if( mouse_hold_start[i-1] > 0 ) {
- mouse_hold_start[i-1] = 0;
- if( i==1 ) {
- LOG(("Drag for %d ended", i));
- bmstate &= ~( BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_1 ) ;
- if( within ) {
- /* drag end */
- browser_window_mouse_track(
- gw->browser->bw, 0, nx, ny
- );
- }
- }
- if( i==2 ) {
- bmstate &= ~( BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_2 ) ;
- LOG(("Drag for %d ended", i));
- if( within ) {
- /* drag end */
- browser_window_mouse_track(
- gw->browser->bw, 0, nx, ny
- );
- }
- }
- }
- }
- }
-}
-
int window_create( struct gui_window * gw, struct browser_window * bw, unsigned long inflags )
@@ -545,72 +469,48 @@ error: static void __CDECL evnt_window_m1( WINDOW * win, short buff[8], void * data)
{
struct gui_window * gw = input_window;
- static bool prev_url = false;
- short mx, my, mbut, mkstate;
- bool a = false; //flags if mouse is within controls or browser
+ static bool prev_url = false; + static short prev_x=0; + static short prev_y=0;
bool within = false;
LGRECT urlbox, bwbox, sbbox; - int nx, ny; // relative mouse position
-
+ int nx, ny; if( gw == NULL)
- return;
-
- if( gw != input_window ){
- return;
+ return; + + if( prev_x == evnt.mx && prev_y == evnt.my ){ + return; }
-
- graf_mkstate(&mx, &my, &mbut, &mkstate);
-
browser_get_rect( gw, BR_CONTENT, &bwbox );
- if( gw->root->toolbar )
- mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
- if( gw->root->statusbar )
- mt_CompGetLGrect(&app, gw->root->statusbar->comp, WF_WORKXYWH, &sbbox);
-
- if( mx > bwbox.g_x && mx < bwbox.g_x + bwbox.g_w &&
- my > bwbox.g_y && my < bwbox.g_y + bwbox.g_h ){
- within = true;
- }
- if( evnt.m1_flag == MO_LEAVE ) {
- if( MOUSE_IS_DRAGGING() ){
- window_track_mouse_state( &bwbox, within, mx, my, mbut, mkstate );
- }
- if( gw->root->toolbar && within == false ) {
- if( (mx > urlbox.g_x && mx < urlbox.g_x + urlbox.g_w ) &&
- (my > urlbox.g_y && my < + urlbox.g_y + urlbox.g_h )) {
- gem_set_cursor( &gem_cursors.ibeam );
- prev_url = a = true;
- }
- }
- if( !a ) {
+ if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
+ evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
+ within = true; + browser_window_mouse_track(
+ input_window->browser->bw,
+ 0,
+ evnt.mx - bwbox.g_x + gw->browser->scroll.current.x,
+ evnt.my - bwbox.g_y + gw->browser->scroll.current.y
+ );
+ } + + if( gw->root->toolbar && within == false ) { + mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
+ if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
+ (evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
+ gem_set_cursor( &gem_cursors.ibeam );
+ prev_url = true;
+ } else { if( prev_url ) {
gem_set_cursor( &gem_cursors.arrow );
prev_url = false;
- }
- /* report mouse move in the browser window */
- if( within ){
- nx = mx - bwbox.g_x;
- ny = my - bwbox.g_y;
- if( ( abs(mx-last_drag_x)>5 || abs(mx-last_drag_y)>5 ) ||
- !MOUSE_IS_DRAGGING() ){
- browser_window_mouse_track(
- input_window->browser->bw,
- bmstate,
- nx + gw->browser->scroll.current.x,
- ny + gw->browser->scroll.current.y
- );
- if( MOUSE_IS_DRAGGING() ){
- last_drag_x = mx;
- last_drag_y = my;
- }
- }
- }
+ } }
- } else {
- /* set input window? */
- }
+ } + + prev_x = evnt.mx; + prev_y = evnt.my;
}
static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
diff --git a/atari/global_evnt.c b/atari/global_evnt.c index 12fff075b..02b1001b6 100755 --- a/atari/global_evnt.c +++ b/atari/global_evnt.c @@ -542,7 +542,6 @@ void bind_global_events( void ) EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
EvntAttach( NULL, AP_TERM, global_evnt_apterm );
EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
- /* EvntDataAttach( NULL, WM_XM1, global_evnt_m1, NULL ); */
/* TODO: maybe instant redraw after this is better! */
set_menu_title( MAINMENU_T_FILE, "Page");
diff --git a/atari/global_evnt.h b/atari/global_evnt.h index c94105a1b..2cbd069de 100755 --- a/atari/global_evnt.h +++ b/atari/global_evnt.h @@ -55,9 +55,6 @@ struct s_menu_item_evnt { Global & Menu event handlers
*/
-
-/* Call this after each call to evnt_multi, to check for states that evnt_multi doesn't: */
-void global_track_mouse_state( LGRECT * bwrect, bool within, short, short, short, short );
void bind_global_events( void );
void unbind_global_events( void );
diff --git a/atari/gui.c b/atari/gui.c index b887a7413..3740fe878 100755 --- a/atari/gui.c +++ b/atari/gui.c @@ -86,12 +86,7 @@ OBJECT * h_gem_menu; OBJECT **rsc_trindex;
short vdih;
short rsc_ntree;
-int mouse_click_time[3] = { INT_MAX, INT_MAX, INT_MAX };
-int mouse_hold_start[3];
-short last_drag_x;
-short last_drag_y;
long next_poll;
-browser_mouse_state bmstate;
/* Comandline / Options: */
int cfg_width;
@@ -110,61 +105,31 @@ void gui_poll(bool active) short mx, my, dummy;
short aestop;
- evnt.timer = schedule_run();
+ evnt.timer = schedule_run(); - wind_get( 0, WF_TOP, &aestop, &winloc[1], &winloc[2], &winloc[3]);
- if( winloc[1] != _AESapid ){
- aestop = 0;
- }
-
- if( (aestop > 0) && !active ) {
- flags |= MU_M1;
- wind_get( aestop, WF_WORKXYWH, &winloc[0],
- &winloc[1], &winloc[2], &winloc[3] );
- graf_mkstate( &mx, &my, &dummy, &dummy );
- /* this can be improved a lot under XaAES - there is an event for mouse move */
- if( mx >= winloc[0] && mx <= winloc[0] + winloc[2] &&
- my >= winloc[1] && my <= winloc[1] + winloc[3] ){
- /* Mouse is within the top window area */
- evnt.m1_flag = MO_LEAVE;
- evnt.m1_w = evnt.m1_h = 1;
- evnt.m1_x = mx;
- evnt.m1_y = my;
- } else {
- /* Mouse is outside of top window area. */
- if( evnt.m1_flag == MO_LEAVE ) {
- /* Previous move was inside the top window area */
- struct gui_window * gw = input_window;
- if(gw != NULL && gw->browser != NULL && gw->browser->bw != NULL ){
- /* reset mouse state */
- /* you could also track further, without reset, but */
- /* when the mouse moves into native scroller area, the mouse is */
- /* the native scroll bar code gets in between.. */
- mouse_hold_start[0] = 0;
- mouse_hold_start[1] = 0;
- bmstate = 0;
- browser_window_mouse_track( gw->browser->bw, bmstate, mx, my );
- }
- }
- evnt.m1_flag = MO_ENTER;
- evnt.m1_w = winloc[2];
- evnt.m1_h = winloc[3];
- evnt.m1_x = winloc[0];
- evnt.m1_y = winloc[1];
- }
- }
-
- /*printf("time: %d, active: %d\n", evnt.timer, active );*/
if( active ) {
- if( clock() >= next_poll ) {
+ if( clock() >= next_poll ) { evnt.timer = 0;
flags |= MU_TIMER;
EvntWindom( flags );
next_poll = clock() + CLOCKS_PER_SEC;
}
- } else {
+ } else { + if( input_window != NULL ){ + wind_get( 0, WF_TOP, &aestop, &winloc[1], &winloc[2], &winloc[3]);
+ if( winloc[1] == _AESapid ){ + /* only check for mouse move when netsurf is on top: */ + // move that into m1 event handler + graf_mkstate( &mx, &my, &dummy, &dummy ); + flags |= MU_M1; + evnt.m1_flag = MO_LEAVE; + evnt.m1_w = evnt.m1_h = 1; + evnt.m1_x = mx; + evnt.m1_y = my; + }
+ } flags |= MU_TIMER;
- EvntWindom( flags );
+ EvntWindom( flags ); }
struct gui_window * g;
@@ -191,8 +156,6 @@ gui_create_browser_window(struct browser_window *bw, bool new_tab)
{
struct gui_window *gw=NULL;
- struct gui_window * gwroot ;
- short winloc[4];
LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw, bw, clone,
(int)new_tab
));
@@ -260,7 +223,6 @@ void gui_window_destroy(struct gui_window *w) w = NULL;
w = window_list;
- int dummy=0;
while( w != NULL ) {
if( w->root ) {
input_window = w;
@@ -325,7 +287,6 @@ void gui_window_redraw_window(struct gui_window *gw) void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
{
- LGRECT work;
CMP_BROWSER b;
if (gw == NULL)
return;
@@ -542,10 +503,8 @@ void gui_window_stop_throbber(struct gui_window *w) /* Place caret in window */ void gui_window_place_caret(struct gui_window *w, int x, int y, int height)
{
- LGRECT work;
if (w == NULL)
return;
- CMP_BROWSER b = w->browser;
if( w->browser->caret.current.g_w > 0 )
gui_window_remove_caret( w );
w->browser->caret.requested.g_x = x;
@@ -563,10 +522,8 @@ void gui_window_place_caret(struct gui_window *w, int x, int y, int height) void
gui_window_remove_caret(struct gui_window *w)
{ - LGRECT rect;
if (w == NULL)
return;
- CMP_BROWSER b = w->browser; if( w->browser->caret.background.fd_addr != NULL ){ browser_restore_caret_background( w, NULL ); @@ -850,12 +807,6 @@ void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, cb(bres, cbpw);
}
-
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- return realloc(ptr, len);
-}
-
void gui_quit(void)
{
LOG((""));
@@ -964,8 +915,7 @@ nsurl *gui_get_resource_url(const char *path) static void gui_init(int argc, char** argv)
{
- char buf[PATH_MAX], sbuf[PATH_MAX];
- int len;
+ char buf[PATH_MAX];
OBJECT * cursors;
atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
@@ -1028,8 +978,6 @@ static void gui_init(int argc, char** argv) static char *theapp = (char*)"NetSurf";
static void gui_init2(int argc, char** argv)
{
- struct browser_window *bw;
- const char *addr = NETSURF_HOMEPAGE;
MenuBar( h_gem_menu , 1 );
bind_global_events();
menu_register( -1, theapp);
diff --git a/atari/gui.h b/atari/gui.h index 826f6d52f..14b4ca463 100755 --- a/atari/gui.h +++ b/atari/gui.h @@ -28,14 +28,6 @@ struct point_s { int y; }; -struct bbox_s { - int x0; - int y0; - int x1; - int y1; -}; - -typedef struct bbox_s BBOX; typedef struct point_s POINT; #define MFORM_EX_FLAG_USERFORM 0x01 @@ -136,6 +128,4 @@ struct gui_window { extern struct gui_window *window_list; -#define MOUSE_IS_DRAGGING() (mouse_hold_start[0] || mouse_hold_start[1]) - #endif diff --git a/atari/treeview.c b/atari/treeview.c index afe7930c5..e976574ab 100755 --- a/atari/treeview.c +++ b/atari/treeview.c @@ -112,8 +112,92 @@ static void __CDECL evnt_tv_redraw( WINDOW *win, short buff[8], void * data ) }
}
+static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data ) +{ + GRECT work;
+ NSTREEVIEW tv = (NSTREEVIEW) data;
+ if( tv == NULL )
+ return;
+ if( evnt.mbut & 2 ) {
+ /* do not handle right click */
+ return;
+ } + + WindGetGrect( tv->window, WF_WORKXYWH, &work ); + + /* mouse click relative origin: */
+ short origin_rel_x = (evnt.mx-work.g_x)+(win->xpos*win->w_u);
+ short origin_rel_y = (evnt.my-work.g_y)+(win->ypos*win->h_u); + + if( origin_rel_x >= 0 && origin_rel_y >= 0 + && evnt.mx < work.g_x + work.g_w + && evnt.my < work.g_y + work.g_h ) + { + int bms; + bool ignore=false; + short cur_rel_x, cur_rel_y, dummy, mbut; + + if( evnt.nb_click == 2 ){
+ tree_mouse_action(tv->tree, + BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_DOUBLE_CLICK, + origin_rel_x, origin_rel_y ); + return; + } + + graf_mkstate(&cur_rel_x, &cur_rel_x, &mbut, &dummy); + if( (mbut&1) == 0 ){ + bms = BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_PRESS_1; + if( evnt.nb_click == 2 ) { + bms = BROWSER_MOUSE_DOUBLE_CLICK; + }
+ tree_mouse_action(tv->tree, bms, origin_rel_x, origin_rel_y ); + } else { + /* button still pressed */ + + short prev_x = origin_rel_x; + short prev_y = origin_rel_y; + + cur_rel_x = origin_rel_x; + cur_rel_y = origin_rel_y; + + if( tree_is_edited(tv->tree) ){ + gem_set_cursor(&gem_cursors.ibeam); + } else { + gem_set_cursor(&gem_cursors.hand); + } + + tv->startdrag.x = origin_rel_x;
+ tv->startdrag.y = origin_rel_y; + + tree_mouse_action( tv->tree, + BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_ON , + cur_rel_x, cur_rel_y ); + do{ + if( abs(prev_x-cur_rel_x) > 5 || abs(prev_y-cur_rel_y) > 5 ){ + tree_mouse_action( tv->tree, + BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON, + cur_rel_x, cur_rel_y); + prev_x = cur_rel_x; + prev_y = cur_rel_y; + } + + if( tv->redraw ) + atari_treeview_redraw( tv ); + /* sample mouse button state: */ + graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy); + cur_rel_x = (cur_rel_x-work.g_x)+(win->xpos*win->w_u);
+ cur_rel_y = (cur_rel_y-work.g_y)+(win->ypos*win->h_u); + } while( mbut & 1 ); +
+ tree_drag_end(tv->tree, 0, tv->startdrag.x, tv->startdrag.y, + cur_rel_x, cur_rel_y ); + gem_set_cursor(&gem_cursors.arrow); + } + } +} + -static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data )
+static void __CDECL evnt_tv_mbutton__( WINDOW *win, short buff[8], void * data )
{
GRECT work;
bool ignore=false;
@@ -156,20 +240,22 @@ static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data ) bmstate = BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_DOUBLE_CLICK;
mouse_hold_start[0] = 0;
} else {
- if( mbut & 1 ) {
+ if( mbut & 1 ) { bmstate |= BROWSER_MOUSE_DRAG_ON;
if( mouse_hold_start[0] == 0) {
+ // start of drag op mouse_hold_start[0] = tnow;
tv->startdrag.x = rx;
tv->startdrag.y = ry;
bmstate |= BROWSER_MOUSE_DRAG_1;
gem_set_cursor(&gem_cursors.cross);
} else {
- /* todo: add more isual indication (grafbox?) */
+ /* todo: add more visual indication (grafbox?) */
ignore = true;
gem_set_cursor(&gem_cursors.cross);
}
- } else {
+ } else { + // mouse button up event
if( bmstate & BROWSER_MOUSE_DRAG_ON ){
bmstate = 0;
tree_drag_end(tv->tree, bmstate, tv->startdrag.x, tv->startdrag.y, rx, ry);
@@ -231,7 +317,7 @@ NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW *win ) EvntDataAdd( new->window, WM_XBUTTON, evnt_tv_mbutton, new, EV_BOT );
EvntDataAttach( new->window, WM_REDRAW, evnt_tv_redraw, new );
EvntDataAttach( new->window, WM_XKEYBD, evnt_tv_keybd, new );
- EvntDataAttach( new->window, WM_XM1, evnt_tv_m1, new );
+ //EvntDataAttach( new->window, WM_XM1, evnt_tv_m1, new );
return(new);
}
@@ -415,8 +501,8 @@ void atari_treeview_resized(struct tree *tree, int width, int height, void *pw) void atari_treeview_scroll_visible(int y, int height, void *pw)
{
- /* we don't support dragging within the treeview */
- /* so we don't need to implement this */
+ /* we don't support dragging outside the treeview */
+ /* so we don't need to implement this? */
}
/**
diff --git a/atari/treeview.h b/atari/treeview.h index 487479a67..3796665af 100755 --- a/atari/treeview.h +++ b/atari/treeview.h @@ -50,4 +50,4 @@ bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y -#endif
\ No newline at end of file +#endif |