From 06081583e4049e7fdad006e4f4561aba6e6445d7 Mon Sep 17 00:00:00 2001 From: wawa Date: Sun, 2 Sep 2018 23:21:06 +0000 Subject: [PATCH] forwarding tidying previous patch (NicJA). git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@55423 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/libs/muimaster/classes/coloradjust.c | 76 +++++++++++++--------- .../libs/muimaster/classes/coloradjust_private.h | 1 - workbench/libs/muimaster/classes/notify.c | 4 +- workbench/libs/muimaster/classes/palette.c | 58 +++++++++-------- workbench/libs/muimaster/classes/palette_private.h | 1 - 5 files changed, 78 insertions(+), 62 deletions(-) diff --git a/workbench/libs/muimaster/classes/coloradjust.c b/workbench/libs/muimaster/classes/coloradjust.c index 1d669c693f..816ab4c52e 100644 --- a/workbench/libs/muimaster/classes/coloradjust.c +++ b/workbench/libs/muimaster/classes/coloradjust.c @@ -72,7 +72,7 @@ static void NotifyGun(Object *obj, struct Coloradjust_DATA *data, ULONG gun) tags[0].ti_Data = data->rgb[gun]; tags[1].ti_Data = (IPTR) data->rgb; - CoerceMethod(data->notifyclass, obj, OM_SET, (IPTR) tags, NULL); + CoerceMethod(OCLASS(obj), obj, OM_SET, (IPTR) tags, TAG_DONE); } static void NotifyAll(Object *obj, struct Coloradjust_DATA *data) @@ -88,7 +88,8 @@ static void NotifyAll(Object *obj, struct Coloradjust_DATA *data) tags[1].ti_Data = data->rgb[1]; tags[2].ti_Data = data->rgb[2]; tags[3].ti_Data = (IPTR) data->rgb; - CoerceMethod(data->notifyclass, obj, OM_SET, (IPTR) tags, NULL); + + CoerceMethod(OCLASS(obj), obj, OM_SET, (IPTR) tags, TAG_DONE); } static void SliderFunc(struct Hook *hook, Object *obj, struct MUIP_CASliderNotifyMsg *msg) @@ -117,7 +118,8 @@ static void SliderFunc(struct Hook *hook, Object *obj, struct MUIP_CASliderNotif ConvertRGBToHSB(&cw, &hsb); nnset(data->wheel, WHEEL_HSB, (IPTR) & hsb); - nnset(data->grad, GRAD_CurVal, 0xFFFF - (hsb.cw_Brightness >> 16)); + if (data->grad) + nnset(data->grad, GRAD_CurVal, 0xFFFF - (hsb.cw_Brightness >> 16)); if (data->gradpen != -1) { @@ -126,7 +128,7 @@ static void SliderFunc(struct Hook *hook, Object *obj, struct MUIP_CASliderNotif SetRGB32(&_screen(obj)->ViewPort, data->gradpen, cw.cw_Red, cw.cw_Green, cw.cw_Blue); - if (data->truecolor) + if ((data->truecolor) && (data->grad)) MUI_Redraw(data->grad, MADF_DRAWUPDATE); } } @@ -142,9 +144,11 @@ static void WheelFunc(struct Hook *hook, Object *obj, struct MUIP_CANotifyMsg *m hsb.cw_Hue = XGET(data->wheel, WHEEL_Hue); hsb.cw_Saturation = XGET(data->wheel, WHEEL_Saturation); - hsb.cw_Brightness = 0xFFFF - XGET(data->grad, GRAD_CurVal); - hsb.cw_Brightness |= (hsb.cw_Brightness << 16); - + if (data->grad) + { + hsb.cw_Brightness = 0xFFFF - XGET(data->grad, GRAD_CurVal); + hsb.cw_Brightness |= (hsb.cw_Brightness << 16); + } ConvertHSBToRGB(&hsb, &cw); data->rgb[0] = cw.cw_Red; @@ -164,7 +168,7 @@ static void WheelFunc(struct Hook *hook, Object *obj, struct MUIP_CANotifyMsg *m SetRGB32(&_screen(obj)->ViewPort, data->gradpen, cw.cw_Red, cw.cw_Green, cw.cw_Blue); - if (data->truecolor) + if ((data->truecolor) && (data->grad)) MUI_Redraw(data->grad, MADF_DRAWUPDATE); } @@ -177,7 +181,9 @@ static void GradFunc(struct Hook *hook, Object *obj, struct MUIP_CANotifyMsg *ms struct ColorWheelHSB hsb; struct ColorWheelRGB cw; - ULONG bright = XGET(data->grad, GRAD_CurVal); + ULONG bright = 0; + if (data->grad) + bright = XGET(data->grad, GRAD_CurVal); bright = 0xFFFF - bright; bright |= (bright << 16); @@ -201,7 +207,6 @@ static void GradFunc(struct Hook *hook, Object *obj, struct MUIP_CANotifyMsg *ms NotifyAll(obj, data); } - IPTR Coloradjust__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) { struct Coloradjust_DATA *data; @@ -239,7 +244,10 @@ IPTR Coloradjust__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) End), Child, (IPTR) VSpace(1), Child, (IPTR) VSpace(1), - Child, (IPTR) (colfield = (Object *) ColorfieldObject, TextFrame, MUIA_Weight, 0, End), + Child, (IPTR) (colfield = (Object *) ColorfieldObject, + TextFrame, + MUIA_Weight, 0, + End), Child, (IPTR) (HGroup, MUIA_Group_HorizSpacing, 2, (!colorwheelbase) ? TAG_IGNORE : Child, @@ -276,6 +284,8 @@ IPTR Coloradjust__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) ICA_TARGET, ICTARGET_IDCMP, MUIA_FillArea, TRUE, End), + (!colorwheelbase && !gradientsliderbase) ? Child : TAG_IGNORE, + (IPTR)HVSpace, End), TAG_MORE, (IPTR) msg->ops_AttrList); @@ -295,9 +305,8 @@ IPTR Coloradjust__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) if (!EXEC_INTERFACE_GET_MAIN(data->icolorwheel, data->colorwheelbase)) { CoerceMethod(cl, obj, OM_DISPOSE); - return 0; + return (IPTR)NULL; } - data->notifyclass = cl->cl_Super->cl_Super; data->sliderhook.h_Entry = HookEntry; data->sliderhook.h_SubEntry = (HOOKFUNC) SliderFunc; @@ -349,7 +358,7 @@ IPTR Coloradjust__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) nnset(gslider, MUIA_Numeric_Value, data->rgb[1] >> 24); nnset(bslider, MUIA_Numeric_Value, data->rgb[2] >> 24); - if (wheel) + if (data->wheel ) { struct ColorWheelRGB cw; struct ColorWheelHSB hsb; @@ -360,12 +369,15 @@ IPTR Coloradjust__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) ConvertRGBToHSB(&cw, &hsb); - nnset(wheel, WHEEL_HSB, (IPTR) & hsb); + nnset(data->wheel, WHEEL_HSB, (IPTR) & hsb); /* just to be sure - colorwheel seems to have some problems */ - nnset(wheel, WHEEL_Saturation, hsb.cw_Saturation); - nnset(wheel, WHEEL_Hue, hsb.cw_Hue); - nnset(data->grad, GRAD_CurVal, 0xFFFF - (hsb.cw_Brightness >> 16)); - nnset(data->grad, GRAD_PenArray, (IPTR) data->gradpenarray); + nnset(data->wheel, WHEEL_Saturation, hsb.cw_Saturation); + nnset(data->wheel, WHEEL_Hue, hsb.cw_Hue); + if (data->grad) + { + nnset(data->grad, GRAD_CurVal, 0xFFFF - (hsb.cw_Brightness >> 16)); + nnset(data->grad, GRAD_PenArray, (IPTR) data->gradpenarray); + } } DoMethod(rslider, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, @@ -378,16 +390,20 @@ IPTR Coloradjust__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) (IPTR) obj, 4, MUIM_CallHook, (IPTR) & data->sliderhook, (IPTR) data, 2); - if (wheel) + if (data->wheel ) { - DoMethod(wheel, MUIM_Notify, WHEEL_Hue, MUIV_EveryTime, (IPTR) obj, - 3, MUIM_CallHook, (IPTR) & data->wheelhook, (IPTR) data); - DoMethod(wheel, MUIM_Notify, WHEEL_Saturation, MUIV_EveryTime, + DoMethod(data->wheel , MUIM_Notify, WHEEL_Hue, MUIV_EveryTime, + (IPTR) obj, 3, MUIM_CallHook, (IPTR) & data->wheelhook, + (IPTR) data); + DoMethod(data->wheel , MUIM_Notify, WHEEL_Saturation, MUIV_EveryTime, (IPTR) obj, 3, MUIM_CallHook, (IPTR) & data->wheelhook, (IPTR) data); - DoMethod(grad, MUIM_Notify, GRAD_CurVal, MUIV_EveryTime, (IPTR) obj, - 3, MUIM_CallHook, (IPTR) & data->gradhook, (IPTR) data); - + } + if (data->grad) + { + DoMethod(data->grad, MUIM_Notify, GRAD_CurVal, MUIV_EveryTime, + (IPTR) obj, 3, MUIM_CallHook, (IPTR) & data->gradhook, + (IPTR) data); } return (IPTR) obj; } @@ -480,8 +496,9 @@ IPTR Coloradjust__OM_SET(struct IClass *cl, Object *obj, nnset(data->wheel, WHEEL_HSB, (IPTR) & hsb); nnset(data->wheel, WHEEL_Saturation, hsb.cw_Saturation); nnset(data->wheel, WHEEL_Hue, hsb.cw_Hue); - nnset(data->grad, GRAD_CurVal, - 0xFFFF - (hsb.cw_Brightness >> 16)); + if (data->grad) + nnset(data->grad, GRAD_CurVal, + 0xFFFF - (hsb.cw_Brightness >> 16)); if ((_flags(obj) & MADF_SETUP) && (data->gradpen != -1)) { @@ -490,12 +507,11 @@ IPTR Coloradjust__OM_SET(struct IClass *cl, Object *obj, SetRGB32(&_screen(obj)->ViewPort, data->gradpen, cw.cw_Red, cw.cw_Green, cw.cw_Blue); - if (data->truecolor) + if ((data->truecolor) && (data->grad)) { MUI_Redraw(data->grad, MADF_DRAWOBJECT); } } - } } diff --git a/workbench/libs/muimaster/classes/coloradjust_private.h b/workbench/libs/muimaster/classes/coloradjust_private.h index c3649298b1..3d203d2e17 100644 --- a/workbench/libs/muimaster/classes/coloradjust_private.h +++ b/workbench/libs/muimaster/classes/coloradjust_private.h @@ -10,7 +10,6 @@ struct Coloradjust_DATA { struct Library *colorwheelbase; struct Library *gradientsliderbase; - struct IClass *notifyclass; struct Hook sliderhook, wheelhook, gradhook; Object *rslider, *gslider, *bslider, *colfield, *wheel, *grad; ULONG rgb[3]; diff --git a/workbench/libs/muimaster/classes/notify.c b/workbench/libs/muimaster/classes/notify.c index e637862296..6be52c99fd 100644 --- a/workbench/libs/muimaster/classes/notify.c +++ b/workbench/libs/muimaster/classes/notify.c @@ -283,10 +283,10 @@ static void check_notify(NNode nnode, Object *obj, struct TagItem *tag) /* Is the notification already being performed? */ if (nnode->nn_Active) { -#if DEBUG static int counter; - D(bug("Notifyloop detected! (#%d)\n", counter++)); + bug("%s: MUI Notification loop detected! (#%d)\n", FindTask(NULL)->tc_Node.ln_Name, counter++); +#if DEBUG D(bug(" Source object: 0x%x", obj)); switch ((IPTR) nnode->nn_DestObj) diff --git a/workbench/libs/muimaster/classes/palette.c b/workbench/libs/muimaster/classes/palette.c index 551f066e1b..e5ea11dda9 100644 --- a/workbench/libs/muimaster/classes/palette.c +++ b/workbench/libs/muimaster/classes/palette.c @@ -72,16 +72,17 @@ static void NotifyGun(Object * obj, struct MUI_PaletteData *data, LONG gun) }; struct TagItem tags[] = { - {0, 0}, - {MUIA_Coloradjust_RGB, 0}, - {TAG_DONE} + { MUIA_NoNotify, TRUE}, + { 0, 0}, + { MUIA_Coloradjust_RGB, 0}, + { TAG_DONE} }; - tags[0].ti_Tag = guntotag[gun]; - tags[0].ti_Data = data->rgb[gun]; - tags[1].ti_Data = (IPTR) data->rgb; + tags[1].ti_Tag = guntotag[gun]; + tags[1].ti_Data = data->rgb[gun]; + tags[2].ti_Data = (IPTR) data->rgb; - CoerceMethod(data->notifyclass, obj, OM_SET, (IPTR) tags, NULL); + SetAttrsA(obj, tags); } static LONG setcolor_func(struct Hook *hook, APTR * obj, struct MUIP_PalNotifyMsg *msg) @@ -106,7 +107,7 @@ static LONG setcolor_func(struct Hook *hook, APTR * obj, struct MUIP_PalNotifyMs data->rgb[0] = r; data->rgb[1] = g; data->rgb[2] = b; - NotifyGun((Object *) obj, data, gun); + NotifyGun(data->coloradjust, data, gun); } } else if (mode == 2) @@ -136,12 +137,13 @@ IPTR Palette__OM_NEW(struct IClass * cl, Object * obj, struct opSet * msg) GroupFrame, MUIA_Background, MUII_ButtonBack, MUIA_Group_Horiz, TRUE, - Child, list = ListviewObject, - MUIA_Listview_List, ListObject, - End, - End, - Child, coloradjust = ColoradjustObject, - End, TAG_MORE, (IPTR) msg->ops_AttrList); + Child, (IPTR)(ListviewObject, + MUIA_Listview_List, (IPTR)(list = ListObject, + End), + End), + Child, (coloradjust = ColoradjustObject, + End), + TAG_MORE, (IPTR) msg->ops_AttrList); if (obj == NULL) return (IPTR) NULL; @@ -179,8 +181,6 @@ IPTR Palette__OM_NEW(struct IClass * cl, Object * obj, struct opSet * msg) } } - data->notifyclass = cl->cl_Super->cl_Super; - if (data->numentries > 0) { for (i = 0; i < data->numentries; i++) @@ -200,18 +200,20 @@ IPTR Palette__OM_NEW(struct IClass * cl, Object * obj, struct opSet * msg) data->rgb[2] = data->entries[0].mpe_Blue; } - DoMethod(data->list, MUIM_Notify, MUIA_List_Active, - MUIV_EveryTime, obj, 5, MUIM_CallHook, &data->setcolor_hook, - data, 1, 0); - DoMethod(data->coloradjust, MUIM_Notify, MUIA_Coloradjust_Red, - MUIV_EveryTime, obj, 5, MUIM_CallHook, &data->setcolor_hook, - data, 2, 0); - DoMethod(data->coloradjust, MUIM_Notify, MUIA_Coloradjust_Green, - MUIV_EveryTime, obj, 5, MUIM_CallHook, &data->setcolor_hook, - data, 2, 1); - DoMethod(data->coloradjust, MUIM_Notify, MUIA_Coloradjust_Blue, - MUIV_EveryTime, obj, 5, MUIM_CallHook, &data->setcolor_hook, - data, 2, 2); + DoMethod(data->list, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, + (IPTR) obj, 5, MUIM_CallHook, (IPTR) &data->setcolor_hook, + (IPTR) data, 1, 0); + + DoMethod(data->coloradjust, MUIM_Notify, MUIA_Coloradjust_Red, MUIV_EveryTime, + (IPTR) obj, 5, MUIM_CallHook, (IPTR) &data->setcolor_hook, + (IPTR) data, 2, 0); + DoMethod(data->coloradjust, MUIM_Notify, MUIA_Coloradjust_Green, MUIV_EveryTime, + (IPTR) obj, 5, MUIM_CallHook, (IPTR) &data->setcolor_hook, + (IPTR) data, 2, 1); + DoMethod(data->coloradjust, MUIM_Notify, MUIA_Coloradjust_Blue, MUIV_EveryTime, + (IPTR) obj, 5, MUIM_CallHook, (IPTR) &data->setcolor_hook, + (IPTR) data, 2, 2); + return (IPTR) obj; } diff --git a/workbench/libs/muimaster/classes/palette_private.h b/workbench/libs/muimaster/classes/palette_private.h index 5ccfc8a032..4dd49e7dc8 100644 --- a/workbench/libs/muimaster/classes/palette_private.h +++ b/workbench/libs/muimaster/classes/palette_private.h @@ -9,7 +9,6 @@ struct MUI_PaletteData { const char **names; struct MUI_Palette_Entry *entries; - struct IClass *notifyclass; Object *list, *coloradjust; ULONG numentries; ULONG group; -- 2.11.4.GIT