From 2c6087938eb7abd4746c62c85e884d8aedff6667 Mon Sep 17 00:00:00 2001 From: derwin12 <4643499+derwin12@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:29:13 -0400 Subject: [PATCH] Add preference to hide/size the Group Crosshair #4885 --- xLights/ModelPreview.cpp | 28 +++++++++++++++++--- xLights/preferences/ViewSettingsPanel.cpp | 26 +++++++++++++++++-- xLights/preferences/ViewSettingsPanel.h | 3 +++ xLights/wxsmith/ViewSettingsPanel.wxs | 31 ++++++++++++++++++++++- xLights/xLightsMain.cpp | 10 ++++++++ xLights/xLightsMain.h | 7 +++-- 6 files changed, 97 insertions(+), 8 deletions(-) diff --git a/xLights/ModelPreview.cpp b/xLights/ModelPreview.cpp index 074c7082c..8099f3c14 100644 --- a/xLights/ModelPreview.cpp +++ b/xLights/ModelPreview.cpp @@ -674,6 +674,7 @@ void ModelPreview::DrawGroupCentre(float x, float y) { auto acc = solidProgram->getAccumulator(); int start = acc->getCount(); + int crosshairChoice = xlights->GetCrosshairSize(); float factor = 1; if (!Is3D()) { @@ -688,9 +689,30 @@ void ModelPreview::DrawGroupCentre(float x, float y) float center_width = std::max(CENTER_MARK_WIDTH, CENTER_MARK_WIDTH * zoom * rs); factor = center_width * 0.40; // adjust this for ideal size. factor = MIN(MAX(factor, 1), 10); // sanity check + switch (crosshairChoice) { + case 0: + factor *= 1.25; + break; + case 1: + // No changes needed + break; + case 2: + factor *= 0.5; + break; + case 3: + factor *= 0.20; + break; + case 4: + factor = 0; + break; + default: + break; + } + } + if (factor > 0) { + acc->AddRectAsTriangles(x - 20.5 * factor, y - 1.5 * factor, x + 20.5 * factor, y + 1.5 * factor, xlREDTRANSLUCENT); + acc->AddRectAsTriangles(x - 1.5 * factor, y - 20.5 * factor, x + 1.5 * factor, y + 20.5 * factor, xlREDTRANSLUCENT); } - acc->AddRectAsTriangles(x - 20.5 * factor, y - 1.5 * factor, x + 20.5 * factor, y + 1.5 * factor, xlREDTRANSLUCENT); - acc->AddRectAsTriangles(x - 1.5 * factor, y - 20.5 * factor, x + 1.5 * factor, y + 20.5 * factor, xlREDTRANSLUCENT); int end = acc->getCount(); solidProgram->addStep([start, end, this, acc](xlGraphicsContext* ctx) { @@ -1110,7 +1132,7 @@ float ModelPreview::GetCameraZoomForHandles() const int ModelPreview::GetHandleScale() const { - return xlights->GetModelHandleScale(); + return xlights->GetModelHandleSize(); } void ModelPreview::SetZoomDelta(float delta) diff --git a/xLights/preferences/ViewSettingsPanel.cpp b/xLights/preferences/ViewSettingsPanel.cpp index 5f86f6dbe..f327dd6f1 100755 --- a/xLights/preferences/ViewSettingsPanel.cpp +++ b/xLights/preferences/ViewSettingsPanel.cpp @@ -33,6 +33,7 @@ const wxWindowID ViewSettingsPanel::ID_CHECKBOX3 = wxNewId(); const wxWindowID ViewSettingsPanel::ID_CHOICE_TIMELINEZOOMING = wxNewId(); const wxWindowID ViewSettingsPanel::ID_CHECKBOX4 = wxNewId(); const wxWindowID ViewSettingsPanel::ID_CHECKBOX_ZoomMethod = wxNewId(); +const wxWindowID ViewSettingsPanel::ID_CHOICE_CROSSHAIRSIZE = wxNewId(); //*) BEGIN_EVENT_TABLE(ViewSettingsPanel, wxPanel) @@ -46,6 +47,7 @@ ViewSettingsPanel::ViewSettingsPanel(wxWindow* parent, xLightsFrame* f, wxWindow //(*Initialize(ViewSettingsPanel) wxGridBagSizer* GridBagSizer1; wxStaticText* StaticText1; + wxStaticText* StaticText2; wxStaticText* StaticText4; wxStaticText* StaticText5; wxStaticText* StaticText6; @@ -59,7 +61,7 @@ ViewSettingsPanel::ViewSettingsPanel(wxWindow* parent, xLightsFrame* f, wxWindow ToolIconSizeChoice->SetSelection( ToolIconSizeChoice->Append(_("Medium")) ); ToolIconSizeChoice->Append(_("Large")); ToolIconSizeChoice->Append(_("Extra Large")); - GridBagSizer1->Add(ToolIconSizeChoice, wxGBPosition(0, 1), wxDefaultSpan, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + GridBagSizer1->Add(ToolIconSizeChoice, wxGBPosition(0, 1), wxDefaultSpan, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); StaticText4 = new wxStaticText(this, wxID_ANY, _("Model Handle Size"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY")); GridBagSizer1->Add(StaticText4, wxGBPosition(1, 0), wxDefaultSpan, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); ModelHandleSizeChoice = new wxChoice(this, ID_CHOICE4, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE4")); @@ -95,6 +97,16 @@ ViewSettingsPanel::ViewSettingsPanel(wxWindow* parent, xLightsFrame* f, wxWindow CheckBox_ZoomMethod = new wxCheckBox(this, ID_CHECKBOX_ZoomMethod, _("Zoom To Cursor"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_ZoomMethod")); CheckBox_ZoomMethod->SetValue(true); GridBagSizer1->Add(CheckBox_ZoomMethod, wxGBPosition(8, 0), wxDefaultSpan, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); + StaticText2 = new wxStaticText(this, wxID_ANY, _("Group Center Crosshair Size"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY")); + GridBagSizer1->Add(StaticText2, wxGBPosition(9, 0), wxDefaultSpan, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); + CrosshairSizeChoice = new wxChoice(this, ID_CHOICE_CROSSHAIRSIZE, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE_CROSSHAIRSIZE")); + CrosshairSizeChoice->Append(_("Large")); + CrosshairSizeChoice->SetSelection( CrosshairSizeChoice->Append(_("Normal")) ); + CrosshairSizeChoice->Append(_("Small")); + CrosshairSizeChoice->Append(_("Tiny")); + CrosshairSizeChoice->Append(_("None")); + CrosshairSizeChoice->SetToolTip(_("Control the size of the crosshair for group centering")); + GridBagSizer1->Add(CrosshairSizeChoice, wxGBPosition(9, 1), wxDefaultSpan, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); SetSizer(GridBagSizer1); Connect(ID_CHOICE3, wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&ViewSettingsPanel::OnToolIconSizeChoiceSelect); @@ -106,6 +118,7 @@ ViewSettingsPanel::ViewSettingsPanel(wxWindow* parent, xLightsFrame* f, wxWindow Connect(ID_CHOICE_TIMELINEZOOMING, wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&ViewSettingsPanel::OnChoice_TimelineZoomingSelect); Connect(ID_CHECKBOX4, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&ViewSettingsPanel::OnPresetPreviewCheckBoxClick); Connect(ID_CHECKBOX_ZoomMethod, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&ViewSettingsPanel::OnCheckBox_ZoomMethodClick); + Connect(ID_CHOICE_CROSSHAIRSIZE, wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&ViewSettingsPanel::OnCrosshairSizeChoiceSelect); //*) #ifdef _MSC_VER @@ -129,7 +142,8 @@ bool ViewSettingsPanel::TransferDataToWindow() i = 0; } EffectAssistChoice->SetSelection(i); - ModelHandleSizeChoice->SetSelection(frame->ModelHandleSize()); + ModelHandleSizeChoice->SetSelection(frame->GetModelHandleSize()); + CrosshairSizeChoice->SetSelection(frame->GetCrosshairSize()); int ts = frame->ToolIconSize(); switch (ts) { case 48: @@ -154,6 +168,7 @@ bool ViewSettingsPanel::TransferDataToWindow() bool ViewSettingsPanel::TransferDataFromWindow() { frame->SetModelHandleSize(ModelHandleSizeChoice->GetSelection()); + frame->SetCrosshairSize(CrosshairSizeChoice->GetSelection()); frame->SetEffectAssistMode(EffectAssistChoice->GetSelection()); frame->SetPlayControlsOnPreview(PlayControlsCheckBox->IsChecked()); frame->SetAutoShowHousePreview(HousePreviewCheckBox->IsChecked()); @@ -257,3 +272,10 @@ void ViewSettingsPanel::OnCheckBox_ZoomMethodClick(wxCommandEvent& event) TransferDataFromWindow(); } } + +void ViewSettingsPanel::OnCrosshairSizeChoiceSelect(wxCommandEvent& event) +{ + if (wxPreferencesEditor::ShouldApplyChangesImmediately()) { + TransferDataFromWindow(); + } +} diff --git a/xLights/preferences/ViewSettingsPanel.h b/xLights/preferences/ViewSettingsPanel.h index efc1cfa07..b444cc871 100755 --- a/xLights/preferences/ViewSettingsPanel.h +++ b/xLights/preferences/ViewSettingsPanel.h @@ -33,6 +33,7 @@ class ViewSettingsPanel: public wxPanel wxCheckBox* HousePreviewCheckBox; wxCheckBox* PlayControlsCheckBox; wxChoice* Choice_TimelineZooming; + wxChoice* CrosshairSizeChoice; wxChoice* EffectAssistChoice; wxChoice* ModelHandleSizeChoice; wxChoice* ToolIconSizeChoice; @@ -53,6 +54,7 @@ class ViewSettingsPanel: public wxPanel static const wxWindowID ID_CHOICE_TIMELINEZOOMING; static const wxWindowID ID_CHECKBOX4; static const wxWindowID ID_CHECKBOX_ZoomMethod; + static const wxWindowID ID_CHOICE_CROSSHAIRSIZE; //*) private: @@ -70,6 +72,7 @@ class ViewSettingsPanel: public wxPanel void OnChoice_TimelineZoomingSelect(wxCommandEvent& event); void OnPresetPreviewCheckBoxClick(wxCommandEvent& event); void OnCheckBox_ZoomMethodClick(wxCommandEvent& event); + void OnCrosshairSizeChoiceSelect(wxCommandEvent& event); //*) DECLARE_EVENT_TABLE() diff --git a/xLights/wxsmith/ViewSettingsPanel.wxs b/xLights/wxsmith/ViewSettingsPanel.wxs index 5e0ade8f9..b054c08b6 100755 --- a/xLights/wxsmith/ViewSettingsPanel.wxs +++ b/xLights/wxsmith/ViewSettingsPanel.wxs @@ -27,7 +27,7 @@