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


C++ UIElement类代码示例

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


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

示例1: GetNumItems

void ListView::ChangeSelection(int delta, bool additive)
{
    if (selections_.Empty())
        return;
    if (!multiselect_)
        additive = false;

    // If going downwards, use the last selection as a base. Otherwise use first
    unsigned selection = delta > 0 ? selections_.Back() : selections_.Front();
    int direction = delta > 0 ? 1 : -1;
    unsigned numItems = GetNumItems();
    unsigned newSelection = selection;
    unsigned okSelection = selection;
    PODVector<unsigned> indices = selections_;

    while (delta != 0)
    {
        newSelection += direction;
        if (newSelection >= numItems)
            break;

        UIElement* item = GetItem(newSelection);
        if (item->IsVisible())
        {
            indices.Push(okSelection = newSelection);
            delta -= direction;
        }
    }

    if (!additive)
        SetSelection(okSelection);
    else
        SetSelections(indices);
}
开发者ID:CarloMaker,项目名称:Urho3D,代码行数:34,代码来源:ListView.cpp

示例2: left_walker

void
TabNavigationWalker::Sort (GPtrArray *array, Types *types)
{
	int end = array->len;
	bool swapped;

	do {
		end --;
		swapped = false;
		for (int i = 0; i < end; i++) {
			UIElement *left = NULL;
			UIElement *right = NULL;

			DeepTreeWalker left_walker ((UIElement *) array->pdata [i], Logical, types);
			DeepTreeWalker right_walker ((UIElement *) array->pdata [i + 1], Logical, types);

			while ((left = left_walker.Step ()) && !types->IsSubclassOf (left->GetObjectType (), Type::CONTROL)) { }
			while ((right = right_walker.Step ()) && !types->IsSubclassOf (right->GetObjectType (), Type::CONTROL)) { }

			if (TabCompare ((Control *)left, (Control *)right) > 0) {
				left = (UIElement *) array->pdata [i];
				array->pdata [i] = array->pdata [i + 1];
				array->pdata [i + 1] = left;
				swapped = true;
			}
		}
	} while (swapped);
}
开发者ID:snorp,项目名称:moon,代码行数:28,代码来源:tabnavigationwalker.cpp

示例3: SetLogoVisible

void LANDiscovery::CreateUI()
{
    SetLogoVisible(true); // We need the full rendering window

    auto* graphics = GetSubsystem<Graphics>();
    UIElement* root = GetSubsystem<UI>()->GetRoot();
    auto* cache = GetSubsystem<ResourceCache>();
    auto* uiStyle = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
    // Set style to the UI root so that elements will inherit it
    root->SetDefaultStyle(uiStyle);

    int marginTop = 20;
    CreateLabel("1. Start server", IntVector2(20, marginTop-20));
    startServer_ = CreateButton("Start server", 160, IntVector2(20, marginTop));
    stopServer_ = CreateButton("Stop server", 160, IntVector2(20, marginTop));
	stopServer_->SetVisible(false);

    // Create client connection related fields
    marginTop += 80;
    CreateLabel("2. Discover LAN servers", IntVector2(20, marginTop-20));
    refreshServerList_ = CreateButton("Search...", 160, IntVector2(20, marginTop));

	marginTop += 80;
	CreateLabel("Local servers:", IntVector2(20, marginTop - 20));
	serverList_ = CreateLabel("", IntVector2(20, marginTop));

    // No viewports or scene is defined. However, the default zone's fog color controls the fill color
    GetSubsystem<Renderer>()->GetDefaultZone()->SetFogColor(Color(0.0f, 0.0f, 0.1f));
}
开发者ID:1vanK,项目名称:Urho3D,代码行数:29,代码来源:LANDiscovery.cpp

示例4: GetRootElement

void PlatformWindowSite::OnMouseButtonDblClk(gm::PointF clientMousePos, int button)
{
	POINT screenMousePos;
	::GetCursorPos(&screenMousePos);

	UIElement* hitElement = nullptr;

	UIElement* child = GetRootElement();
//	Visual* child = get_Child();
	if (child)
	{
		hitElement = child->HitTest_(clientMousePos);
	}
//	hitElement = child;

	if (hitElement)
	{
		MouseButtonEventArgs* args = new MouseButtonEventArgs(nullptr, 0);

		if (button == 0)			args->set_RoutedEvent(UIElement::get_MouseLeftButtonDoubleClickEvent());
		else if (button == 1)	args->set_RoutedEvent(UIElement::get_MouseMiddleButtonDoubleClickEvent());
		else						args->set_RoutedEvent(UIElement::get_MouseRightButtonDoubleClickEvent());

		args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
		args->m_clientpos = clientMousePos;

		hitElement->RaiseEvent(args);
	}
}
开发者ID:sigurdle,项目名称:FirstProject2,代码行数:29,代码来源:Window.cpp

示例5: Color

	void UIButton::InitDefaultElements()
	{
		UIElement Element;

		// Button
		{
			Element.SetTexture(0, UIManager::Instance().ElementTextureRect(UICT_Button, 0));
			Element.SetFont(0);
			Element.TextureColor().States[UICS_Normal] = Color(1, 1, 1, 150.0f / 255);
			Element.TextureColor().States[UICS_Pressed] = Color(1, 1, 1, 200.0f / 255);
			Element.FontColor().States[UICS_MouseOver] = Color(0, 0, 0, 1.0f);

			elements_.push_back(MakeSharedPtr<UIElement>(Element));
		}

		// Fill layer
		{
			Element.SetTexture(0, UIManager::Instance().ElementTextureRect(UICT_Button, 1), Color(1, 1, 1, 0));
			Element.TextureColor().States[UICS_MouseOver] = Color(1, 1, 1, 160.0f / 255);
			Element.TextureColor().States[UICS_Pressed] = Color(0, 0, 0, 60.0f / 255);
			Element.TextureColor().States[UICS_Focus] = Color(1, 1, 1, 30.0f / 255);

			elements_.push_back(MakeSharedPtr<UIElement>(Element));
		}
	}
开发者ID:BitYorkie,项目名称:KlayGE,代码行数:25,代码来源:UIButton.cpp

示例6: CreateUI

void SoundEffects::CreateUI()
{
    UIElement* root = GetSubsystem<UI>()->GetRoot();
    auto* cache = GetSubsystem<ResourceCache>();
    auto* uiStyle = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
    // Set style to the UI root so that elements will inherit it
    root->SetDefaultStyle(uiStyle);

    // Create buttons for playing back sounds
    for (unsigned i = 0; i < NUM_SOUNDS; ++i)
    {
        Button* button = CreateButton(i * 140 + 20, 20, 120, 40, soundNames[i]);
        // Store the sound effect resource name as a custom variable into the button
        button->SetVar(VAR_SOUNDRESOURCE, soundResourceNames[i]);
        SubscribeToEvent(button, E_PRESSED, URHO3D_HANDLER(SoundEffects, HandlePlaySound));
    }

    // Create buttons for playing/stopping music
    Button* button = CreateButton(20, 80, 120, 40, "Play Music");
    SubscribeToEvent(button, E_RELEASED, URHO3D_HANDLER(SoundEffects, HandlePlayMusic));

    button = CreateButton(160, 80, 120, 40, "Stop Music");
    SubscribeToEvent(button, E_RELEASED, URHO3D_HANDLER(SoundEffects, HandleStopMusic));

    auto* audio = GetSubsystem<Audio>();

    // Create sliders for controlling sound and music master volume
    Slider* slider = CreateSlider(20, 140, 200, 20, "Sound Volume");
    slider->SetValue(audio->GetMasterGain(SOUND_EFFECT));
    SubscribeToEvent(slider, E_SLIDERCHANGED, URHO3D_HANDLER(SoundEffects, HandleSoundVolume));

    slider = CreateSlider(20, 200, 200, 20, "Music Volume");
    slider->SetValue(audio->GetMasterGain(SOUND_MUSIC));
    SubscribeToEvent(slider, E_SLIDERCHANGED, URHO3D_HANDLER(SoundEffects, HandleMusicVolume));
}
开发者ID:TrevorCash,项目名称:Urho3D,代码行数:35,代码来源:SoundEffects.cpp

示例7: SaveXML

bool Menu::SaveXML(XMLElement& dest)
{
    // Write type and internal flag
    if (!dest.SetString("type", GetTypeName()))
        return false;
    if (internal_)
    {
        if (!dest.SetBool("internal", internal_))
            return false;
    }
    
    // Write attributes
    if (!Serializable::SaveXML(dest))
        return false;
    
    // Write child elements
    for (unsigned i = 0; i < children_.Size(); ++i)
    {
        UIElement* element = children_[i];
        XMLElement childElem = dest.CreateChild("element");
        if (!element->SaveXML(childElem))
            return false;
    }
    
    // Save the popup element as a "virtual" child element
    if (popup_)
    {
        XMLElement childElem = dest.CreateChild("element");
        childElem.SetBool("popup", true);
        if (!popup_->SaveXML(childElem))
            return false;
    }
    
    return true;
}
开发者ID:acremean,项目名称:urho3d,代码行数:35,代码来源:Menu.cpp

示例8: GetStackTop

UIElement * UserInterface::Activate(){
	UIElement * stackTop = GetStackTop();
	if (!stackTop)
		return NULL;
	UIElement * result = NULL;
	result = stackTop->Activate();
	if (result)
	{
		if (result->activationMessage.Length() == 0){
		//	assert(false && "Activatable UI element has no valid activation message string!");
			return NULL;
		}
		if (result->activationMessage.Length() != 0){
			if (result->activationMessage.Type() == String::WIDE_CHAR)
				result->activationMessage.ConvertToChar();
			List<String> msgs = result->activationMessage.Tokenize("&");
			for (int i = 0; i < msgs.Size(); ++i){
				Message * message = new Message(msgs[i]);
				message->element = result;
				MesMan.QueueMessage(message);
			}
			return result;
		}
		else {
			std::cout<<"\nonActivate and activationMessage both NULL in element: "<<result->name;
			return NULL;
		}
	}
	return result;
}
开发者ID:erenik,项目名称:engine,代码行数:30,代码来源:UserInterface.cpp

示例9: GetElementsByState

/// Fetches all elements conforming to the bitwise and'ed (&) state flags provided.
bool UserInterface::GetElementsByState(int stateFlag, List<UIElement*> & listToFill){
	UIElement * e = this->GetStackTop();
	if (!e)
		return false;
	e->GetElementsByState(stateFlag, listToFill);
	return true;
}
开发者ID:erenik,项目名称:engine,代码行数:8,代码来源:UserInterface.cpp

示例10: findElem

bool UserInterface::scroll(bool up){
    UIElement *clikedElem = findElem(userInterfaceListener.getMousePos());
    if(clikedElem!=nullptr){
        return clikedElem->executeScroll(up);
    }
    return false;
}
开发者ID:lazarev-pv,项目名称:robot-game,代码行数:7,代码来源:UserInterface.cpp

示例11: Update

void ScrollView::Update(float timeStep)
{
    // Update touch scrolling here if necessary
    if (touchScrollSpeed_ == Vector2::ZERO && touchScrollSpeedMax_ == Vector2::ZERO && !barScrolling_)
        return;

    // Check if we should not scroll:
    // - ScrollView is not visible, is not enabled, or doesn't have focus
    // - The element being dragged is not a child of the ScrollView, or is one of our scrollbars
    if (!IsVisible() || !IsEnabled() || !HasFocus())
    {
        touchScrollSpeed_ = Vector2::ZERO;
        touchScrollSpeedMax_ = Vector2::ZERO;
        return;
    }

    if (GetSubsystem<UI>()->IsDragging())
    {
        Vector<UIElement*> dragElements = GetSubsystem<UI>()->GetDragElements();

        for (unsigned i = 0; i < dragElements.Size(); i++)
        {
            UIElement* dragElement = dragElements[i];
            int dragButtons = dragElement->GetDragButtonCombo();

            if (dragButtons != MOUSEB_LEFT)
                continue;

            UIElement* dragParent = dragElement->GetParent();
            bool dragElementIsChild = false;

            while (dragParent)
            {
                if (dragParent == this)
                {
                    dragElementIsChild = true;
                    break;
                }
                dragParent = dragParent->GetParent();
            }

            if (!dragElementIsChild || dragElement == horizontalScrollBar_->GetSlider() ||
                dragElement == verticalScrollBar_->GetSlider())
            {
                touchScrollSpeed_ = Vector2::ZERO;
                touchScrollSpeedMax_ = Vector2::ZERO;
                return;
            }
        }
    }

    // Update view position
    IntVector2 newPosition = viewPosition_;
    newPosition.x_ += (int)touchScrollSpeed_.x_;
    newPosition.y_ += (int)touchScrollSpeed_.y_;
    SetViewPosition(newPosition);

    // Smooth deceleration
    ScrollSmooth(timeStep);
}
开发者ID:TheComet93,项目名称:Urho3D,代码行数:60,代码来源:ScrollView.cpp

示例12: Object

Console::Console(Context* context) :
    Object(context),
    historyRows_(DEFAULT_HISTORY_SIZE),
    historyPosition_(0)
{
    UI* ui = GetSubsystem<UI>();
    UIElement* uiRoot = ui->GetRoot();

    background_ = new BorderImage(context_);
    background_->SetBringToBack(false);
    background_->SetClipChildren(true);
    background_->SetEnabled(true);
    background_->SetVisible(false); // Hide by default
    background_->SetPriority(200); // Show on top of the debug HUD
    background_->SetLayout(LM_VERTICAL);

    rowContainer_ = new UIElement(context_);
    rowContainer_->SetClipChildren(true);
    rowContainer_->SetLayout(LM_VERTICAL);
    background_->AddChild(rowContainer_);

    lineEdit_ = new LineEdit(context_);
    lineEdit_->SetFocusMode(FM_FOCUSABLE); // Do not allow defocus with ESC
    background_->AddChild(lineEdit_);

    uiRoot->AddChild(background_);

    SetNumRows(DEFAULT_CONSOLE_ROWS);

    SubscribeToEvent(lineEdit_, E_TEXTFINISHED, HANDLER(Console, HandleTextFinished));
    SubscribeToEvent(lineEdit_, E_UNHANDLEDKEY, HANDLER(Console, HandleLineEditKey));
    SubscribeToEvent(E_SCREENMODE, HANDLER(Console, HandleScreenMode));
    SubscribeToEvent(E_LOGMESSAGE, HANDLER(Console, HandleLogMessage));
    SubscribeToEvent(E_POSTUPDATE, HANDLER(Console, HandlePostUpdate));
}
开发者ID:CarloMaker,项目名称:Urho3D,代码行数:35,代码来源:Console.cpp

示例13: hide

void UIElements::setup(const Common::Point &pt) {
	_slotStart = 0;
	_itemList.clear();
	_scoreValue = 0;
	_active = true;
	UICollection::setup(pt);
	hide();

	_object1.setup(1, 3, 1, 0, 0, 255);
	add(&_object1);

	// Set up the inventory slots
	int xp = 0;
	for (int idx = 0; idx < 4; ++idx) {
		UIElement *item = NULL;
		switch (idx) {
		case 0:
			item = &_slot1;
			break;
		case 1:
			item = &_slot2;
			break;
		case 2:
			item = &_slot3;
			break;
		case 3:
			item = &_slot4;
			break;
		}

		xp = idx * 63 + 2;
		item->setup(9, 1, idx, xp, 4, 255);
		add(item);
	}

	// Setup bottom-right hand buttons
	xp += 62;
	_question.setup(1, 4, 7, xp, 16, 255);
	_question.setEnabled(false);
	add(&_question);

	xp += 21;
	_scrollLeft.setup(1, 4, 1, xp, 16, 255);
	add(&_scrollLeft);
	_scrollLeft._isLeft = true;

	xp += 22;
	_scrollRight.setup(1, 4, 4, xp, 16, 255);
	add(&_scrollRight);
	_scrollRight._isLeft = false;

	// Set up the score
	_score.postInit();
	add(&_score);

	// Set interface area
	_bounds = Rect(0, BF_INTERFACE_Y - 1, SCREEN_WIDTH, SCREEN_HEIGHT);

	updateInventory();
}
开发者ID:AdamRi,项目名称:scummvm-pink,代码行数:60,代码来源:blueforce_ui.cpp

示例14: get_ShadowTree

void UIElement::OnComputedPropertyValueChanging(PropertyValue* pPropertyVal, const Variant& oldValue, const Variant& newValue, bool handled)
{
	if (pPropertyVal->m_dp == get_ShadowTreeProperty())
	{
		// remove old

		UIElement* uielement = get_ShadowTree();

		if (uielement)
		{
			uielement->SetRoot(nullptr);
			uielement->set_Parent(nullptr);
			uielement->set_ParentWindow(nullptr);
		}

		handled = true;
	}

	if (m_elementProvider)
	{
		PROPERTYID propertyId = 0;
		if (pPropertyVal->m_dp == Window::get_TitleTextProperty())
		{
			propertyId = UIA_NamePropertyId;
		}

		HRESULT hr;
		if (propertyId)
		{
			hr = UiaRaiseAutomationPropertyChangedEvent(m_elementProvider, propertyId, oldValue, newValue);
		}
	}

	baseClass::OnComputedPropertyValueChanging(pPropertyVal, oldValue, newValue, handled);
}
开发者ID:sigurdle,项目名称:FirstProject2,代码行数:35,代码来源:UIElement.cpp

示例15: Object

DebugHud::DebugHud(Context* context) :
    Object(context),
    profilerMaxDepth_(M_MAX_UNSIGNED),
    profilerInterval_(1000),
    useRendererStats_(false),
    mode_(DEBUGHUD_SHOW_NONE)
{
    UI* ui = GetSubsystem<UI>();
    UIElement* uiRoot = ui->GetRoot();

    statsText_ = new Text(context_);
    statsText_->SetAlignment(HA_LEFT, VA_TOP);
    statsText_->SetPriority(100);
    statsText_->SetVisible(false);
    uiRoot->AddChild(statsText_);

    modeText_ = new Text(context_);
    modeText_->SetAlignment(HA_LEFT, VA_BOTTOM);
    modeText_->SetPriority(100);
    modeText_->SetVisible(false);
    uiRoot->AddChild(modeText_);

    profilerText_ = new Text(context_);
    profilerText_->SetAlignment(HA_RIGHT, VA_TOP);
    profilerText_->SetPriority(100);
    profilerText_->SetVisible(false);
    uiRoot->AddChild(profilerText_);

    SubscribeToEvent(E_POSTUPDATE, HANDLER(DebugHud, HandlePostUpdate));
}
开发者ID:RobertoMalatesta,项目名称:AtomicGameEngine,代码行数:30,代码来源:DebugHud.cpp


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