• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ widget::Ptr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addChild

void Widget::addChild(Widget::Ptr child) {
	if (child->parent().get() != this) {
		return child->setParent(shared_from_this());
	}

	m_children.push_back(child);
}
开发者ID:deepbansal15,项目名称:game-engine-1,代码行数:7,代码来源:Widget.cpp


示例2: UpdateChild

void Alignment::UpdateChild() {
	Widget::Ptr child = GetChild();

	if( !child ) {
		return;
	}

	sf::FloatRect allocation( GetAllocation() );

	sf::Vector2f spare_space( allocation.width, allocation.height );
	spare_space -= child->GetRequisition();
	spare_space.x *= 1.f - GetScale().x;
	spare_space.y *= 1.f - GetScale().y;

	if( ( spare_space.x < 0 ) || ( spare_space.y < 0 ) ) {
#ifdef SFGUI_DEBUG
		std::cerr << "SFGUI warning: Alignment got a smaller allocation than it requested." << std::endl;
		return;
#endif
	}

	allocation.left = spare_space.x * GetAlignment().x;
	allocation.top = spare_space.y * GetAlignment().y;
	allocation.width -= spare_space.x;
	allocation.height -= spare_space.y;

	child->SetAllocation( allocation );
}
开发者ID:spacechase0,项目名称:SFGUI,代码行数:28,代码来源:Alignment.cpp


示例3: GetChild

sf::Vector2f Alignment::CalculateRequisition() {
	Widget::Ptr child = GetChild();

	if( !child ) {
		return sf::Vector2f( 0.f, 0.f );
	}

	return child->GetRequisition();
}
开发者ID:spacechase0,项目名称:SFGUI,代码行数:9,代码来源:Alignment.cpp


示例4: removeChild

void Widget::removeChild(Widget::Ptr child) {
	if (child->parent() != 0) {
		return child->setParent(0);
	}

	auto it = std::find(m_children.begin(), m_children.end(), child);
	if (it != m_children.begin()) {
		m_children.erase(it);
	}
}
开发者ID:deepbansal15,项目名称:game-engine-1,代码行数:10,代码来源:Widget.cpp


示例5: RemoveAll

void Container::RemoveAll() {
	while( !m_children.empty() ) {
		Widget::Ptr widget = m_children.back();

		m_children.pop_back();
		widget->SetParent( Widget::Ptr() );
		HandleRemove( widget );
	}

	RequestResize();
}
开发者ID:Soth1985,项目名称:Survive,代码行数:11,代码来源:Container.cpp


示例6: handleUnconditionalExitInstrumentation

bool Instrumenter::handleUnconditionalExitInstrumentation(RelocBlock *trace, RelocGraph *, instPoint *exit) {
  // Easy
  RelocBlock::WidgetList &elements = trace->elements();
  // For now, we're inserting this instrumentation immediately before the last instruction
  // in the list of elements. 
  
  Widget::Ptr inst = makeInstrumentation(exit);
  if (!inst) return false;
  
  inst.swap(elements.back());
  elements.push_back(inst);
  return true;
}
开发者ID:Zirkon,项目名称:dyninst,代码行数:13,代码来源:Instrumenter.C


示例7: setParent

void Widget::setParent(Widget::Ptr parent) {
	if (m_parent == parent)
		return;

	if (m_parent) {
		std::cout << m_parent << std::endl;
		Widget::Ptr old = m_parent;
		m_parent = 0;
		old->removeChild(shared_from_this());
	}

	if (parent) {
		m_parent = parent;
		parent->addChild(shared_from_this());
	}
}
开发者ID:deepbansal15,项目名称:game-engine-1,代码行数:16,代码来源:Widget.cpp


示例8: pack

void Container::pack(Widget::Ptr widget)
{
    mChildren.push_back(widget);

    if(!hasSelection() && widget->isSelectable())
        select(mChildren.size() -1);
}
开发者ID:Lo-X,项目名称:hammer,代码行数:7,代码来源:container.cpp


示例9: SetParent

