throbber crap

This commit is contained in:
Chris Young 2019-05-08 00:56:07 +01:00
parent a5aa53657c
commit ae36d35728
3 changed files with 70 additions and 10 deletions

View File

@ -379,6 +379,45 @@ void ami_gui_set_throbbing(struct gui_window *gw, bool throbbing)
gw->throbbing = throbbing; gw->throbbing = throbbing;
} }
int ami_gui_get_throbber_frame(struct gui_window *gw)
{
assert(gw != NULL);
assert(gw->shared != NULL);
return gw->shared->throbber_frame;
}
void ami_gui_set_throbber_frame(struct gui_window *gw, int frame)
{
assert(gw != NULL);
assert(gw->shared != NULL);
gw->shared->throbber_frame = frame;
}
Object *ami_gui_get_object(struct gui_window *gw, int object_type)
{
ULONG obj = 0;
assert(gw != NULL);
assert(gw->shared != NULL);
switch(object_type) {
case AMI_GAD_THROBBER:
obj = GID_THROBBER;
break;
case AMI_GAD_TABS:
obj = GID_TABS;
break;
default:
return NULL;
break;
}
return gw->shared->objects[obj];
}
struct Window *ami_gui2_get_window(struct gui_window_2 *gwin) struct Window *ami_gui2_get_window(struct gui_window_2 *gwin)
{ {
assert(gwin != NULL); assert(gwin != NULL);

View File

@ -38,6 +38,12 @@
#define HOOKF(ret,func,type,ptr,msgtype) static ASM ret func(REG(a0, struct Hook *hook),REG(a2, type ptr), REG(a1, msgtype msg)) #define HOOKF(ret,func,type,ptr,msgtype) static ASM ret func(REG(a0, struct Hook *hook),REG(a2, type ptr), REG(a1, msgtype msg))
#endif #endif
/* valid options for ami_gui_get_object */
enum {
AMI_GAD_THROBBER = 0,
AMI_GAD_TABS
};
enum enum
{ {
OID_MAIN = 0, OID_MAIN = 0,
@ -322,11 +328,26 @@ void ami_gui_set_find_window(struct gui_window *gw, struct find_window *fw);
*/ */
bool ami_gui_get_throbbing(struct gui_window *gw); bool ami_gui_get_throbbing(struct gui_window *gw);
/**
* Get throbbing frame from gui_window
*/
int ami_gui_get_throbber_frame(struct gui_window *gw);
/**
* Set throbbing frame in gui_window
*/
void ami_gui_set_throbber_frame(struct gui_window *gw, int frame);
/** /**
* Set throbbing status in gui_window * Set throbbing status in gui_window
*/ */
void ami_gui_set_throbbing(struct gui_window *gw, bool throbbing); void ami_gui_set_throbbing(struct gui_window *gw, bool throbbing);
/**
* Get object from gui_window
*/
Object *ami_gui_get_object(struct gui_window *gw, int object_type);
/** /**
* Get window from gui_window * Get window from gui_window
*/ */

View File

@ -432,13 +432,13 @@ void gui_window_start_throbber(struct gui_window *g)
if(ami_gui_get_tab_node(g) && (ami_gui_get_gui_window_2(g)->tabs > 1)) if(ami_gui_get_tab_node(g) && (ami_gui_get_gui_window_2(g)->tabs > 1))
{ {
SetClickTabNodeAttrs(ami_gui_get_tab_node(g), TNA_Flagged, TRUE, TAG_DONE); SetClickTabNodeAttrs(ami_gui_get_tab_node(g), TNA_Flagged, TRUE, TAG_DONE);
RefreshGadgets((APTR)ami_gui_get_gui_window_2(g)->objects[GID_TABS], RefreshGadgets((APTR)ami_gui_get_object(g, AMI_GAD_TABS),
ami_gui_get_window(g), NULL); ami_gui_get_window(g), NULL);
} }
#endif #endif
ami_gui_set_throbbing(g, true); ami_gui_set_throbbing(g, true);
if(ami_gui_get_gui_window_2(g)->throbber_frame == 0) ami_gui_get_gui_window_2(g)->throbber_frame = 1; if(ami_gui_get_throbber_frame(g) == 0) ami_gui_set_throbber_frame(g, 1);
ami_throbber_redraw_schedule(throbber_update_interval, g); ami_throbber_redraw_schedule(throbber_update_interval, g);
} }
@ -453,13 +453,13 @@ void gui_window_stop_throbber(struct gui_window *g)
if(ami_gui_get_tab_node(g) && (ami_gui_get_gui_window_2(g)->tabs > 1)) if(ami_gui_get_tab_node(g) && (ami_gui_get_gui_window_2(g)->tabs > 1))
{ {
SetClickTabNodeAttrs(ami_gui_get_tab_node(g), TNA_Flagged, FALSE, TAG_DONE); SetClickTabNodeAttrs(ami_gui_get_tab_node(g), TNA_Flagged, FALSE, TAG_DONE);
RefreshGadgets((APTR)ami_gui_get_gui_window_2(g)->objects[GID_TABS], RefreshGadgets((APTR)ami_gui_get_object(g, AMI_GAD_TABS),
ami_gui_get_window(g), NULL); ami_gui_get_window(g), NULL);
} }
#endif #endif
if(IS_CURRENT_GW(ami_gui_get_gui_window_2(g), g)) { if(IS_CURRENT_GW(ami_gui_get_gui_window_2(g), g)) {
if(ami_gui_get_space_box(ami_gui_get_gui_window_2(g)->objects[GID_THROBBER], &bbox) != NSERROR_OK) { if(ami_gui_get_space_box(ami_gui_get_object(g, AMI_GAD_THROBBER), &bbox) != NSERROR_OK) {
amiga_warn_user("NoMemory", ""); amiga_warn_user("NoMemory", "");
return; return;
} }
@ -484,17 +484,17 @@ static void ami_throbber_update(void *p)
int frame = 0; int frame = 0;
if(!g) return; if(!g) return;
if(!ami_gui_get_gui_window_2(g)->objects[GID_THROBBER]) return; if(!ami_gui_get_object(g, AMI_GAD_THROBBER)) return;
if(ami_gui_get_throbbing(g) == true) { if(ami_gui_get_throbbing(g) == true) {
frame = ami_gui_get_gui_window_2(g)->throbber_frame; frame = ami_gui_get_throbber_frame(g);
ami_gui_get_gui_window_2(g)->throbber_frame++; ami_gui_set_throbber_frame(g, frame + 1);
if(ami_gui_get_gui_window_2(g)->throbber_frame > (throbber_frames-1)) if(ami_gui_get_throbber_frame(g) > (throbber_frames-1))
ami_gui_get_gui_window_2(g)->throbber_frame=1; ami_gui_set_throbber_frame(g, 1);
} }
if(IS_CURRENT_GW(ami_gui_get_gui_window_2(g),g)) { if(IS_CURRENT_GW(ami_gui_get_gui_window_2(g),g)) {
if(ami_gui_get_space_box(ami_gui_get_gui_window_2(g)->objects[GID_THROBBER], &bbox) != NSERROR_OK) { if(ami_gui_get_space_box(ami_gui_get_object(g, AMI_GAD_THROBBER), &bbox) != NSERROR_OK) {
amiga_warn_user("NoMemory", ""); amiga_warn_user("NoMemory", "");
return; return;
} }