Ejemplo n.º 1
0
void Slider::init()
{
    mAllowLogic = false;
    setFocusable(true);
    setFrameSize(1);

    addMouseListener(this);
    addKeyListener(this);

    setFrameSize(0);

    // Load resources
    if (mInstances == 0)
    {
        if (theme)
        {
            for (int mode = 0; mode < 2; mode ++)
                theme->loadRect(buttons[mode], data[mode], "slider.xml", 0, 8);
        }
        updateAlpha();
    }

    mInstances++;

    if (buttons[0].grid[HGRIP])
        setMarkerLength(buttons[0].grid[HGRIP]->getWidth());
}
Ejemplo n.º 2
0
    Slider::Slider(double scaleStart, double scaleEnd)
    {
        mDragged = false;

        mScaleStart = scaleStart;
        mScaleEnd = scaleEnd;

        setFocusable(true);
        setFrameSize(1);
        setOrientation(HORIZONTAL);
        setValue(scaleStart);
        setStepLength((scaleEnd  - scaleStart)/ 10);
        setMarkerLength(10);

        addMouseListener(this);
        addKeyListener(this);
    }
Ejemplo n.º 3
0
    Slider::Slider(double scaleEnd)
    {
        mDragged = false;

        mScaleStart = 0;
        mScaleEnd = scaleEnd;

        setFocusable(true);
        setFrameSize(1);
        setOrientation(Horizontal);
        setValue(0);
        setStepLength(scaleEnd / 10);
        setMarkerLength(10);

        addMouseListener(this);
        addKeyListener(this);
    }
Ejemplo n.º 4
0
    Slider::Slider(double scaleEnd)
    {
        mMouseDrag = false;


        mScaleStart = 0;
        mScaleEnd = scaleEnd;

        setFocusable(true);
        setBorderSize(1);
        setOrientation(HORIZONTAL);
        setValue(0);
        setStepLength(scaleEnd / 10);
        setMarkerLength(10);

        addMouseListener(this);
        addKeyListener(this);
    }
Ejemplo n.º 5
0
void Slider::init()
{
    int x, y, w, h,o1,o2;
    setFrameSize(0);

    // Load resources
    if (mInstances == 0)
    {
        mAlpha = config.getValue("guialpha", 0.8);

        ResourceManager *resman = ResourceManager::getInstance();
        Image *slider = resman->getImage("graphics/gui/slider.png");
        Image *highlight = resman->getImage("graphics/gui/sliderhi.png");

        x = 0; y = 0;
        w = 15; h = 6;
        o1 = 4; o2 = 11;
        hStart = slider->getSubImage(x, y, o1 - x, h);
        hStartHi = highlight->getSubImage(x, y, o1 - x, h);
        hMid = slider->getSubImage(o1, y, o2 - o1, h);
        hMidHi = highlight->getSubImage(o1, y, o2 - o1, h);
        hEnd = slider->getSubImage(o2, y, w - o2 + x, h);
        hEndHi = highlight->getSubImage(o2, y, w - o2 + x, h);

        x = 6; y = 8;
        w = 9; h = 10;
        hGrip = slider->getSubImage(x, y, w, h);
        hGripHi = highlight->getSubImage(x, y, w, h);

        x = 0; y = 6;
        w = 6; h = 21;
        o1 = 10; o2 = 18;
        vStart = slider->getSubImage(x, y, w, o1 - y);
        vStartHi = highlight->getSubImage(x, y, w, o1 - y);
        vMid = slider->getSubImage(x, o1, w, o2 - o1);
        vMidHi = highlight->getSubImage(x, o1, w, o2 - o1);
        vEnd = slider->getSubImage(x, o2, w, h - o2 + y);
        vEndHi = highlight->getSubImage(x, o2, w, h - o2 + y);

        x = 6; y = 8;
        w = 9; h = 10;
        vGrip = slider->getSubImage(x, y, w, h);
        vGripHi = highlight->getSubImage(x, y, w, h);

        slider->decRef();
        highlight->decRef();

        hStart->setAlpha(mAlpha);
        hStartHi->setAlpha(mAlpha);
        hMid->setAlpha(mAlpha);
        hMidHi->setAlpha(mAlpha);
        hEnd->setAlpha(mAlpha);
        hEndHi->setAlpha(mAlpha);
        hGrip->setAlpha(mAlpha);
        hGripHi->setAlpha(mAlpha);

        vStart->setAlpha(mAlpha);
        vStartHi->setAlpha(mAlpha);
        vMid->setAlpha(mAlpha);
        vMidHi->setAlpha(mAlpha);
        vEnd->setAlpha(mAlpha);
        vEndHi->setAlpha(mAlpha);
        vGrip->setAlpha(mAlpha);
        vGripHi->setAlpha(mAlpha);

        mConfigListener = new SliderConfigListener(this);
        config.addListener("guialpha", mConfigListener);
    }

    mProtFocusListener = new ProtectedFocusListener();

    addFocusListener(mProtFocusListener);

    mProtFocusListener->blockKey(SDLK_LEFT);
    mProtFocusListener->blockKey(SDLK_RIGHT);
    mProtFocusListener->blockKey(SDLK_UP);
    mProtFocusListener->blockKey(SDLK_DOWN);

    mInstances++;

    setMarkerLength(hGrip->getWidth());
}