Teh Gooey!!

posted in Gaiiden's Scroll
Published October 22, 2004
Advertisement
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.
Previous Entry Codin' Frenzy!
0 likes 4 comments

Comments

evolutional
Will you be releasing your GUI system at any point?
October 22, 2004 09:04 AM
TANSTAAFL
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
October 22, 2004 12:03 PM
Gaiiden
"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
October 23, 2004 12:09 AM
Gaiiden
 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

October 23, 2004 12:10 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement