QuickGUI Combobox

Teknoman117

12-06-2010 07:02:30

I am trying to set up comboboxes in quickgui to display the settings and their alternatives in my application. I can't figure out how to use them and I can't find anything around. I have declared it and filled it with data.

mSettingResolution = mSettingsMenu->createComboBox(QuickGUI::Rect(150.0f, 50.0f, 280.0f, 25.0f));
mSettingFrequency = mSettingsMenu->createComboBox(QuickGUI::Rect(150.0f, 80.0f, 280.0f, 25.0f));
mSettingFS = mSettingsMenu->createComboBox(QuickGUI::Rect(150.0f, 110.0f, 280.0f, 25.0f));
mSettingAA = mSettingsMenu->createComboBox(QuickGUI::Rect(150.0f, 140.0f, 280.0f, 25.0f));
Ogre::StringVector vals = voptions["Video Mode"].possibleValues;
int x = 0;
for(int i=0;i<vals.size();i++) {
Ogre::String str = vals[i];
mSettingResolution->createTextItem(vals[i],i);
if(str==voptions["Video Mode"].currentValue) x = i;
}
mSettingResolution->selectItem(x);


When it renders, the list appears behind the window it is in and I can't click on any of the options that extend out from behind the window. Anyone know what I am missing. I am assuming it is certain function calls but I really don't know.

kungfoomasta

14-06-2010 02:35:42

The drop down list appears behind the window it is on? Hm, is the drop down on a Modal window? Because those are always drawn last and appear above anything else. How do you create mSettingsMenu?

Teknoman117

14-06-2010 02:57:23

Yes mSettingsMenu window is a Modal Window. Here is more complete code.

The .h file for UIController

#ifndef UICONTROLLER_H
#define UICONTROLLER_H

#include "World.h"
#include "Teknogin.h"

namespace Teknogin {

class UIController
{
public:
QuickGUI::GUIManager *mGUIManager;
QuickGUI::Sheet *mSheet;
QuickGUI::MouseCursor *mMouseCursor;
Teknogin::World *mWorld;
bool fpsEnabled;
bool noQuit;
private:
Ogre::RenderWindow *mRenderWindow;
Ogre::SceneManager *mSceneMgr;
Ogre::Camera *mCamera;
Ogre::Root *mRoot;
Ogre::NameValuePairList *mSettings;
/* Main Menu */
QuickGUI::ContextMenu *mMainMenu;
QuickGUI::MenuTextItem *mLoadButton;
QuickGUI::MenuTextItem *mSettingsButton;
QuickGUI::MenuTextItem *mQuitButton;
/* Load Menu */
QuickGUI::ModalWindow *mLoadMenu;
QuickGUI::TextBox *mLoadMenuFileName;
/* Settings Menu */
QuickGUI::ModalWindow *mSettingsMenu;
QuickGUI::ComboBox *mSettingResolution;
QuickGUI::ComboBox *mSettingFrequency;
QuickGUI::ComboBox *mSettingFS;
QuickGUI::ComboBox *mSettingAA;
/* Pause Menu */
QuickGUI::ContextMenu *mPauseMenu;
public:
UIController( Ogre::Root *root, Ogre::SceneManager *sceneMgr, Ogre::Camera *cam, Ogre::RenderWindow *win, Ogre::NameValuePairList *teknoginSettings, Ogre::ConfigOptionMap voptions );
virtual ~UIController();
void hideMainMenu();
void showMainMenu();
void hidePauseMenu();
void showPauseMenu();
void onLoadButton(const QuickGUI::EventArgs& args) {
mLoadMenu->setVisible(true);
}
void onSettingsButton(const QuickGUI::EventArgs& args) {
mSettingsMenu->setVisible(true);
}
void onQuitButton(const QuickGUI::EventArgs& args) {
noQuit = false;
}
void onLoadMenuLoadPressed(const QuickGUI::EventArgs& args) {
if(mLoadMenuFileName->getText() != "") {
if(mWorld) delete mWorld;
mWorld = new Teknogin::World((*mSettings)["TeknoginRoot"] + "/maps/" + mLoadMenuFileName->getText(), mRoot, mSceneMgr, mRenderWindow);
hideMainMenu();
}
else onLoadMenuCancelPressed(args);
}
void onLoadMenuCancelPressed(const QuickGUI::EventArgs& args) {
mLoadMenu->setVisible(false);
mMainMenu->setVisible(true);
}
void onKeyDownInTextBox(const QuickGUI::EventArgs& args) {
const QuickGUI::KeyEventArgs& kea = dynamic_cast<const QuickGUI::KeyEventArgs&>(args);
if(kea.scancode == QuickGUI::KC_RETURN) onLoadMenuLoadPressed(args);
}
void onSettingsMenuAcceptPressed(const QuickGUI::EventArgs& args) {
mSettingsMenu->setVisible(false);
mMainMenu->setVisible(true);
}
void onSettingsMenuCancelPressed(const QuickGUI::EventArgs& args) {
mSettingsMenu->setVisible(false);
mMainMenu->setVisible(true);
}
bool mainMenuVisible() {
return (mMainMenu->getVisible() || mSettingsMenu->getVisible() || mLoadMenu->getVisible());
}
};

}

