Ejemplo n.º 1
0
	void ArrayEditor<ElementType>::SetupWidget(Model* model)
	{
		// Set dimensions
		CEGUI::UDim dimLeft = model->IsShareable() ? cegui_absdim(16) : cegui_absdim(0);

		// Setup label widget
		CEGUI::Window* labelWidget = mHeaderWidget->getChildAtIdx(0);
		labelWidget->setArea(CEGUI::URect(dimLeft, cegui_absdim(0), CEGUI::UDim(0.5f, -2), cegui_reldim(1)));
		labelWidget->setText(utf8StringToCEGUI(model->GetName()));
		labelWidget->setTooltipText(model->GetTooltip());

		// Setup buttons
		if (model->IsReadOnly())
		{
			mButtonAddElement->setEnabled(false);
			mButtonSave->setEnabled(false);
			mButtonRevert->setEnabled(false);
		}
		else
		{
			mButtonAddElement->setEnabled(true);
			mButtonSave->setEnabled(false);
			mButtonRevert->setEnabled(false);
		}
		
		// Setup is-shared checkbox
		CEGUI::Checkbox* isSharedCheckbox = static_cast<CEGUI::Checkbox*>(mHeaderWidget->getChildAtIdx(4));
		if (model->IsShareable())
		{
			isSharedCheckbox->setVisible(true);
			isSharedCheckbox->setPosition(CEGUI::UVector2(cegui_absdim(0), cegui_absdim(0)));
			isSharedCheckbox->setSelected(model->IsShared());
		}
		else
		{
			isSharedCheckbox->setVisible(false);
		}

		// Setup body widget
		mEditorWidget->getChildAtIdx(1)->setHeight(cegui_absdim(0));
		mBodyLayout->Clear();
	}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------------
    void ItemSelectorViewManager::addItemSelector(const Ogre::String& displayText)
    {
        // add a new item selector
        // determine new index for item
        assert(mScrollablePane);
        const size_t idx = mItemSelectorContainer.size();
        mItemSelectorContainer.push_back(ItemSelector());
        ItemSelector& item = mItemSelectorContainer.back();
        // create new checkbox
        CEGUI::Checkbox* checkbox = item.CheckBoxWidget = (CEGUI::Checkbox*)CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Checkbox",
                                    ( ("ItemCheckbox" + Ogre::StringConverter::toString(idx)).c_str() ));
        // set checkbox ID to selector ID
        checkbox->setID(idx);
        checkbox->setSize(CEGUI::UVector2(CEGUI::UDim(0, 140), CEGUI::UDim(0, ITEM_YSIZE)));
        checkbox->setText(displayText.c_str());
        checkbox->setProperty("HoverTextColour", CEGUI::PropertyHelper::colourToString(CEGUI::colour(1.0, 1.0, 0.0)));
        // add event handler for when checkbox state changes
        checkbox->subscribeEvent(CEGUI::Checkbox::EventCheckStateChanged, CEGUI::Event::Subscriber(&ItemSelectorViewManager::handleCheckStateChanged, this ));
        checkbox->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 12 + (ITEM_YSIZE + ITEM_YSPACING)* static_cast<float>(idx))));
        // add checkbox to the scroll pane
        mScrollablePane->addChildWindow(checkbox);
    }
Ejemplo n.º 3
0
	void ArrayEditor<ElementType>::InitWidget()
	{
		static unsigned int editorCounter = 0;
		OC_DASSERT(mEditorWidget == 0);

		CEGUI::String editorName = "Editor/EntityWindow/ValueEditors/ArrayEditor" + string(Reflection::PropertyTypes::GetStringName(Reflection::PropertyTypes::GetTypeID<ElementType>())) +  Utils::StringConverter::ToString(editorCounter++);
		
		// Create main editor widget
		mEditorWidget = gGUIMgr.CreateWindow("DefaultWindow", editorName);
		mMainLayout = new GUISystem::VerticalLayout(mEditorWidget, 0, true);
		
		// Create header widget
		mHeaderWidget = gGUIMgr.CreateWindow("DefaultWindow", editorName + "/Header");
		mHeaderWidget->setHeight(CEGUI::UDim(0, GetEditboxHeight()));
		mMainLayout->AddChildWindow(mHeaderWidget);

		// Create label widget
		CEGUI::Window* labelWidget = this->CreateLabelWidget(editorName + "/Header/Label");
		labelWidget->setArea(CEGUI::URect(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0), CEGUI::UDim(0.5f, -2), CEGUI::UDim(0, GetEditboxHeight())));
		mHeaderWidget->addChildWindow(labelWidget);

		// Create add element button
		mButtonAddElement = static_cast<CEGUI::PushButton*>(gGUIMgr.CreateWindow("Editor/ImageButton", editorName + "/Header/AddElementButton"));
		mButtonAddElement->setProperty("NormalImage", "set:EditorToolbar image:btnAddNormal");
		mButtonAddElement->setProperty("HoverImage", "set:EditorToolbar image:btnAddHover");
		mButtonAddElement->setProperty("PushedImage", "set:EditorToolbar image:btnAddPushed");
		mButtonAddElement->setProperty("DisabledImage", "set:EditorToolbar image:btnAddDisabled");
		mButtonAddElement->setWantsMultiClickEvents(false);
		mButtonAddElement->setTooltipText(TR("entity_editor_add_hint"));
		mButtonAddElement->setVisible(true);
		mButtonAddElement->setSize(CEGUI::UVector2(cegui_absdim(24), cegui_absdim(24)));
		mButtonAddElement->setPosition(CEGUI::UVector2(CEGUI::UDim(1, -80), CEGUI::UDim(0, 0)));
		mButtonAddElement->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Editor::ArrayEditor<ElementType>::OnEventButtonAddPressed, this));
		mHeaderWidget->addChildWindow(mButtonAddElement);

		// Create revert button
		mButtonRevert = static_cast<CEGUI::PushButton*>(gGUIMgr.CreateWindow("Editor/ImageButton", editorName + "/Header/RevertButton"));
		mButtonRevert->setProperty("NormalImage", "set:EditorToolbar image:btnCancelNormal");
		mButtonRevert->setProperty("HoverImage", "set:EditorToolbar image:btnCancelHover");
		mButtonRevert->setProperty("PushedImage", "set:EditorToolbar image:btnCancelPushed");
		mButtonRevert->setProperty("DisabledImage", "set:EditorToolbar image:btnCancelDisabled");
		mButtonRevert->setWantsMultiClickEvents(false);
		mButtonRevert->setTooltipText(TR("entity_editor_revert_hint"));
		mButtonRevert->setVisible(true);
		mButtonRevert->setSize(CEGUI::UVector2(cegui_absdim(24), cegui_absdim(24)));
		mButtonRevert->setPosition(CEGUI::UVector2(CEGUI::UDim(1, -52), CEGUI::UDim(0, 0)));
		mButtonRevert->setEnabled(false);
		mButtonRevert->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Editor::ArrayEditor<ElementType>::OnEventButtonRevertPressed, this));
		mHeaderWidget->addChildWindow(mButtonRevert);

		// Create save button
		mButtonSave = static_cast<CEGUI::PushButton*>(gGUIMgr.CreateWindow("Editor/ImageButton", editorName + "/Header/SaveButton"));
		mButtonSave->setProperty("NormalImage", "set:EditorToolbar image:btnSaveNormal");
		mButtonSave->setProperty("HoverImage", "set:EditorToolbar image:btnSaveHover");
		mButtonSave->setProperty("PushedImage", "set:EditorToolbar image:btnSavePushed");
		mButtonSave->setProperty("DisabledImage", "set:EditorToolbar image:btnSaveDisabled");
		mButtonSave->setWantsMultiClickEvents(false);
		mButtonSave->setTooltipText(TR("entity_editor_save_hint"));
		mButtonSave->setVisible(true);
		mButtonSave->setSize(CEGUI::UVector2(cegui_absdim(24), cegui_absdim(24)));
		mButtonSave->setPosition(CEGUI::UVector2(CEGUI::UDim(1, -24), CEGUI::UDim(0, 0)));
		mButtonSave->setEnabled(false);
		mButtonSave->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Editor::ArrayEditor<ElementType>::OnEventButtonSavePressed, this));
		mHeaderWidget->addChildWindow(mButtonSave);

		// Create is-shared checkbox
		CEGUI::Checkbox* isSharedCheckbox = CreateIsSharedCheckboxWidget(editorName + "/Header/IsSharedCheckbox");
		isSharedCheckbox->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
		isSharedCheckbox->subscribeEvent(CEGUI::Checkbox::EventCheckStateChanged, CEGUI::Event::Subscriber(&ArrayEditor::OnEventIsSharedCheckboxChanged, this));
		mHeaderWidget->addChildWindow(isSharedCheckbox);

		// Create body widget
		CEGUI::Window* bodyWidget = gGUIMgr.CreateWindow("DefaultWindow", editorName + "/Body");
		mBodyLayout = new GUISystem::VerticalLayout(bodyWidget, 0, true);
		mMainLayout->AddChildWindow(bodyWidget);
	}