Permalink
Browse files

Merge pull request #17 from akmokhtari/master

Font handling, and an audio device-related crash fix.
  • Loading branch information...
2 parents 39bc9db + 207c411 commit e97166e527d66581f7fa03df84780266fd5b034c open-ephys committed Dec 17, 2012
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 44;
+ objectVersion = 45;
objects = {
/* Begin PBXBuildFile section */
@@ -75,6 +75,7 @@
<ProgramDatabaseFile>.\Debug\open-ephys.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
+ <AdditionalOptions>-lftdi -lftgl %(AdditionalOptions)</AdditionalOptions>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -115,6 +116,7 @@
<TargetMachine>MachineX86</TargetMachine>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <AdditionalOptions>-lftdi -lftgl %(AdditionalOptions)</AdditionalOptions>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -64,6 +64,21 @@
</Filter>
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="..\..\Resources\Fonts\cpmono-black-serialized">
+ <Filter>open-ephys\Resources\Fonts</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\Resources\Fonts\cpmono-bold-serialized">
+ <Filter>open-ephys\Resources\Fonts</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\Resources\Fonts\cpmono-extralight-serialized">
+ <Filter>open-ephys\Resources\Fonts</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\Resources\Fonts\cpmono-light-serialized">
+ <Filter>open-ephys\Resources\Fonts</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\Resources\Fonts\cpmono-plain-serialized">
+ <Filter>open-ephys\Resources\Fonts</Filter>
+ </ClCompile>
<ClCompile Include="..\..\Resources\Fonts\BebasNeue.otf">
<Filter>open-ephys\Resources\Fonts</Filter>
</ClCompile>
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,12 +1,27 @@
/* =========================================================================================
- This is an auto-generated file, created by The Jucer V3.0.0
+ This is an auto-generated file, created by The Introjucer 3.0.0
Do not edit anything in this file!
*/
namespace BinaryData
{
+ extern const char* cpmonoblackserialized;
+ const int cpmonoblackserializedSize = 15547;
+
+ extern const char* cpmonoboldserialized;
+ const int cpmonoboldserializedSize = 16442;
+
+ extern const char* cpmonoextralightserialized;
+ const int cpmonoextralightserializedSize = 17136;
+
+ extern const char* cpmonolightserialized;
+ const int cpmonolightserializedSize = 18090;
+
+ extern const char* cpmonoplainserialized;
+ const int cpmonoplainserializedSize = 17831;
+
extern const char* BebasNeue_otf;
const int BebasNeue_otfSize = 48648;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -27,19 +27,52 @@
AudioComponent::AudioComponent() : isPlaying(false)
{
-
- deviceManager.initialise(0, // numInputChannelsNeeded
- 2, // numOutputChannelsNeeded
- 0, // *savedState (XmlElement)
- true, // selectDefaultDeviceOnFailure
- String::empty, // preferred device
- 0); // preferred device setup options
-
+ // if this is nonempty, we got an error
+ String error = deviceManager.initialise(0, // numInputChannelsNeeded
+ 2, // numOutputChannelsNeeded
+ 0, // *savedState (XmlElement)
+ true, // selectDefaultDeviceOnFailure
+ String::empty, // preferred device
+ 0); // preferred device setup options
+ if (error != String::empty)
+ {
+ String titleMessage = String("Audio device initialization error");
+ String contentMessage = String("There was a problem initializing the audio device:\n" + error);
+ // this uses a bool since there are only two options
+ // also, omitting parameters works fine, even though the docs don't show defaults
+ bool retryButtonClicked = AlertWindow::showOkCancelBox(AlertWindow::QuestionIcon,
+ titleMessage,
+ contentMessage,
+ String("Retry"),
+ String("Quit"));
+
+ if (retryButtonClicked)
+ {
+ // as above
+ error = deviceManager.initialise(0, 2, 0, true, String::empty, 0);
+ } else { // quit button clicked
+ JUCEApplication::quit();
+ }
+ }
+
+
AudioIODevice* aIOd = deviceManager.getCurrentAudioDevice();
+ // the error string doesn't tell you if there's no audio device found...
+ if (aIOd == 0)
+ {
+ String titleMessage = String("No audio device found");
+ String contentMessage = String("Couldn't find an audio device. ") +
+ String("Perhaps some other program has control of the default one.");
+ AlertWindow::showMessageBox(AlertWindow::InfoIcon,
+ titleMessage,
+ contentMessage);
+ JUCEApplication::quit();
+ }
+
+
std::cout << "Got audio device." << std::endl;
- String devType = deviceManager.getCurrentAudioDeviceType();
String devName = aIOd->getName();
std::cout << std::endl << "Audio device name: " << devName << std::endl;
@@ -56,7 +89,7 @@ AudioComponent::AudioComponent() : isPlaying(false)
String msg = deviceManager.setAudioDeviceSetup(setup, false);
- devType = deviceManager.getCurrentAudioDeviceType();
+ String devType = deviceManager.getCurrentAudioDeviceType();
std::cout << "Audio device type: " << devType << std::endl;
float sr = setup.sampleRate;
View
@@ -152,7 +152,7 @@ void MainWindow::loadWindowBounds()
XmlDocument doc (file);
XmlElement* xml = doc.getDocumentElement();
- if (xml == 0 || ! xml->hasTagName (T("MAINWINDOW")))
+ if (xml == 0 || ! xml->hasTagName ("MAINWINDOW"))
{
std::cout << "File not found." << std::endl;
@@ -161,7 +161,7 @@ void MainWindow::loadWindowBounds()
} else {
- String description;// = T(" ");
+ String description;
forEachXmlChildElement (*xml, e)
{
@@ -183,4 +183,4 @@ void MainWindow::loadWindowBounds()
delete xml;
}
// return "Everything went ok.";
-}
+}
@@ -87,7 +87,7 @@ AudioEditor::AudioEditor (AudioNode* owner)
audioWindowButton->setToggleState(false,false);
addAndMakeVisible(audioWindowButton);
- volumeSlider = new Slider (T("High-Cut Slider"));
+ volumeSlider = new Slider ("High-Cut Slider");
volumeSlider->setRange(0,100,1);
volumeSlider->addListener(this);
volumeSlider->setTextBoxStyle(Slider::NoTextBox,
@@ -224,4 +224,4 @@ void AudioConfigurationWindow::resized()
void AudioConfigurationWindow::paint(Graphics& g)
{
g.fillAll(Colours::darkgrey);
-}
+}
@@ -25,7 +25,7 @@
#include "../Utilities/Merger.h"
// PipelineSelectorButton::PipelineSelectorButton()
-// : DrawableButton (T("Selector"), DrawableButton::ImageFitted)
+// : DrawableButton ("Selector", DrawableButton::ImageFitted)
// {
// DrawablePath normal, over, down;
@@ -152,4 +152,4 @@ void MergerEditor::switchSource()
Merger* processor = (Merger*) getProcessor();
processor->switchIO();
-}
+}
@@ -25,7 +25,7 @@
#include "../Utilities/Splitter.h"
// PipelineSelectorButton::PipelineSelectorButton()
-// : DrawableButton (T("Selector"), DrawableButton::ImageFitted)
+// : DrawableButton ("Selector", DrawableButton::ImageFitted)
// {
// DrawablePath normal, over, down;
@@ -158,4 +158,4 @@ void SplitterEditor::switchDest()
pipelineSelectorA->setToggleState(false,false);
}
-}
+}
@@ -27,7 +27,7 @@
#include <math.h>
PlayButton::PlayButton()
- : DrawableButton (T("PlayButton"), DrawableButton::ImageFitted)
+ : DrawableButton ("PlayButton", DrawableButton::ImageFitted)
{
DrawablePath normal, over, down;
@@ -61,7 +61,7 @@ PlayButton::~PlayButton()
}
RecordButton::RecordButton()
- : DrawableButton (T("RecordButton"), DrawableButton::ImageFitted)
+ : DrawableButton ("RecordButton", DrawableButton::ImageFitted)
{
DrawablePath normal, over, down;
@@ -88,7 +88,7 @@ RecordButton::~RecordButton()
}
-CPUMeter::CPUMeter() : Label(T("CPU Meter"),"0.0"), cpu(0.0f), lastCpu(0.0f)
+CPUMeter::CPUMeter() : Label("CPU Meter","0.0"), cpu(0.0f), lastCpu(0.0f)
{
MemoryInputStream mis(BinaryData::silkscreenserialized, BinaryData::silkscreenserializedSize, false);
Typeface::Ptr typeface = new CustomTypeface(mis);
@@ -688,4 +688,4 @@ void ControlPanel::toggleState()
cpb->toggleState();
getUIComponent()->childComponentChanged();
-}
+}
@@ -23,10 +23,50 @@
#include "CustomLookAndFeel.h"
-CustomLookAndFeel::CustomLookAndFeel()
+CustomLookAndFeel::CustomLookAndFeel() :
+ // third argument to MIS means don't copy the binary data to make a new stream
+ cpmonoExtraLightStream(BinaryData::cpmonoextralightserialized,
+ BinaryData::cpmonoextralightserializedSize,
+ false),
+ cpmonoLightStream(BinaryData::cpmonolightserialized,
+ BinaryData::cpmonolightserializedSize,
+ false),
+ cpmonoPlainStream(BinaryData::cpmonoplainserialized,
+ BinaryData::cpmonoplainserializedSize,
+ false),
+ cpmonoBoldStream(BinaryData::cpmonoboldserialized,
+ BinaryData::cpmonoboldserializedSize,
+ false),
+ cpmonoBlackStream(BinaryData::cpmonoblackserialized,
+ BinaryData::cpmonoblackserializedSize,
+ false),
+ misoRegularStream(BinaryData::misoserialized,
+ BinaryData::misoserializedSize,
+ false),
+ silkscreenStream(BinaryData::silkscreenserialized,
+ BinaryData::silkscreenserializedSize,
+ false),
+ // heap allocation is necessary here, because otherwise the typefaces are
+ // deleted too soon (there's a singleton typefacecache that holds references
+ // to them whenever they're used).
+ cpmonoExtraLight(new CustomTypeface(cpmonoExtraLightStream)),
+ cpmonoLight(new CustomTypeface(cpmonoLightStream)),
+ cpmonoPlain(new CustomTypeface(cpmonoPlainStream)),
+ cpmonoBold(new CustomTypeface(cpmonoBoldStream)),
+ cpmonoBlack(new CustomTypeface(cpmonoBlackStream)),
+ misoRegular(new CustomTypeface(misoRegularStream)),
+ silkscreen(new CustomTypeface(silkscreenStream))
+
{
- MemoryInputStream mis(BinaryData::misoserialized, BinaryData::misoserializedSize, false);
- Miso = new CustomTypeface(mis);
+
+ // UNCOMMENT AFTER UPDATE
+ // typefaceMap.set(String("Default Extra Light"), cpmonoExtraLight);
+ // typefaceMap.set(String("Default Light"), cpmonoLight);
+ // typefaceMap.set(String("Default"), cpmonoPlain);
+ // typefaceMap.set(String("Default Bold"), cpmonoBold);
+ // typefaceMap.set(String("Default Black"), cpmonoBlack);
+ // typefaceMap.set(String("Paragraph"), misoRegular);
+ // typefaceMap.set(String("Silkscreen"), silkscreen);
enum {
PROCESSOR_COLOR = 0x801,
@@ -47,21 +87,57 @@ CustomLookAndFeel::CustomLookAndFeel()
setColour(PopupMenu::highlightedBackgroundColourId, Colours::grey);
setColour(PopupMenu::highlightedTextColourId, Colours::yellow);
-
}
CustomLookAndFeel::~CustomLookAndFeel() {}
-// ===============
-// const Typeface::Ptr CustomLookAndFeel::getTypefaceForFont (const Font& font)
-// {
-
-// return Miso;
+//==============================================================================
+// FONT/TYPEFACE METHODS :
+//==============================================================================
-// }
+const Typeface::Ptr CustomLookAndFeel::getTypefaceForFont (const Font& font)
+{
+ String typefaceName = font.getTypefaceName();
+ // some of these names might be unnecessary, and there may be good ones
+ // missing. adjust as needed
+ if (typefaceName.equalsIgnoreCase("Default Extra Light"))
+ {
+ return cpmonoExtraLight;
+ } else if (typefaceName.equalsIgnoreCase("Default Light"))
+ {
+ return cpmonoLight;
+ } else if (typefaceName.equalsIgnoreCase("Default"))
+ {
+ return cpmonoPlain;
+ } else if (typefaceName.equalsIgnoreCase("Default Bold"))
+ {
+ return cpmonoBold;
+ } else if (typefaceName.equalsIgnoreCase("Default Black"))
+ {
+ return cpmonoBlack;
+ } else if (typefaceName.equalsIgnoreCase("Paragraph"))
+ {
+ return misoRegular;
+ } else if (typefaceName.equalsIgnoreCase("Small Text"))
+ {
+ return silkscreen;
+ } else // default
+ {
+ return LookAndFeel::getTypefaceForFont(font);
+ }
+
+ // UNCOMMENT AFTER UPDATE
+ // if (typefaceMap.contains(typefaceName))
+ // return typefaceMap[typefaceName];
+ // else
+ // return LookAndFeel::getTypefaceForFont(font);
+}
//==============================================================================
+// TAB METHODS :
+//==============================================================================
+
int CustomLookAndFeel::getTabButtonOverlap (int tabDepth)
{
return 0; //1 + tabDepth / 4;
@@ -616,4 +692,4 @@ void CustomLookAndFeel::drawComboBox (Graphics& g, int width, int height,
}
-}
+}
Oops, something went wrong.

0 comments on commit e97166e

Please sign in to comment.