IOAttributes implementation

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: IOAttributes implementation

Post by chronologicaldot »

Missed your reply til just now, sorry!

At the time, I may have thought setAlignment changed DesiredRect, but it doesn't. It only changes the ScaledRect. You can replace the above code with DesiredRect if you want.

EDIT: Here it is again, but cleaner. Note too the usage of default values for setAlignment()

Code: Select all

 
    virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
    {
        setID(in->getAttributeAsInt("Id", ID));
        setVisible(in->getAttributeAsBool("Visible", IsVisible));
        setEnabled(in->getAttributeAsBool("Enabled", IsEnabled));
        setName(in->getAttributeAsString("Name", Name));
        setText(in->getAttributeAsStringW("Caption", Text.c_str()).c_str());
        setToolTipText(in->getAttributeAsStringW("ToolTip", ToolTipText.c_str()).c_str());
        IsTabStop = in->getAttributeAsBool("TabStop", IsTabStop);
        IsTabGroup = in->getAttributeAsBool("TabGroup", IsTabGroup);
        TabOrder = in->getAttributeAsInt("TabOrder", TabOrder);
 
        core::position2di p = in->getAttributeAsPosition2d("MaxSize", core::position2di(MaxSize.Width, MaxSize.Height));
        setMaxSize(core::dimension2du(p.X,p.Y));
 
        p = in->getAttributeAsPosition2d("MinSize", core::position2di(MinSize.Width, MinSize.Height));
        setMinSize(core::dimension2du(p.X,p.Y));
 
        setAlignment(
            (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("LeftAlign", GUIAlignmentNames, (s32)AlignLeft),
            (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("RightAlign", GUIAlignmentNames, (s32)AlignRight),
            (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("TopAlign", GUIAlignmentNames, (s32)AlignTop),
            (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("BottomAlign", GUIAlignmentNames, (s32)AlignBottom)
        );
 
        setRelativePosition(in->getAttributeAsRect("Rect", DesiredRect));
 
        setNotClipped(in->getAttributeAsBool("NoClip", NoClip));
    }
 
Post Reply