summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xatari/gui.c46
-rwxr-xr-xatari/rootwin.c62
-rwxr-xr-xatari/rootwin.h34
3 files changed, 95 insertions, 47 deletions
diff --git a/atari/gui.c b/atari/gui.c
index 8429c15f2..d930b0c14 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -116,9 +116,11 @@ EVMULT_IN aes_event_in = {
EVMULT_OUT aes_event_out;
short aes_msg_out[8];
+
+
void gui_poll(bool active)
{
- int flags = MU_MESAG | MU_KEYBD | MU_BUTTON;
+ int flags = MU_MESAG | MU_KEYBD | MU_BUTTON | MU_M1 | MU_MX;
short mx, my, dummy;
unsigned short nkc = 0;
@@ -172,12 +174,17 @@ void gui_poll(bool active)
}
}
- if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
+ if((aes_event_out.emo_events & MU_KEYBD) != 0) {
uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta,
(short)aes_event_out.emo_kreturn);
deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
aes_event_out.emo_kmeta, nkc);
}
+/*
+ if((aes_event_out.emo_events & MU_KEYBD|MU_MX) != 0) {
+ on_m1();
+ }
+*/
}
} while ( gui_poll_repeat && !(active||rendering));
@@ -376,34 +383,24 @@ void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
{
+ int x,y;
if (w == NULL)
return false;
- *sx = w->browser->scroll.current.x;
- *sy = w->browser->scroll.current.y;
+
+ window_get_scroll(w->root, &x, &y);
return( true );
}
void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
{
- if ((w == NULL) ||
- (w->browser->bw == NULL) ||
- (w->browser->bw->current_content == NULL))
- return;
- if( sx != 0 ) {
- if( sx < 0 ) {
- browser_scroll(w, WA_LFLINE, abs(sx), true );
- } else {
- browser_scroll(w, WA_RTLINE, abs(sx), true );
- }
- }
-
- if( sy != 0 ) {
- if( sy < 0) {
- browser_scroll(w, WA_UPLINE, abs(sy), true );
- } else {
- browser_scroll(w, WA_DNLINE, abs(sy), true );
- }
- }
+ int units = 0;
+ if ((w == NULL)
+ || (w->browser->bw == NULL)
+ || (w->browser->bw->current_content == NULL))
+ return;
+
+ printf("scroll %d, %d\n", sx, sy);
+ window_scroll_by(w->root, sx, sy);
return;
}
@@ -411,8 +408,9 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
void gui_window_scroll_visible(struct gui_window *w, int x0, int y0, int x1, int y1)
{
LOG(("%s:(%p, %d, %d, %d, %d)", __func__, w, x0, y0, x1, y1));
+ printf("scroll visible\n");
gui_window_set_scroll(w,x0,y0);
- browser_schedule_redraw_rect( w, 0, 0, x1-x0,y1-y0);
+ //browser_schedule_redraw_rect( w, 0, 0, x1-x0,y1-y0);
}
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 20fbc4903..980685223 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -160,6 +160,10 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
on_content_mouse_click(data->rootwin);
}
}
+ if ((ev_out->emo_events & (MU_M1 | MU_MX)) != 0) {
+ printf("mx event at %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
+ }
return(retval);
}
@@ -358,6 +362,37 @@ void window_set_title(struct s_gui_win_root * rootwin, char *title)
wind_set_str(guiwin_get_handle(rootwin->win), WF_NAME, title);
}
+void window_scroll_by(ROOTWIN *root, int sx, int sy)
+{
+ int units;
+ GRECT content_area;
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(root->win);
+
+ if (sx != 0) {
+ units = sx / slid->x_unit_px;
+ if (units == 0) {
+ units = 1;
+ if(units < 0)
+ units = -units;
+ }
+ guiwin_scroll(root->win, GUIWIN_HSLIDER, units, true);
+ }
+
+ guiwin_get_grect(root->win, GUIWIN_AREA_CONTENT, &content_area);
+ if (sy != 0) {
+ units = sy / slid->y_unit_px;
+ if( sx < 0 ) {
+ // units = -units;
+ }
+ if(units == 0){
+ units = 1;
+ if(units < 0)
+ units = -units;
+ }
+ guiwin_scroll(root->win, GUIWIN_VSLIDER, units, true);
+ }
+}
+
void window_set_content_size(ROOTWIN *rootwin, int width, int height)
{
GRECT area;
@@ -456,6 +491,16 @@ struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin) {
return(rootwin->active_gui_window);
}
+void window_get_scroll(ROOTWIN *rootwin, int *x, int *y)
+{
+ struct guiwin_scroll_info_s *slid;
+
+ slid = guiwin_get_scroll_info(rootwin->win);
+
+ *x = slid->x_pos * slid->x_unit_px;
+ *y = slid->y_pos * slid->y_unit_px;
+}
+
/**
* Redraw the favicon
@@ -689,7 +734,7 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
/* Detect left mouse button state and compare with event state: */
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
- if( (mbut & 1) && (evnt.mbut & 1) ) {
+ if( (mbut & 1) && (aes_event_out.emo_mbutton & 1) ) {
/* Mouse still pressed, report drag */
rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
@@ -711,10 +756,14 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
rel_cur_x, rel_cur_y);
}
}
+
// we may need to process scrolling:
- if (rootwin->redraw_slots.areas_used > 0) {
- window_process_redraws(rootwin);
- }
+ // TODO: this doesn't work, because gemtk schedules redraw via
+ // AES window messages but we do not process them right here...
+ if (rootwin->redraw_slots.areas_used > 0) {
+ window_process_redraws(rootwin);
+ }
+
graf_mkstate(&rel_cur_x, &rel_cur_y, &mbut, &dummy);
rel_cur_x = (rel_cur_x - cwork.g_x) + slid->x_pos * slid->x_unit_px;
rel_cur_y = (rel_cur_y - cwork.g_y) + slid->y_pos * slid->y_unit_px;
@@ -722,7 +771,7 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
browser_window_mouse_track(gw->browser->bw, 0, rel_cur_x,rel_cur_y);
} else {
/* Right button pressed? */
- if( (evnt.mbut & 2 ) ) {
+ if ((aes_event_out.emo_mbutton & 2 ) ) {
context_popup( gw, aes_event_out.emo_mouse.p_x,
aes_event_out.emo_mouse.p_x);
} else {
@@ -734,6 +783,9 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
sx_origin,sy_origin);
}
}
+ if (rootwin->redraw_slots.areas_used > 0) {
+ window_process_redraws(rootwin);
+ }
}
/*
diff --git a/atari/rootwin.h b/atari/rootwin.h
index 85aeff97e..7eb55393c 100755
--- a/atari/rootwin.h
+++ b/atari/rootwin.h
@@ -41,37 +41,35 @@
int window_create(struct gui_window * gw,
struct browser_window * bw, unsigned long flags );
/* Destroys WinDom part of gui_window */
-int window_destroy(struct s_gui_win_root * rootwin);
+int window_destroy(ROOTWIN *rootwin);
/* show the window */
-void window_open(struct s_gui_win_root * rootwin, GRECT pos);
+void window_open(ROOTWIN *rootwin, GRECT pos);
-void window_snd_redraw(struct s_gui_win_root * rootwin, short x, short y,
- short w, short h );
+void window_snd_redraw(ROOTWIN *rootwin, short x, short y, short w, short h );
/* Update Shade / Unshade state of the fwd/back buttons*/
void window_update_back_forward(struct s_gui_win_root * rootwin);
/* set root browser component: */
-void window_attach_browser(struct s_gui_win_root * rootwin, CMP_BROWSER b);
+void window_attach_browser(ROOTWIN *rootwin, CMP_BROWSER b);
/* set focus element */
-void window_set_focus(struct s_gui_win_root * rootwin,
- enum focus_element_type type, void * element );
-/* adjust scroll settings */
-void window_set_scroll_info(struct s_gui_win_root * rootwin, int content_h,
- int content_w);
+void window_set_focus(ROOTWIN *rootwin, enum focus_element_type type,
+ void * element );
/* Shade / Unshade the forward/back bt. of toolbar, depending on history.*/
-bool window_widget_has_focus(struct s_gui_win_root * rootwin,
- enum focus_element_type t, void * element);
-bool window_url_widget_has_focus(struct s_gui_win_root * rootwin);
-void window_set_url(struct s_gui_win_root * rootwin, const char * text);
-void window_set_stauts(struct s_gui_win_root * rootwin, char * text);
-void window_set_title(struct s_gui_win_root * rootwin, char * text);
-void window_set_content_size(struct s_gui_win_root * rootwin, int w, int h);
-void window_set_icon(struct s_gui_win_root * rootwin, struct bitmap * bmp );
+bool window_widget_has_focus(ROOTWIN *rootwin, enum focus_element_type t,
+ void * element);
+bool window_url_widget_has_focus(ROOTWIN *rootwin);
+void window_set_url(ROOTWIN *rootwin, const char * text);
+void window_set_stauts(ROOTWIN *rootwin, char * text);
+void window_set_title(ROOTWIN *rootwin, char * text);
+void window_set_content_size(ROOTWIN *rootwin, int w, int h);
+void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp );
void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
+void window_scroll_by(ROOTWIN *rootwin, int x, int y);
void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area);
void window_process_redraws(ROOTWIN * rootwin);
struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin);
+void window_get_scroll(ROOTWIN *rootwin, int *x, int *y);
void window_redraw_favicon(struct s_gui_win_root * rootwin, GRECT *clip);
void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
bool window_key_input(unsigned short kcode, unsigned short kstate,