[C++] GUI Builder - How to wrap GUI Objects?

Started by
1 comment, last by Mybowlcut 13 years, 5 months ago
I'm building a GUI builder in C++. I have existing GUI elements that all derive from GUI_Object. My plan is to wrap every GUI class that I have, and register it with a property grid to change the details of the underlying GUI object:
class GUI_Object_Builder  {    // ...  };    class Image_Builder  {    public:        Image_Builder();                virtual void Handle_Field_Change(const std::string& data);    private:        image_ptr image;  };  class Button_Builder {};  // etc.    Image_Builder::Do_Registration()  {        GEM.Register(this, Trigger("property_grid", INPUT / PROPERTY_FIELD_CHANGED));  }    Image_Builder::Notify(const GUI_Event& event_)  {        if(Has_Focus() && event_.Name() == "property_grid" && event_.Type() == INPUT / PROPERTY_FIELD_CHANGED)        {            GUI_Object_Builder::Handle_Field_Change(event_.Data());                        Handle_Field_Change(event_);        }  }    Image_Builder::Handle_Field_Change(const std::string& data)  {        std::string field = Get_Field(data);        std::string value = Get_Value(data);                if(field == "size")        {            image->Set_Size(from_string<PointI>(data));        }        else if(field == "position")        {            image->Set_Position(from_string<PointI>(data));        }        // etc.  }


Is there a nicer way to do this? It's gonna involve a lot of work, but I'm guessing any alternative will...

Cheers.

Advertisement
Look into immediate mode GUIs.
Quote:Original post by zyrolasting
Look into immediate mode GUIs.

I'm very slowly downloading that video (still capped apparently)... but I'm not making any changes to my existing GUI objects - I'm happy with how they work for now. I'd just like to know the best way to allow the objects to be displayed on a canvas and edited. I'll have a property grid that will send events to the wrapper objects notifying them of field changes. I'd like to know if the idea I've put forth is good or if it can be improved.

Cheers.

This topic is closed to new replies.

Advertisement