• Advertisement
Sign in to follow this  

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

This topic is 2652 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement