mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Added Shift+LMB shortcut to remove selection.
This commit is contained in:
parent
3d5587cbd0
commit
696189e171
8 changed files with 79 additions and 27 deletions
|
@ -10,7 +10,8 @@ enum LC_CURSOR_TYPE
|
|||
LC_CURSOR_SPOTLIGHT,
|
||||
LC_CURSOR_CAMERA,
|
||||
LC_CURSOR_SELECT,
|
||||
LC_CURSOR_SELECT_GROUP,
|
||||
LC_CURSOR_SELECT_ADD,
|
||||
LC_CURSOR_SELECT_REMOVE,
|
||||
LC_CURSOR_MOVE,
|
||||
LC_CURSOR_ROTATE,
|
||||
LC_CURSOR_ROTATEX,
|
||||
|
|
|
@ -3326,7 +3326,7 @@ void lcModel::FocusOrDeselectObject(const lcObjectSection& ObjectSection)
|
|||
Object->SetFocused(Section, true);
|
||||
}
|
||||
else
|
||||
Object->SetSelected(Section, false);
|
||||
Object->SetFocused(Section, false);
|
||||
|
||||
bool IsSelected = Object->IsSelected();
|
||||
|
||||
|
@ -3386,7 +3386,7 @@ void lcModel::AddToSelection(const lcArray<lcObject*>& Objects)
|
|||
lcObject* Object = Objects[ObjectIdx];
|
||||
|
||||
bool WasSelected = Object->IsSelected();
|
||||
Object->SetSelected(Objects[ObjectIdx]);
|
||||
Object->SetSelected(true);
|
||||
|
||||
if (!WasSelected && Object->GetType() == LC_OBJECT_PIECE)
|
||||
SelectGroup(((lcPiece*)Object)->GetTopGroup(), true);
|
||||
|
@ -3396,6 +3396,39 @@ void lcModel::AddToSelection(const lcArray<lcObject*>& Objects)
|
|||
gMainWindow->UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::RemoveFromSelection(const lcArray<lcObject*>& Objects)
|
||||
{
|
||||
for (int ObjectIdx = 0; ObjectIdx < Objects.GetSize(); ObjectIdx++)
|
||||
{
|
||||
lcObject* Object = Objects[ObjectIdx];
|
||||
|
||||
bool WasSelected = Object->IsSelected();
|
||||
Object->SetSelected(false);
|
||||
|
||||
if (WasSelected && Object->GetType() == LC_OBJECT_PIECE)
|
||||
SelectGroup(((lcPiece*)Object)->GetTopGroup(), false);
|
||||
}
|
||||
|
||||
gMainWindow->UpdateSelectedObjects(true);
|
||||
gMainWindow->UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::RemoveFromSelection(const lcObjectSection& ObjectSection)
|
||||
{
|
||||
lcObject* Object = ObjectSection.Object;
|
||||
|
||||
if (!Object)
|
||||
return;
|
||||
|
||||
if (Object->IsFocused(ObjectSection.Section))
|
||||
Object->SetSelected(ObjectSection.Section, false);
|
||||
else
|
||||
Object->SetSelected(false);
|
||||
|
||||
gMainWindow->UpdateSelectedObjects(true);
|
||||
gMainWindow->UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::SelectAllPieces()
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
|
|
|
@ -253,6 +253,8 @@ public:
|
|||
void ClearSelectionAndSetFocus(const lcObjectSection& ObjectSection);
|
||||
void SetSelectionAndFocus(const lcArray<lcObject*>& Selection, lcObject* Focus, lcuint32 Section);
|
||||
void AddToSelection(const lcArray<lcObject*>& Objects);
|
||||
void RemoveFromSelection(const lcArray<lcObject*>& Objects);
|
||||
void RemoveFromSelection(const lcObjectSection& ObjectSection);
|
||||
void SelectAllPieces();
|
||||
void InvertSelection();
|
||||
|
||||
|
|
|
@ -349,8 +349,14 @@ lcMatrix44 View::GetTileProjectionMatrix(int CurrentRow, int CurrentColumn, int
|
|||
|
||||
LC_CURSOR_TYPE View::GetCursor() const
|
||||
{
|
||||
if (mTrackTool == LC_TRACKTOOL_SELECT && (mInputState.Modifiers & Qt::ControlModifier))
|
||||
return LC_CURSOR_SELECT_GROUP;
|
||||
if (mTrackTool == LC_TRACKTOOL_SELECT)
|
||||
{
|
||||
if (mInputState.Modifiers & Qt::ControlModifier)
|
||||
return LC_CURSOR_SELECT_ADD;
|
||||
|
||||
if (mInputState.Modifiers & Qt::ShiftModifier)
|
||||
return LC_CURSOR_SELECT_REMOVE;
|
||||
}
|
||||
|
||||
const LC_CURSOR_TYPE CursorFromTrackTool[] =
|
||||
{
|
||||
|
@ -1997,7 +2003,7 @@ void View::UpdateTrackTool()
|
|||
}
|
||||
}
|
||||
|
||||
if (CurrentTool == LC_TOOL_SELECT && NewTrackTool == LC_TRACKTOOL_SELECT)
|
||||
if (CurrentTool == LC_TOOL_SELECT && NewTrackTool == LC_TRACKTOOL_SELECT && mInputState.Modifiers == Qt::NoModifier)
|
||||
{
|
||||
lcObjectSection ObjectSection = FindObjectUnderPointer(false, false);
|
||||
lcObject* Object = ObjectSection.Object;
|
||||
|
@ -2405,6 +2411,8 @@ void View::StopTracking(bool Accept)
|
|||
|
||||
if (mInputState.Modifiers & Qt::ControlModifier)
|
||||
mModel->AddToSelection(Objects);
|
||||
else if (mInputState.Modifiers & Qt::ShiftModifier)
|
||||
mModel->RemoveFromSelection(Objects);
|
||||
else
|
||||
mModel->SetSelectionAndFocus(Objects, nullptr, 0);
|
||||
}
|
||||
|
@ -2519,6 +2527,8 @@ void View::OnButtonDown(lcTrackButton TrackButton)
|
|||
|
||||
if (mInputState.Modifiers & Qt::ControlModifier)
|
||||
mModel->FocusOrDeselectObject(ObjectSection);
|
||||
else if (mInputState.Modifiers & Qt::ShiftModifier)
|
||||
mModel->RemoveFromSelection(ObjectSection);
|
||||
else
|
||||
mModel->ClearSelectionAndSetFocus(ObjectSection);
|
||||
|
||||
|
@ -2606,6 +2616,8 @@ void View::OnLeftButtonDoubleClick()
|
|||
|
||||
if (mInputState.Modifiers & Qt::ControlModifier)
|
||||
mModel->FocusOrDeselectObject(ObjectSection);
|
||||
else if (mInputState.Modifiers & Qt::ShiftModifier)
|
||||
mModel->RemoveFromSelection(ObjectSection);
|
||||
else
|
||||
mModel->ClearSelectionAndSetFocus(ObjectSection);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,8 @@
|
|||
<file>resources/cursor_rotatey.png</file>
|
||||
<file>resources/cursor_rotate_view.png</file>
|
||||
<file>resources/cursor_select.png</file>
|
||||
<file>resources/cursor_select_multiple.png</file>
|
||||
<file>resources/cursor_select_add.png</file>
|
||||
<file>resources/cursor_select_remove.png</file>
|
||||
<file>resources/cursor_spotlight.png</file>
|
||||
<file>resources/cursor_zoom.png</file>
|
||||
<file>resources/cursor_zoom_region.png</file>
|
||||
|
|
|
@ -49,7 +49,8 @@ void lcGLWidget::SetCursor(LC_CURSOR_TYPE CursorType)
|
|||
{ 7, 10, ":/resources/cursor_spotlight" }, // LC_CURSOR_SPOTLIGHT
|
||||
{ 15, 9, ":/resources/cursor_camera" }, // LC_CURSOR_CAMERA
|
||||
{ 0, 2, ":/resources/cursor_select" }, // LC_CURSOR_SELECT
|
||||
{ 0, 2, ":/resources/cursor_select_multiple" }, // LC_CURSOR_SELECT_GROUP
|
||||
{ 0, 2, ":/resources/cursor_select_add" }, // LC_CURSOR_SELECT_ADD
|
||||
{ 0, 2, ":/resources/cursor_select_remove" }, // LC_CURSOR_SELECT_REMOVE
|
||||
{ 15, 15, ":/resources/cursor_move" }, // LC_CURSOR_MOVE
|
||||
{ 15, 15, ":/resources/cursor_rotate" }, // LC_CURSOR_ROTATE
|
||||
{ 15, 15, ":/resources/cursor_rotatex" }, // LC_CURSOR_ROTATEX
|
||||
|
@ -63,6 +64,8 @@ void lcGLWidget::SetCursor(LC_CURSOR_TYPE CursorType)
|
|||
{ 15, 15, ":/resources/cursor_rotate_view" }, // LC_CURSOR_ROTATE_VIEW
|
||||
};
|
||||
|
||||
static_assert(sizeof(Cursors) / sizeof(Cursors[0]) == LC_CURSOR_COUNT, "Array size mismatch");
|
||||
|
||||
QGLWidget* widget = (QGLWidget*)mWidget;
|
||||
|
||||
if (CursorType != LC_CURSOR_DEFAULT && CursorType < LC_CURSOR_COUNT)
|
||||
|
@ -171,7 +174,7 @@ void lcQGLWidget::paintGL()
|
|||
|
||||
void lcQGLWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (isView && event->key() == Qt::Key_Control)
|
||||
if (isView && (event->key() == Qt::Key_Control || event->key() == Qt::Key_Shift))
|
||||
{
|
||||
widget->mInputState.Modifiers = event->modifiers();
|
||||
widget->OnUpdateCursor();
|
||||
|
@ -182,7 +185,7 @@ void lcQGLWidget::keyPressEvent(QKeyEvent *event)
|
|||
|
||||
void lcQGLWidget::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
if (isView && event->key() == Qt::Key_Control)
|
||||
if (isView && (event->key() == Qt::Key_Control || event->key() == Qt::Key_Shift))
|
||||
{
|
||||
widget->mInputState.Modifiers = event->modifiers();
|
||||
widget->OnUpdateCursor();
|
||||
|
|
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 369 B |
BIN
resources/cursor_select_remove.png
Normal file
BIN
resources/cursor_select_remove.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 189 B |
Loading…
Reference in a new issue