void S3DViewPanel::OnMouseEvent(wxMouseEvent& event)
{
	if( GLOBAL::ObserverCamera() == NULL )
		return;

	if( UpdateDrag(event) )
		return;

	if( event.LeftDown() )
	{
		SetFocus();

		SSelectionMgr* pSelectMgr = GLOBAL::SelectionMgr();
		if( pSelectMgr->GetTransformMode() == TRANSFORM_SELECT )
		{
			TYPE_ENTITY_LIST list;
			PickFromScreen( list, event.GetX(), event.GetY() );

			if( list.size() > 0 )
			{
				IEntity* pSelectedEntity = *list.begin();

				if( pSelectedEntity != pSelectMgr->First() )
				{
					pSelectMgr->SelectEntity( pSelectedEntity );
					GLOBAL::PropertyPanel()->SetObject( pSelectedEntity );
				}	
			}
		}
	}

	UpdateCamera(event);
}
void SimUIForm::FingerHandler::OnPenMove(Event *pevt) {
    m_x1 = pevt->x;
    m_y1 = pevt->y;

    if (m_state == FHS_DRAG) {
        UpdateDrag(pevt);
        return;
    }

    if (m_state == FHS_SELECT) {
        UpdateSelect(pevt);
        return;
    }

    if (m_state == FHS_HILIGHT) {
        if (CheckDragged(pevt, LARGE_DRAG)) {
            EnterDrag(pevt);
        }
    }
}
Exemple #3
0
/*
 * HandleMouseEvent - handle main editor mouse events
 */
