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 @@ 1 0 - wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL 5 @@ -169,6 +169,35 @@ 5 + + + + + 0 + 9 + wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL + 5 + + + + + + Large + Normal + Small + Tiny + None + + 1 + Control the size of the crosshair for group centering + + + 1 + 9 + wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL + 5 + + diff --git a/xLights/xLightsMain.cpp b/xLights/xLightsMain.cpp index 92e02947b..fd5265ff9 100755 --- a/xLights/xLightsMain.cpp +++ b/xLights/xLightsMain.cpp @@ -1489,6 +1489,7 @@ xLightsFrame::xLightsFrame(wxWindow* parent, int ab, wxWindowID id, bool renderO mAltBackupDir = ""; mIconSize = 16; _modelHandleSize = 1; + _crosshairSize = 1; _acParm1Intensity = 100; _acParm1RampUp = 0; @@ -1743,6 +1744,9 @@ xLightsFrame::xLightsFrame(wxWindow* parent, int ab, wxWindowID id, bool renderO config->Read("xLightsModelHandleSize", &_modelHandleSize, 1); logger_base.debug("Model Handle Size: %d.", _modelHandleSize); + config->Read("xLightsCrosshairSize", &_crosshairSize, 1); + logger_base.debug("Group View Crosshair Size: %d.", _crosshairSize); + config->Read("xLightsBackupOnSave", &mBackupOnSave, false); logger_base.debug("Backup on save: %s.", toStr(mBackupOnSave)); @@ -2157,6 +2161,7 @@ xLightsFrame::~xLightsFrame() config->Write("xLightsAltBackupDir", mAltBackupDir); config->Write("xFadePort", _xFadePort); config->Write("xLightsModelHandleSize", _modelHandleSize); + config->Write("xLightsCrosshairSize", _crosshairSize); config->Write("xLightsPlayVolume", playVolume); config->Write("xLightsVideoExportCodec", _videoExportCodec); config->Write("xLightsVideoExportBitrate", _videoExportBitrate); @@ -9862,6 +9867,11 @@ void xLightsFrame::SetModelHandleSize(int i) layoutPanel->Refresh(); } +void xLightsFrame::SetCrosshairSize(int i) { + _crosshairSize = i; + layoutPanel->Refresh(); +} + void xLightsFrame::SetSuppressFadeHints(bool b) { mSuppressFadeHints = b; diff --git a/xLights/xLightsMain.h b/xLights/xLightsMain.h index 638b64569..7e536e275 100755 --- a/xLights/xLightsMain.h +++ b/xLights/xLightsMain.h @@ -1312,10 +1312,12 @@ private : int EffectAssistMode() const { return mEffectAssistMode;} void SetEffectAssistMode(int i); - int GetModelHandleScale() const { return _modelHandleSize; } - int ModelHandleSize() const { return _modelHandleSize;} + int GetModelHandleSize() const { return _modelHandleSize; } void SetModelHandleSize(int i); + int GetCrosshairSize() const { return _crosshairSize; } + void SetCrosshairSize(int i); + const wxArrayString &RandomEffectsToUse() const { return _randomEffectsToUse;} void SetRandomEffectsToUse(const wxArrayString &e); @@ -1624,6 +1626,7 @@ private : int abortedRenderJobs = 0; bool mSaveFseqOnSave; int _modelHandleSize = 1; + int _crosshairSize = 1; class RenderTree { public: