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


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

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


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


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