-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08bc778
commit 0262249
Showing
9 changed files
with
164 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include "MessageComponent.h" | ||
#include "../lookAndFeel/LookAndFeelFactory.h" | ||
#include "../Utils.h" | ||
#include <IconManager.h> | ||
|
||
MessageComponent::MessageComponent() { | ||
/** Mouse Cursor */ | ||
this->setMouseCursor(juce::MouseCursor::PointingHandCursor); | ||
|
||
/** Look And Feel */ | ||
this->setLookAndFeel( | ||
LookAndFeelFactory::getInstance()->forMessage()); | ||
|
||
/** Icon */ | ||
this->mesIcon = flowUI::IconManager::getSVG( | ||
utils::getIconFile("Media", "notification-3-line").getFullPathName()); | ||
this->mesIcon->replaceColour(juce::Colours::black, | ||
this->getLookAndFeel().findColour(juce::Label::ColourIds::textColourId)); | ||
|
||
/** Message */ | ||
this->emptyMes = TRANS("No notification"); | ||
} | ||
|
||
void MessageComponent::paint(juce::Graphics& g) { | ||
auto& laf = this->getLookAndFeel(); | ||
|
||
/** Size */ | ||
int paddingWidth = this->getHeight() * 0.2; | ||
int paddingHeight = this->getHeight() * 0.15; | ||
int splitWidth = this->getHeight() * 0.2; | ||
|
||
int iconHeight = this->getHeight() * 0.4; | ||
float noticeHeight = this->getHeight() * 0.15; | ||
int mesHeight = this->getHeight() - paddingHeight * 2; | ||
int mesLines = 2; | ||
float textHeight = mesHeight / (float)mesLines; | ||
|
||
/** Color */ | ||
juce::Colour backgroundColor = laf.findColour( | ||
juce::ResizableWindow::ColourIds::backgroundColourId); | ||
juce::Colour textColor = laf.findColour( | ||
juce::Label::ColourIds::textColourId); | ||
juce::Colour noticeColor = juce::Colours::red; | ||
|
||
/** Font */ | ||
juce::Font textFont(textHeight); | ||
|
||
/** BackGround */ | ||
g.setColour(backgroundColor); | ||
g.fillAll(); | ||
|
||
/** Icon */ | ||
g.setColour(textColor); | ||
juce::Rectangle<float> iconRect( | ||
paddingWidth, this->getHeight() / 2 - iconHeight / 2, iconHeight, iconHeight); | ||
this->mesIcon->drawWithin(g, iconRect, | ||
juce::RectanglePlacement::centred | juce::RectanglePlacement::fillDestination, 1.f); | ||
|
||
/** Notice */ | ||
if (this->showNoticeDot) { | ||
g.setColour(noticeColor); | ||
juce::Point<float> centerPoint = iconRect.getTopRight(); | ||
juce::Rectangle<float> noticeRect( | ||
centerPoint.getX() - noticeHeight / 2, centerPoint.getY() - noticeHeight / 2, | ||
noticeHeight, noticeHeight); | ||
g.fillEllipse(noticeRect); | ||
} | ||
|
||
/** Message */ | ||
g.setColour(textColor); | ||
g.setFont(textFont); | ||
juce::Rectangle<int> mesRect( | ||
iconRect.getRight() + splitWidth, paddingHeight, | ||
this->getWidth() - (iconRect.getRight() + splitWidth), mesHeight); | ||
g.drawFittedText(this->mes.isEmpty() ? this->emptyMes : this->mes, mesRect, | ||
juce::Justification::centredLeft, mesLines, 1.f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include <JuceHeader.h> | ||
|
||
class MessageComponent final : public juce::Component { | ||
public: | ||
MessageComponent(); | ||
|
||
void paint(juce::Graphics& g) override; | ||
|
||
private: | ||
std::unique_ptr<juce::Drawable> mesIcon = nullptr; | ||
bool showNoticeDot = false; | ||
juce::String mes, emptyMes; | ||
|
||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MessageComponent) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "MessageLookAndFeel.h" | ||
#include "../misc/ColorMap.h" | ||
|
||
MessageLookAndFeel::MessageLookAndFeel() | ||
: LookAndFeel_V4() { | ||
/** Background */ | ||
this->setColour(juce::ResizableWindow::ColourIds::backgroundColourId, | ||
ColorMap::getInstance()->get("ThemeColorB1")); | ||
|
||
/** Text */ | ||
this->setColour(juce::Label::ColourIds::backgroundColourId, | ||
ColorMap::getInstance()->get("ThemeColorB1")); | ||
this->setColour(juce::Label::ColourIds::textColourId, | ||
ColorMap::getInstance()->get("ThemeColorB10")); | ||
this->setColour(juce::Label::ColourIds::outlineColourId, | ||
ColorMap::getInstance()->get("ThemeColorB1")); | ||
this->setColour(juce::Label::ColourIds::backgroundWhenEditingColourId, | ||
ColorMap::getInstance()->get("ThemeColorB1")); | ||
this->setColour(juce::Label::ColourIds::textWhenEditingColourId, | ||
ColorMap::getInstance()->get("ThemeColorB10")); | ||
this->setColour(juce::Label::ColourIds::outlineWhenEditingColourId, | ||
ColorMap::getInstance()->get("ThemeColorB1")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include <JuceHeader.h> | ||
|
||
class MessageLookAndFeel : public juce::LookAndFeel_V4 { | ||
public: | ||
MessageLookAndFeel(); | ||
|
||
private: | ||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MessageLookAndFeel) | ||
}; | ||
|