示例#1
0
	///  mouse button
	//-----------------------------------------------------------------------------------------------
	void Slider::notifyMouse(Widget* _sender, int _left, int _top, MouseButton _id)
	{
		//eventMouseButtonPressed(this, _left, _top, _id);
		const IntPoint& p = mWidgetTrack->getParent()->getAbsolutePosition();
		const IntSize& s = mWidgetTrack->getParent()->getSize();
		int iTrack = mWidgetTrack->getSize().width;

		//  LMB set (in slider range)
		if (_id == MouseButton::Left)
		{
			float fx = (_left-iTrack/2 - p.left) / float(s.width - iTrack);
			//float fy = (_top - p.top) / float(s.height);
			fx = std::max(0.f, std::min(1.f, fx));
			
			mfValue = fx;
			eventValueChanged(this, mfValue);
			updateTrack();
		}
		else  /// RMB reset to default value
		if (_id == MouseButton::Right)
		{
			mfValue = mfDefault;
			eventValueChanged(this, mfValue);
			updateTrack();
		}
	}
示例#2
0
 void NumericEditBox::onKeyButtonPressed(MyGUI::KeyCode key, MyGUI::Char character)
 {
     if (key == MyGUI::KeyCode::ArrowUp)
     {
         setValue(std::min(mValue+1, mMaxValue));
         eventValueChanged(mValue);
     }
     else if (key == MyGUI::KeyCode::ArrowDown)
     {
         setValue(std::max(mValue-1, mMinValue));
         eventValueChanged(mValue);
     }
     else if (character == 0 || (character >= '0' && character <= '9'))
         Base::onKeyButtonPressed(key, character);
 }
示例#3
0
    void NumericEditBox::onEditTextChange(MyGUI::EditBox *sender)
    {
        std::string newCaption = sender->getCaption();
        if (newCaption.empty())
        {
            return;
        }

        try
        {
            mValue = std::stoi(newCaption);
            int capped = std::min(mMaxValue, std::max(mValue, mMinValue));
            if (capped != mValue)
            {
                mValue = capped;
                setCaption(MyGUI::utility::toString(mValue));
            }
        }
        catch (const std::invalid_argument&)
        {
            setCaption(MyGUI::utility::toString(mValue));
        }
        catch (const std::out_of_range&)
        {
            setCaption(MyGUI::utility::toString(mValue));
        }

        eventValueChanged(mValue);
    }
示例#4
0
///  mouse button
//-----------------------------------------------------------------------------------------------
void Slider::notifyMouse(Widget* _sender, int _left, int _top, MouseButton _id)
{
    //eventMouseButtonPressed(this, _left, _top, _id);
    //if (MouseButton::Left != _id)
    //	return;

    const IntPoint& p = mWidgetTrack->getParent()->getAbsolutePosition();
    const IntSize& s = mWidgetTrack->getParent()->getSize();
    int iTrack = mWidgetTrack->getSize().width;

    float fx = (_left-iTrack/2 - p.left) / float(s.width - iTrack);
    //float fy = (_top - p.top) / float(s.height);
    fx = std::max(0.f, std::min(1.f, fx));

    mfValue = fx;
    eventValueChanged(this, mfValue);
    updateTrack();
}
示例#5
0
	void Slider::notifyMouseWheel(Widget* _sender, int _rel)
	{
		mfValue = std::max(0.f, std::min(1.f, mfValue - _rel/120.f*0.5f * 0.125f ));
		eventValueChanged(this, mfValue);
		updateTrack();
	}
示例#6
0
void
CUISlider::onPush()
{
  eventValueChanged(m_pSlider->GetPos());
}