Skip to content

Commit

Permalink
More suggestive naming of colour combo methods and variables
Browse files Browse the repository at this point in the history
  • Loading branch information
hsstraub committed Jan 27, 2018
1 parent 500ce74 commit 90228d6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Source/SingleNoteAssign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void SingleNoteAssign::buttonClicked (Button* buttonThatWasClicked)
colourSelector->setName("Colour picker");
colourSelector->addChangeListener(this);

Colour currentColor = colourCombo->getColourObjectFromText(DONTADDCOLOURTOCOMBOBOX);
Colour currentColor = colourCombo->getColourAsObjectFromText(ColourComboBox::DoNotAddColourToCombobox);

colourSelector->setCurrentColour(currentColor);

Expand All @@ -281,7 +281,7 @@ void SingleNoteAssign::changeListenerCallback(ChangeBroadcaster *source)

Colour currentColor = cs->getCurrentColour();

colourCombo->setTextFieldToColourObject(currentColor);
colourCombo->setTextFieldToColourAsObject(currentColor);
}

// Called from MainComponent when one of the keys is clicked
Expand All @@ -307,7 +307,7 @@ void SingleNoteAssign::PerformMouseClickEdit(int setSelection, int keySelection)
// Set colour if specified
if (setColourToggleButton->getToggleState())
{
keyData.colour = colourCombo->getColourIDFromText(ADDCOLOURTOCOMBOBOX);
keyData.colour = colourCombo->getColourAsNumberFromText(ColourComboBox::AddColourToComboBox);
}

// Send to device
Expand Down
18 changes: 9 additions & 9 deletions Source/ViewComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,21 @@ ColourComboBox::ColourComboBox(const String& componentName) : ComboBox(component
{
}

void ColourComboBox::setTextFieldToColourObject(Colour newColour, NotificationType notification)
void ColourComboBox::setTextFieldToColourAsObject(Colour newColourAsObject, NotificationType notification)
{
setText(newColour.toDisplayString(false));
setText(newColourAsObject.toDisplayString(false));

// XXX Add to box
}

int ColourComboBox::getColourIDFromText(bool addToBox)
int ColourComboBox::getColourAsNumberFromText(colourComboboxOptions boxOptions)
{
String colourString = getText();

// XXX validation of colour value
int colourID = colourString.getHexValue32();
int colourAsNumber = colourString.getHexValue32();

if (addToBox)
if (boxOptions == colourComboboxOptions::AddColourToComboBox)
{
// Add colour to combo box
int pos;
Expand All @@ -185,11 +185,11 @@ int ColourComboBox::getColourIDFromText(bool addToBox)
}
}

return colourID;
return colourAsNumber;
}

Colour ColourComboBox::getColourObjectFromText(bool addToBox)
Colour ColourComboBox::getColourAsObjectFromText(colourComboboxOptions boxOptions)
{
int colourID = getColourIDFromText(addToBox);
return Colour(colourID);
int colourAsNumber = getColourAsNumberFromText(boxOptions);
return Colour(colourAsNumber);
}
14 changes: 10 additions & 4 deletions Source/ViewComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,18 @@ Combo box with colours
class ColourComboBox : public ComboBox
{
public:
enum colourComboboxOptions
{
DoNotAddColourToCombobox = 0,
AddColourToComboBox
};

explicit ColourComboBox(const String& componentName = String());

void setTextFieldToColourObject(Colour newColour,
void setTextFieldToColourAsObject(Colour newColourAsObject,
NotificationType notification = sendNotificationAsync);

int getColourIDFromText(bool addToBox);
Colour getColourObjectFromText(bool addToBox);
int getColourAsNumberFromText(colourComboboxOptions boxOptions);
Colour getColourAsObjectFromText(colourComboboxOptions boxOptions);
};

#endif // VIEWCOMPOONENTS_H_INCLUDED

0 comments on commit 90228d6

Please sign in to comment.