Logo Search packages:      
Sourcecode: cadencii version File versions  Download package

VsqEvent org::kbinani::cadencii::FormMain::getItemAtClickedPosition ( Point  mouse_position,
ByRef< Rectangle >  rect 
) [inline, private]

マウス位置におけるIDを返します。該当するIDが無ければnullを返します rectには、該当するIDがあればその画面上での形状を、該当するIDがなければ、 画面上で最も近かったIDの画面上での形状を返します

Parameters:
mouse_position
Returns:

Definition at line 1837 of file FormMain.cs.

References org::kbinani::cadencii::AppManager::getSelected(), org::kbinani::cadencii::AppManager::getVsqFile(), org::kbinani::vsq::VsqEvent::InternalID, org::kbinani::cadencii::AppManager::keyWidth, org::kbinani::cadencii::AppManager::mDrawObjects, and org::kbinani::vsq::VsqFile::Track.

        {
            rect.value = new Rectangle();
            int width = pictPianoRoll.getWidth();
            int height = pictPianoRoll.getHeight();
            int key_width = AppManager.keyWidth;

            // マウスが可視範囲になければ死ぬ
            if ( mouse_position.x < key_width || width < mouse_position.x )
            {
                return null;
            }
            if ( mouse_position.y < 0 || height < mouse_position.y )
            {
                return null;
            }

            // 表示中のトラック番号が異常だったら死ぬ
            int selected = AppManager.getSelected();
            if ( selected < 1 )
            {
                return null;
            }
            lock ( AppManager.mDrawObjects )
            {
                Vector<DrawObject> dobj_list = AppManager.mDrawObjects.get( selected - 1 );
                int count = dobj_list.size();
                int start_to_draw_x = controller.getStartToDrawX();
                int start_to_draw_y = controller.getStartToDrawY();
                VsqFileEx vsq = AppManager.getVsqFile();
                VsqTrack vsq_track = vsq.Track.get( selected );

                for ( int i = 0; i < count; i++ )
                {
                    DrawObject dobj = dobj_list.get( i );
                    int x = dobj.mRectangleInPixel.x + key_width - start_to_draw_x;
                    int y = dobj.mRectangleInPixel.y - start_to_draw_y;
                    if ( mouse_position.x < x )
                    {
                        continue;
                    }
                    if ( x + dobj.mRectangleInPixel.width < mouse_position.x )
                    {
                        continue;
                    }
                    if ( width < x )
                    {
                        break;
                    }
                    if ( mouse_position.y < y )
                    {
                        continue;
                    }
                    if ( y + dobj.mRectangleInPixel.height < mouse_position.y )
                    {
                        continue;
                    }
                    int internal_id = dobj.mInternalID;
                    for ( Iterator<VsqEvent> itr = vsq_track.getEventIterator(); itr.hasNext(); )
                    {
                        VsqEvent item = itr.next();
                        if ( item.InternalID == internal_id )
                        {
                            rect.value = new Rectangle( x, y, dobj.mRectangleInPixel.width, dobj.mRectangleInPixel.height );
                            return item;
                        }
                    }
                }
            }
            return null;
        }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index