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


C++ Theme::getStyle方法代码示例

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


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

示例1: initialize

void InputSample::initialize()
{
    setMultiTouch(true);

    // Load font
    _font = Font::create("res/ui/arial.gpb");
    assert(_font);

    // Reuse part of the gamepad texture as the crosshair in this sample.
    _crosshair = SpriteBatch::create("res/png/gamepad.png");
    _crosshairDstRect.set(0, 0, 256, 256);
    _crosshairSrcRect.set(256, 0, 256, 256);
    _crosshairLowerLimit.set(-_crosshairSrcRect.width / 2.0f, -_crosshairSrcRect.height / 2.0f);
    _crosshairUpperLimit.set((float)getWidth(), (float)getHeight());
    _crosshairUpperLimit += _crosshairLowerLimit;

    // Create input sample controls
    _keyboardState = false;
    _inputSampleControls = Form::create("res/common/inputs.form");
    static_cast<Button*>(_inputSampleControls->getControl("showKeyboardButton"))->addListener(this, Listener::CLICK);
    static_cast<Button*>(_inputSampleControls->getControl("captureMouseButton"))->addListener(this, Listener::CLICK);

    if (!hasMouse())
    {
        static_cast<Button*>(_inputSampleControls->getControl("captureMouseButton"))->setVisible(false);
    }
    _inputSampleControls->getControl("restoreMouseLabel")->setVisible(false);

    _mousePoint.set(-100, -100);

    // Create a 3D form that responds to raw sensor inputs.
    // For this, we will need a scene with a camera node.
    Camera* camera = Camera::createPerspective(45.0f, (float)getWidth() / (float)getHeight(), 0.25f, 100.0f);
    _scene = Scene::create();
    Node* cameraNode = _scene->addNode("Camera");
    cameraNode->setCamera(camera);
    _scene->setActiveCamera(camera);
    SAFE_RELEASE(camera);
    _formNodeParent = _scene->addNode("FormParent");
    _formNode = Node::create("Form");
    _formNodeParent->addChild(_formNode);
    Theme* theme = _inputSampleControls->getTheme();
    Form* form = Form::create("testForm", theme->getStyle("basicContainer"), Layout::LAYOUT_ABSOLUTE);
    form->setSize(225, 100);
    Label* label = Label::create("sensorLabel", theme->getStyle("iconNoBorder"));
    label->setPosition(25, 15);
    label->setSize(175, 50);
    label->setText("Raw sensor response (accel/gyro)");
    form->addControl(label);
    label->release();
    _formNode->setScale(0.0015f, 0.0015f, 1.0f);
    _formNodeRestPosition.set(0, 0, -1.5f);
    _formNodeParent->setTranslation(_formNodeRestPosition);
    _formNode->setTranslation(-0.2f, -0.2f, 0);
    _formNode->setDrawable(form);
    form->release();
}
开发者ID:ConfusedReality,项目名称:pkg_game-engine_gameplay,代码行数:57,代码来源:InputSample.cpp

示例2: lua_Theme_getStyle

static int lua_Theme_getStyle(lua_State* state)
{
    // Get the number of parameters.
    int paramCount = lua_gettop(state);

    // Attempt to match the parameters to a valid binding.
    switch (paramCount)
    {
        case 2:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
            {
                // Get parameter 1 off the stack.
                const char* param1 = gameplay::ScriptUtil::getString(2, false);

                Theme* instance = getInstance(state);
                void* returnPtr = ((void*)instance->getStyle(param1));
                if (returnPtr)
                {
                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
                    object->instance = returnPtr;
                    object->owns = false;
                    luaL_getmetatable(state, "ThemeStyle");
                    lua_setmetatable(state, -2);
                }
                else
                {
                    lua_pushnil(state);
                }

                return 1;
            }

            lua_pushstring(state, "lua_Theme_getStyle - Failed to match the given parameters to a valid function signature.");
            lua_error(state);
            break;
        }
        default:
        {
            lua_pushstring(state, "Invalid number of parameters (expected 2).");
            lua_error(state);
            break;
        }
    }
    return 0;
}
开发者ID:03050903,项目名称:GamePlay,代码行数:47,代码来源:lua_Theme.cpp

示例3: create

Form* Form::create(const char* url)
{
    // Load Form from .form file.
    Properties* properties = Properties::create(url);
    if (properties == NULL)
    {
        GP_ASSERT(properties);
        return NULL;
    }

    // Check if the Properties is valid and has a valid namespace.
    Properties* formProperties = (strlen(properties->getNamespace()) > 0) ? properties : properties->getNextNamespace();
    assert(formProperties);
    if (!formProperties || !(strcmp(formProperties->getNamespace(), "form") == 0))
    {
        GP_ASSERT(formProperties);
        SAFE_DELETE(properties);
        return NULL;
    }

    // Create new form with given ID, theme and layout.
    const char* themeFile = formProperties->getString("theme");
    const char* layoutString = formProperties->getString("layout");
        
    Layout* layout;
    switch (getLayoutType(layoutString))
    {
    case Layout::LAYOUT_ABSOLUTE:
        layout = AbsoluteLayout::create();
        break;
    case Layout::LAYOUT_FLOW:
        layout = FlowLayout::create();
        break;
    case Layout::LAYOUT_VERTICAL:
        layout = VerticalLayout::create();
        break;
    default:
        GP_ERROR("Unsupported layout type '%d'.", getLayoutType(layoutString));
        break;
    }

    Theme* theme = Theme::create(themeFile);
    GP_ASSERT(theme);

    Form* form = new Form();
    form->_layout = layout;
    form->_theme = theme;

    // Get default projection matrix.
    Game* game = Game::getInstance();
    Matrix::createOrthographicOffCenter(0, game->getWidth(), game->getHeight(), 0, 0, 1, &form->_defaultProjectionMatrix);

    Theme::Style* style = NULL;
    const char* styleName = formProperties->getString("style");
    if (styleName)
    {
        style = theme->getStyle(styleName);
    }
    else
    {
        style = theme->getEmptyStyle();
    }
    form->initialize(style, formProperties);

    form->_consumeInputEvents = formProperties->getBool("consumeInputEvents", false);

    // Alignment
    if ((form->_alignment & Control::ALIGN_BOTTOM) == Control::ALIGN_BOTTOM)
    {
        form->_bounds.y = Game::getInstance()->getHeight() - form->_bounds.height;
    }
    else if ((form->_alignment & Control::ALIGN_VCENTER) == Control::ALIGN_VCENTER)
    {
        form->_bounds.y = Game::getInstance()->getHeight() * 0.5f - form->_bounds.height * 0.5f;
    }

    if ((form->_alignment & Control::ALIGN_RIGHT) == Control::ALIGN_RIGHT)
    {
        form->_bounds.x = Game::getInstance()->getWidth() - form->_bounds.width;
    }
    else if ((form->_alignment & Control::ALIGN_HCENTER) == Control::ALIGN_HCENTER)
    {
        form->_bounds.x = Game::getInstance()->getWidth() * 0.5f - form->_bounds.width * 0.5f;
    }

    form->_scroll = getScroll(formProperties->getString("scroll"));
    form->_scrollBarsAutoHide = formProperties->getBool("scrollBarsAutoHide");
    if (form->_scrollBarsAutoHide)
    {
        form->_scrollBarOpacity = 0.0f;
    }

    // Add all the controls to the form.
    form->addControls(theme, formProperties);

    SAFE_DELETE(properties);
    
    form->updateBounds();

    __forms.push_back(form);
//.........这里部分代码省略.........
开发者ID:5guo,项目名称:GamePlay,代码行数:101,代码来源:Form.cpp

示例4: create

    Form* Form::create(const char* url)
    {
        // Load Form from .form file.
        assert(url);

        Properties* properties = Properties::create(url);
        assert(properties);
        if (properties == NULL)
            return NULL;

        // Check if the Properties is valid and has a valid namespace.
        Properties* formProperties = (strlen(properties->getNamespace()) > 0) ? properties : properties->getNextNamespace();
        assert(formProperties);
        if (!formProperties || !(strcmp(formProperties->getNamespace(), "form") == 0))
        {
            SAFE_DELETE(properties);
            return NULL;
        }

        // Create new form with given ID, theme and layout.
        const char* themeFile = formProperties->getString("theme");
        const char* layoutString = formProperties->getString("layout");
        
        Layout* layout;
        switch (getLayoutType(layoutString))
        {
        case Layout::LAYOUT_ABSOLUTE:
            layout = AbsoluteLayout::create();
            break;
        case Layout::LAYOUT_FLOW:
            break;
        case Layout::LAYOUT_VERTICAL:
            layout = VerticalLayout::create();
            break;
        }

        assert(themeFile);
        Theme* theme = Theme::create(themeFile);
        assert(theme);

        Form* form = new Form();
        form->_layout = layout;
        form->_theme = theme;

        //Theme* theme = form->_theme;
        const char* styleName = formProperties->getString("style");
        form->initialize(theme->getStyle(styleName), formProperties);

        if (form->_autoWidth)
        {
            form->_bounds.width = Game::getInstance()->getWidth();
        }

        if (form->_autoHeight)
        {
            form->_bounds.height = Game::getInstance()->getHeight();
        }

        // Add all the controls to the form.
        form->addControls(theme, formProperties);

        SAFE_DELETE(properties);

        __forms.push_back(form);

        return form;
    }
开发者ID:Jaegermeiste,项目名称:GamePlay,代码行数:67,代码来源:Form.cpp


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