Skip to content

Commit

Permalink
Aesthetic improvements to FilterViewport and Editors
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiegle committed Feb 16, 2012
1 parent 8cf5aa2 commit 77a2ccb
Show file tree
Hide file tree
Showing 21 changed files with 467 additions and 160 deletions.
2 changes: 2 additions & 0 deletions Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj
Expand Up @@ -112,6 +112,7 @@
C2A7939DF5ED600BBB2F30C4 = { isa = PBXFileReference; lastKnownFileType = file; name = "silkscreen-serialized"; path = "../../Resources/Fonts/silkscreen-serialized"; sourceTree = SOURCE_ROOT; };
F8CAE2412B173788F325BD8B = { isa = PBXFileReference; lastKnownFileType = file.ttf; name = silkscreen.ttf; path = ../../Resources/Fonts/silkscreen.ttf; sourceTree = SOURCE_ROOT; };
363B59958615D35C5C948300 = { isa = PBXFileReference; lastKnownFileType = file.otf; name = "unibody-8.otf"; path = "../../Resources/Fonts/unibody-8.otf"; sourceTree = SOURCE_ROOT; };
2A1D9144C59B92B32483924B = { isa = PBXFileReference; lastKnownFileType = image.png; name = SourceDrop.png; path = ../../Resources/Images/Icons/SourceDrop.png; sourceTree = SOURCE_ROOT; };
D99F56FB46F631F67AF23F2C = { isa = PBXFileReference; lastKnownFileType = image.png; name = DefaultDataSource.png; path = ../../Resources/Images/Icons/DefaultDataSource.png; sourceTree = SOURCE_ROOT; };
66C7E42D7FDE3600982A1F46 = { isa = PBXFileReference; lastKnownFileType = image.png; name = FileReaderIcon.png; path = ../../Resources/Images/Icons/FileReaderIcon.png; sourceTree = SOURCE_ROOT; };
A4C8AB3F5E7A708350F72E7C = { isa = PBXFileReference; lastKnownFileType = image.png; name = IntanIcon.png; path = ../../Resources/Images/Icons/IntanIcon.png; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -275,6 +276,7 @@
F8CAE2412B173788F325BD8B,
363B59958615D35C5C948300 ); name = Fonts; sourceTree = "<group>"; };
891C5A157F059822288EDC9F = { isa = PBXGroup; children = (
2A1D9144C59B92B32483924B,
D99F56FB46F631F67AF23F2C,
66C7E42D7FDE3600982A1F46,
A4C8AB3F5E7A708350F72E7C ); name = Icons; sourceTree = "<group>"; };
Expand Down
94 changes: 94 additions & 0 deletions JuceLibraryCode/BinaryData.cpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions JuceLibraryCode/BinaryData.h
Expand Up @@ -49,6 +49,9 @@ namespace BinaryData
extern const char* silkscreen_ttf;
const int silkscreen_ttfSize = 18336;

extern const char* SourceDrop_png;
const int SourceDrop_pngSize = 6274;

extern const char* DefaultDataSource_png;
const int DefaultDataSource_pngSize = 14143;

Expand Down
8 changes: 4 additions & 4 deletions Resources/Fonts/font_serializer/Source/Main.cpp
Expand Up @@ -48,10 +48,10 @@ int main (int argc, char* argv[])
// make sure the font is installed on the current system
StringArray fontNames = Font::findAllTypefaceNames();

for (int n = 0; n < fontNames.size(); n++)
{
std::cout << fontNames[n] << std::endl;
}
// for (int n = 0; n < fontNames.size(); n++)
// {
// std::cout << fontNames[n] << std::endl;
// }

