Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preference to hide/size the Group Crosshair #4885 #4916

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions xLights/ModelPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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) {
Expand Down Expand Up @@ -1110,7 +1132,7 @@ float ModelPreview::GetCameraZoomForHandles() const

int ModelPreview::GetHandleScale() const
{
return xlights->GetModelHandleScale();
return xlights->GetModelHandleSize();
}

void ModelPreview::SetZoomDelta(float delta)
Expand Down
26 changes: 24 additions & 2 deletions xLights/preferences/ViewSettingsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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"));
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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());
Expand Down Expand Up @@ -257,3 +272,10 @@ void ViewSettingsPanel::OnCheckBox_ZoomMethodClick(wxCommandEvent& event)
TransferDataFromWindow();
}
}

void ViewSettingsPanel::OnCrosshairSizeChoiceSelect(wxCommandEvent& event)
{
if (wxPreferencesEditor::ShouldApplyChangesImmediately()) {
TransferDataFromWindow();
}
}
3 changes: 3 additions & 0 deletions xLights/preferences/ViewSettingsPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ViewSettingsPanel: public wxPanel
wxCheckBox* HousePreviewCheckBox;
wxCheckBox* PlayControlsCheckBox;
wxChoice* Choice_TimelineZooming;
wxChoice* CrosshairSizeChoice;
wxChoice* EffectAssistChoice;
wxChoice* ModelHandleSizeChoice;
wxChoice* ToolIconSizeChoice;
Expand All @@ -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:
Expand All @@ -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()
Expand Down
31 changes: 30 additions & 1 deletion xLights/wxsmith/ViewSettingsPanel.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</object>
<col>1</col>
<row>0</row>
<flag>wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
<flag>wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL</flag>
<border>5</border>
<option>1</option>
</object>
Expand Down Expand Up @@ -169,6 +169,35 @@
<border>5</border>
<option>1</option>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="wxID_ANY" variable="StaticText2" member="no">
<label>Group Center Crosshair Size</label>
</object>
<col>0</col>
<row>9</row>
<flag>wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL</flag>
<border>5</border>
<option>1</option>
</object>
<object class="sizeritem">
<object class="wxChoice" name="ID_CHOICE_CROSSHAIRSIZE" variable="CrosshairSizeChoice" member="yes">
<content>
<item>Large</item>
<item>Normal</item>
<item>Small</item>
<item>Tiny</item>
<item>None</item>
</content>
<selection>1</selection>
<tooltip>Control the size of the crosshair for group centering</tooltip>
<handler function="OnCrosshairSizeChoiceSelect" entry="EVT_CHOICE" />
</object>
<col>1</col>
<row>9</row>
<flag>wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL</flag>
<border>5</border>
<option>1</option>
</object>
</object>
</object>
</wxsmith>
10 changes: 10 additions & 0 deletions xLights/xLightsMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions xLights/xLightsMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -1624,6 +1626,7 @@ private :
int abortedRenderJobs = 0;
bool mSaveFseqOnSave;
int _modelHandleSize = 1;
int _crosshairSize = 1;

class RenderTree {
public:
Expand Down
Loading