#endif // UICONTROLLER_H


And here is the .cpp file for UIController

#include "UIController.h"

namespace Teknogin {

UIController::UIController( Ogre::Root *root, Ogre::SceneManager *sceneMgr, Ogre::Camera *cam, Ogre::RenderWindow *win, Ogre::NameValuePairList *teknoginSettings, Ogre::ConfigOptionMap voptions ) {
noQuit = true;
mSceneMgr = sceneMgr;
mCamera = cam;
mSettings = teknoginSettings;
mRenderWindow = win;
mWorld = NULL;
fpsEnabled = true;
/* Start up QuickGUI */
new QuickGUI::Root();
QuickGUI::SkinTypeManager::getSingleton().loadTypes();
QuickGUI::GUIManagerDesc d;
d.sceneManager = mSceneMgr;
d.viewport = mCamera->getViewport();
d.queueID = Ogre::RENDER_QUEUE_OVERLAY;
mGUIManager = QuickGUI::Root::getSingletonPtr()->createGUIManager(d);
QuickGUI::SheetDesc* sd = QuickGUI::DescManager::getSingletonPtr()->getDefaultSheetDesc();
float width = mCamera->getViewport()->getActualWidth();
float height = mCamera->getViewport()->getActualHeight();
sd->resetToDefault();
sd->widget_name = "Teknogin.MainSheet";
sd->widget_dimensions.size = QuickGUI::Size(width,height);
mSheet = QuickGUI::SheetManager::getSingleton().createSheet(sd);
mGUIManager->setActiveSheet(mSheet);
mMouseCursor = mGUIManager->getMouseCursor();
/* Main Menu */
mMainMenu = mSheet->createContextMenu("Teknogin Main Menu",QuickGUI::Size(width/4,height/2));
mMainMenu->setPosition(QuickGUI::Point(width*0.375f,0));
mMainMenu->setTitleBarDragable(false);
mMainMenu->setVisible(false);
mLoadButton = mMainMenu->createTextItem("Load Teknogin Map");
mLoadButton->setVisible(true);
mLoadButton->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_DOWN,&UIController::onLoadButton,this);
mSettingsButton = mMainMenu->createTextItem("Configure Teknogin Graphics");
mSettingsButton->setVisible(true);
mSettingsButton->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_DOWN,&UIController::onSettingsButton,this);
mQuitButton = mMainMenu->createTextItem("Exit Teknogin");
mQuitButton->setVisible(true);
mQuitButton->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_DOWN,&UIController::onQuitButton,this);
/* Settings Menu */
QuickGUI::ModalWindowDesc* mwd = QuickGUI::DescManager::getSingletonPtr()->getDefaultModalWindowDesc();
mwd->resetToDefault();
mwd->window_titleBarCloseButton = false;
mwd->window_titleBarDragable = false;
mwd->textDesc.horizontalTextAlignment = QuickGUI::TEXT_ALIGNMENT_HORIZONTAL_CENTER;
mwd->textDesc.segments.push_back(QuickGUI::TextSegment("Configure Teknogin"));
mwd->widget_visible = false;
mwd->widget_resizeFromBottom = false;
mwd->widget_resizeFromLeft = false;
mwd->widget_resizeFromRight = false;
mwd->widget_resizeFromTop = false;
mwd->widget_dimensions.size = QuickGUI::Size(450,450);
mwd->widget_relativeOpacity = 0.8;
mSettingsMenu = mSheet->createModalWindow(mwd);
QuickGUI::Rect r = mSettingsMenu->getClientDimensions();
float buttonWidth = r.size.width / 3.0;
float buttonHeight = 30;
float buttonYPos = r.size.height - (buttonHeight * 2);
QuickGUI::Button* acceptButton = mSettingsMenu->createButton("Accept",QuickGUI::Rect(buttonWidth / 3.0,buttonYPos,buttonWidth,buttonHeight));
acceptButton->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&UIController::onSettingsMenuAcceptPressed,this);
QuickGUI::Button* cancelButton = mSettingsMenu->createButton("Cancel",QuickGUI::Rect((buttonWidth * 2.0) - (buttonWidth / 3.0),buttonYPos,buttonWidth,buttonHeight));
cancelButton->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&UIController::onSettingsMenuCancelPressed,this);
mSettingResolution = mSettingsMenu->createComboBox(QuickGUI::Rect(150.0f, 50.0f, 280.0f, 25.0f));
mSettingFrequency = mSettingsMenu->createComboBox(QuickGUI::Rect(150.0f, 80.0f, 280.0f, 25.0f));
mSettingFS = mSettingsMenu->createComboBox(QuickGUI::Rect(150.0f, 110.0f, 280.0f, 25.0f));
mSettingAA = mSettingsMenu->createComboBox(QuickGUI::Rect(150.0f, 140.0f, 280.0f, 25.0f));
Ogre::StringVector vals = voptions["Video Mode"].possibleValues;
int x = 0;
for(int i=0;i<vals.size();i++) {
Ogre::String str = vals[i];
mSettingResolution->createTextItem(vals[i],i);
if(str==voptions["Video Mode"].currentValue) x = i;
}
mSettingResolution->selectItem(x);
//mSettingResolution->
mwd = QuickGUI::DescManager::getSingletonPtr()->getDefaultModalWindowDesc();
mwd->resetToDefault();
mwd->window_titleBarCloseButton = false;
mwd->window_titleBarDragable = false;
mwd->textDesc.horizontalTextAlignment = QuickGUI::TEXT_ALIGNMENT_HORIZONTAL_CENTER;
mwd->textDesc.segments.push_back(QuickGUI::TextSegment("Load Teknogin Map"));
mwd->widget_visible = false;
mwd->widget_resizeFromBottom = false;
mwd->widget_resizeFromLeft = false;
mwd->widget_resizeFromRight = false;
mwd->widget_resizeFromTop = false;
mwd->widget_dimensions.size = QuickGUI::Size(300,200);
mwd->widget_relativeOpacity = 0.8;
mLoadMenu = mSheet->createModalWindow(mwd);
mLoadMenu->setPosition(QuickGUI::Point(width*0.333f,height*0.333f));
r = mLoadMenu->getClientDimensions();
buttonWidth = r.size.width / 3.0;
buttonHeight = 30;
buttonYPos = r.size.height - (buttonHeight * 2);
QuickGUI::Button* loadButton = mLoadMenu->createButton("Load",QuickGUI::Rect(buttonWidth / 3.0,buttonYPos,buttonWidth,buttonHeight));
loadButton->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&UIController::onLoadMenuLoadPressed,this);
cancelButton = mLoadMenu->createButton("Cancel",QuickGUI::Rect((buttonWidth * 2.0) - (buttonWidth / 3.0),buttonYPos,buttonWidth,buttonHeight));
cancelButton->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_MOUSE_BUTTON_UP,&UIController::onLoadMenuCancelPressed,this);
float labelXPos = 25;
float labelYPos = 25;
QuickGUI::Label* labelTB = mLoadMenu->createLabel("File Name:",QuickGUI::Point(labelXPos,labelYPos));
float textBoxHeight = 25;
float textBoxWidth = r.size.width - (labelTB->getPosition().x + labelTB->getWidth()) - 50;
float textBoxXPos = (labelTB->getPosition().x + labelTB->getWidth()) + 25;
mLoadMenuFileName = mLoadMenu->createTextBox(QuickGUI::Rect(textBoxXPos,labelYPos - ((textBoxHeight - labelTB->getHeight()) / 2.0),textBoxWidth,25));
mLoadMenuFileName->addWidgetEventHandler(QuickGUI::WIDGET_EVENT_KEY_DOWN,&UIController::onKeyDownInTextBox,this);

}

UIController::~UIController() {

}

void UIController::showMainMenu() {
mSheet->setVisible(true);
mMouseCursor->setVisible(true);
mMainMenu->setVisible(true);
}

void UIController::hideMainMenu() {
mSheet->setVisible(false);
mMouseCursor->setVisible(false);
mMainMenu->setVisible(false);
mLoadMenu->setVisible(false);
mSettingsMenu->setVisible(false);
}

}


Is there any way to have the combo boxes drawn last? Some setting perhaps? Or is there a better way to create a dialog sort of thing to configure settings
Teknoman

kungfoomasta

14-06-2010 06:23:16

I'm betting this is a bug in QuickGUI, since Drop Down Lists and Menu's are really Windows, yet ModalWindows are always drawn after Windows, so they're always on top. A temporary solution be to use a regular Window instead of a ModalWindow. I'm currently writing the next version of QuickGUI, so I won't be able to provide a fix for this in the near future, however I'll make sure this problem doesn't happen in the next version. :)