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 ); }
bool Cinder2DInteractItem::detect_click_selection(ci::app::MouseEvent mouse_event) { if (!detect_selection_) return false; Rect bounds = bounding_rect(); bounds *= scale().x; bounds += ci::Vec2f(position().x, position().y); if (bounds.isInside(ci::Vec2f(mouse_event.getX(), mouse_event.getY()))) { activate(Client::user_identity()); return true; } return false; }
void ImGui_ImplCinder_MouseMoveCallback(ci::app::MouseEvent e) { g_MousePos.x = e.getX(); g_MousePos.y = e.getY(); }