void Widget::SetParent( Widget::Ptr parent ) {
	auto cont = std::dynamic_pointer_cast<Container>( parent );
	auto oldparent = m_parent.lock();

	if( cont == oldparent ) {
		return;
	}

	if( oldparent ) {
		oldparent->Remove( shared_from_this() );
	}

	m_parent = cont;

	auto iter = std::find( root_widgets.begin(), root_widgets.end(), this );

	if( parent ) {
		// If this widget has a parent, it is no longer a root widget.
		if( iter != root_widgets.end() ) {
			root_widgets.erase( iter );
		}

		SetHierarchyLevel( parent->GetHierarchyLevel() + 1 );
	}
	else {
		// If this widget does not have a parent, it becomes a root widget.
		if( iter == root_widgets.end() ) {
			root_widgets.push_back( this );
		}

		SetHierarchyLevel( 0 );
	}

	HandleAbsolutePositionChange();
}
开发者ID:Cruel,项目名称:SFGUI,代码行数:35,代码来源:Widget.cpp


示例10: remove

    bool ScrollablePanel::remove(const Widget::Ptr& widget)
    {
        const sf::Vector2f bottomRight = widget->getPosition() + widget->getFullSize();

        const bool ret = Panel::remove(widget);

        if (m_contentSize == sf::Vector2f{0, 0})
        {
            if ((bottomRight.x == m_mostBottomRightPosition.x) || (bottomRight.y == m_mostBottomRightPosition.y))
            {
                recalculateMostBottomRightPosition();
                updateScrollbars();
            }
        }

        return ret;
    }
开发者ID:Mizugola,项目名称:MeltingSagaEngine,代码行数:17,代码来源:ScrollablePanel.cpp


示例11: Remove

void Container::Remove( const Widget::Ptr& widget ) {
	WidgetsList::iterator iter( std::find( m_children.begin(), m_children.end(), widget ) );

	if( iter != m_children.end() ) {
		m_children.erase( iter );
		widget->SetParent( Widget::Ptr() );
		HandleRemove( widget );

		RequestResize();
	}
}
开发者ID:Soth1985,项目名称:Survive,代码行数:11,代码来源:Container.cpp


示例12: Add

void Container::Add( const Widget::Ptr& widget ) {
	if( IsChild( widget ) ) {
		return;
	}

	m_children.push_back( widget );
	HandleAdd( widget );

	// Check if HandleAdd still wants the little boy.
	if( IsChild( widget ) ) {
		widget->SetParent( shared_from_this() );
		RequestResize();
	}
}
开发者ID:Stigmatized,项目名称:glassomium,代码行数:14,代码来源:Container.cpp


示例13: loadWidget

    TGUI_API Widget::Ptr loadWidget(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget)
    {
        assert(widget != nullptr);

        if (node->propertyValuePairs["visible"])
        {
            bool visible = parseBoolean(node->propertyValuePairs["visible"]->value);
            if (visible)
                widget->show();
            else
                widget->hide();
        }
        if (node->propertyValuePairs["enabled"])
        {
            bool enabled = parseBoolean(node->propertyValuePairs["enabled"]->value);
            if (enabled)
                widget->enable();
            else
                widget->disable();
        }
        if (node->propertyValuePairs["position"])
            widget->setPosition(parseLayout(node->propertyValuePairs["position"]->value));
        if (node->propertyValuePairs["size"])
            widget->setSize(parseLayout(node->propertyValuePairs["size"]->value));
        if (node->propertyValuePairs["opacity"])
            widget->setOpacity(tgui::stof(node->propertyValuePairs["opacity"]->value));

        /// TODO: Font and ToolTip (and Theme?)

        for (auto& childNode : node->children)
        {
            if (toLower(childNode->name) == "renderer")
            {
                for (auto& pair : childNode->propertyValuePairs)
                    widget->getRenderer()->setProperty(pair.first, pair.second->value);
            }
        }
        REMOVE_CHILD("renderer");

        return widget;
    }
开发者ID:wpbest,项目名称:XPF,代码行数:41,代码来源:WidgetLoader.cpp


示例14: SetParent

