Skip to content

Commit

Permalink
Update Look And Feel
Browse files Browse the repository at this point in the history
  • Loading branch information
FangCunWuChang committed Jan 13, 2024
1 parent b3580b6 commit 4bf997f
Show file tree
Hide file tree
Showing 22 changed files with 101 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/ui/lookAndFeel/ControllerLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../misc/ColorMap.h"

ControllerLookAndFeel::ControllerLookAndFeel()
: LookAndFeel_V4() {
: MainLookAndFeel() {
/** Buttons */
this->setColour(juce::TextButton::ColourIds::buttonColourId,
ColorMap::getInstance()->get("ThemeColorB2"));
Expand Down
4 changes: 3 additions & 1 deletion src/ui/lookAndFeel/ControllerLookAndFeel.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#pragma once

#include <JuceHeader.h>
#include "MainLookAndFeel.h"

class ControllerLookAndFeel : public juce::LookAndFeel_V4 {
class ControllerLookAndFeel : public MainLookAndFeel {
public:
ControllerLookAndFeel();


private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ControllerLookAndFeel)
};
8 changes: 8 additions & 0 deletions src/ui/lookAndFeel/LookAndFeelFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ToolsLookAndFeel.h"
#include "MessageLookAndFeel.h"
#include "MessageViewLookAndFeel.h"
#include "PluginViewLookAndFeel.h"
#include "../misc/ColorMap.h"
#include <FlowUI.h>

Expand Down Expand Up @@ -66,6 +67,9 @@ void LookAndFeelFactory::initialise() {

/** Message View */
this->messageViewLAF = std::make_unique<MessageViewLookAndFeel>();

/** Plugin View */
this->pluginViewLAF = std::make_unique<PluginViewLookAndFeel>();
}

void LookAndFeelFactory::setDefaultSansSerifTypeface(juce::Typeface::Ptr typeface) {
Expand Down Expand Up @@ -105,6 +109,10 @@ juce::LookAndFeel_V4* LookAndFeelFactory::forMessageView() const {
return this->messageViewLAF.get();
}

juce::LookAndFeel_V4* LookAndFeelFactory::forPluginView() const {
return this->pluginViewLAF.get();
}

LookAndFeelFactory* LookAndFeelFactory::getInstance() {
return LookAndFeelFactory::instance ? LookAndFeelFactory::instance
: (LookAndFeelFactory::instance = new LookAndFeelFactory{});
Expand Down
2 changes: 2 additions & 0 deletions src/ui/lookAndFeel/LookAndFeelFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class LookAndFeelFactory final : private juce::DeletedAtShutdown {
juce::LookAndFeel_V4* forTools() const;
juce::LookAndFeel_V4* forMessage() const;
juce::LookAndFeel_V4* forMessageView() const;
juce::LookAndFeel_V4* forPluginView() const;

private:
std::unique_ptr<juce::LookAndFeel> mainLAF = nullptr;
Expand All @@ -28,6 +29,7 @@ class LookAndFeelFactory final : private juce::DeletedAtShutdown {
std::unique_ptr<juce::LookAndFeel_V4> toolsLAF = nullptr;
std::unique_ptr<juce::LookAndFeel_V4> messageLAF = nullptr;
std::unique_ptr<juce::LookAndFeel_V4> messageViewLAF = nullptr;
std::unique_ptr<juce::LookAndFeel_V4> pluginViewLAF = nullptr;

public:
static LookAndFeelFactory* getInstance();
Expand Down
40 changes: 38 additions & 2 deletions src/ui/lookAndFeel/MainLookAndFeel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "MainLookAndFeel.h"
#include "../misc/ColorMap.h"
#include "../Utils.h"

MainLookAndFeel::MainLookAndFeel()
: LookAndFeel_V4() {
Expand Down Expand Up @@ -80,6 +81,8 @@ MainLookAndFeel::MainLookAndFeel()
juce::Colour::fromRGBA(0, 0, 0, 0));
this->setColour(juce::TextEditor::ColourIds::shadowColourId + 1,
ColorMap::getInstance()->get("ThemeColorB9"));/**< Empty Text */
this->setColour(juce::CaretComponent::ColourIds::caretColourId,
ColorMap::getInstance()->get("ThemeColorB9"));

/** Set Scroll Bar Color */
this->setColour(juce::ScrollBar::ColourIds::backgroundColourId,
Expand Down Expand Up @@ -195,8 +198,7 @@ void MainLookAndFeel::drawPopupMenuItem(juce::Graphics& g, const juce::Rectangle
const bool isHighlighted, const bool isTicked,
const bool hasSubMenu, const juce::String& text,
const juce::String& shortcutKeyText,
const juce::Drawable* icon, const juce::Colour* const textColourToUse)
{
const juce::Drawable* icon, const juce::Colour* const textColourToUse) {
if (isSeparator) {
auto r = area.reduced(5, 0);
r.removeFromTop(juce::roundToInt(((float)r.getHeight() * 0.5f) - 0.5f));
Expand Down Expand Up @@ -269,3 +271,37 @@ void MainLookAndFeel::drawPopupMenuItem(juce::Graphics& g, const juce::Rectangle
}
}
}

juce::Font MainLookAndFeel::getTextButtonFont(juce::TextButton& b, int) {
auto screenSize = utils::getScreenSize(&b);
return juce::Font{ screenSize.getHeight() * 0.02f };
}

void MainLookAndFeel::drawCallOutBoxBackground(
juce::CallOutBox& box, juce::Graphics& g, const juce::Path& path, juce::Image& cachedImage) {
juce::Colour colorBackground = this->findColour(
juce::ResizableWindow::ColourIds::backgroundColourId);

if (cachedImage.isNull()) {
cachedImage = { juce::Image::ARGB, box.getWidth(), box.getHeight(), true };
juce::Graphics g2(cachedImage);

juce::DropShadow(juce::Colours::black.withAlpha(0.7f), 8, { 0, 2 }).drawForPath(g2, path);
}

g.setColour(juce::Colours::black);
g.drawImageAt(cachedImage, 0, 0);

g.setColour(colorBackground);
g.fillPath(path);
};

int MainLookAndFeel::getCallOutBoxBorderSize(const juce::CallOutBox& box) {
auto screenSize = utils::getScreenSize(&box);
return screenSize.getHeight() * 0.005;
};

float MainLookAndFeel::getCallOutBoxCornerSize(const juce::CallOutBox& box) {
auto screenSize = utils::getScreenSize(&box);
return screenSize.getHeight() * 0.01;
};
7 changes: 7 additions & 0 deletions src/ui/lookAndFeel/MainLookAndFeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ class MainLookAndFeel : public juce::LookAndFeel_V4 {
const juce::String& shortcutKeyText,
const juce::Drawable* icon, const juce::Colour* const textColourToUse) override;

juce::Font getTextButtonFont(juce::TextButton& b, int) override;

void drawCallOutBoxBackground(
juce::CallOutBox&, juce::Graphics&, const juce::Path&, juce::Image&) override;
int getCallOutBoxBorderSize(const juce::CallOutBox&) override;
float getCallOutBoxCornerSize(const juce::CallOutBox&) override;

private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainLookAndFeel)
};
2 changes: 1 addition & 1 deletion src/ui/lookAndFeel/MainMenuLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../misc/ColorMap.h"

MainMenuLookAndFeel::MainMenuLookAndFeel()
: LookAndFeel_V4() {
: MainLookAndFeel() {
/** Buttons */
this->setColour(juce::TextButton::ColourIds::buttonColourId,
ColorMap::getInstance()->get("ThemeColorB2"));
Expand Down
3 changes: 2 additions & 1 deletion src/ui/lookAndFeel/MainMenuLookAndFeel.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include <JuceHeader.h>
#include "MainLookAndFeel.h"

class MainMenuLookAndFeel : public juce::LookAndFeel_V4 {
class MainMenuLookAndFeel : public MainLookAndFeel {
public:
MainMenuLookAndFeel();

Expand Down
2 changes: 1 addition & 1 deletion src/ui/lookAndFeel/MessageLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../misc/ColorMap.h"

MessageLookAndFeel::MessageLookAndFeel()
: LookAndFeel_V4() {
: MainLookAndFeel() {
/** Background */
this->setColour(juce::ResizableWindow::ColourIds::backgroundColourId,
ColorMap::getInstance()->get("ThemeColorB1"));
Expand Down
3 changes: 2 additions & 1 deletion src/ui/lookAndFeel/MessageLookAndFeel.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include <JuceHeader.h>
#include "MainLookAndFeel.h"

class MessageLookAndFeel : public juce::LookAndFeel_V4 {
class MessageLookAndFeel : public MainLookAndFeel {
public:
MessageLookAndFeel();

Expand Down
31 changes: 1 addition & 30 deletions src/ui/lookAndFeel/MessageViewLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "../Utils.h"

MessageViewLookAndFeel::MessageViewLookAndFeel()
: LookAndFeel_V4() {
: MainLookAndFeel() {
/** Background */
this->setColour(juce::ResizableWindow::ColourIds::backgroundColourId,
ColorMap::getInstance()->get("ThemeColorB3"));
Expand Down Expand Up @@ -46,32 +46,3 @@ MessageViewLookAndFeel::MessageViewLookAndFeel()
this->setColour(juce::ScrollBar::ColourIds::trackColourId,
ColorMap::getInstance()->get("ThemeColorB1"));
}

void MessageViewLookAndFeel::drawCallOutBoxBackground(
juce::CallOutBox& box, juce::Graphics& g, const juce::Path& path, juce::Image& cachedImage) {
juce::Colour colorBackground = this->findColour(
juce::ResizableWindow::ColourIds::backgroundColourId);

if (cachedImage.isNull()) {
cachedImage = { juce::Image::ARGB, box.getWidth(), box.getHeight(), true };
juce::Graphics g2(cachedImage);

juce::DropShadow(juce::Colours::black.withAlpha(0.7f), 8, { 0, 2 }).drawForPath(g2, path);
}

g.setColour(juce::Colours::black);
g.drawImageAt(cachedImage, 0, 0);

g.setColour(colorBackground);
g.fillPath(path);
};

int MessageViewLookAndFeel::getCallOutBoxBorderSize(const juce::CallOutBox& box) {
auto screenSize = utils::getScreenSize(&box);
return screenSize.getHeight() * 0.005;
};

float MessageViewLookAndFeel::getCallOutBoxCornerSize(const juce::CallOutBox& box) {
auto screenSize = utils::getScreenSize(&box);
return screenSize.getHeight() * 0.01;
};
8 changes: 2 additions & 6 deletions src/ui/lookAndFeel/MessageViewLookAndFeel.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#pragma once

#include <JuceHeader.h>
#include "MainLookAndFeel.h"

class MessageViewLookAndFeel : public juce::LookAndFeel_V4 {
class MessageViewLookAndFeel : public MainLookAndFeel {
public:
MessageViewLookAndFeel();

void drawCallOutBoxBackground(
juce::CallOutBox&, juce::Graphics&, const juce::Path&, juce::Image&) override;
int getCallOutBoxBorderSize(const juce::CallOutBox&) override;
float getCallOutBoxCornerSize(const juce::CallOutBox&) override;

private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MessageViewLookAndFeel)
};
9 changes: 9 additions & 0 deletions src/ui/lookAndFeel/PluginViewLookAndFeel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "PluginViewLookAndFeel.h"
#include "../misc/ColorMap.h"

PluginViewLookAndFeel::PluginViewLookAndFeel()
: MainLookAndFeel() {
/** Background */
this->setColour(juce::ResizableWindow::ColourIds::backgroundColourId,
ColorMap::getInstance()->get("ThemeColorB1"));
}
12 changes: 12 additions & 0 deletions src/ui/lookAndFeel/PluginViewLookAndFeel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <JuceHeader.h>
#include "MainLookAndFeel.h"

class PluginViewLookAndFeel : public MainLookAndFeel {
public:
PluginViewLookAndFeel();

private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginViewLookAndFeel)
};
2 changes: 1 addition & 1 deletion src/ui/lookAndFeel/SystemStatusLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../misc/ColorMap.h"

SystemStatusLookAndFeel::SystemStatusLookAndFeel()
: LookAndFeel_V4() {
: MainLookAndFeel() {
/** Background */
this->setColour(juce::ResizableWindow::ColourIds::backgroundColourId,
ColorMap::getInstance()->get("ThemeColorB1"));
Expand Down
3 changes: 2 additions & 1 deletion src/ui/lookAndFeel/SystemStatusLookAndFeel.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include <JuceHeader.h>
#include "MainLookAndFeel.h"

class SystemStatusLookAndFeel : public juce::LookAndFeel_V4 {
class SystemStatusLookAndFeel : public MainLookAndFeel {
public:
SystemStatusLookAndFeel();

Expand Down
2 changes: 1 addition & 1 deletion src/ui/lookAndFeel/TimeLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../misc/ColorMap.h"

TimeLookAndFeel::TimeLookAndFeel()
: LookAndFeel_V4() {
: MainLookAndFeel() {
/** Background */
this->setColour(juce::ResizableWindow::ColourIds::backgroundColourId,
ColorMap::getInstance()->get("ThemeColorB1"));
Expand Down
3 changes: 2 additions & 1 deletion src/ui/lookAndFeel/TimeLookAndFeel.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include <JuceHeader.h>
#include "MainLookAndFeel.h"

class TimeLookAndFeel : public juce::LookAndFeel_V4 {
class TimeLookAndFeel : public MainLookAndFeel {
public:
TimeLookAndFeel();

Expand Down
2 changes: 1 addition & 1 deletion src/ui/lookAndFeel/ToolBarLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../misc/ColorMap.h"

ToolBarLookAndFeel::ToolBarLookAndFeel()
: LookAndFeel_V4() {
: MainLookAndFeel() {
/** Background */
this->setColour(juce::ResizableWindow::ColourIds::backgroundColourId,
ColorMap::getInstance()->get("ThemeColorB2"));
Expand Down
3 changes: 2 additions & 1 deletion src/ui/lookAndFeel/ToolBarLookAndFeel.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include <JuceHeader.h>
#include "MainLookAndFeel.h"

class ToolBarLookAndFeel : public juce::LookAndFeel_V4 {
class ToolBarLookAndFeel : public MainLookAndFeel {
public:
ToolBarLookAndFeel();

Expand Down
2 changes: 1 addition & 1 deletion src/ui/lookAndFeel/ToolsLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../misc/ColorMap.h"

ToolsLookAndFeel::ToolsLookAndFeel()
: LookAndFeel_V4() {
: MainLookAndFeel() {
/** Buttons */
this->setColour(juce::TextButton::ColourIds::buttonColourId,
ColorMap::getInstance()->get("ThemeColorB2"));
Expand Down
3 changes: 2 additions & 1 deletion src/ui/lookAndFeel/ToolsLookAndFeel.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include <JuceHeader.h>
#include "MainLookAndFeel.h"

class ToolsLookAndFeel : public juce::LookAndFeel_V4 {
class ToolsLookAndFeel : public MainLookAndFeel {
public:
ToolsLookAndFeel();

Expand Down

0 comments on commit 4bf997f

Please sign in to comment.