diff options
author | Ole Loots <ole@monochrom.net> | 2012-11-29 02:01:13 +0100 |
---|---|---|
committer | Ole Loots <ole@monochrom.net> | 2012-11-29 02:01:13 +0100 |
commit | 1b93b72b9b731bb1844d5941e5165ff0ebc6711a (patch) | |
tree | 90ae6b57e574949a8ebbafdcfa60ea4888c50f2b /atari | |
parent | 9ec2e77b2782454facda6858ca04735cb03f6743 (diff) | |
download | netsurf-1b93b72b9b731bb1844d5941e5165ff0ebc6711a.tar.gz netsurf-1b93b72b9b731bb1844d5941e5165ff0ebc6711a.tar.bz2 |
re-implemented browser toolbar redraw / URL area redraw.
Diffstat (limited to 'atari')
-rwxr-xr-x | atari/gui.c | 46 | ||||
-rwxr-xr-x | atari/res/netsurf.rsc | bin | 35788 -> 35788 bytes | |||
-rwxr-xr-x | atari/res/netsurf.rsm | 4 | ||||
-rwxr-xr-x | atari/rootwin.c | 16 | ||||
-rw-r--r-- | atari/toolbar.c | 211 | ||||
-rw-r--r-- | atari/toolbar.h | 38 |
6 files changed, 186 insertions, 129 deletions
diff --git a/atari/gui.c b/atari/gui.c index 2528eff1f..753dd087d 100755 --- a/atari/gui.c +++ b/atari/gui.c @@ -552,20 +552,15 @@ static void throbber_advance( void * data ) { LGRECT work; struct gui_window * gw = (struct gui_window *)data; - if( gw->root == NULL ) + if (gw->root == NULL) return; - if( gw->root->toolbar == NULL ) + if (gw->root->toolbar == NULL) return; - // TODO: implement access to throbber - //if( gw->root->toolbar->throbber.running == false) - // return; -// mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp, -// WF_WORKXYWH, &work); -// gw->root->toolbar->throbber.index++; -// if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index ) -// gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX; -// ApplWrite(_AESapid, WM_REDRAW, guiwin_get_handle(gw->root->win), -// work.g_x, work.g_y, work.g_w, work.g_h); + + if (gw->root->toolbar->throbber.running == false) + return; + + toolbar_throbber_progress(gw->root->toolbar); schedule(100, throbber_advance, gw ); } @@ -574,41 +569,26 @@ void gui_window_start_throbber(struct gui_window *w) GRECT work; if (w == NULL) return; - // TODO: implement throbber acess - //if( w->root->toolbar->throbber.running == true ) - // return; -// browser_get_rect(w, BR_THROBBER, &work); -// w->root->toolbar->throbber.running = true; -// w->root->toolbar->throbber.index = THROBBER_MIN_INDEX; - schedule(100, throbber_advance, w ); -// ApplWrite( _AESapid, WM_REDRAW, guiwin_get_handle(w->root->win), -// work.g_x, work.g_y, work.g_w, work.g_h ); + toolbar_set_throbber_state(w->root->toolbar, true); + schedule(100, throbber_advance, w ); rendering = true; } void gui_window_stop_throbber(struct gui_window *w) { - LGRECT work; if (w == NULL) return; - // TODO: implement something like throbber_is_running(); - //if( w->root->toolbar->throbber.running == false ) - // return; + if (w->root->toolbar->throbber.running == false) + return; schedule_remove(throbber_advance, w); + toolbar_set_throbber_state(w->root->toolbar, false); + /* refresh toolbar buttons: */ toolbar_update_buttons(w->root->toolbar, w->browser->bw, -1); - /* redraw throbber: */ -// mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp, -// WF_WORKXYWH, &work); -// w->root->toolbar->throbber.running = false; -// ApplWrite( _AESapid, WM_REDRAW, guiwin_get_handle(w->root->win), -// work.g_x, work.g_y, work.g_w, work.g_h ); - // TODO: send throbber redraw - rendering = false; } diff --git a/atari/res/netsurf.rsc b/atari/res/netsurf.rsc Binary files differindex 803cb2b7d..f911df9e9 100755 --- a/atari/res/netsurf.rsc +++ b/atari/res/netsurf.rsc diff --git a/atari/res/netsurf.rsm b/atari/res/netsurf.rsm index 587fefa45..649ea82e2 100755 --- a/atari/res/netsurf.rsm +++ b/atari/res/netsurf.rsm @@ -3,7 +3,7 @@ ResourceMaster v3.65 #N 99@32@AZAaza___ _@AZAaza090___ _@@_@
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
#R 0@0@1@1@1@1@
-#M 20010100@0@7728@618@
+#M 20010100@0@7728@622@
#T 0@1@MAINMENU@@62@@
#O 4@32@T_FILE@@
#O 5@32@T_EDIT@@
@@ -198,4 +198,4 @@ ResourceMaster v3.65 #O 5@33@BT_DOWN_PIC@@
#O 6@25@BT_UP@@
#O 4@33@BT_UP_PIC@@
-#c 770@
+#c 780@
diff --git a/atari/rootwin.c b/atari/rootwin.c index c0ad68863..11a4a425e 100755 --- a/atari/rootwin.c +++ b/atari/rootwin.c @@ -189,8 +189,10 @@ int window_create(struct gui_window * gw, return( -1 ); memset( gw->root, 0, sizeof(struct s_gui_win_root) ); gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1); - // TODO: use desk size + redraw_slots_init(&gw->root->redraw_slots, 8); + + // TODO: use desk size aes_handle = wind_create(flags, 40, 40, app.w, app.h); if(aes_handle<0) { free(gw->root->title); @@ -200,7 +202,12 @@ int window_create(struct gui_window * gw, gw->root->win = guiwin_add(aes_handle, GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event); + struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s)); + data->rootwin = gw->root; + guiwin_set_user_data(gw->root->win, (void*)data); + /* create toolbar component: */ + guiwin_set_toolbar(gw->root->win, get_tree(TOOLBAR), 0, 0); if( tb ) { gw->root->toolbar = toolbar_create(gw->root); assert(gw->root->toolbar); @@ -224,13 +231,6 @@ int window_create(struct gui_window * gw, wind_set(aes_handle, WF_OPTS, 1, WO0_NOBLITW, 0, 0); wind_set(aes_handle, WF_OPTS, 1, WO0_NOBLITH, 0, 0); - redraw_slots_init(&gw->root->redraw_slots, 8); - - guiwin_set_toolbar(gw->root->win, get_tree(TOOLBAR), 0, 0); - struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s)); - data->rootwin = gw->root; - guiwin_set_user_data(gw->root->win, (void*)data); - if (inflags & WIN_TOP) { window_set_focus(gw->root, BROWSER, gw->browser); } diff --git a/atari/toolbar.c b/atari/toolbar.c index 75d7abe28..50343aa7b 100644 --- a/atari/toolbar.c +++ b/atari/toolbar.c @@ -87,39 +87,6 @@ struct s_tb_button };
-struct s_url_widget
-{ - /* widget is only redrawn when this flag is set */
- bool redraw;
- struct text_area *textarea; - GRECT rdw_area; - GRECT area;
-};
-
-struct s_throbber_widget
-{
- short index;
- short max_index;
- bool running; - GRECT area;
-};
- -struct s_toolbar
-{
- struct s_gui_win_root *owner; - struct s_url_widget url;
- struct s_throbber_widget throbber; - GRECT btdim; - GRECT area;
- /* size & location of buttons: */ - struct s_tb_button * buttons; - bool hidden;
- int btcnt; - int style; - bool redraw; - bool reflow;
-}; - extern char * option_homepage_url;
extern void * h_gem_rsrc;
extern struct gui_window * input_window; @@ -206,7 +173,13 @@ static struct s_toolbar_style toolbar_styles[] = {18, 34, 64, 64, 2, 0, 0 }, /* custom style: */ {18, 34, 64, 64, 2, 0, 0 } -};
+}; + +static const struct redraw_context toolbar_rdrw_ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &atari_plotters
+ };
static void tb_txt_request_redraw(void *data, int x, int y, int w, int h ); static nserror toolbar_icon_callback( hlcache_handle *handle, @@ -216,31 +189,30 @@ static nserror toolbar_icon_callback( hlcache_handle *handle, * Callback for textarea redraw */ static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
-{
- LGRECT work;
- if( data == NULL )
- return;
- CMP_TOOLBAR t = data;
- if( t->url.redraw == false ){
- t->url.redraw = true; - //t->redraw = true;
- t->url.rdw_area.g_x = x;
- t->url.rdw_area.g_y = y;
- t->url.rdw_area.g_w = w;
- t->url.rdw_area.g_h = h;
- } else {
- /* merge the redraw area to the new area.: */
- int newx1 = x+w;
- int newy1 = y+h;
- int oldx1 = t->url.rdw_area.g_x + t->url.rdw_area.g_w;
- int oldy1 = t->url.rdw_area.g_y + t->url.rdw_area.g_h;
- t->url.rdw_area.g_x = MIN(t->url.rdw_area.g_x, x);
- t->url.rdw_area.g_y = MIN(t->url.rdw_area.g_y, y);
- t->url.rdw_area.g_w = ( oldx1 > newx1 ) ?
- oldx1 - t->url.rdw_area.g_x : newx1 - t->url.rdw_area.g_x;
- t->url.rdw_area.g_h = ( oldy1 > newy1 ) ?
- oldy1 - t->url.rdw_area.g_y : newy1 - t->url.rdw_area.g_y;
- }
+{ + + GRECT area; + printf("data: %p\n", data);
+ struct s_toolbar * tb = (struct s_toolbar *)data; + + + printf("tb gx: %d\n", tb->area.g_x); + printf("aes tb: %p\n", aes_toolbar); + + + toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area); + area.g_x += x; + area.g_y += y; + area.g_w = w; + area.g_h = h; + + //guiwin_get_grect(tb->owner->win, GUIWIN_AREA_TOOLBAR, &area); + + + dbg_grect("toolbar redraw request", &area); + + window_schedule_redraw_grect(tb->owner, &area); + return;
} /** @@ -278,24 +250,6 @@ static struct s_tb_button *button_init(struct s_toolbar *tb, OBJECT * tree, int } -static void toolbar_reflow(struct s_toolbar *tb) -{ - LOG(("")); -/* - int i=0, x=0; - - x = 2; - while (tb->buttons[i].rsc_id > 0) { - tb->buttons[i].area.g_x = x; - x += tb->buttons[i].area.g_w; - x += 2; - i++; - } - tb->url.area.g_x = x; -*/ -} - - void toolbar_init( void ) { int i=0, n; @@ -379,9 +333,6 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner) ta_height -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM);
t->url.textarea = textarea_create(300, ta_height, 0, &font_style_url, tb_txt_request_redraw, t);
- if( t->url.textarea != NULL ){
- textarea_set_text(t->url.textarea, "http://");
- }
/* create the throbber widget: */
t->throbber.area.g_h = toolbar_styles[t->style].height;
@@ -391,7 +342,8 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner) t->throbber.index = 0;
t->throbber.max_index = 8; } else { - t->throbber.index = THROBBER_MIN_INDEX;
+ t->throbber.running = false; + t->throbber.index = THROBBER_INACTIVE_INDEX;
t->throbber.max_index = THROBBER_MAX_INDEX; }
t->throbber.running = false; @@ -409,7 +361,7 @@ void toolbar_destroy(struct s_toolbar *tb) free(tb); } -static void toolbar_objc_reflow(struct s_toolbar *tb) +static void toolbar_reflow(struct s_toolbar *tb) { // position toolbar areas: @@ -423,9 +375,11 @@ static void toolbar_objc_reflow(struct s_toolbar *tb) aes_toolbar[TOOLBAR_URL_AREA].ob_width = tb->area.g_w - (aes_toolbar[TOOLBAR_NAVIGATION_AREA].ob_width - + aes_toolbar[TOOLBAR_THROBBER_AREA].ob_width); + + aes_toolbar[TOOLBAR_THROBBER_AREA].ob_width + 1); + // position throbber image: + printf("throbber reflow for index: %d\n", tb->throbber.index); throbber_form[tb->throbber.index].ob_x = tb->area.g_x + aes_toolbar[TOOLBAR_THROBBER_AREA].ob_x; @@ -438,17 +392,48 @@ static void toolbar_objc_reflow(struct s_toolbar *tb) ((aes_toolbar[TOOLBAR_THROBBER_AREA].ob_height - throbber_form[tb->throbber.index].ob_height) >> 1); + tb->reflow = false; } void toolbar_redraw(struct s_toolbar *tb, GRECT *clip) { + GRECT area; + if(tb->reflow == true) - toolbar_objc_reflow(tb); + toolbar_reflow(tb); + objc_draw_grect(aes_toolbar,0,8,clip); + printf("rdrw throbber (%d) at: %d,%d, %d, %d\n", tb->throbber.index, + throbber_form[tb->throbber.index].ob_x, + throbber_form[tb->throbber.index].ob_y, + throbber_form[tb->throbber.index].ob_width, + throbber_form[tb->throbber.index].ob_height ); objc_draw_grect(&throbber_form[tb->throbber.index], 0, 1, clip); + + GRECT url_area; + toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area); + url_area = area; + if (rc_intersect(clip, &area)) { + + struct rect r = {
+ .x0 = 0,
+ .y0 = 0,
+ .x1 = url_area.g_w,
+ .y1 = url_area.g_h
+ }; + + r.x0 = area.g_x - url_area.g_x; + r.x1 = r.x0 + area.g_w; + plot_set_dimensions(url_area.g_x, url_area.g_y, url_area.g_w, + url_area.g_h); + textarea_set_dimensions(tb->url.textarea, + aes_toolbar[TOOLBAR_URL_AREA].ob_width, + 20); + textarea_redraw(tb->url.textarea, 0, 0, &r, &toolbar_rdrw_ctx); + } } @@ -469,8 +454,47 @@ void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area) void toolbar_set_url(struct s_toolbar *tb, const char * text) { LOG(("")); + textarea_set_text(tb->url.textarea, text); + + GRECT area; + toolbar_get_grect(tb, TOOLBAR_URL_AREA, &area); + + window_schedule_redraw_grect(tb->owner, &area); +} + +void toolbar_set_throbber_state(struct s_toolbar *tb, bool active) +{ + GRECT throbber_area; + + tb->throbber.running = active; + if (active) { + tb->throbber.index = THROBBER_MIN_INDEX; + } else { + tb->throbber.index = THROBBER_INACTIVE_INDEX; + } + + tb->reflow = true; + toolbar_get_grect(tb, TOOLBAR_THROBBER_AREA, &throbber_area); + window_schedule_redraw_grect(tb->owner, &throbber_area); } +void toolbar_throbber_progress(struct s_toolbar *tb) +{ + GRECT throbber_area; + + assert(tb->throbber.running == true); + + if(tb->throbber.running == false) + return; + + tb->throbber.index++; + if(tb->throbber.index > THROBBER_MAX_INDEX) + tb->throbber.index = THROBBER_MIN_INDEX; + + tb->reflow = true; + toolbar_get_grect(tb, TOOLBAR_THROBBER_AREA, &throbber_area); + window_schedule_redraw_grect(tb->owner, &throbber_area); +} bool toolbar_text_input(struct s_toolbar *tb, char *text) { @@ -497,10 +521,27 @@ void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my) } +/** +* Receive a specific region of the toolbar. +* @param tb - the toolbar pointer +* @param which - the area to retrieve: TOOLBAR_URL_AREA, +* TOOLBAR_NAVIGATION_AREA, +* TOOLBAR_THROBBER_AREA +* @param dst - GRECT pointer receiving the area. +*/ -void toolbar_get_grect(struct s_toolbar *tb, short which, short opt, GRECT *dst) +void toolbar_get_grect(struct s_toolbar *tb, short which, GRECT *dst) { + if (tb->reflow == true) { + toolbar_reflow(tb); + } + + objc_offset(aes_toolbar, which, &dst->g_x, &dst->g_y); + dst->g_w = aes_toolbar[which].ob_width; + dst->g_h = aes_toolbar[which].ob_height; + printf("Toolbar get grect (%d): ", which); + dbg_grect("", dst); } diff --git a/atari/toolbar.h b/atari/toolbar.h index 17cb16d08..6a40cf3e5 100644 --- a/atari/toolbar.h +++ b/atari/toolbar.h @@ -13,6 +13,40 @@ enum toolbar_textarea { URL_INPUT_TEXT_AREA = 1 }; +struct s_url_widget
+{ + /* widget is only redrawn when this flag is set */
+ bool redraw;
+ struct text_area *textarea; + GRECT rdw_area; + GRECT area;
+}; + +struct s_throbber_widget
+{
+ short index;
+ short max_index;
+ bool running; + GRECT area;
+};
+ +struct s_toolbar
+{
+ struct s_gui_win_root *owner; + struct s_url_widget url;
+ struct s_throbber_widget throbber; + GRECT btdim; + GRECT area;
+ /* size & location of buttons: */ + struct s_tb_button * buttons; + bool hidden;
+ int btcnt; + int style; + bool redraw; + bool reflow;
+}; + + void toolbar_init(void); struct s_toolbar *toolbar_create(struct s_gui_win_root *owner); void toolbar_destroy(struct s_toolbar * tb); @@ -24,10 +58,12 @@ bool toolbar_key_input(struct s_toolbar *tb, short nkc); void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my); void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw, short idx); -void toolbar_get_grect(struct s_toolbar *tb, short which, short opt, GRECT *g); +void toolbar_get_grect(struct s_toolbar *tb, short which, GRECT *g); struct text_area *toolbar_get_textarea(struct s_toolbar *tb, enum toolbar_textarea which); +void toolbar_set_throbber_state(struct s_toolbar *tb, bool active); void toolbar_redraw(struct s_toolbar *tb, GRECT *clip); +void toolbar_throbber_progress(struct s_toolbar *tb); /* public events handlers: */ void toolbar_back_click(struct s_toolbar *tb);
void toolbar_reload_click(struct s_toolbar *tb);
|