Jump to content
  • entries
    740
  • comments
    957
  • views
    732042

Teh Gooey!!

Sign in to follow this  
Gaiiden

244 views

Thursday, October 21st
So I tweaked my log data load code a bit more today. Nothing serious, I just noticed a few things that needed some cleaning up. My big project today was laying the groundwork for Katana's GUI system. I've never done a GUI before, but the general concepts are easy enough. I already have my objects:

  • Static Text

  • Input Text

  • Selectable Text

  • Button

  • Image

  • Sprite


And by using them, I shall create:

  • Scroll Bar

  • List Box

  • Dropdown List

  • Radio Buttons

  • Check Box

  • Input Textbox


Of course, these are all based off a CWidget class (of course) with all the common widget properties.

In addition, the UI manager will be able to display dialog boxes that can:

  • Display any sized message, and sizes to fit the message

  • Display OK and/or Cancel buttons

  • Skinnable

  • Modal, which means it can take focus away from the rest of the UI until it's closed

  • Static, which means there are no buttons (automatically modal)

  • Timeout, which lets you display a static message box for a certain amount of seconds


The way the UI will work is a widget will be composed of objects. The object callbacks will route to the widget, and the widget will have its own callback that programs can use.

So let's take a Scroll Bar, for example. It'll be made up of Button and Image objects. When a user clicks on a scroll button, the callback is routed to the Scroll Bar. The Scroll Bar then updates itself, and calls the user function, passing along its new value. A simple interface. The Button and Image objects render themselves, all the Scroll Bar object has to do is update their positions on screen to make them act like a scroll bar.

So like I said, I have the groundwork laid out and compiled. I got my base widget header, my scrollbar header, and my UI manager header, plus associated files (enums, structs, etc). Sat I'll actually start implementing stuff, and hopefully I'll be able to test the GUI with a scrollbar scrolling some text by the end of the day. Prob won't be until Sun tho, since I have a busy weekend. But that's my goal.
Sign in to follow this  


4 Comments


Recommended Comments

After doing this a number of times, I have found it best to have a nice base class for controls. In particular, I have the IControl class:


typedef void (*controlid_t)();

class IControl : public IEventHandler
{
private:
IControl();
IControl(const IControl&);

CRegion m_Region;
controlid_t m_ControlID;
CPoint m_ptPosition;
CSurface* m_pSurface;
bool m_bVisible;
bool m_bEnabled;

protected:

IControl(IMessageHandler* pmhParent,controlid_t ControlID,const CPoint& ptPosition,CSurface* pSurface,bool bEnabled=true,bool bVisible=true,const CRegion& Region=CRegion(CRectangle(0,0,0,0)));
CSurface* GetParentSurface(){if(GetParentControl()!=NULL){return(GetParentControl()->GetSurface());}else{return(CSurface::GetDisplaySurface());}}
IControl* GetParentControl();
void Update();
void Display();
CPoint GlobalToLocal(const CPoint& Point){return(Point-GetGlobalPosition());}
CPoint LocalToGlobal(const CPoint& Point){return(Point+GetGlobalPosition());}

virtual void OnUpdate()=0;
virtual bool OnHasMouseFocus(IControl* pControl){return(false);}
virtual bool OnHasMouseHover(IControl* pControl){return(false);}
virtual bool OnHasInputFocus(IControl* pControl){return(false);}
virtual bool OnRequestInputFocus(IControl* pControl){return(false);}
virtual bool OnRequestMouseFocus(IControl* pControl){return(false);}
virtual bool OnRequestMouseHover(IControl* pControl){return(false);}
virtual bool OnRequestBringToTop(IControl* pControl){return(false);}
virtual bool OnRequestClose(IControl* pControl){return(false);}
virtual bool OnCancelInputFocus(IControl* pControl){return(false);}
virtual bool OnCancelMouseFocus(IControl* pControl){return(false);}
virtual bool OnCancelMouseHover(IControl* pControl){return(false);}
virtual bool OnCancelBringToTop(IControl* pControl){return(false);}
virtual bool OnCancelClose(IControl* pControl){return(false);}

virtual bool OnCheckInputFocus(){return(false);}
virtual bool OnCheckMouseFocus(){return(false);}

virtual bool CheckInputFocus();
virtual bool CheckMouseFocus();

static void MSGID_HasMouseFocus(){}
static void MSGID_HasMouseHover(){}
static void MSGID_HasInputFocus(){}
static void MSGID_RequestInputFocus(){}
static void MSGID_RequestMouseFocus(){}
static void MSGID_RequestMouseHover(){}
static void MSGID_RequestBringToTop(){}
static void MSGID_RequestClose(){}
static void MSGID_CancelInputFocus(){}
static void MSGID_CancelMouseFocus(){}
static void MSGID_CancelMouseHover(){}
static void MSGID_CancelBringToTop(){}
static void MSGID_CancelClose(){}
static void MSGID_CheckInputFocus(){}
static void MSGID_CheckMouseFocus(){}
public:
virtual ~IControl();
controlid_t GetControlID(){return(m_ControlID);}
CSurface* GetSurface(){if(m_pSurface)return(m_pSurface);else return(CSurface::GetDisplaySurface());}
const CPoint& GetPosition(){return(m_ptPosition);}
CPoint GetGlobalPosition(){if(GetParentControl())return(GetParentControl()->GetGlobalPosition()+GetPosition());else return(GetPosition());}
bool

Share this comment


Link to comment
"source" TAN!! "source"!!! *grumbles*

Hee hee. Anyways thanks for the info. 'Fraid my architecture isn't anywhere near like yours tho.
Quote:
Original post by Evolutional
Will you be releasing your GUI system at any point?

Possibly. If so it'll come as a full package with the Katana Engine, Tanto log viewer, and any other apps I devise for Katana. But as of right now I honestly can't say

Share this comment


Link to comment
 TAN!! !!! *grumbles*


Hee hee. Anyways thanks for the info. 'Fraid my architecture isn't anywhere near like yours tho.
[quote][i]Original post by Evolutional[/i]
Will you be releasing your GUI system at any point?
[/quote]
Possibly. If so it'll come as a full package with the Katana Engine, Tanto log viewer, and any other apps I devise for Katana. But as of right now I honestly can't say

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!