Ejemplo n.º 1
0
    void PropertyGridManager::updateRangeControlValue(MyGUI::Widget *const control, PropertyGridProperty *const property)
    {
        MyGUI::ScrollBar *scrollBar = (MyGUI::ScrollBar *)control->findWidget("ScrollBar");

        if(nullptr == scrollBar)
        {
            Debug::error(STEEL_METH_INTRO, "could not find scrollBar in Range propertyControl. Control: ", control, " property: ", *property, ". Aborting.").endl();
            return;
        }

        PropertyGridProperty::Range *range = new PropertyGridProperty::Range();
        property->read(*range);
        auto it = mRanges.insert( {property->id(), range});

        if(!it.second) // true iff already there
        {
            STEEL_DELETE(it.first->second);
            it.first->second = range;
        }

        // min label
        {
            MyGUI::TextBox *label = (MyGUI::TextBox *)control->findWidget("minLabel");

            if(nullptr != label)
                label->setCaption(Ogre::StringConverter::toString(range->min));
        }

        // max label
        {
            MyGUI::TextBox *label = (MyGUI::TextBox *)control->findWidget("maxLabel");

            if(nullptr != label)
                label->setCaption(Ogre::StringConverter::toString(range->max));
        }

        // value label
        {
            MyGUI::TextBox *label = (MyGUI::TextBox *)control->findWidget("valueLabel");

            if(nullptr != label)
                label->setCaption(Ogre::StringConverter::toString(range->value, 6));
        }

        decltype(range->value) percent = (range->value - range->min) / (range->max - range->min) * ((decltype(range->value))99.f); // within [0, 99]
        scrollBar->setScrollPosition((size_t)percent);

    }
Ejemplo n.º 2
0
    void SettingsWindow::configureWidgets(MyGUI::Widget* widget)
    {
        MyGUI::EnumeratorWidgetPtr widgets = widget->getEnumerator();
        while (widgets.next())
        {
            MyGUI::Widget* current = widgets.current();

            std::string type = getSettingType(current);
            if (type == checkButtonType)
            {
                std::string initialValue = Settings::Manager::getBool(getSettingName(current),
                                                                      getSettingCategory(current))
                        ? "#{sOn}" : "#{sOff}";
                current->castType<MyGUI::Button>()->setCaptionWithReplacing(initialValue);
                current->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
            }
            if (type == sliderType)
            {
                MyGUI::ScrollBar* scroll = current->castType<MyGUI::ScrollBar>();
                std::string valueStr;
                if (getSettingValueType(current) == "Float")
                {
                    // TODO: ScrollBar isn't meant for this. should probably use a dedicated FloatSlider widget
                    float min,max;
                    getSettingMinMax(scroll, min, max);
                    float value = Settings::Manager::getFloat(getSettingName(current), getSettingCategory(current));
                    valueStr = MyGUI::utility::toString((int)value);
                    value = std::max(min, std::min(value, max));
                    value = (value-min)/(max-min);

                    scroll->setScrollPosition(static_cast<size_t>(value * (scroll->getScrollRange() - 1)));
                }
                else
                {
                    int value = Settings::Manager::getInt(getSettingName(current), getSettingCategory(current));
                    valueStr = MyGUI::utility::toString(value);
                    scroll->setScrollPosition(value);
                }
                scroll->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
                updateSliderLabel(scroll, valueStr);
            }

            configureWidgets(current);
        }
    }
Ejemplo n.º 3
0
/////////////////// <RANGE CONTROL>
    void PropertyGridManager::buildRangeControl(MyGUI::Widget *const control, PropertyGridProperty *const property)
    {
        int left = insertPropertyIdLabel(control, property) ;

        // scrollbar in between
        int width = control->getWidth() - left - WIDGET_SPACING * 2;
        MyGUI::IntCoord coord(left + WIDGET_SPACING, 1, width, control->getHeight() - 2);
        MyGUI::ScrollBar *scrollBar = (MyGUI::ScrollBar *)control->createWidget<MyGUI::ScrollBar>("SliderH", coord, MyGUI::Align::Left | MyGUI::Align::Top, "ScrollBar");
        scrollBar->setEnabled(!property->isReadOnly());
        MyGUIUtils::expandWidgetCoord(control, 0, 0, 0, 2);

        scrollBar->setScrollRange(100);
        scrollBar->setUserData(property);
        static_cast<MyGUI::ScrollBar *>(scrollBar)->eventScrollChangePosition += MyGUI::newDelegate(this, &PropertyGridManager::onMyGUIScrollChangePosition);


        MyGUI::TextBox *labelPtr;

        // label for min value
        left = insertLabel(control, "minLabel", "0.000", scrollBar->getLeft() + WIDGET_SPACING, labelPtr);
        labelPtr->setAlign(MyGUI::Align::Left | MyGUI::Align::VCenter);
        labelPtr->setNeedMouseFocus(false);
        labelPtr->setTextAlign(MyGUI::Align::Left);
        labelPtr->setTextColour(MyGUI::Colour::Black);

        // label for max value
        insertLabel(control, "maxLabel", "0.000", scrollBar->getRight() - labelPtr->getWidth() - WIDGET_SPACING, labelPtr); // built right after the minLabel
        labelPtr->setAlign(MyGUI::Align::Right | MyGUI::Align::VCenter);
        labelPtr->setNeedMouseFocus(false);
        labelPtr->setTextAlign(MyGUI::Align::Right);
        labelPtr->setTextColour(MyGUI::Colour::Black);

        // label for value
        insertLabel(control, "valueLabel", "0.000", (scrollBar->getLeft() + scrollBar->getRight()) / 2, labelPtr); // built right after the minLabel
        labelPtr->setAlign(MyGUI::Align::Center);
        labelPtr->setNeedMouseFocus(false);
        labelPtr->setTextAlign(MyGUI::Align::Center);
        labelPtr->setTextColour(MyGUI::Colour::Black);
    }
Ejemplo n.º 4
0
	void DemoKeeper::notifyEventAction(MainPanel::TypeEvents _action, size_t _index)
	{
		if (_action == MainPanel::EventQuit)
		{
			quit();
		}
		else if (_action == MainPanel::EventNew)
		{
			removeRenderBoxes();
			destroyWindows();
			mEditorWindow->clearView();
		}
		else if (_action == MainPanel::EventLoad)
		{
			createWindows();
		}
		else if (_action == MainPanel::EventCreate)
		{
			MyGUI::Widget* view = mEditorWindow->getView();
			const MyGUI::IntCoord& coord = view->getClientCoord();

			if (_index == 0)
			{
				const MyGUI::IntSize size(80, 80);
				MyGUI::Window* window = view->createWidget<MyGUI::Window>(MyGUI::WidgetStyle::Overlapped, "WindowCS", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				window->setCaption("Frame");
				window->setMinSize(size);
			}
			else if (_index == 1)
			{
				const MyGUI::IntSize size(180, 15);
				MyGUI::ScrollBar* scroll = view->createWidget<MyGUI::ScrollBar>("ScrollBarH", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				scroll->setScrollRange(200);
				scroll->setScrollPosition(10);
				scroll->setScrollPage(1);
				scroll->setScrollViewPage(20);
			}
			else if (_index == 2)
			{
				const MyGUI::IntSize size(15, 180);
				MyGUI::ScrollBar* scroll = view->createWidget<MyGUI::ScrollBar>("ScrollBarV", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				scroll->setScrollRange(200);
				scroll->setScrollPosition(10);
				scroll->setScrollPage(1);
				scroll->setScrollViewPage(20);
			}
			else if (_index == 3)
			{
				const MyGUI::IntSize size(80, 26);
				MyGUI::TextBox* text = view->createWidget<MyGUI::TextBox>("TextBox", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				text->setCaption("TextBox");
			}
			else if (_index == 4)
			{
				const MyGUI::IntSize size(50, 50);
				MyGUI::ImageBox* image = view->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				image->setImageTexture("HelpIcon.png");
			}
			else if (_index == 5)
			{
				const MyGUI::IntSize size(150, 150);
				MyGUI::Window* window = view->createWidget<MyGUI::Window>(MyGUI::WidgetStyle::Overlapped, "WindowC", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				window->setCaption("Render");
				MyGUI::Canvas* canvas = window->createWidget<MyGUI::Canvas>("Canvas", MyGUI::IntCoord(0, 0, window->getClientCoord().width, window->getClientCoord().height), MyGUI::Align::Stretch);

				createRenderBox(canvas);
			}
		}
	}
Ejemplo n.º 5
0
	void DemoKeeper::notifyEventAction(MainPanel::TypeEvents _action, size_t _index)
	{
		static MyGUI::IVertexBuffer* vbo = nullptr;

		if (_action == MainPanel::EventQuit)
		{
			if (vbo)
				MyGUI::RenderManager::getInstance().destroyVertexBuffer(vbo);
			quit();
		}
		else if (_action == MainPanel::EventNew)
		{
			//cocos2d::extension::CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_BACKGROUND);
			//cocos2d::CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND);

			//removeRenderBoxes();
			//destroyWindows();
			//mEditorWindow->clearView();
			//MyGUI::Widget *tempWindow = mEditorWindow->getView()->findWidget("tempWindow");
			//if (tempWindow)
			//	MyGUI::Gui::getInstance().destroyWidget(tempWindow);

			if (vbo)
			{
				MyGUI::RenderManager::getInstance().destroyVertexBuffer(vbo);
				vbo = nullptr;
			}
		}
		else if (_action == MainPanel::EventLoad)
		{
			//mEditorWindow->getView()->createWidget<MyGUI::Window>(
			//	MyGUI::WidgetStyle::Overlapped, "WindowCSX",
			//	MyGUI::IntCoord(10, 10, 100, 100),
			//	MyGUI::Align::Default, "", "tempWindow");

			
			if (!vbo)
			{
				vbo = MyGUI::RenderManager::getInstance().createVertexBuffer();
			}

			for (unsigned i = 2; i < 2048; i += 4)
			{
				vbo->setVertexCount(i);
				vbo->lock();
				vbo->unlock();
			}

			//createWindows();
		}
		else if (_action == MainPanel::EventCreate)
		{
			MyGUI::Widget* view = mEditorWindow->getView();
			const MyGUI::IntCoord& coord = view->getClientCoord();

			if (_index == 0)
			{
				const MyGUI::IntSize size(80, 80);
				MyGUI::Window* window = view->createWidget<MyGUI::Window>(MyGUI::WidgetStyle::Overlapped, "WindowCS", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				window->setCaption("Frame");
				window->setMinSize(size);
			}
			else if (_index == 1)
			{
				const MyGUI::IntSize size(180, 15);
				MyGUI::ScrollBar* scroll = view->createWidget<MyGUI::ScrollBar>("ScrollBarH", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				scroll->setScrollRange(200);
				scroll->setScrollPosition(10);
				scroll->setScrollPage(1);
				scroll->setScrollViewPage(20);
			}
			else if (_index == 2)
			{
				const MyGUI::IntSize size(15, 180);
				MyGUI::ScrollBar* scroll = view->createWidget<MyGUI::ScrollBar>("ScrollBarV", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				scroll->setScrollRange(200);
				scroll->setScrollPosition(10);
				scroll->setScrollPage(1);
				scroll->setScrollViewPage(20);
			}
			else if (_index == 3)
			{
				const MyGUI::IntSize size(80, 26);
				MyGUI::TextBox* text = view->createWidget<MyGUI::TextBox>("TextBox", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				text->setCaption("TextBox");
			}
			else if (_index == 4)
			{
				const MyGUI::IntSize size(50, 50);
				MyGUI::ImageBox* image = view->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				image->setImageTexture("HelpIcon.png");
			}
			else if (_index == 5)
			{
				const MyGUI::IntSize size(480, 320);
				MyGUI::Window* window = view->createWidget<MyGUI::Window>(MyGUI::WidgetStyle::Overlapped, "WindowCSX", MyGUI::IntCoord(getRand(0, coord.width - size.width), getRand(0, coord.height - size.height), size.width, size.height), MyGUI::Align::Default);
				window->setCaption("Render");
				MyGUI::Canvas* canvas = window->createWidget<MyGUI::Canvas>("Canvas", MyGUI::IntCoord(0, 0, window->getClientCoord().width, window->getClientCoord().height), MyGUI::Align::Stretch);

				createRenderBox(canvas);
			}
		}
	}
Ejemplo n.º 6
0
    SettingsWindow::SettingsWindow() :
        WindowBase("openmw_settings_window.layout"),
        mKeyboardMode(true)
    {
        configureWidgets(mMainWidget);

        setTitle("#{sOptions}");

        getWidget(mSettingsTab, "SettingsTab");
        getWidget(mOkButton, "OkButton");
        getWidget(mResolutionList, "ResolutionList");
        getWidget(mFullscreenButton, "FullscreenButton");
        getWidget(mWindowBorderButton, "WindowBorderButton");
        getWidget(mTextureFilteringButton, "TextureFilteringButton");
        getWidget(mAnisotropyBox, "AnisotropyBox");
        getWidget(mControlsBox, "ControlsBox");
        getWidget(mResetControlsButton, "ResetControlsButton");
        getWidget(mKeyboardSwitch, "KeyboardButton");
        getWidget(mControllerSwitch, "ControllerButton");
        getWidget(mWaterTextureSize, "WaterTextureSize");

#ifndef WIN32
        // hide gamma controls since it currently does not work under Linux
        MyGUI::ScrollBar *gammaSlider;
        getWidget(gammaSlider, "GammaSlider");
        gammaSlider->setVisible(false);
        MyGUI::TextBox *textBox;
        getWidget(textBox, "GammaText");
        textBox->setVisible(false);
        getWidget(textBox, "GammaTextDark");
        textBox->setVisible(false);
        getWidget(textBox, "GammaTextLight");
        textBox->setVisible(false);
#endif

        mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &SettingsWindow::onWindowResize);

        mSettingsTab->eventTabChangeSelect += MyGUI::newDelegate(this, &SettingsWindow::onTabChanged);
        mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
        mTextureFilteringButton->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onTextureFilteringChanged);
        mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected);

        mWaterTextureSize->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWaterTextureSizeChanged);

        mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
        mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked);

        center();

        mResetControlsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings);

        // fill resolution list
        int screen = Settings::Manager::getInt("screen", "Video");
        int numDisplayModes = SDL_GetNumDisplayModes(screen);
        std::vector < std::pair<int, int> > resolutions;
        for (int i = 0; i < numDisplayModes; i++)
        {
            SDL_DisplayMode mode;
            SDL_GetDisplayMode(screen, i, &mode);
            resolutions.push_back(std::make_pair(mode.w, mode.h));
        }
        std::sort(resolutions.begin(), resolutions.end(), sortResolutions);
        for (std::vector < std::pair<int, int> >::const_iterator it=resolutions.begin();
             it!=resolutions.end(); ++it)
        {
            std::string str = MyGUI::utility::toString(it->first) + " x " + MyGUI::utility::toString(it->second)
                    + " (" + getAspect(it->first,it->second) + ")";

            if (mResolutionList->findItemIndexWith(str) == MyGUI::ITEM_NONE)
                mResolutionList->addItem(str);
        }
        highlightCurrentResolution();

        std::string tmip = Settings::Manager::getString("texture mipmap", "General");
        mTextureFilteringButton->setCaption(textureMipmappingToStr(tmip));

        int waterTextureSize = Settings::Manager::getInt ("rtt size", "Water");
        if (waterTextureSize >= 512)
            mWaterTextureSize->setIndexSelected(0);
        if (waterTextureSize >= 1024)
            mWaterTextureSize->setIndexSelected(1);
        if (waterTextureSize >= 2048)
            mWaterTextureSize->setIndexSelected(2);

        mWindowBorderButton->setEnabled(!Settings::Manager::getBool("fullscreen", "Video"));

        mKeyboardSwitch->setStateSelected(true);
        mControllerSwitch->setStateSelected(false);
    }