void Widget::SetParent( const Widget::Ptr& parent ) {
	Container::Ptr cont( DynamicPointerCast<Container>( parent ) );

	if( !cont ) {
		return;
	}

	Container::Ptr oldparent = m_parent.lock();

	if( oldparent ) {
		oldparent->Remove( shared_from_this() );
	}

	m_parent = cont;

	SetHierarchyLevel( parent->GetHierarchyLevel() + 1 );

	HandleAbsolutePositionChange();
}
开发者ID:ksandison,项目名称:sfgui,代码行数:19,代码来源:Widget.cpp


示例15: addWidget

    void Grid::addWidget(const Widget::Ptr& widget, unsigned int row, unsigned int col,
                         const Borders& borders, Alignment alignment)
    {
        // If the widget hasn't already been added then add it now
        if (std::find(getWidgets().begin(), getWidgets().end(), widget) == getWidgets().end())
            add(widget);

        // Create the row if it did not exist yet
        if (m_gridWidgets.size() < row + 1)
        {
            m_gridWidgets.resize(row + 1);
            m_objBorders.resize(row + 1);
            m_objAlignment.resize(row + 1);
        }

        // Create the column if it did not exist yet
        if (m_gridWidgets[row].size() < col + 1)
        {
            m_gridWidgets[row].resize(col + 1, nullptr);
            m_objBorders[row].resize(col + 1);
            m_objAlignment[row].resize(col + 1);
        }

        // If this is a new row then reserve some space for it
        if (m_rowHeight.size() < row + 1)
            m_rowHeight.resize(row + 1, 0);

        // If this is the first row to have so many columns then reserve some space for it
        if (m_columnWidth.size() < col + 1)
            m_columnWidth.resize(col + 1, 0);

        // Add the widget to the grid
        m_gridWidgets[row][col] = widget;
        m_objBorders[row][col] = borders;
        m_objAlignment[row][col] = alignment;

        // Update the widgets
        updateWidgets();

        // Automatically update the widgets when their size changes
        m_connectedCallbacks[widget] = widget->connect("SizeChanged", &Grid::updateWidgets, this);
    }
开发者ID:texus,项目名称:TGUI,代码行数:42,代码来源:Grid.cpp


示例16: create

// Case 2: wrap a CF-category instruction
CFWidget::Ptr CFWidget::create(Widget::Ptr atom) {
   CFWidget::Ptr ptr = Ptr(new CFWidget(atom->insn(), atom->addr()));
   return ptr;
}
开发者ID:Zirkon,项目名称:dyninst,代码行数:5,代码来源:CFWidget.C


示例17: HandleAdd

void Container::HandleAdd( const Widget::Ptr& child ) {
	child->SetViewport( GetViewport() );
}
开发者ID:Stigmatized,项目名称:glassomium,代码行数:3,代码来源:Container.cpp


