Added shortcut to toggle the grid.

This commit is contained in:
Leonardo Zide 2020-12-23 19:10:54 -08:00
parent 95bf7e43ff
commit 72bb41e8aa
6 changed files with 25 additions and 0 deletions

View file

@ -61,6 +61,7 @@ public:
quint32 mFadeStepsColor;
bool mHighlightNewParts;
quint32 mHighlightNewPartsColor;
bool mGridEnabled = true;
bool mDrawGridStuds;
quint32 mGridStudColor;
bool mDrawGridLines;

View file

@ -1137,6 +1137,13 @@ const lcCommand gCommands[] =
QT_TRANSLATE_NOOP("Status", "Toggle axis icon"),
""
},
// LC_VIEW_TOGGLE_GRID
{
QT_TRANSLATE_NOOP("Action", "View.ToggleGrid"),
QT_TRANSLATE_NOOP("Menu", "Grid"),
QT_TRANSLATE_NOOP("Status", "Toggle grid"),
""
},
// LC_VIEW_FADE_PREVIOUS_STEPS
{
QT_TRANSLATE_NOOP("Action", "View.FadePreviousSteps"),

View file

@ -178,6 +178,7 @@ enum lcCommandId
LC_VIEW_PROJECTION_LAST = LC_VIEW_PROJECTION_ORTHO,
LC_VIEW_TOGGLE_VIEW_SPHERE,
LC_VIEW_TOGGLE_AXIS_ICON,
LC_VIEW_TOGGLE_GRID,
LC_VIEW_FADE_PREVIOUS_STEPS,
LC_PIECE_INSERT,
LC_PIECE_DELETE,

View file

@ -1370,6 +1370,13 @@ void lcMainWindow::ToggleAxisIcon()
lcGLWidget::UpdateAllViews();
}
void lcMainWindow::ToggleGrid()
{
lcGetPreferences().mGridEnabled = !lcGetPreferences().mGridEnabled;
lcGLWidget::UpdateAllViews();
}
void lcMainWindow::ToggleFadePreviousSteps()
{
lcGetPreferences().mFadeSteps = !lcGetPreferences().mFadeSteps;
@ -2843,6 +2850,10 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
ToggleAxisIcon();
break;
case LC_VIEW_TOGGLE_GRID:
ToggleGrid();
break;
case LC_VIEW_FADE_PREVIOUS_STEPS:
ToggleFadePreviousSteps();
break;

View file

@ -301,6 +301,7 @@ public:
void SetSelectionMode(lcSelectionMode SelectionMode);
void ToggleViewSphere();
void ToggleAxisIcon();
void ToggleGrid();
void ToggleFadePreviousSteps();
void NewProject();

View file

@ -1390,9 +1390,13 @@ void View::DrawRotateViewOverlay()
void View::DrawGrid()
{
const lcPreferences& Preferences = lcGetPreferences();
if (!Preferences.mDrawGridStuds && !Preferences.mDrawGridLines)
return;
if (!Preferences.mGridEnabled)
return;
const int Spacing = lcMax(Preferences.mGridLineSpacing, 1);
int MinX, MaxX, MinY, MaxY;
lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX);