r5310 chris_y - in /trunk/netsurf/amiga: gui.c gui.h options.h

netsurf at semichrome.net netsurf at semichrome.net
Sat Sep 13 23:39:49 BST 2008


Author: chris_y
Date: Sat Sep 13 17:39:48 2008
New Revision: 5310

URL: http://source.netsurf-browser.org?rev=5310&view=rev
Log:
Improved throbber, works independently on multiple windows, stops when it should, no
weird crashes, lock-ups etc.

The format has changed, Resources/Throbber now needs to be in a picture.datatype
format, as a "film strip" of frames with the first image the inactive (stopped
throbber) and the rest the active animation.  The number of frames needs to be set in
the Options file throbber_frames variable (currently - will probably move to a
tooltype of Resources/Throbber in the future for better theming ability)

Modified:
    trunk/netsurf/amiga/gui.c
    trunk/netsurf/amiga/gui.h
    trunk/netsurf/amiga/options.h

Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=5310&r1=5309&r2=5310&view=diff
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Sat Sep 13 17:39:48 2008
@@ -43,7 +43,7 @@
 #include <proto/asl.h>
 #include <proto/iffparse.h>
 #include <datatypes/textclass.h>
-#include <datatypes/animationclass.h>
+#include <datatypes/pictureclass.h>
 #include "desktop/selection.h"
 #include "utils/utf8.h"
 #include "amiga/utf8.h"
@@ -95,7 +95,8 @@
 struct Library  *PopupMenuBase = NULL;
 struct PopupMenuIFace *IPopupMenu = NULL;
 
-Object *throbber = NULL;
+struct BitMap *throbber = NULL;
+ULONG throbber_width,throbber_height;
 
 bool win_destroyed = false;
 static struct RastPort dummyrp;
@@ -127,6 +128,7 @@
 	"Resources/Pointers/NotAllowed",
 	"Resources/Pointers/Progress"};
 
+void ami_update_throbber(struct gui_window *g);
 void ami_update_buttons(struct gui_window *);
 void ami_scroller_hook(struct Hook *,Object *,struct IntuiMessage *);
 uint32 ami_popup_hook(struct Hook *hook,Object *item,APTR reserved);
@@ -144,6 +146,7 @@
 	BPTR lock=0;
 	struct RastPort mouseptr;
 	struct IFFHandle *mpiff = NULL;
+	Object *dto;
 
 /* ttengine.library
 	if(!ami_open_tte())
@@ -190,14 +193,6 @@
 			InitIFFasClip(iffh);
 		}
 	}
-
-	throbber = NewDTObject("Resources/Throbber",
-						GA_ID,OID_THROBBER,
-						GA_ReadOnly,TRUE,
-						DTA_ControlPanel,FALSE,
-						DTA_Repeat,TRUE,
-						DTA_GroupID,GID_ANIMATION,
-						TAG_DONE);
 
 	InitRastPort(&mouseptr);
 
@@ -342,6 +337,44 @@
 	hotlist = options_load_tree(option_hotlist_file);
 
 	if(!hotlist) ami_hotlist_init(&hotlist);
+
+	if(dto = NewDTObject("Resources/Throbber",
+					DTA_GroupID,GID_PICTURE,
+					PDTA_DestMode,PMODE_V43,
+					TAG_DONE))
+	{
+		struct BitMapHeader *throbber_bmh;
+		struct RastPort throbber_rp;
+
+		if(GetDTAttrs(dto,PDTA_BitMapHeader,&throbber_bmh,TAG_DONE))
+		{
+			throbber_width = throbber_bmh->bmh_Width / option_throbber_frames;
+			throbber_height = throbber_bmh->bmh_Height;
+
+			InitRastPort(&throbber_rp);
+
+			if(throbber = p96AllocBitMap(throbber_bmh->bmh_Width,
+				throbber_height,32,
+				BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED,
+				NULL,RGBFB_A8R8G8B8))
+			{
+				struct RenderInfo ri;
+				UBYTE *throbber_tempmem = AllocVec(throbber_bmh->bmh_Width*throbber_height*4,MEMF_CLEAR);
+				throbber_rp.BitMap = throbber;
+				ri.Memory = throbber_tempmem;
+				ri.BytesPerRow = 4*throbber_bmh->bmh_Width;
+				ri.RGBFormat = RGBFB_A8R8G8B8;
+
+				IDoMethod(dto,PDTM_READPIXELARRAY,ri.Memory,PBPAFMT_ARGB,ri.BytesPerRow,0,0,throbber_bmh->bmh_Width,throbber_height);
+
+				p96WritePixelArray((struct RenderInfo *)&ri,0,0,&throbber_rp,0,0,throbber_bmh->bmh_Width,throbber_height);
+
+				FreeVec(throbber_tempmem);
+			}
+		}
+		DisposeDTObject(dto);
+	}
+
 }
 
 void gui_init2(int argc, char** argv)
@@ -657,6 +690,9 @@
 		if(gwin->redraw_required)
 			ami_do_redraw(gwin);
 
+		if(gwin->throbber_frame)
+			ami_update_throbber(gwin);
+
 		node = nnode;
 	}
 }
@@ -854,7 +890,7 @@
 {
 	int i;
 
-	DisposeDTObject(throbber);
+	p96FreeBitMap(throbber);
 
 	urldb_save(option_url_file);
 	urldb_save_cookies(option_cookie_file);
@@ -1166,8 +1202,13 @@
 						GA_ID,GID_URL,
 						GA_RelVerify,TRUE,
 					StringEnd,
-					LAYOUT_AddChild,throbber,
-					CHILD_NoDispose,TRUE,
+					LAYOUT_AddChild, gwin->gadgets[GID_THROBBER] = SpaceObject,
+						GA_ID,GID_THROBBER,
+						SPACE_MinWidth,throbber_width,
+						SPACE_MinHeight,throbber_height,
+					SpaceEnd,
+					CHILD_WeightedWidth,0,
+					CHILD_WeightedHeight,0,
 				LayoutEnd,
 				CHILD_WeightedHeight,0,
 				LAYOUT_AddChild, gwin->gadgets[GID_BROWSER] = SpaceObject,
@@ -1590,12 +1631,43 @@
 
 void gui_window_start_throbber(struct gui_window *g)
 {
-	IDoMethod(throbber,ADTM_START,0); // g->objects[OID_THROBBER]
+	struct IBox *bbox;
+	GetAttr(SPACE_AreaBox,g->gadgets[GID_THROBBER],&bbox);
+
+	g->throbber_frame=1;
+
+	BltBitMapRastPort(throbber,throbber_width,0,g->win->RPort,bbox->Left,bbox->Top,throbber_width,throbber_height,0x0C0);
 }
 
 void gui_window_stop_throbber(struct gui_window *g)
 {
-	IDoMethod(throbber,ADTM_STOP,0);
+	struct IBox *bbox;
+	GetAttr(SPACE_AreaBox,g->gadgets[GID_THROBBER],&bbox);
+
+	BltBitMapRastPort(throbber,0,0,g->win->RPort,bbox->Left,bbox->Top,throbber_width,throbber_height,0x0C0);
+
+	g->throbber_frame = 0;
+}
+
+void ami_update_throbber(struct gui_window *g)
+{
+	struct IBox *bbox;
+
+	if(g->throbber_update_count < 1000)
+	{
+		g->throbber_update_count++;
+		return;
+	}
+
+	g->throbber_update_count = 0;
+
+	GetAttr(SPACE_AreaBox,g->gadgets[GID_THROBBER],&bbox);
+
+	g->throbber_frame++;
+	if(g->throbber_frame > (option_throbber_frames-1))
+		g->throbber_frame=1;
+
+	BltBitMapRastPort(throbber,throbber_width*g->throbber_frame,0,g->win->RPort,bbox->Left,bbox->Top,throbber_width,throbber_height,0x0C0);
 }
 
 void gui_window_place_caret(struct gui_window *g, int x, int y, int height)

Modified: trunk/netsurf/amiga/gui.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.h?rev=5310&r1=5309&r2=5310&view=diff
==============================================================================
--- trunk/netsurf/amiga/gui.h (original)
+++ trunk/netsurf/amiga/gui.h Sat Sep 13 17:39:48 2008
@@ -37,6 +37,7 @@
 	GID_HOME,
 	GID_BACK,
 	GID_FORWARD,
+	GID_THROBBER,
 	GID_USER,
 	GID_PASS,
 	GID_LOGIN,
@@ -50,7 +51,6 @@
 	OID_VSCROLL,
 	OID_HSCROLL,
 	OID_MENU,
-	OID_THROBBER,
     OID_LAST
 };
 
@@ -84,6 +84,8 @@
 	union content_msg_data *redraw_data;
 	browser_mouse_state mouse_state;
 	browser_mouse_state key_state;
+	int throbber_frame;
+	ULONG throbber_update_count;
 	int c_x;
 	int c_y;
 	int c_h;

Modified: trunk/netsurf/amiga/options.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/options.h?rev=5310&r1=5309&r2=5310&view=diff
==============================================================================
--- trunk/netsurf/amiga/options.h (original)
+++ trunk/netsurf/amiga/options.h Sat Sep 13 17:39:48 2008
@@ -28,6 +28,7 @@
 extern char *option_toolbar_images;
 extern bool option_no_iframes;
 extern bool option_utf8_clipboard;
+extern int option_throbber_frames;
 
 #define EXTRA_OPTION_DEFINE \
 bool option_verbose_log = false; \
@@ -38,6 +39,7 @@
 char *option_toolbar_images = 0; \
 bool option_no_iframes = false; \
 bool option_utf8_clipboard = false; \
+int option_throbber_frames = 1;
 
 #define EXTRA_OPTION_TABLE \
 { "verbose_log",	OPTION_BOOL,	&option_verbose_log}, \
@@ -47,5 +49,6 @@
 { "screen_modeid",	OPTION_INTEGER,	&option_modeid}, \
 { "toolbar_images",		OPTION_STRING,	&option_toolbar_images }, \
 { "no_iframes",	OPTION_BOOL,	&option_no_iframes}, \
-{ "clipboard_write_utf8",	OPTION_BOOL,	&option_utf8_clipboard},
+{ "clipboard_write_utf8",	OPTION_BOOL,	&option_utf8_clipboard}, \
+{ "throbber_frames",	OPTION_INTEGER,	&option_throbber_frames},
 #endif




More information about the netsurf-commits mailing list