Skip to content

Instantly share code, notes, and snippets.

/Application.h

Created Sep 29, 2017
Embed
What would you like to do?
Circular Dependency Issue
/*
==============================================================================
Application.h
Created: 21 Sep 2017 11:33:33pm
Author: Jefferson Bledsoe
==============================================================================
*/
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
#include "Windows/WindowList.h"
#include "Utility/CommandIDs.h"
#include "Utility/MyoMapperLookAndFeel.h"
//==============================================================================
/*
*/
class MyoMapperApplication : public JUCEApplication,
private AsyncUpdater
{
public:
MyoMapperApplication();
static MyoMapperApplication& getApp();
static ApplicationCommandManager& getCommandManager();
static ApplicationProperties& getAppProperties();
static WindowList& getWindowList();
//==========================================================================
const String getApplicationName() override { return ProjectInfo::projectName; }
const String getApplicationVersion() override { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() override { return true; }
//==========================================================================
void initialise (const String& commandLine) override;
void shutdown() override;
void systemRequestedQuit() override;
void handleAsyncUpdate() override;
//==========================================================================
MenuBarModel* getMenuModel();
StringArray getMenuBarNames();
void createMenu (PopupMenu&, const String& menuName);
void createFileMenu (PopupMenu&);
void createViewMenu (PopupMenu&);
void createWindowMenu (PopupMenu&);
void createHelpMenu (PopupMenu&);
void createAppleMenu (PopupMenu&);
void menuCommand (int menuItemID);
//==========================================================================
void getAllCommands (Array<CommandID>&) override;
void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) override;
bool perform (const InvocationInfo& info) override;
//==========================================================================
void createNewMapper();
void userFileOpenDialog();
void openFile();
void saveMapper();
void saveMapperAs();
void quitMapper();
void windowZoomIncrease();
void windowZoomDecrease();
void enableFullscreen();
void showSettingsWindow();
void newDisplayWindow();
void moveWindowsToFront();
void hideAllWindows();
void closeWindow();
void closeAllWindows();
void showAboutWindow();
void showDocumentationWindow();
void showPreferencesWindow();
// ==========================================================================
MyoMapperLookAndFeel lookAndFeel; // For new UI
struct MainMenuBarModel;
ScopedPointer<MainMenuBarModel> menuModel;
// Document Manager Goes Here
ScopedPointer<ApplicationCommandManager> commandManager;
ScopedPointer<ApplicationProperties> appProperties;
// General floating window builder used to create these windows
ScopedPointer<WindowList> windowList;
ScopedPointer<Component> settingsWindow;
// ScopedPointer<Component> aboutWindow, documentationWindow;
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MyoMapperApplication)
};
/*
==============================================================================
WindowsList.h
Created: 22 Sep 2017 3:51:10am
Author: Jefferson Bledsoe
==============================================================================
*/
#pragma once
class WindowSetter;
#include "../JuceLibraryCode/JuceHeader.h"
#include "WindowSetter.h"
#include "FeedbackWindow.h"
#include "SettingsWindow.h"
//==============================================================================
/*
*/
class WindowList
{
public:
WindowList();
void createInitialWindow();
void createNewFeedbackWindow();
void getOrCreateSettingsWindow();
void forceCloseWindows();
void askAllWindowsToClose();
void closeWindow (WindowSetter*);
// void closeWindow (SettingsWindow*);
void closeWindow (FeedbackWindow*);
OwnedArray<WindowSetter> windows;
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowList)
};
/*
==============================================================================
WindowSetter.h
Created: 22 Sep 2017 5:16:30pm
Author: Jefferson Bledsoe
==============================================================================
*/
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
//#include "WindowList.h"
#include "../Application.h"
//==============================================================================
/*
*/
class WindowSetter : public DialogWindow
{
public:
WindowSetter (const String& title,
Component* content,
bool shouldBeResizeable,
int initWidth, int initHeight,
int minWidth, int minHeight,
int maxWidth, int maxHeight)
: DialogWindow (title, Colours::white, true, true),
owner (this)
{
setUsingNativeTitleBar (true);
setResizable (true, true);
setResizeLimits (minWidth, minHeight, maxWidth, maxHeight);
setContentOwned (content, false);
setVisible (true);
}
~WindowSetter()
{
}
void closeButtonPressed() override
{
MyoMapperApplication::getWindowList().remove (/*Pointer To This Window*/);
owner = nullptr;
}
bool escapeKeyPressed() override
{
return true;
}
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowSetter)
ScopedPointer<Component> owner;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.