本文整理汇总了C++中ci::app::MouseEvent::isMetaDown方法的典型用法代码示例。如果您正苦于以下问题:C++ MouseEvent::isMetaDown方法的具体用法?C++ MouseEvent::isMetaDown怎么用?C++ MouseEvent::isMetaDown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ci::app::MouseEvent
的用法示例。
在下文中一共展示了MouseEvent::isMetaDown方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: input
void MultiSlider::input( ci::app::MouseEvent &event )
{
vec2 pt = event.getPos();
vec2 hp = getHitPercent( event.getPos() );
hp.x = std::min( std::max( hp.x, 0.0f ), 1.0f );
if( event.isMetaDown() ) {
setValue( hp.x );
return;
}
if( mHitKey == "" ) {
mHitKey = getKey( pt );
mHoverKey = "";
}
if( mHitKey != "" ) {
setValue( mHitKey, lmap<double>( hp.x, 0.0, 1.0, mDataMap[mHitKey]->mMin, mDataMap[mHitKey]->mMax ) );
}
}
示例3: input
void BSplineEditor::input( const ci::app::MouseEvent &event )
{
vec2 hp = getHitPercent( event.getPos() );
hp.x = std::min( std::max( hp.x, 0.0f ), 1.0f );
hp.y = std::min( std::max( hp.y, 0.0f ), 1.0f );
hp = vec2( lmap<float>( hp.x, 0.0, 1.0, mFormat.mMin.x, mFormat.mMax.x ),
lmap<float>( hp.y, 0.0, 1.0, mFormat.mMin.y, mFormat.mMax.y ) );
if( event.isMetaDown() || mFormat.mSticky ) {
if( mFormat.mGrid ) {
float w = mHitRect.getWidth();
float h = mHitRect.getHeight();
float sv = h > w ? h : w;
sv = mFormat.mGridSize / sv;
hp.x = ceil( hp.x / sv ) * sv;
hp.y = ceil( hp.y / sv ) * sv;
}
else {
hp.x = ceil( hp.x / mFormat.mStickyValue ) * mFormat.mStickyValue;
hp.y = ceil( hp.y / mFormat.mStickyValue ) * mFormat.mStickyValue;
}
}
if( getState() == State::NORMAL || getState() == State::OVER ) {
mHitIndex = -1;
}
else if( mHitIndex == -1 ) {
float distance = 100000.0;
int index = -1;
std::map<float, int> distMap;
int totalCtrlPts = mControlPoints.size();
bool addToEnd = true;
for( int i = 0; i < totalCtrlPts; i++ ) {
float len = length( hp - mControlPoints[i] );
distMap[len] = i;
if( len < distance ) {
distance = len;
index = i;
}
}
if( distance < ( length( mFormat.mMax - mFormat.mMin ) * mFormat.mThreshold ) ) {
mHitIndex = index;
if( ( event.isRight() || event.isMetaDown() ) ) {
mControlPoints.erase( mControlPoints.begin() + mHitIndex );
updateSplineRef();
mHitIndex = -1;
}
addToEnd = false;
}
else {
float thres = 0.1f * length( mFormat.mMax - mFormat.mMin );
float tpp = 1.0f / float( totalCtrlPts - 1.0f );
float bestDistance = 1000000;
float bestTime = -1;
int bestIndex = -1;
if( mValid ) {
for( auto &it : distMap ) {
int id = it.second;
int bid = ( id > 0 ) ? ( id - 1 ) : id;
int eid = ( ( id + 1 ) == totalCtrlPts ) ? id : ( id + 1 );
if( bid == eid ) {
continue;
}
float startTime = bid * tpp;
float endTime = eid * tpp;
for( float t = startTime; t <= endTime; t += 0.01f ) {
vec2 pt = mSplineRef->getPosition( t );
float d = length( hp - pt );
if( d < bestDistance ) {
bestDistance = d;
bestTime = t;
bestIndex = id;
}
}
if( bestDistance < thres ) {
int insertIndex = bid + 1;
if( bestTime > ( id * tpp ) ) {
insertIndex = id + 1;
}
mControlPoints.insert( mControlPoints.begin() + insertIndex, hp );
updateSplineRef();
addToEnd = false;
break;
}
}
}
}
if( addToEnd ) {
mHitIndex = mControlPoints.size();
mControlPoints.push_back( hp );
updateSplineRef();
}
}
else {
//.........这里部分代码省略.........