vi_rc HandleMouseEvent( void )
{
    windim      win_x, win_y;
    window_id   wid;
    info        *cinfo;
    window      *w;
    int         i;
    bool        diff_word;
    vi_rc       rc;

    wid = GetMousePosInfo( &win_x, &win_y );
    if( BAD_ID( wid ) ) {
        return( ERR_NO_ERR );
    }
    w = WINDOW_FROM_ID( wid );
    if( !w->has_border ) {
        win_x += 1;
        win_y += 1;
    }

    if( dragThumb ) {
        if( LastMouseEvent == MOUSE_RELEASE ) {
            dragThumb = false;
        }
        if( wid != current_window_id ) {
            return( ERR_NO_ERR );
        }
        if( win_x == w->width - 1 ) {
            return( PositionToNewThumbPosition( w, win_y ) );
        }
        return( ERR_NO_ERR );
    }

    if( EditFlags.Dragging ) {
        if( LastMouseEvent == MOUSE_DRAG || LastMouseEvent == MOUSE_REPEAT ) {
            UpdateDrag( wid, win_x, win_y );
        } else {
            if( LastMouseEvent == MOUSE_PRESS_R || LastMouseEvent == MOUSE_PRESS ) {
                EditFlags.Dragging = false;
                if( LastMouseEvent == MOUSE_PRESS_R ) {
                    LastMouseEvent = MOUSE_RELEASE_R;
                }
            }
        }
    }

    if( LastMouseEvent == MOUSE_RELEASE_R || LastMouseEvent == MOUSE_DCLICK ) {
        if( wid == current_window_id && InsideWindow( wid, win_x, win_y ) ) {
            diff_word = (LastMouseEvent == MOUSE_DCLICK);
            if( GoToLineRelCurs( LeftTopPos.line + win_y - 1 ) ) {
                return( ERR_NO_ERR );
            }
            win_x += LeftTopPos.column;
            win_x = RealColumnOnCurrentLine( win_x );
            GoToColumnOnCurrentLine( win_x );
            if( diff_word ) {
                InitWordSearch( EditVars.WordAltDefn );
            }
            rc = DoSelectSelection( true );
            if( diff_word ) {
                InitWordSearch( EditVars.WordDefn );
            }
            return( rc );
        }
    }

    /*
     * all kinds of stuff to do if the button was pressed
     */
    if( LastMouseEvent == MOUSE_PRESS || LastMouseEvent == MOUSE_PRESS_R ) {
        if( wid != current_window_id ) {
            /*
             * swap to another window
             */
            for( cinfo = InfoHead; cinfo != NULL; cinfo = cinfo->next ) {
                if( wid == cinfo->current_window_id ) {
                    BringUpFile( cinfo, true );
                    break;
                }
            }
        }
        if( wid == current_window_id ) {
            if( !ShiftDown() ) {
                UnselectRegion();
            }
            if( w->has_border && LastMouseEvent == MOUSE_PRESS ) {
                /*
                 * clicked on menu for window
                 */
                if( win_x == 0 && win_y == 0 ) {
                    return( DoWindowGadgetMenu() );
                }

                /*
                 * check for resize request
                 */
                if( win_x == w->width - 1 && win_y == w->height - 1 ) {
                    return( ResizeCurrentWindowWithMouse() );
                }

                /*
                 * check for move request
                 */
                if( win_y == 0 ) {
                    return( MoveCurrentWindowWithMouse() );
                }
            }

            /*
             * check for locate cursor
             */
            if( InsideWindow( wid, win_x, win_y ) ) {
                if( ShiftDown() ) {
                    EditFlags.Dragging = true;
                }
                if( GoToLineRelCurs( LeftTopPos.line + win_y - 1 ) ) {
                    return( ERR_NO_ERR );
                }
                win_x += LeftTopPos.column;
                win_x = RealColumnOnCurrentLine( win_x );
                GoToColumnOnCurrentLine( win_x );
                if( ShiftDown() ) {
                    EditFlags.Dragging = false;
                } else {
                    InitSelectedRegion();
                }
                return( ERR_NO_ERR );
            }
        }
        if( EditFlags.Menus && wid == menu_window_id ) {
            i = GetMenuIdFromCoord( win_x - 1 );
            if( i >= 0 ) {
                return( SetToMenuId( i ) );
            }
        }
    }

    /*
     * allow double click to close window
     */
    if( wid == current_window_id && LastMouseEvent == MOUSE_DCLICK ) {
        if( win_y == 0 && win_x == 0 ) {
            return( NextFile() );
        }
    }

    /*
     * try to scroll screen
     */
    if( (LastMouseEvent == MOUSE_REPEAT || LastMouseEvent == MOUSE_DCLICK ||
         LastMouseEvent == MOUSE_PRESS) && w->has_border &&
        wid == current_window_id && win_x == w->width - 1 ) {
        if( win_y == w->height - 2 ) {
            return( MoveScreenDown() );
        }
        if( win_y == 1 ) {
            return( MoveScreenUp() );
        }
        /*
         * if we have gadgets, then scroll based on position of scroll
         * thumb. furthermore, if the thumb is selected, then begin
         * thumb dragging mode
         */
        if( w->has_gadgets ) {
            if( win_y == w->vert_scroll_pos ) {
                dragThumb = true;
                return( ERR_NO_ERR );
            } else if( win_y < w->vert_scroll_pos ) {
                return( MovePageUp() );
            } else {
                return( MovePageDown() );
            }
        } else {
            if( win_y < w->height / 2 ) {
                return( MovePageUp() );
            } else {
                return( MovePageDown() );
            }
        }
    }

    /*
     * start dragging
     */
    if( wid == current_window_id && (LastMouseEvent == MOUSE_DRAG ||
                                LastMouseEvent == MOUSE_DRAG_R ) &&
        InsideWindow( wid, win_x, win_y ) ) {
        EditFlags.Dragging = true;
        UpdateDrag( wid, win_x, win_y );
    }

    return( ERR_NO_ERR );

} /* HandleMouseEvent */
void GamePanel::UpdateElements(){
	if(dynamicElements.find("barPlaceHolder") != dynamicElements.end()){
		if(dynamicElements["barPlaceHolder"]->pressed)
			UpdateDrag();
		else
			dragOffset = sf::Vector2f(-1,-1);
	}
	for(MyPair x: backgroundElements){
		if(x.second->isSliced)
			x.second->Update(this);
		else
			x.second->Draw(this);
	}
	std::vector<Drawn*> remaining;
	std::vector<Drawn*> remaining2;
	int current = 1;
	for(MyPair x: staticElements){
	if(x.second->z == 0)
			x.second->Update(this);
	else
			remaining.push_back(x.second);
	}
	current = 1;
	while(remaining.size() > 0 || remaining2.size() > 0){
		    for(int x = 0; x < remaining.size(); x++){
			if(remaining[x]->z == (current))
				    remaining[x]->Update(this);
			else
				    remaining2.push_back(remaining[x]);
		    }
		    current++;
		    remaining.clear();
		    for(int x = 0; x < remaining2.size(); x++){
			if(remaining2[x]->z == (current))
				    remaining2[x]->Update(this);
			else
				    remaining.push_back(remaining2[x]);
		    };
			remaining2.clear();
		current++;
	}
	remaining.clear();
	remaining2.clear();
	for(MyPair x: dynamicElements){
	if(x.second->z == 0)
			x.second->Update(this);
	else
			remaining.push_back(x.second);
	}
	current = 1;
	while(remaining.size() > 0 || remaining2.size() > 0){
		    for(int x = 0; x < remaining.size(); x++){
			if(remaining[x]->z == (current))
				    remaining[x]->Update(this);
			else
				    remaining2.push_back(remaining[x]);
		    }
		    current++;
		    remaining.clear();
		    for(int x = 0; x < remaining2.size(); x++){
			if(remaining2[x]->z == (current))
				    remaining2[x]->Update(this);
			else
				    remaining.push_back(remaining2[x]);
		    };
			remaining2.clear();
		current++;
	}
	if(RClickMenu::currentPanel == this){
	    RClickMenu::Update(this);
	}
};
Exemple #5
0
void VisualTool<FeatureType>::OnMouseEvent(wxMouseEvent &event) {
	bool left_click = event.LeftDown();
	bool left_double = event.LeftDClick();
	shift_down = event.ShiftDown();
	ctrl_down = event.CmdDown();
	alt_down = event.AltDown();

	mouse_pos = event.GetPosition();

	if (event.Leaving()) {
		mouse_pos = Vector2D();
		parent->Render();
		return;
	}

	if (!dragging) {
		int max_layer = INT_MIN;
		active_feature = nullptr;
		for (auto& feature : features) {
			if (feature.IsMouseOver(mouse_pos) && feature.layer >= max_layer) {
				active_feature = &feature;
				max_layer = feature.layer;
			}
		}
	}

	if (dragging) {
		// continue drag
		if (event.LeftIsDown()) {
			for (auto sel : sel_features)
				sel->UpdateDrag(mouse_pos - drag_start, shift_down);
			for (auto sel : sel_features)
				UpdateDrag(sel);
			Commit();
		}
		// end drag
		else {
			dragging = false;

			// mouse didn't move, fiddle with selection
			if (active_feature && !active_feature->HasMoved()) {
				// Don't deselect stuff that was selected in this click's mousedown event
				if (!sel_changed) {
					if (ctrl_down)
						RemoveSelection(active_feature);
					else
						SetSelection(active_feature, true);
				}
			}

			active_feature = nullptr;
			parent->ReleaseMouse();
			parent->SetFocus();
		}
	}
	else if (holding) {
		if (!event.LeftIsDown()) {
			holding = false;

			parent->ReleaseMouse();
			parent->SetFocus();
		}

		UpdateHold();
		Commit();

	}
	else if (left_click) {
		drag_start = mouse_pos;

		// start drag
		if (active_feature) {
			if (!sel_features.count(active_feature)) {
				sel_changed = true;
				SetSelection(active_feature, !ctrl_down);
			}
			else
				sel_changed = false;

			if (active_feature->line)
				c->selectionController->SetActiveLine(active_feature->line);

			if (InitializeDrag(active_feature)) {
				for (auto sel : sel_features) sel->StartDrag();
				dragging = true;
				parent->CaptureMouse();
			}
		}
		// start hold
		else {
			if (!alt_down && features.size() > 1) {
				sel_features.clear();
				c->selectionController->SetSelectedSet({ c->selectionController->GetActiveLine() });
			}
			if (active_line && InitializeHold()) {
				holding = true;
				parent->CaptureMouse();
			}
		}
	}

	if (active_line && left_double)
		OnDoubleClick();

	parent->Render();

	// Only coalesce the changes made in a single drag
	if (!event.LeftIsDown())
		commit_id = -1;
}