• UI Programming Concept Design
    1 replies, posted
Hi I'm currently underway in designing the UI for my flash game's level editor, I'm not using Flash's built in UI components instead I'm doing it from scratch using OOP. I want to have buttons, drop down menus, panels/windows that contain text fields and buttons. At the moment I have the buttons down whenever one is created it is added to a static class's static array, and given a unique id number dependent on how many buttons have been created and added to the array so far. I figured this would be good as whenever a button is created I could apply an Event Listener looking for a MouseEvent.CLICK. Then just using the event.currentTarget.getID(), to find out what button has been pressed. I'm about to start making panels/windows so the user can enter numerical values then submit them via a button, which will also close the window. I was thinking about doing more of the same and having static classes for each input type which lists all instances of that type of object. I was wondering if anyone had better ways of programming UI, or maybe even tutorials. It's not the programming that is hindering me in my progress, but the actual design concept itself. Please help. Thanks in advance. [editline]25th April 2011[/editline] bump
Have a base class that all controls derive from, this class should handle basic things like position, size, hierarchy stuff, etc. [cpp] class BaseControl { public: BaseControl(BaseControl *parent); // Calls parent's onChildAdded(). ~BaseControl(); // Calls parent's onChildRemoved(). // Position & size stuff goes here. BaseControl *getParent(); int getChildCount(); BaseControl *getChild(int index); private: void onChildAdded(BaseControl *child); // Adds a child to the child list. void onChildRemoved(BaseControl *child); // Removes a child from the child list. BaseControl *m_parent; // Parent. BaseControl **m_children; // List of children. }; [/cpp]
Sorry, you need to Log In to post a reply to this thread.