if(!fontNames.contains(fontName))
{
Expand Down
Binary file added Resources/Images/Icons/SourceDrop.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 51 additions & 16 deletions Source/Processors/Editors/FilterEditor.cpp
Expand Up @@ -14,22 +14,35 @@


FilterEditor::FilterEditor (GenericProcessor* parentNode, FilterViewport* vp)
: GenericEditor(parentNode, vp), lowSlider(0), highSlider(0)
: GenericEditor(parentNode, vp)

{
desiredWidth = 250;

lowSlider = new Slider (T("Low-Cut Slider"));
lowSlider->setBounds(25,20,200,40);
lowSlider->setRange(10,600,10);
lowSlider->addListener(this);
addAndMakeVisible(lowSlider);
StringArray lowCutValues;
lowCutValues.add("1");
lowCutValues.add("10");
lowCutValues.add("100");
lowCutValues.add("500");

highSlider = new Slider (T("High-Cut Slider"));
highSlider->setBounds(25,65,200,40);
highSlider->setRange(1000,10000,500);
highSlider->addListener(this);
addAndMakeVisible(highSlider);
StringArray highCutValues;
highCutValues.add("1K");
highCutValues.add("3K");
highCutValues.add("6K");
highCutValues.add("9K");

createRadioButtons(35, 50, 160, lowCutValues, "Low Cutoff");
createRadioButtons(35, 90, 160, highCutValues, "High Cutoff");

for (int n = 0; n < getNumChildComponents(); n++)
{
Button* c = (Button*) getChildComponent(n);

if (c->isVisible())
c->addListener(this);

c->setVisible(true);
}

}

Expand All @@ -38,12 +51,34 @@ FilterEditor::~FilterEditor()
deleteAllChildren();
}

void FilterEditor::sliderValueChanged (Slider* slider)
// void FilterEditor::sliderValueChanged (Slider* slider)
// {

// if (slider == lowSlider)
// getAudioProcessor()->setParameter(0,slider->getValue());
// else
// getAudioProcessor()->setParameter(1,slider->getValue());

// }

void FilterEditor::buttonClicked (Button* button)
{
//std::cout << button->getRadioGroupId() << " " << button->getName() << std::endl;
String value = button->getName();
float val;

if (value.getLastCharacter() == juce_wchar('k')) {
val = value.dropLastCharacters(1).getFloatValue() * 1000.0f;
}
else {
val = value.getFloatValue();
}

//if (button->getRadioGroupId() == 1)
/// //getAudioProcessor()->setParameter(0,val);
//else
//getAudioProcessor()->setParameter(1,val);

if (slider == lowSlider)
getAudioProcessor()->setParameter(0,slider->getValue());
else
getAudioProcessor()->setParameter(1,slider->getValue());
//std::cout << button->getRadioGroupId() << " " << val << std::endl;

}
10 changes: 6 additions & 4 deletions Source/Processors/Editors/FilterEditor.h
Expand Up @@ -18,16 +18,18 @@
class FilterViewport;

class FilterEditor : public GenericEditor,
public Slider::Listener
public Button::Listener
{
public:
FilterEditor (GenericProcessor* parentNode, FilterViewport* vp);
virtual ~FilterEditor();
void sliderValueChanged (Slider* slider);
//void sliderValueChanged (Slider* slider);
void buttonClicked(Button* button);

private:
Slider* lowSlider;
Slider* highSlider;
//Slider* lowSlider;
//Slider* highSlider;


JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FilterEditor);

Expand Down
87 changes: 80 additions & 7 deletions Source/Processors/Editors/GenericEditor.cpp
Expand Up @@ -12,7 +12,7 @@

GenericEditor::GenericEditor (GenericProcessor* owner, FilterViewport* vp)
: AudioProcessorEditor (owner), isSelected(false), viewport(vp),
desiredWidth(150), tNum(-1), isEnabled(true)
desiredWidth(150), tNum(-1), isEnabled(true), radioGroupId(1)

