@@ -446,6 +446,7 @@ static Exec_stat MCBitmapEffectGetProperty(MCBitmapEffect *effect, MCBitmapEffec
446446 return ES_NORMAL ;
447447}
448448
449+
449450Exec_stat MCBitmapEffectsGetProperties (MCBitmapEffectsRef& self, Properties which_type, MCExecPoint& ep, MCNameRef prop)
450451{
451452 // Reset ep to empty, the default value.
@@ -508,6 +509,88 @@ Exec_stat MCBitmapEffectsGetProperties(MCBitmapEffectsRef& self, Properties whic
508509 return ES_NORMAL ;
509510}
510511
512+
513+ bool MCBitmapEffectsGetPropertyElement (MCBitmapEffectsRef& self, Properties which_type, MCNameRef p_prop, MCValueRef& r_setting)
514+ {
515+ MCExecPoint ep (nil, nil, nil);
516+
517+ // First map the property type
518+ MCBitmapEffectType t_type;
519+ t_type = (MCBitmapEffectType)(which_type - P_BITMAP_EFFECT_DROP_SHADOW );
520+
521+ // Now fetch the bitmap effect we are processing - note that if this is
522+ // NULL it means it isn't set. In this case we still carry on since we
523+ // need to report a invalid key error (if applicable).
524+ MCBitmapEffect *t_effect;
525+ if (self != nil && (self -> mask & (1 << t_type)) != 0 )
526+ t_effect = &self -> effects[t_type];
527+ else
528+ t_effect = nil;
529+
530+ MCBitmapEffectProperty t_property;
531+ if (MCBitmapEffectLookupProperty (t_type, p_prop, t_property) != ES_NORMAL )
532+ return false ;
533+
534+ // If there is no effect set for this type, then we are done.
535+ if (t_effect == nil)
536+ return true ;
537+
538+ // Otherwise fetch for the appropriate effect.
539+ if (MCBitmapEffectGetProperty (&self -> effects[t_type], t_property, ep) == ES_NORMAL )
540+ {
541+ /* UNCHECKED */ ep . copyasvalueref (r_setting);
542+ return true ;
543+ }
544+
545+ return false ;
546+ }
547+
548+ bool MCBitmapEffectsGetProperties (MCBitmapEffectsRef& self, Properties which_type, MCArrayRef& r_props)
549+ {
550+ MCExecPoint ep (nil, nil, nil);
551+
552+ // First map the property type
553+ MCBitmapEffectType t_type;
554+ t_type = (MCBitmapEffectType)(which_type - P_BITMAP_EFFECT_DROP_SHADOW );
555+
556+ // Now fetch the bitmap effect we are processing - note that if this is
557+ // NULL it means it isn't set. In this case we still carry on since we
558+ // need to report a invalid key error (if applicable).
559+ MCBitmapEffect *t_effect;
560+ if (self != nil && (self -> mask & (1 << t_type)) != 0 )
561+ t_effect = &self -> effects[t_type];
562+ else
563+ t_effect = nil;
564+
565+ // If there is no effect set for this type, then we are done.
566+ if (t_effect == nil)
567+ return true ;
568+
569+ // Otherwise we have an array get, so first create a new value
570+ MCAutoArrayRef v;
571+ if (!MCArrayCreateMutable (&v))
572+ return false ;
573+
574+ // Now loop through all the properties, getting the ones applicable to this type.
575+ for (uint32_t i = 0 ; i < ELEMENTS (s_bitmap_effect_properties); i++)
576+ if ((s_bitmap_effect_properties[i] . mask & (1 << t_type)) != 0 )
577+ {
578+ MCValueRef t_prop_value;
579+ MCNewAutoNameRef t_key;
580+
581+ /* UNCHECKED */ MCNameCreateWithCString (s_bitmap_effect_properties[i] . token, &t_key);
582+ // Attempt to fetch the property, then store it into the array.
583+ if (MCBitmapEffectGetProperty (t_effect, s_bitmap_effect_properties[i] . value, ep) != ES_NORMAL )
584+ return false ;
585+
586+ /* UNCHECKED */ ep . copyasvalueref (t_prop_value);
587+ MCArrayStoreValue (*v, kMCCompareExact , *t_key, t_prop_value);
588+ }
589+
590+ // Give the array to the ep
591+ r_props = MCValueRetain (*v);
592+ }
593+
511594// Set the given effect to default values for its type.
512595static void MCBitmapEffectDefault (MCBitmapEffect *p_effect, MCBitmapEffectType p_type)
513596{
@@ -777,6 +860,7 @@ Exec_stat MCBitmapEffectSetProperty(MCBitmapEffect *self, MCBitmapEffectProperty
777860 return ES_NORMAL ;
778861}
779862
863+
780864Exec_stat MCBitmapEffectsSetProperties (MCBitmapEffectsRef& self, Properties which_type, MCExecPoint& ep, MCNameRef prop, Boolean& r_dirty)
781865{
782866 // First map the property type
@@ -892,6 +976,183 @@ Exec_stat MCBitmapEffectsSetProperties(MCBitmapEffectsRef& self, Properties whic
892976 return ES_NORMAL ;
893977}
894978
979+
980+ bool MCBitmapEffectsSetPropertyElement (MCBitmapEffectsRef& self, Properties which_type, MCValueRef p_setting, MCNameRef p_prop, bool & r_dirty)
981+ {
982+ MCExecPoint ep (nil, nil, nil);
983+
984+ // First map the property type
985+ MCBitmapEffectType t_type;
986+ t_type = (MCBitmapEffectType)(which_type - P_BITMAP_EFFECT_DROP_SHADOW );
987+
988+ // A temporary bool to store the dirtiness
989+ bool t_dirty;
990+
991+ // Fetch (a copy of) the bitmap effect we are processing, otherwise
992+ // initialize one with defaults for the type.
993+ MCBitmapEffect t_effect;
994+ if (self != nil && (self -> mask & (1 << t_type)) != 0 )
995+ {
996+ t_effect = self -> effects[t_type];
997+
998+ // At this point we have made no changes.
999+ t_dirty = false ;
1000+ }
1001+ else
1002+ {
1003+ MCBitmapEffectDefault (&t_effect, t_type);
1004+
1005+ // If the effect doesn't yet exist, it means we will dirty the object
1006+ // regardless.
1007+ t_dirty = true ;
1008+ }
1009+
1010+ Boolean t_dirty_boolean;
1011+ t_dirty_boolean = False;
1012+ // Now update the copy of the effect with any newly set properties
1013+
1014+ // Lookup the property and ensure it is appropriate for our type.
1015+ MCBitmapEffectProperty t_property;
1016+ if (MCBitmapEffectLookupProperty (t_type, p_prop, t_property) != ES_NORMAL )
1017+ return false ;
1018+
1019+ // Set the property in our (copy of the) bitmap effect.
1020+ /* UNCHECKED */ ep . setvalueref (p_setting);
1021+
1022+ if (MCBitmapEffectSetProperty (&t_effect, t_property, ep, t_dirty_boolean) != ES_NORMAL )
1023+ return false ;
1024+
1025+ if (t_dirty_boolean != False)
1026+ t_dirty = true ;
1027+
1028+ // If no changes have been made, we have nothing to do.
1029+ if (!t_dirty)
1030+ return true ;
1031+
1032+ // Otherwise we must commit the changes
1033+
1034+ // If we are currently empty, then allocate a new object
1035+ if (self == NULL )
1036+ {
1037+ self = new MCBitmapEffects;
1038+ if (self == NULL )
1039+ return false ;
1040+
1041+ // Only need to initialize the mask.
1042+ self -> mask = 0 ;
1043+ }
1044+
1045+ // Now copy in the updated effect.
1046+ self -> mask |= (1 << t_type);
1047+ self -> effects[t_type] = t_effect;
1048+
1049+ r_dirty = t_dirty;
1050+ return true ;
1051+ }
1052+
1053+
1054+ bool MCBitmapEffectsSetProperties (MCBitmapEffectsRef& self, Properties which_type, MCArrayRef p_setting, bool & r_dirty)
1055+ {
1056+ MCExecPoint ep (nil, nil, nil);
1057+
1058+ // First map the property type
1059+ MCBitmapEffectType t_type;
1060+ t_type = (MCBitmapEffectType)(which_type - P_BITMAP_EFFECT_DROP_SHADOW );
1061+
1062+ // First handle the 'clear' action (i.e. carray is empty and ep is 'empty')
1063+ if (MCArrayIsEmpty (p_setting))
1064+ {
1065+ if (self == nil || (self -> mask & (1 << t_type)) == 0 )
1066+ return true ;
1067+
1068+ // We are set, so just unset our bit in the mask
1069+ self -> mask &= ~(1 << t_type);
1070+
1071+ // If we are now empty, then clear.
1072+ if (self -> mask == 0 )
1073+ MCBitmapEffectsClear (self);
1074+
1075+ // Mark the object as dirty
1076+ r_dirty = true ;
1077+
1078+ return true ;
1079+ }
1080+
1081+ // A temporary boolean to store the dirtiness
1082+ bool t_dirty;
1083+
1084+ // Fetch (a copy of) the bitmap effect we are processing, otherwise
1085+ // initialize one with defaults for the type.
1086+ MCBitmapEffect t_effect;
1087+ if (self != nil && (self -> mask & (1 << t_type)) != 0 )
1088+ {
1089+ t_effect = self -> effects[t_type];
1090+
1091+ // At this point we have made no changes.
1092+ t_dirty = false ;
1093+ }
1094+ else
1095+ {
1096+ MCBitmapEffectDefault (&t_effect, t_type);
1097+
1098+ // If the effect doesn't yet exist, it means we will dirty the object
1099+ // regardless.
1100+ t_dirty = true ;
1101+ }
1102+
1103+ Boolean t_dirty_boolean;
1104+ t_dirty_boolean = False;
1105+
1106+ // Loop through all the properties in the table and apply the relevant
1107+ // ones.
1108+ for (uint32_t i = 0 ; i < ELEMENTS (s_bitmap_effect_properties); i++)
1109+ if ((s_bitmap_effect_properties[i] . mask & (1 << t_type)) != 0 )
1110+ {
1111+ MCValueRef t_prop_value;
1112+ MCNewAutoNameRef t_key;
1113+
1114+ /* UNCHECKED */ MCNameCreateWithCString (s_bitmap_effect_properties[i] . token, &t_key);
1115+ // If we don't have the given element, then move to the next one
1116+ if (!MCArrayFetchValue ((MCArrayRef)p_setting, kMCCompareExact , *t_key, t_prop_value))
1117+ continue ;
1118+
1119+ // Otherwise, fetch the keys value and attempt to set the property
1120+ /* UNCHECKED */ ep . setvalueref (t_prop_value);
1121+ if (!MCBitmapEffectSetProperty (&t_effect, s_bitmap_effect_properties[i] . value, ep, t_dirty_boolean))
1122+ return false ;
1123+
1124+ if (t_dirty_boolean != False)
1125+ t_dirty = true ;
1126+ }
1127+
1128+ // If no changes have been made, we have nothing to do.
1129+ if (!t_dirty)
1130+ return true ;
1131+
1132+ // Otherwise we must commit the changes
1133+
1134+ // If we are currently empty, then allocate a new object
1135+ if (self == NULL )
1136+ {
1137+ self = new MCBitmapEffects;
1138+ if (self == NULL )
1139+ return false ;
1140+
1141+ // Only need to initialize the mask.
1142+ self -> mask = 0 ;
1143+ }
1144+
1145+ // Now copy in the updated effect.
1146+ self -> mask |= (1 << t_type);
1147+ self -> effects[t_type] = t_effect;
1148+
1149+ // Return the dirtiness.
1150+ r_dirty = t_dirty;
1151+
1152+ return true ;
1153+ }
1154+
1155+
8951156uint32_t MCBitmapEffectsWeigh (MCBitmapEffectsRef self)
8961157{
8971158 uint32_t t_size;
0 commit comments