Viewables

A consequence of the new object runtime is that the format of viewable objects will change for Rosemary. Class Viewable no longer inherits from class Linkable, but directly from class Object instead. Class Viewable now also inherits directly from the HasCount and HasIndexing mixin classes to implement the list API that was previously inherited from class Linkable. (Class Linkable inherited from HasCount and HasIndexing, so this doesn't represent a change in the API of the Viewable class.)

While the API for the Viewable class won't undergo major changes in the Rosemary release, the fact that Viewable no longer inherits from Linkable means that the data format of Viewable instances will be different. View chains are no longer represented by links to a next and previous viewable. Instead, view chains are represented as an embedded subview list in the containing viewable:

        instance ControlBar controlBar;
        relativeOrigin: <0.0,140.0>;
           contentSize: <480.0,32.0>;
             viewFlags: 0x11004020;
            labelStyle: iBook12;
                 color: 0xFF333333;
              altColor: 0xFF000000;
                shadow: nilObject;
                 sound: nilObject;
                border: iControlBarImage;
             separator: <70.5>;
           hiliteIndex: 0;
               subview: (Gadget desk);
               subview: (TrashGadget trash);
               subview: (KeyboardGadget keyboard);
               subview: (ToolGadget toolCup);
               subview: (MagicHat magicHat);
               subview: (CommandGadget magicLamp);
               subview: (Gadget unnamed663);
        end instance;
While the new format represents a change, new view chains should be easier to maintain. Subviews are still listed in back to front order, but rearranging viewables is now simply a matter of reordering object references in a list. The superview field is still present but no longer specified explicitly; the object compiler fills it in automatically.

For the most part, the change in the viewable data format won't have a direct effect on Magic Cap package code, as the API remains mostly unchanged. A script that converts viewable instances in object definition files from the old style to the new style will be provided with developer releases of Rosemary. However, code that directly accesses fields of a viewable object needs to be changed use the viewable API to manipulate viewable objects.

Removed Viewable_SetSuperview and Viewable_SetSubview. SwitchContainer() or the new SwitchContainerAt() operations should be used instead. SwitchContainer() no longer changes the origin if the viewable is being switched to or from nilObject.

Last() and First() can no longer be called on an arbitrary viewable because they are no longer stored as linkables. Use LastSubview(Superview()) and FirstSubview(Superview()) instead.

View chains, which are currently implemented as viewables linked by their next and previous fields, need to be re-implemented, probably as lists. System classes that used to store view chains now store object lists instead. Class ViewChainList will not exist in Rosemary. Operations that used to return view chains now return object lists of viewables.

Added many operations to provide better support for viewables stored in lists. Operations which return lists of viewables return an ephemeral list. Added SwitchAllContainers() which calls SwitchContainer() on each viewable in a list. Added ContentsList which returns an ephemeral list with all the subviews of self. Added SubstituteInPlace that replaces self in the view hierarchy with a new viewable.

Renamed Scene_Stamps to LocalStamps(). It now returns an ephemeral list holding the stamps in this scene's SceneAdditions. SetLocalStamps() stores the contents of the list passed to it instead of storing the list itself.

Drawers now store object lists instead of view chains per drawer. Added methods SwitchBankAndDrawers, DisplayedStoredViewables and StoreDisplayedViewables.

Replaced MagicWindow_titleList field, which remembered a list of category boxes and sets of viewables, with categoryBox, which holds a single CategoryBox object.

To distinguish Corridor_Remove and Corridor_AddTo from other Remove and AddTo methods, renamed them to RemoveFromCorridor() and InsertIntoCorridor().
Renamed StoreroomShelf_Remove to RemoveStorageBoxFor() for similar reasons.

Added MemoryImageObject that can be overridden instead of overriding MemoryImage and TouchedMemoryImage.

Added Viewable_AlwaysOnTop. This attribute specifies whether or not a particular viewable can be swallowed or can change containers. By default, this attribute returns false. Dragging viewables that are always on top is now much faster because hit testing can be minimized for these viewables.

Introduced Viewable_BlinkBox which inverts and uninverts a box multiple times. Introduced support routines BlinkLabelAt() in classes AddressPanel and PhonePanel to support revealing and blinking labels on name cards when searching for contact information.

The word "hilite" is a leftover of days when compilers would only recognize idenitifiers of a certain length. Those days are long gone. All occurences of "hilite" in Magic Cap have been changed into the more proper "highlight". Most of these happen to be in class Viewable.

Class ContainerWindow now implements the attributes GridSize() and GridOffset() so that grid spacing clients no longer need to access the fields directly.

The new runtime does not support AttributeType(). Control instances used to rely on this call to determine the type of value in the targetAttribute field. The attribute type is now specified by three bits in the controlFlags now. The valid types are boolean, short, long, fixed and object. Created the attribute TargetAttributeType() to access these bits. Updated TargetAttributeAsLevel(), SetTargetAttributeByLevel() and ZeroLevelWhenOffscreen() to use this new attribute instead of AttributeType().

In TargetAttributeAsLevel(), cast the result from IntegerAttribute() to a short if the attribute type is a short. This is necessary in the new runtime, the high word is not automatically cleared or sign extended.

Renamed dontConvertValueMask control flag to convertToMicronMask. The reverseSenseBit is now only meaningful for boolean attribute types.

A new window flag, noZoomMask has been defined which allows window objects to control whether or not the zoom animation should be performed. This bit is respected by ZoomFromWhere().

Gadget windows that have targets that are subviews of another open window are now automatically made dependent on the second window.

The Rosemary Magic Cap API tries to avoid having multiple operations have the same name but different interfaces. Since Magic Cap doesn't do polymorphism, this is just plain confusing. Many operations have been removed or renamed to avoid this problem. Renamed the AddSorted() operation of clas ArchiveIcon and FolderTray to FileCard(), since it doesn't have the same parameters as SortedList_AddSorted(). Renamed the Max() attribute of class TrashGadget to ItemsToKeep(). In the process, moved the attribute and field to the TrashWindow class since it has most of the responsibility for the trash now anyway.

Fixed a bug in ArchiveIcon_Swallow where it would refuse to swallow minicards if the option key is down. This may explain why some people who've set their rule to file cards as they come in sometimes find cards sitting on top of the file cabinet instead of filed in it.

SceneAdditions now has a new field, ownerScene which refers back to the scene that these additions appear in.

Dirtying is now suspended when AboutToShow() and AboutToHide() are called. The reasoning is that the area occupied by your viewable is going to get dirtied anyway, so if you change a visible attribute of your viewable, extra dirtying is redundant. However, if you change the visible attribute of another viewable inside AboutToShow() or AboutToHide(), you need to call SuspendDirtyLevel() and ResumeDirtyLevel() so that the viewables you change will be dirtied correctly.

Added Viewable_FirstSubviewOfClassDeep. This is similar to FirstSubviewOfClass(), but it will traverse down a view chain, whereas FirstSubviewOfClass() only did a shallow traversal.

Added methods Viewable_BlinkVisibility and Viewable_BlinkHighlighted. BlinkVisibility() blinks a viewable by making it alternately invisible then visible a few times. BlinkHighlighted() blinks a viewable by alternating its highlight state. Added constants kDefaultBlinkCount, and kDefaultBlinkDelay which can be used as values for parameters to BlinkVisibility(), BlinkHighlighted(), and BlinkBox().

Added the method DrawFloor() to class Corridor. This is the method that should be overridden instead of Draw() to draw the floor in a corridor. CarpetedCorridor and Road now override this method instead of Draw().

Fixed a bug where items in the desk drawer were too large. Buildings without logo images were returning the image of the building itself as the image to use when creating an icon. nilObject is now returned, which causes the generic icon image to be used.

Changed the interface to Screen_CloseAllWindows. It now returns a boolean that specifies whether any windows were actually closed. Removed the similar but obsolete operation Screen_RemoveAllWindows.

Added a Label() method to class ImageGallery that returns the name of the displayed image. The name of the ImageGallery object is no longer changed to be that of the image.

Book pages can no longer be faxed.

Corridors now keep around a list of names of objects they know about. Whenever one of these items is inserted, it will be placed in the corridor in the position specified by the list. This was done to provide a way to specify the order of doors in the hallway and downtown. This list is maintained in the new field knownItemNames. Corridor instances that don't care about the order if its contents should specify nilObject in this field.

The flags field of many classes have been split into individual Boolean fields in the class. This makes it easier to set and clear particular attributes for these classes. The classes that are affected are Announcement, AttributeText, ChoiceBox, City, CityClock, Clock, ContainerIcon, DateChooser, DeliveryReportCard, Drawer, EditableClock, Folder, FolderTray, Gadget, ImageGallery, IndexTab, LessonTool, Line, ListWindow, MCDeliveryStatus, PhoneCallCard, PhoneNumberFormatter, PhonePanel, RuleView, Scene, ScheduleBar, Screen, Shelf, SpeedDialButton, StackOfCards, StorageBox, StructuredField, TimePicker and Window.

Class LessonCard also works the same way. LessonCards no longer specify the position into which they should be installed in a LessonStack. Now, LessonStacks maintain a list of names for LessonCards that should go in a known order.

Viewable_ExtendBottom has been renamed Viewable_ExtendBottomBy since it takes a delta parameter.

The flags field of class SongStamp has been split into individual Boolean attributes.

The Viewable class implements a new method, MatchTextDeep(), which calls MatchText() on each subview. Most callers will want to use this call instead of MatchText(). The Card class overrides MatchText() to call MatchTextDeep() on its form after installing its form, if the form was not installed. A new method, Card_CardOrEnvelopeContainsText, which checks a card and its envelope (if any) for specified text by calling MatchTextDeep() on them.

Added the method MatchImageDeep() to the Viewable class, which calls MatchImage() on each subview. Added Card_CardOrEnvelopeDisplaysImage, which works likes CardOrEnvelopeContainsText(), but for images.

Viewable_Finalize now unlinks self from the view chain if the viewable's superview is not being destroyed. Unlinking a viewable from the view chain causes AboutToHide() to get called. If you destroy your viewable in an AboutToHide() override, be aware that this operation is now being called in a situation where the viewable might already be in the process of being destroyed.

The ContentIcon() method has been renamed TinyImage(), since that's what it really was. Renamed SmallClassImage() to TinyClassImage().

Previously, hitting return in a scene with many text fields would rely on the front to back ordering of text fields to determine the next text field to activate. This means you had to be careful about how you laid out your view hierarchy to get the insertion point to move from text field to text field in an intelligible manner. Now, you can override Viewable_FindNextSubviewAcceptingTyping to customize how the insertion point moves from text container to text container. By default, this uses the old front to back ordering method.

Added the read only attribute Attribute_TextMapping. This allows subclasses to specify which text mapping should be used instead of using iStandardTextMapping directly.

Added the method TitledWindow_DotInCloseBox. This method checks to see if the specified point is inside the close box of a titled window. You would normally pass in the starting point of a touch input.

Classes affected by these changes

Announcement
ArchiveIcon
BookScene
Building new
Button
CanBeSearchResult new
CanBeSearched new
Card
CardSlotIcon
ContainerWindow
ContentChoicesWindow new
Control
ControlBar
Corridor
CorridorScene new
DatebookSearchResult new
DateChooser
DrawerGadget
Drawers
EditWindow
ErasableAnnotation new
ExchangeObjectSwitch new
ImageGallery
IndexTab
LessonCard
LessonStack new
ListViewIndexTab new
MagicWindow
MainDesktop new
MiniCard
ModeButton
NameBar
NameCardsIcon new
NameCardsSceneIndexTab new
NotebookPageTypeWindow new
PageTurnBox
PhonePanel
PurgeablaContents
Road
Scene
SceneAdditions
Screen
SeasonalStamp new
Snapshot
SongStamp
SpoutedEditWindow new
Stamp
StarburstHilite obsolete
StarburstHighlight new
Task
TaskAnnotation
TextSearchResult new
TimePicker
TitledWindow
TrashGadget
TrashWindow
TodayButton
Viewable
ViewChainList obsolete
XScreenWindow new
XWindow new