{
name = getAudioProcessor()->getName();
Expand Down Expand Up @@ -136,20 +136,17 @@ void GenericEditor::paint (Graphics& g)

GenericProcessor* p = (GenericProcessor*) getProcessor();

if (isSelected) {
g.setColour(Colours::yellow);
g.fillRect(0,0,getWidth()-offset,getHeight());
}

if (isEnabled)
g.setColour(backgroundColor);
else
g.setColour(Colours::lightgrey);

// draw colored background
g.fillRect(1,1,getWidth()-(2+offset),getHeight()-2);

// draw gray workspace
g.setColour(Colour(192, 205, 209));
g.fillRect(1,22,getWidth()-2, getHeight()-26);
g.fillRect(1,22,getWidth()-2, getHeight()-29);

g.setFont(titleFont);
g.setFont(14);
Expand All @@ -161,6 +158,82 @@ void GenericEditor::paint (Graphics& g)
g.setColour(Colours::grey);
}

// draw title
g.drawText(name, 6, 5, 500, 15, Justification::left, false);


if (isSelected) {
g.setColour(Colours::yellow);

} else {
g.setColour(Colours::black);
}

// draw highlight box
g.drawRect(0,0,getWidth(),getHeight(),2.0);

}

void GenericEditor::createRadioButtons(int x, int y, int w, StringArray values, const String& groupName)
{
int numButtons = values.size();
int width = w / numButtons;

for (int i = 0; i < numButtons; i++)
{

RadioButton* b = new RadioButton(values[i], radioGroupId);
addAndMakeVisible(b);
b->setBounds(x+width*i,y,width,15);
// b->addListener(this);


if (i == numButtons-1)
{
b->setToggleState(true, true);
}
}

Label* l = new Label("Label",groupName);
addChildComponent(l);
l->setBounds(x,y-15,200,10);
titleFont.setHeight(10);
l->setFont(titleFont);

radioGroupId++;
}


RadioButton::RadioButton(const String& name, int groupId) : Button(name)
{

setRadioGroupId(groupId);
setClickingTogglesState(true);

MemoryInputStream mis(BinaryData::silkscreenserialized, BinaryData::silkscreenserializedSize, false);
Typeface::Ptr typeface = new CustomTypeface(mis);
buttonFont = Font(typeface);
buttonFont.setHeight(10);
}


void RadioButton::paintButton(Graphics &g, bool isMouseOver, bool isButtonDown)
{
if (getToggleState() == true)
g.setColour(Colours::orange);
else
g.setColour(Colours::darkgrey);

if (isMouseOver)
g.setColour(Colours::white);

g.fillRect(0,0,getWidth(),getHeight());

g.setFont(buttonFont);
g.setColour(Colours::black);

g.drawRect(0,0,getWidth(),getHeight(),1.0);

g.drawText(getName(),0,0,getWidth(),getHeight(),Justification::centred,true);
}

29 changes: 27 additions & 2 deletions Source/Processors/Editors/GenericEditor.h
Expand Up @@ -21,7 +21,8 @@
class GenericProcessor;
class FilterViewport;

class GenericEditor : public AudioProcessorEditor
class GenericEditor : public AudioProcessorEditor//,
// public Button::Listener

{
public:
Expand Down Expand Up @@ -58,7 +59,13 @@ class GenericEditor : public AudioProcessorEditor
void setConfiguration(Configuration* cf) {config = cf;}
Configuration* getConfiguration() {return config;}

AudioProcessor* getProcessor() const {return getAudioProcessor();}
AudioProcessor* getProcessor() const {return getAudioProcessor();}

void createRadioButtons(int x, int y, int w, StringArray values, const String& name);

int radioGroupId;

//virtual void buttonClicked(Button* b);

private:

Expand All @@ -69,6 +76,8 @@ class GenericEditor : public AudioProcessorEditor

int tNum;



Font titleFont;

String name;
Expand All @@ -80,4 +89,20 @@ class GenericEditor : public AudioProcessorEditor



class RadioButton : public Button
{
public:
RadioButton(const String& name, int groupId);// : Button("Name") {configurationChanged = true;}
~RadioButton() {}

private:

void paintButton(Graphics &g, bool isMouseOver, bool isButtonDown);

Font buttonFont;
};




#endif // __GENERICEDITOR_H_DD406E71__

0 comments on commit 77a2ccb

Please sign in to comment.