Skip to content

Commit 84f1b11

Browse files
committed
Improve main stream button visibility handling in SyncLineSelector
1 parent 067c3b9 commit 84f1b11

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

Source/Processors/Editors/SyncLineSelector.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void SyncLineSelector::buttonClicked (Button* button)
205205
}
206206

207207
listener->selectedLineChanged (selectedLine);
208-
repaint();
208+
updatePopup();
209209
}
210210

211211
detectedChange = true;
@@ -221,4 +221,30 @@ void SyncLineSelector::updatePopup()
221221
else
222222
buttons[i]->setToggleState (false, NotificationType::dontSendNotification);
223223
}
224+
225+
if (listener->isPrimaryStream() && setPrimaryStreamButton != nullptr)
226+
{
227+
setPrimaryStreamButton->setVisible (false);
228+
isPrimary = true;
229+
setSize (width, buttonSize * nRows);
230+
height = buttonSize * (nRows);
231+
}
232+
else if (! listener->isPrimaryStream())
233+
{
234+
height = buttonSize * (nRows);
235+
if (setPrimaryStreamButton == nullptr)
236+
{
237+
setPrimaryStreamButton = new SetPrimaryButton ("Set as main clock");
238+
setPrimaryStreamButton->setBounds (0, height, 0.5 * width, buttonSize);
239+
setPrimaryStreamButton->addListener (this);
240+
addChildAndSetID (setPrimaryStreamButton, "SETPRIMARY");
241+
}
242+
243+
setPrimaryStreamButton->setVisible (true);
244+
setSize (width, height + buttonSize);
245+
isPrimary = false;
246+
247+
if (canSelectNone && selectedLine == -1)
248+
setPrimaryStreamButton->setEnabled (false);
249+
}
224250
}

Source/Processors/Editors/SyncLineSelector.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class PLUGIN_API SyncLineSelector : public PopupComponent,
8888

8989
// Called when the user sets the primary stream for synchronization
9090
virtual void primaryStreamChanged() = 0;
91+
92+
// Called when the updating to popup to reflect changes
93+
virtual bool isPrimaryStream() = 0;
9194
};
9295

9396
/** Constructor */

Source/Processors/Parameter/ParameterEditor.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,15 @@ void TtlLineParameterEditor::primaryStreamChanged()
10061006
syncParam->setNextValue (streamIndex);
10071007
}
10081008

1009+
bool TtlLineParameterEditor::isPrimaryStream()
1010+
{
1011+
if (syncParam == nullptr || syncParam->getType() != Parameter::SELECTED_STREAM_PARAM)
1012+
return true;
1013+
1014+
DataStream* paramStream = (DataStream*) param->getOwner();
1015+
return ((SelectedStreamParameter*) syncParam)->getValueAsString() == paramStream->getKey();
1016+
}
1017+
10091018
void TtlLineParameterEditor::buttonClicked (Button* button_)
10101019
{
10111020
if (param == nullptr)

Source/Processors/Parameter/ParameterEditor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,9 @@ class PLUGIN_API TtlLineParameterEditor : public ParameterEditor,
547547
/** Sets parameter's stream as primary */
548548
void primaryStreamChanged() override;
549549

550+
/** Returns true if this is the primary stream */
551+
bool isPrimaryStream() override;
552+
550553
/** Sets sub-component locations */
551554
virtual void resized() override;
552555

0 commit comments

Comments
 (0)