Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit juce wrapper to not force using the namespace #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion wrappers/juce/module/fontaudio/fontaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

#include "juce_core/juce_core.h"
#include "juce_graphics/juce_graphics.h"
using namespace juce;

#include "data/FontAudioData.h"
#include "data/Icons.h"
Expand Down
30 changes: 15 additions & 15 deletions wrappers/juce/module/fontaudio/src/FontAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ namespace fontaudio
{
int scaledSize = int(size * scaleFactor);

String identifier = juce::String(icon + "@" + String(scaledSize) + "@" + colour.toString());
int64 hash = identifier.hashCode64();
Image canvas = juce::ImageCache::getFromHashCode(hash);
juce::String identifier = juce::String(icon + "@" + juce::String(scaledSize) + "@" + colour.toString());
juce::int64 hash = identifier.hashCode64();
juce::Image canvas = juce::ImageCache::getFromHashCode(hash);
if (canvas.isValid())
return canvas;

Font FontAudio = getFont((float)scaledSize);
juce::Font FontAudio = getFont((float)scaledSize);
scaledSize = std::max(FontAudio.getStringWidth(icon), scaledSize);

canvas = Image(Image::PixelFormat::ARGB, scaledSize, scaledSize, true);
Graphics g(canvas);
canvas = juce::Image(juce::Image::PixelFormat::ARGB, scaledSize, scaledSize, true);
juce::Graphics g(canvas);
g.setColour(colour);
g.setFont(FontAudio);
g.drawText(icon, 0, 0, scaledSize, scaledSize, Justification::centred, true);
g.drawText(icon, 0, 0, scaledSize, scaledSize, juce::Justification::centred, true);
juce::ImageCache::addImageToCache(canvas, hash);
return canvas;
}

RenderedIcon IconHelper::getRotatedIcon(IconName icon, float size, juce::Colour colour, float iconRotation, float scaleFactor)
{
int scaledSize = int(size * scaleFactor);
String identifier = String(icon + "@" + String(scaledSize) + "@" + colour.toString() + "@" + String(iconRotation) + "@");
int64 hash = identifier.hashCode64();
Image canvas = juce::ImageCache::getFromHashCode(hash);
juce::String identifier = juce::String(icon + "@" + juce::String(scaledSize) + "@" + colour.toString() + "@" + juce::String(iconRotation) + "@");
juce::int64 hash = identifier.hashCode64();
juce::Image canvas = juce::ImageCache::getFromHashCode(hash);
if (canvas.isValid())
return canvas;

RenderedIcon renderdIcon = getIcon(icon, size, colour, scaleFactor);
canvas = Image(Image::PixelFormat::ARGB, renderdIcon.getWidth(), renderdIcon.getHeight(), true);
Graphics g(canvas);
g.drawImageTransformed(renderdIcon, AffineTransform::rotation(-(float_Pi * iconRotation), renderdIcon.getWidth() * 0.5f, renderdIcon.getHeight() * 0.5f));
canvas = juce::Image(juce::Image::PixelFormat::ARGB, renderdIcon.getWidth(), renderdIcon.getHeight(), true);
juce::Graphics g(canvas);
g.drawImageTransformed(renderdIcon, juce::AffineTransform::rotation(-(juce::float_Pi * iconRotation), renderdIcon.getWidth() * 0.5f, renderdIcon.getHeight() * 0.5f));
juce::ImageCache::addImageToCache(canvas, hash);
return canvas;
}
Expand All @@ -60,7 +60,7 @@ namespace fontaudio
false);
}

void IconHelper::drawCenterdAt(juce::Graphics &g, RenderedIcon icon, Rectangle<int> r, float scaleFactor)
void IconHelper::drawCenterdAt(juce::Graphics &g, RenderedIcon icon, juce::Rectangle<int> r, float scaleFactor)
{
float iconWidth = icon.getWidth() / scaleFactor;
float iconHeight = icon.getHeight() / scaleFactor;
Expand All @@ -72,7 +72,7 @@ namespace fontaudio

juce::Font IconHelper::getFont()
{
static Font FontAudioFont(FontAudio_ptr);
static juce::Font FontAudioFont(FontAudio_ptr);
return FontAudioFont;
}

Expand Down