Start re-organizing demos so the physics setup can be shared easier (explicit create graphics objects, init/exit physics etc)
Add B3G_RETURN key code, only implemented in Windows so far (todo: Mac, Linux) Fix Windows key management (use WM_CHAR event instead of WM_KEYUP Add Return (OnKeyReturn) key support TreeNode, so we can select an item using the return key.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "Gwen/Controls/ListBox.h"
|
||||
#include "Gwen/Skins/Simple.h"
|
||||
//#include "Gwen/Skins/TexturedBase.h"
|
||||
#include "gwenUserInterface.h"
|
||||
|
||||
|
||||
struct GwenInternalData
|
||||
@@ -36,12 +37,14 @@ struct GwenInternalData
|
||||
Gwen::Controls::Canvas* pCanvas;
|
||||
GLPrimitiveRenderer* m_primRenderer;
|
||||
Gwen::Controls::TabButton* m_demoPage;
|
||||
Gwen::Controls::TabButton* m_explorerPage;
|
||||
Gwen::Controls::TreeControl* m_explorerTreeCtrl;
|
||||
|
||||
int m_curYposition;
|
||||
|
||||
Gwen::Controls::Label* m_rightStatusBar;
|
||||
Gwen::Controls::Label* m_leftStatusBar;
|
||||
|
||||
b3AlignedObjectArray<struct Gwen::Event::Handler*> m_handlers;
|
||||
b3AlignedObjectArray<class Gwen::Event::Handler*> m_handlers;
|
||||
b3ToggleButtonCallback m_toggleButtonCallback;
|
||||
b3ComboBoxCallback m_comboBoxCallback;
|
||||
|
||||
|
||||
@@ -151,29 +151,22 @@ void GwenUserInterface::init(int width, int height,struct sth_stash* stash,float
|
||||
//m_data->m_leftStatusBar->SetText( L"Label Added to Left" );
|
||||
m_data->m_leftStatusBar->SetWidth(width/2);
|
||||
bar->AddControl( m_data->m_leftStatusBar,false);
|
||||
|
||||
//Gwen::KeyboardFocus
|
||||
/*Gwen::Controls::GroupBox* box = new Gwen::Controls::GroupBox(m_data->pCanvas);
|
||||
box->SetText("text");
|
||||
box->SetName("name");
|
||||
box->SetHeight(500);
|
||||
*/
|
||||
Gwen::Controls::ScrollControl* windowLeft= new Gwen::Controls::ScrollControl(m_data->pCanvas);
|
||||
windowLeft->Dock(Gwen::Pos::Right);
|
||||
windowLeft->SetWidth(150);
|
||||
windowLeft->SetHeight(250);
|
||||
windowLeft->SetScroll(false,true);
|
||||
Gwen::Controls::ScrollControl* windowRight= new Gwen::Controls::ScrollControl(m_data->pCanvas);
|
||||
windowRight->Dock(Gwen::Pos::Right);
|
||||
windowRight->SetWidth(150);
|
||||
windowRight->SetHeight(250);
|
||||
windowRight->SetScroll(false,true);
|
||||
|
||||
|
||||
/*Gwen::Controls::WindowControl* windowLeft = new Gwen::Controls::WindowControl(m_data->pCanvas);
|
||||
windowLeft->Dock(Gwen::Pos::Left);
|
||||
windowLeft->SetTitle("title");
|
||||
windowLeft->SetWidth(150);
|
||||
windowLeft->SetClosable(false);
|
||||
windowLeft->SetShouldDrawBackground(true);
|
||||
windowLeft->SetTabable(true);
|
||||
*/
|
||||
|
||||
//windowLeft->SetSkin(
|
||||
Gwen::Controls::TabControl* tab = new Gwen::Controls::TabControl(windowLeft);
|
||||
Gwen::Controls::TabControl* tab = new Gwen::Controls::TabControl(windowRight);
|
||||
|
||||
//tab->SetHeight(300);
|
||||
tab->SetWidth(140);
|
||||
@@ -217,6 +210,39 @@ void GwenUserInterface::init(int width, int height,struct sth_stash* stash,float
|
||||
|
||||
|
||||
*/
|
||||
|
||||
Gwen::Controls::ScrollControl* windowLeft = new Gwen::Controls::ScrollControl(m_data->pCanvas);
|
||||
windowLeft->Dock(Gwen::Pos::Left);
|
||||
// windowLeft->SetTitle("title");
|
||||
windowLeft->SetScroll(false, false);
|
||||
windowLeft->SetWidth(250);
|
||||
windowLeft->SetPos(50, 50);
|
||||
windowLeft->SetHeight(500);
|
||||
//windowLeft->SetClosable(false);
|
||||
// windowLeft->SetShouldDrawBackground(true);
|
||||
windowLeft->SetTabable(true);
|
||||
|
||||
Gwen::Controls::TabControl* explorerTab = new Gwen::Controls::TabControl(windowLeft);
|
||||
|
||||
//tab->SetHeight(300);
|
||||
// explorerTab->SetWidth(230);
|
||||
explorerTab->SetHeight(250);
|
||||
//tab->Dock(Gwen::Pos::Left);
|
||||
explorerTab->Dock(Gwen::Pos::Fill);
|
||||
|
||||
Gwen::UnicodeString explorerStr1(L"Explorer");
|
||||
m_data->m_explorerPage = explorerTab->AddPage(explorerStr1);
|
||||
Gwen::UnicodeString shapesStr1(L"Shapes");
|
||||
explorerTab->AddPage(shapesStr1);
|
||||
Gwen::UnicodeString testStr1(L"Test");
|
||||
explorerTab->AddPage(testStr1);
|
||||
|
||||
Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl(m_data->m_explorerPage->GetPage());
|
||||
m_data->m_explorerTreeCtrl = ctrl;
|
||||
ctrl->SetKeyboardInputEnabled(true);
|
||||
ctrl->Focus();
|
||||
ctrl->SetBounds(2, 10, 236, 400);
|
||||
|
||||
}
|
||||
|
||||
b3ToggleButtonCallback GwenUserInterface::getToggleButtonCallback()
|
||||
@@ -318,6 +344,47 @@ bool GwenUserInterface::mouseMoveCallback( float x, float y)
|
||||
return handled;
|
||||
|
||||
}
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
|
||||
bool GwenUserInterface::keyboardCallback(int bulletKey, int state)
|
||||
{
|
||||
int key = -1;
|
||||
if (m_data->pCanvas)
|
||||
{
|
||||
//convert 'Bullet' keys into 'Gwen' keys
|
||||
switch (bulletKey)
|
||||
{
|
||||
case B3G_RETURN:
|
||||
{
|
||||
key = Gwen::Key::Return;
|
||||
break;
|
||||
}
|
||||
case B3G_LEFT_ARROW:
|
||||
key = Gwen::Key::Left;
|
||||
break;
|
||||
case B3G_RIGHT_ARROW:
|
||||
key = Gwen::Key::Right;
|
||||
break;
|
||||
|
||||
case B3G_UP_ARROW:
|
||||
key = Gwen::Key::Up;
|
||||
break;
|
||||
case B3G_DOWN_ARROW:
|
||||
key = Gwen::Key::Down;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
bool bDown = (state == 1);
|
||||
|
||||
return m_data->pCanvas->InputKey(key, bDown);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool GwenUserInterface::mouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
bool handled = false;
|
||||
@@ -327,7 +394,7 @@ bool GwenUserInterface::mouseButtonCallback(int button, int state, float x, floa
|
||||
|
||||
if (button>=0)
|
||||
{
|
||||
handled = m_data->pCanvas->InputMouseButton(button,state);
|
||||
handled = m_data->pCanvas->InputMouseButton(button,(bool)state);
|
||||
if (handled)
|
||||
{
|
||||
//if (!state)
|
||||
|
||||
@@ -6,6 +6,8 @@ struct GwenInternalData;
|
||||
typedef void (*b3ComboBoxCallback) (int combobox, const char* item);
|
||||
typedef void (*b3ToggleButtonCallback)(int button, int state);
|
||||
|
||||
|
||||
|
||||
class GwenUserInterface
|
||||
{
|
||||
GwenInternalData* m_data;
|
||||
@@ -24,6 +26,8 @@ class GwenUserInterface
|
||||
|
||||
bool mouseMoveCallback( float x, float y);
|
||||
bool mouseButtonCallback(int button, int state, float x, float y);
|
||||
bool keyboardCallback(int key, int state);
|
||||
|
||||
|
||||
void setToggleButtonCallback(b3ToggleButtonCallback callback);
|
||||
b3ToggleButtonCallback getToggleButtonCallback();
|
||||
@@ -33,7 +37,7 @@ class GwenUserInterface
|
||||
void setComboBoxCallback(b3ComboBoxCallback callback);
|
||||
b3ComboBoxCallback getComboBoxCallback();
|
||||
void registerComboBox(int buttonId, int numItems, const char** items, int startItem = 0);
|
||||
|
||||
|
||||
void setStatusBarMessage(const char* message, bool isLeft=true);
|
||||
|
||||
GwenInternalData* getInternalData()
|
||||
|
||||
Reference in New Issue
Block a user