示例18: handleEvent

    bool EventManager::handleEvent(sf::Event& event)
    {
        // Check if a mouse button has moved
        if (event.type == sf::Event::MouseMoved)
        {
            // Loop through all widgets
            for (unsigned int i=0; i<m_Widgets.size(); ++i)
            {
                // Check if the mouse went down on the widget
                if (m_Widgets[i]->m_MouseDown)
                {
                    // Some widgets should always receive mouse move events while dragging them, even if the mouse is no longer on top of them.
                    if ((m_Widgets[i]->m_DraggableWidget) || (m_Widgets[i]->m_ContainerWidget))
                    {
                        m_Widgets[i]->mouseMoved(static_cast<float>(event.mouseMove.x), static_cast<float>(event.mouseMove.y));
                        return true;
                    }
                }
            }

            // Check if the mouse is on top of an widget
            Widget::Ptr widget = mouseOnWidget(static_cast<float>(event.mouseMove.x), static_cast<float>(event.mouseMove.y));
            if (widget != nullptr)
            {
                // Send the event to the widget
                widget->mouseMoved(static_cast<float>(event.mouseMove.x), static_cast<float>(event.mouseMove.y));
                return true;
            }

            return false;
        }

        // Check if a mouse button was pressed
        else if (event.type == sf::Event::MouseButtonPressed)
        {
            // Check if the left mouse was pressed
            if (event.mouseButton.button == sf::Mouse::Left)
            {
                // Check if the mouse is on top of an widget
                Widget::Ptr widget = mouseOnWidget(static_cast<float>(event.mouseButton.x), static_cast<float>(event.mouseButton.y));
                if (widget != nullptr)
                {
                    // Focus the widget
                    focusWidget(widget.get());

                    // Check if the widget is a container
                    if (widget->m_ContainerWidget)
                    {
                        // If another widget was focused then unfocus it now
                        if ((m_FocusedWidget) && (m_Widgets[m_FocusedWidget-1] != widget))
                        {
                            m_Widgets[m_FocusedWidget-1]->m_Focused = false;
                            m_Widgets[m_FocusedWidget-1]->widgetUnfocused();
                            m_FocusedWidget = 0;
                        }
                    }

                    widget->leftMousePressed(static_cast<float>(event.mouseButton.x), static_cast<float>(event.mouseButton.y));
                    return true;
                }
                else // The mouse didn't went down on an widget, so unfocus the focused widget
                    unfocusAllWidgets();
            }

            return false;
        }

        // Check if a mouse button was released
        else if (event.type == sf::Event::MouseButtonReleased)
        {
            // Check if the left mouse was released
            if (event.mouseButton.button == sf::Mouse::Left)
            {
                // Check if the mouse is on top of an widget
                Widget::Ptr widget = mouseOnWidget(static_cast<float>(event.mouseButton.x), static_cast<float>(event.mouseButton.y));
                if (widget != nullptr)
                    widget->leftMouseReleased(static_cast<float>(event.mouseButton.x), static_cast<float>(event.mouseButton.y));

                // Tell all the other widgets that the mouse has gone up
                for (std::vector<Widget::Ptr>::iterator it = m_Widgets.begin(); it != m_Widgets.end(); ++it)
                {
                    if (*it != widget)
                        (*it)->mouseNoLongerDown();
                }

                if (widget != nullptr)
                    return true;
            }

            return false;
        }

        // Check if a key was pressed
        else if (event.type == sf::Event::KeyPressed)
        {
            // Only continue when the character was recognised
            if (event.key.code != sf::Keyboard::Unknown)
            {
                // Check if there is a focused widget
                if (m_FocusedWidget)
//.........这里部分代码省略.........
开发者ID:gupascal,项目名称:TGUI,代码行数:101,代码来源:EventManager.cpp


示例19: saveWidget

    TGUI_API std::shared_ptr<DataIO::Node> saveWidget(Widget::Ptr widget)
    {
        std::string widgetName;
        if (widget->getParent())
            widget->getParent()->getWidgetName(widget, widgetName);

        auto node = std::make_shared<DataIO::Node>();
        if (widgetName.empty())
            node->name = widget->getWidgetType();
        else
            node->name = widget->getWidgetType() + "." + widgetName;

        if (!widget->isVisible())
            SET_PROPERTY("Visible", "false");
        if (!widget->isEnabled())
            SET_PROPERTY("Enabled", "false");
        if (widget->getPosition() != sf::Vector2f{})
            SET_PROPERTY("Position", emitLayout(widget->getPositionLayout()));
        if (widget->getSize() != sf::Vector2f{})
            SET_PROPERTY("Size", emitLayout(widget->getSizeLayout()));
        if (widget->getOpacity() != 255)
            SET_PROPERTY("Opacity", tgui::to_string(widget->getOpacity()));

        /// TODO: Font and ToolTip

        if (widget->getRenderer())
        {
            node->children.emplace_back(std::make_shared<DataIO::Node>());
            node->children.back()->name = "Renderer";
            for (auto& pair : widget->getRenderer()->getPropertyValuePairs())
                node->children.back()->propertyValuePairs[pair.first] = std::make_shared<DataIO::ValueNode>(node->children.back().get(), Serializer::serialize(std::move(pair.second)));
        }

        return node;
    }
开发者ID:wpbest,项目名称:XPF,代码行数:35,代码来源:WidgetSaver.cpp


示例20: remove

 void Grid::remove(const Widget::Ptr& widget)
 {
     remove(widget.get());
 }
开发者ID:DalikarFT,项目名称:dndgame,代码行数:4,代码来源:Grid.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dow::Handle类代码示例发布时间:2022-05-31
下一篇:
C++ wfmath::Vector类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap