本文整理汇总了C++中ci::app::MouseEvent类的典型用法代码示例。如果您正苦于以下问题:C++ MouseEvent类的具体用法?C++ MouseEvent怎么用?C++ MouseEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MouseEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseDownInternal
bool XRect::mouseDownInternal( ci::app::MouseEvent event )
{
bool hit = hitTest( event.getPos() );
if (hit && mScript)
mScript->call("mouseDown", event.getPos().x, event.getPos().y);
return hit;
}
示例2: mouseDown
void GraphNodeHandler::mouseDown(ci::app::MouseEvent &event)
{
if (glm::length(*position - ci::vec2(event.getPos())) < size)
{
if (event.isAltDown())
{
if (selection == Selection::addEdge)
{
selection = Selection::none;
}
else
{
selection = Selection::addEdge;
selectedInFrame = ci::app::getElapsedFrames();
}
}
else
{
selection = Selection::move;
}
event.setHandled(true);
}
else
{
if (selection == Selection::move)
selection = Selection::none;
}
}
示例3: mouseWheel
void ColorPicker::mouseWheel( ci::app::MouseEvent &event )
{
if( isHit( event.getPos() ) && !mHit ) {
mColor.a -= event.getWheelIncrement() * mFormat.mSensitivity;
mColor.a = std::max( std::min( mColor.a, mFormat.mAlphaLimits.y ), mFormat.mAlphaLimits.x );
updateColorRef();
updateLabel();
setNeedsDisplay();
if( (int)mTrigger & (int)Trigger::CHANGE ) {
trigger();
}
}
else if( mHit ) {
vec3 color = mColor.get( mFormat.mColorModel );
color.z -= event.getWheelIncrement() * mFormat.mSensitivity;
color.z = std::max( std::min( color.z, 1.0f ), 0.0f );
mColor.set( mFormat.mColorModel, vec4( color.x, color.y, color.z, mColor.a ) );
updateColorRef();
updateLabel();
setNeedsDisplay();
if( (int)mTrigger & (int)Trigger::CHANGE ) {
trigger();
}
}
}
示例4: mouseUp
void MultiSlider::mouseUp( ci::app::MouseEvent &event )
{
if( mHit ) {
#ifdef CINDER_COCOA_TOUCH
setState( State::NORMAL );
#else
if( isHit( event.getPos() ) ) {
setState( State::OVER );
std::string newKey = getKey( event.getPos() );
if( newKey != mHoverKey ) {
mHoverKey = newKey;
changeState();
setNeedsDisplay();
}
}
else {
setState( State::NORMAL );
}
#endif
if( (int)mTrigger & (int)Trigger::END ) {
trigger();
}
}
mHitKey = "";
mHit = false;
}
示例5: mouseDrag
bool Monitor::mouseDrag( ci::app::MouseEvent event )
{
switch( mMouseState )
{
case MS_NOTHING :
break;
case MS_MOVE :
{
Vec2i diff = event.getPos() - mPosMouseDrag;
mArea += diff;
mPosMouseDrag = event.getPos();
}
break;
case MS_RESIZE :
{
Vec2i diff = event.getPos() - mPosMouseDrag;
int width = math<int>::max( mArea.getWidth() + diff.x, mMinWidth );
int height = math<int>::max( mArea.getHeight() + diff.y, mMinHeight );
mArea.x2 = mArea.x1 + width;
mArea.y2 = mArea.y1 + height;
mPosMouseDrag = event.getPos();
}
break;
}
return mMouseState != MS_NOTHING;
}
示例6: mouseDrag
void RibbonPaint::mouseDrag( ci::app::MouseEvent event )
{
if(_state != kStateNormal) return;
// Not drawing lines, clear the frame
if(_drawLines == false)
ci::gl::clear( _clearColor );
// invisible if shift is helpd down
if( event.isShiftDown() )
{
// Store it the first time
if(_alphaWhenDrawing > 0) {
_oldAlphaWhenDrawing = _alphaWhenDrawing;
}
// make zero until they let go, or mouse up
_alphaWhenDrawing = 0;
} else {
_alphaWhenDrawing = _oldAlphaWhenDrawing;
}
// start drawing lines
_mousePosition = event.getPos();
_drawLines = true;
}
示例7: onMouseDown
void PretzelRoot::onMouseDown(ci::app::MouseEvent &event)
{
PretzelGui *pg;
// only click the top-most gui
for( auto it = mGuiList.begin(); it!=mGuiList.end(); ++it){
pg = *it;
if( pg->getGlobalBounds().contains( event.getPos() ) ){
pg->mouseDown( event.getPos() );
break;
}
}
// If this gui isn't on top, do z sorting to bring it up
if( pg != mGuiList[0] ){
for( auto it = mGuiList.begin(); it!=mGuiList.end(); ){
if( *it == pg ){
it = mGuiList.erase(it);
}else{
++it;
}
}
mGuiList.push_front(pg);
}
}
示例8: mouseDrag
void GraphNodeHandler::mouseDrag(ci::app::MouseEvent &event)
{
if (selection == Selection::move)
{
*position = event.getPos();
changed = true;
}
event.setHandled(selection == Selection::move);
}
示例9: mouseUp
void GraphNodeHandler::mouseUp(ci::app::MouseEvent &event)
{
if (selection == Selection::move)
{
selection = Selection::none;
event.setHandled(true);
return;
}
event.setHandled(false);
}
示例10: mouseDrag
bool Camera::mouseDrag(ci::app::MouseEvent m_event) {
/*
if (draw_interface_)
return false;
*/
cam_->mouseDrag(m_event.getPos(), m_event.isLeftDown(), m_event.isMiddleDown(),
m_event.isRightDown());
return false;
}
示例11: ImGui_ImplCinder_MouseButtonCallback
void ImGui_ImplCinder_MouseButtonCallback(ci::app::MouseEvent e, bool isDown)
{
ImGui_ImplCinder_MouseState state = isDown ? MouseState_Pressed : MouseState_Released;
if (e.isLeft())
g_MousePressed[0] = state;
else if (e.isRight())
g_MousePressed[1] = state;
else if (e.isMiddle())
g_MousePressed[2] = state;
}
示例12: signbit
void DialerT<T>::mouseWheel( ci::app::MouseEvent &event )
{
if( isHit( event.getPos() ) )
{
T value = *mValueRef + mZoneMultiplier*( signbit( event.getWheelIncrement() ) > 0 ? 1.0 : -1.0 );
setValue( max( min( value, mMax ), mMin ) );
if( (int)mTrigger & (int)Trigger::CHANGE )
{
trigger();
}
}
}
示例13: mouseDrag
void ColorPicker::mouseDrag( ci::app::MouseEvent &event )
{
if( mHit ) {
vec2 pt = event.getPos();
vec3 color = mColor.get( mFormat.mColorModel );
if( mFormat.mRelative ) {
//COMMON
vec2 delta = pt - mHitPoint;
delta *= mFormat.mSensitivity;
color.x += delta.x;
//SPECIFIC
if( mFormat.mColorModel == ColorModel::CM_HSV ) {
color.x = color.x > 1.0 ? 0.0 : color.x < 0.0 ? 1.0 : color.x;
color.y -= delta.y;
}
else {
color.x = std::max( std::min( color.x, 1.0f ), 0.0f );
color.y += delta.y;
}
}
else {
//COMMON
color.x = (float)event.getX() / (float)app::getWindow()->getWidth();
//SPECIFIC
if( mFormat.mColorModel == ColorModel::CM_HSV ) {
color.x = color.x > 1.0 ? 0.0 : color.x < 0.0 ? 1.0 : color.x;
color.y = 1.0 - ( (float)event.getY() / (float)app::getWindow()->getHeight() );
}
else {
color.x = std::max( std::min( color.x, 1.0f ), 0.0f );
color.y = (float)event.getY() / (float)app::getWindow()->getHeight();
}
}
color.y = std::max( std::min( color.y, 1.0f ), 0.0f );
mColor.set( mFormat.mColorModel, vec4( color.x, color.y, color.z, mColor.a ) );
mHitPoint = pt;
updateColorRef();
updateLabel();
setNeedsDisplay();
setState( State::DOWN );
if( (int)mTrigger & (int)Trigger::CHANGE ) {
trigger();
}
}
else {
setState( State::NORMAL );
}
View::mouseDrag( event );
}
示例14: getHitPercent
void SliderT<T>::input( ci::app::MouseEvent &event )
{
vec2 hp = getHitPercent( event.getPos() );
hp.x = min( max( hp.x, 0.0f ), 1.0f );
float value = lmap<double>( hp.x, 0.0, 1.0, mMin, mMax );
if( mFormat.mSticky || event.isMetaDown() )
{
value = ceil( value / mFormat.mStickyValue ) * mFormat.mStickyValue;
}
setValue( value );
}
示例15: mouseUp
void Game::mouseUp(ci::app::MouseEvent e)
{
int button;
if (e.isLeft())
button = Button::LEFT;
else if (e.isRight())
button = Button::RIGHT;
else if (e.isMiddle())
button = Button::MIDDLE;
else
return;
mEngine.mouseEvent(false, button);
}