当前位置: 首页>>代码示例>>C++>>正文


C++ UIElement::SetPosition方法代码示例

本文整理汇总了C++中UIElement::SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ UIElement::SetPosition方法的具体用法?C++ UIElement::SetPosition怎么用?C++ UIElement::SetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIElement的用法示例。


在下文中一共展示了UIElement::SetPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Object

	InGameEditor::InGameEditor(Context* context) : Object(context),
		mainEditorPlugin_(NULL)
	{
		editorData_ = new EditorSelection(context_);

		/// ResourcePickerManager is needed for the Attribute Inspector, so don't forget to init it
		context_->RegisterSubsystem(new ResourcePickerManager(context_));
		ResourcePickerManager* resPickerMng = GetSubsystem<ResourcePickerManager>();
		resPickerMng->Init();

		/// cache some Subsystems
		cache_ = GetSubsystem<ResourceCache>();
		ui_ = GetSubsystem<UI>();
		graphics_ = GetSubsystem<Graphics>();

		/// load default style files, can be edited afterwards
		defaultStyle_ = cache_->GetResource<XMLFile>("UI/IDEStyle.xml");
		iconStyle_ = cache_->GetResource<XMLFile>("UI/IDEIcons.xml");

		/// create main ui element
		rootUI_ = ui_->GetRoot()->CreateChild<UIElement>("InGameEditor");
		rootUI_->SetSize(ui_->GetRoot()->GetSize());
		rootUI_->SetTraversalMode(TM_DEPTH_FIRST);     // This is needed for root-like element to prevent artifacts
		rootUI_->SetPriority(100);
		rootUI_->SetDefaultStyle(defaultStyle_);
		rootUI_->SetOpacity(0.65f);

		//////////////////////////////////////////////////////////////////////////
		/// create menu bar with default menu entries
		menubar_ = MenuBarUI::Create(rootUI_, "EditorMenuBar");
		menubar_->CreateMenu("File");
		menubar_->CreateMenuItem("File", "Exit Editor", A_QUITEDITOR_VAR);
		menubar_->CreateMenu("Windows");
		menubar_->CreateMenuItem("Windows", "Attribute", A_SHOWATTRIBUTE_VAR);
		menubar_->CreateMenuItem("Windows", "Hierarchy", A_SHOWHIERARCHY_VAR);

		SubscribeToEvent(menubar_, E_MENUBAR_ACTION, URHO3D_HANDLER(InGameEditor, HandleMenuBarAction));

		//////////////////////////////////////////////////////////////////////////
		/// create the hierarchy editor
		hierarchyWindow_ = rootUI_->CreateChild<HierarchyWindow>("SceneHierarchyWindow");
		hierarchyWindow_->SetSize(200, 200);
		hierarchyWindow_->SetMovable(true);
		hierarchyWindow_->SetIconStyle(iconStyle_);
		hierarchyWindow_->SetTitle("Scene Hierarchy");
		hierarchyWindow_->SetPosition(0, menubar_->GetHeight());
		hierarchyWindow_->SetHeight(graphics_->GetHeight() - menubar_->GetHeight());
		hierarchyWindow_->SetDefaultStyle(defaultStyle_);
		hierarchyWindow_->SetStyleAuto();
		/// \todo
		// dont know why the auto style does not work ...
		hierarchyWindow_->SetTexture(cache_->GetResource<Texture2D>("Textures/UI.png"));
		hierarchyWindow_->SetImageRect(IntRect(48, 0, 64, 16));
		hierarchyWindow_->SetBorder(IntRect(4, 4, 4, 4));
		hierarchyWindow_->SetResizeBorder(IntRect(8, 8, 8, 8));

		SubscribeToEvent(hierarchyWindow_->GetHierarchyList(), E_SELECTIONCHANGED, URHO3D_HANDLER(InGameEditor, HandleHierarchyListSelectionChange));

		//////////////////////////////////////////////////////////////////////////
		/// create the attribute editor
		attributeInspector_ = new AttributeInspector(context_);
		UIElement* attrinsp = attributeInspector_->Create();
		rootUI_->AddChild(attrinsp);

		attrinsp->SetHeight(graphics_->GetHeight() - menubar_->GetHeight());
		attrinsp->SetWidth(ATTRNAME_WIDTH * 2);

		attrinsp->SetPosition(graphics_->GetWidth() - ATTRNAME_WIDTH * 2, menubar_->GetHeight());

		rootUI_->SetVisible(false);

		//////////////////////////////////////////////////////////////////////////
		/// create view
		cameraNode_ = new Node(context_);
		camera_ = cameraNode_->CreateComponent<Camera>();
		camera_->SetFarClip(1300.0f);
		// Set an initial position for the camera scene node above the plane
		cameraNode_->SetPosition(Vector3(0.0f, 8.0f, 0.0f));

		//////////////////////////////////////////////////////////////////////////
		/// create default editor plugins

		SharedPtr<PluginScene3DEditor> scene3dEditor(new PluginScene3DEditor(context_));

		RegisterEditorPlugin(scene3dEditor);
		mainEditorPlugin_ = scene3dEditor;
	}
开发者ID:PeaceSells50,项目名称:Urho3DIDE,代码行数:87,代码来源:InGameEditor.cpp

示例2:

void Hello3DUI::HandleDragMove(StringHash eventType, VariantMap& eventData)
{
    IntVector2 dragCurrentPosition = IntVector2(eventData["X"].GetInt(), eventData["Y"].GetInt());
    UIElement* draggedElement = static_cast<UIElement*>(eventData["Element"].GetPtr());
    draggedElement->SetPosition(dragCurrentPosition - dragBeginPosition_);
}
开发者ID:rokups,项目名称:Urho3D,代码行数:6,代码来源:Hello3DUI.cpp

示例3: HandlerSplashUpdate


//.........这里部分代码省略.........
        BorderImage * Splash = (BorderImage * ) uiRoot_ -> GetChild("Splash", true);

        if(Splash!=NULL)
        {
            /// Remove splash
            Splash -> Remove();
        }


        /// Get rendering window size as floats
        float width = (float)graphics_->GetWidth();
        float height = (float)graphics_->GetHeight();

        /// Create LetterBox Sprite
        Sprite* LetterBoxSprite = new Sprite(context_);
        LetterBoxSprite->SetName("LetterBoxSprite");

        /// Get letter box image
        Texture2D* texture = cache_ ->GetResource<Texture2D>("Resources/Textures/LetterBox.png");

        /// Set letter box properties
        LetterBoxSprite->SetTexture(texture); // Set texture
        LetterBoxSprite->SetSize(width,height);
        LetterBoxSprite->SetAlignment(HA_CENTER, VA_CENTER);

        /// Create letter box image to UIElement
        UIElement * LetterBoxUIElement = new UIElement(context_);
        LetterBoxUIElement->AddChild(LetterBoxSprite);

        /// Add letter box UIElement to ui
        uiRoot_->AddChild(LetterBoxUIElement);

        /// Set style of UIElements
        LetterBoxUIElement->SetOpacity(.8);

        LetterBoxSprite->SetStyleAuto();
        LetterBoxUIElement->SetStyleAuto();

        /// Create HangarsSymbolSmall Sprite
        Sprite* HangarsSymbolSmallSprite = new Sprite(context_);
        HangarsSymbolSmallSprite->SetName("HangarsSymbolSmallSprite");

        /// Get letter box image
        Texture2D* HangarsSymbolTexture = cache_ ->GetResource<Texture2D>("Resources/Textures/HangarsSymbolSmall.png");

        /// Set letter box properties
        HangarsSymbolSmallSprite->SetTexture(HangarsSymbolTexture); // Set texture
        HangarsSymbolSmallSprite->SetSize(HangarsSymbolTexture->GetWidth()/2,HangarsSymbolTexture->GetHeight()/2);
        HangarsSymbolSmallSprite->SetAlignment(HA_LEFT, VA_TOP);

        /// Create letter box image to UIElement
        UIElement * HangarsSymbolSmallUIElement = new UIElement(context_);
        HangarsSymbolSmallUIElement->AddChild(HangarsSymbolSmallSprite);

        /// Add letter box UIElement to ui
        uiRoot_->AddChild(HangarsSymbolSmallUIElement);

        /// Set style of UIElements
        HangarsSymbolSmallUIElement->SetOpacity(.8);
        HangarsSymbolSmallUIElement->SetPosition((width/2)-((HangarsSymbolTexture->GetWidth()/2)/2),250);

        HangarsSymbolSmallSprite->SetStyleAuto();
        HangarsSymbolSmallUIElement->SetStyleAuto();

        /// Load fonts
        Font * Mionta = cache_ ->GetResource<Font>("Resources/Fonts/mionta.ttf");
        Font * Neuton = cache_ ->GetResource<Font>("Resources/Fonts/Neuton-SC-Light.ttf");

        /// Create logo text
        Text * LogoText = new Text(context_);
        LogoText -> SetTextAlignment(HA_CENTER);
        LogoText -> SetFont(Mionta,32);
        LogoText -> SetText("HANGARS");
        LogoText -> SetColor(Color(.9f,.9f,.9f));

        /// Create LetterBox UI Element
        UIElement * LogoTextUIElement = new UIElement(context_);

        LogoTextUIElement->AddChild(LogoText);

        /// Add to UI
        uiRoot_->AddChild(LogoTextUIElement);

        ///TitleText->SetStyleAuto();
        LogoTextUIElement->SetStyleAuto();

        /// Move text to a position
        LogoTextUIElement->SetPosition((width/2)-240,200);

        /// Create a event
        VariantMap gamestatechange;
        gamestatechange[GameState::P_CMD] = GAME_STATE_LOGIN;

        cout << "Debug: Attempt to send a state change" << endl;

        SendEvent(G_STATES_CHANGE,gamestatechange);
    }
    return ;

}
开发者ID:vivienneanthony,项目名称:Urho3D-gameeconomic,代码行数:101,代码来源:GameEconomicGameClientStateSplash.cpp


注:本文中的UIElement::SetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。