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


C++ Style::createIcon方法代码示例

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


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

示例1: createGraphicsImplementation

void ComboBox::createGraphicsImplementation()
{
    Style *style = (getStyle() != 0) ? getStyle() : Style::instance().get();

    _buttonSwitch = new osg::Switch;
    _popup        = new osgUI::Popup;
    _popup->setVisible(false);
    _popup->setFrameSettings(getFrameSettings());

    osg::BoundingBox extents(_extents);

    osg::ref_ptr<osg::Group> group         = new osg::Group;
    bool                     requiresFrame = (getFrameSettings() && getFrameSettings()->getShape() != osgUI::FrameSettings::NO_FRAME);
    float                    frameWidth    = 0.0;
    float                    unFocused     = 0.92;
    float                    withFocus     = 0.97;
    osg::Vec4                frameColor(unFocused, unFocused, unFocused, 1.0f);

    if (requiresFrame)
    {
        frameWidth = getFrameSettings()->getLineWidth();

        group->addChild(style->createFrame(_extents, getFrameSettings(), frameColor));
        extents.xMin() += frameWidth;
        extents.xMax() -= frameWidth;
        extents.yMin() += frameWidth;
        extents.yMax() -= frameWidth;
    }


    bool itemsHaveColor = false;

    for (Items::iterator itr = _items.begin();
         itr != _items.end();
         ++itr)
    {
        Item *item = itr->get();
        if (item->getColor().a() != 0.0f)
        {
            itemsHaveColor = true; break;
        }
    }

    // work out position of carat.
    float h            = extents.yMax() - extents.yMin();
    float w            = h * 0.7;
    float minItemWidth = (extents.xMax() - extents.xMin()) * 0.5f;
    if (w > minItemWidth)
        w = minItemWidth;

    float xDivision = extents.xMax() - w;

    osg::BoundingBox backgroundExtents = extents;
    osg::BoundingBox iconExtents       = backgroundExtents;
    iconExtents.xMin() = xDivision;
    extents.xMax()     = xDivision;

    if (itemsHaveColor)
    {
        backgroundExtents.xMin() = xDivision;
    }

    OSG_NOTICE << "itemsHaveColor = " << itemsHaveColor << std::endl;

    // clear background of edit region
    _backgroundSwitch = new osg::Switch;
    _backgroundSwitch->addChild(style->createPanel(backgroundExtents, osg::Vec4(unFocused, unFocused, unFocused, 1.0)));
    _backgroundSwitch->addChild(style->createPanel(backgroundExtents, osg::Vec4(withFocus, withFocus, withFocus, 1.0)));
    _backgroundSwitch->setSingleChildOn(0);


    // assign carat
    group->addChild(_backgroundSwitch.get());

    group->addChild(_buttonSwitch.get());

    // group->addChild(style->createIcon(iconExtents, "cow.osgt", osg::Vec4(withFocus, withFocus, withFocus,1.0)));
    group->addChild(style->createIcon(iconExtents, "Images/osg64.png", osg::Vec4(withFocus, withFocus, withFocus, 1.0)));

    if (!_items.empty())
    {
        float margin = (extents.yMax() - extents.yMin()) * 0.1f;
        // float itemWidth = (_extents.xMax()-_extents.xMin()) - 2.0f*frameWidth;
        float itemHeight  = (_extents.yMax() - _extents.yMin()) - 2.0f * frameWidth;
        float popupHeight = (itemHeight) * _items.size() + margin * static_cast<float>(_items.size() - 1) + 2.0f * frameWidth;
        float popupTop    = _extents.yMin() - frameWidth - margin * 1.0f;
        float popupLeft   = _extents.xMin();
        float popupRight  = _extents.xMax();



        osg::BoundingBox popupExtents(popupLeft, popupTop - popupHeight, _extents.zMin(), popupRight, popupTop, _extents.zMax());
        _popup->setExtents(popupExtents);

        osg::BoundingBox popupItemExtents(popupExtents.xMin() + frameWidth, popupTop - frameWidth - itemHeight, popupExtents.zMin(), popupExtents.xMax() - frameWidth, popupTop - frameWidth, popupExtents.zMax());

        _popupItemOrigin.set(popupItemExtents.xMin(), popupItemExtents.yMax(), popupExtents.zMin());
        _popupItemSize.set(popupItemExtents.xMax() - popupItemExtents.xMin(), -(itemHeight + margin), 0.0);

        unsigned int index = 0;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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