| @@ -25,6 +25,7 @@ OBJS = \ | |||||
| src/ImageWidgets.cpp.o \ | src/ImageWidgets.cpp.o \ | ||||
| src/NanoVG.cpp.o \ | src/NanoVG.cpp.o \ | ||||
| src/NanoWidgets.cpp.o \ | src/NanoWidgets.cpp.o \ | ||||
| src/Resources.cpp.o \ | |||||
| src/Widget.cpp.o | src/Widget.cpp.o | ||||
| ifeq ($(MACOS),true) | ifeq ($(MACOS),true) | ||||
| @@ -20,6 +20,8 @@ | |||||
| #include "Color.hpp" | #include "Color.hpp" | ||||
| #include "Widget.hpp" | #include "Widget.hpp" | ||||
| #define NANOVG_DEJAVU_SANS_TTF "__dpf_dejavusans_ttf__" | |||||
| struct NVGcontext; | struct NVGcontext; | ||||
| struct NVGpaint; | struct NVGpaint; | ||||
| @@ -28,6 +30,7 @@ START_NAMESPACE_DGL | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // Forward class names | // Forward class names | ||||
| class BlendishWidget; | |||||
| class NanoVG; | class NanoVG; | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -841,10 +844,16 @@ public: | |||||
| */ | */ | ||||
| int textBreakLines(const char* string, const char* end, float breakRowWidth, TextRow& rows, int maxRows); | int textBreakLines(const char* string, const char* end, float breakRowWidth, TextRow& rows, int maxRows); | ||||
| /** | |||||
| Load DPF's internal shared resources for this NanoVG class. | |||||
| */ | |||||
| virtual void loadSharedResources(); | |||||
| private: | private: | ||||
| NVGcontext* const fContext; | NVGcontext* const fContext; | ||||
| bool fInFrame; | bool fInFrame; | ||||
| bool fIsSubWidget; | bool fIsSubWidget; | ||||
| friend class BlendishWidget; | |||||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NanoVG) | DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NanoVG) | ||||
| }; | }; | ||||
| @@ -18,13 +18,23 @@ | |||||
| #define DGL_NANO_WIDGETS_HPP_INCLUDED | #define DGL_NANO_WIDGETS_HPP_INCLUDED | ||||
| #include "NanoVG.hpp" | #include "NanoVG.hpp" | ||||
| #include "../distrho/extra/String.hpp" | |||||
| START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| class BlendishButton : public NanoWidget | |||||
| class BlendishWidget : public NanoWidget | |||||
| { | |||||
| public: | |||||
| explicit BlendishWidget(Window& parent); | |||||
| explicit BlendishWidget(NanoWidget* widget); | |||||
| void loadSharedResources() override; | |||||
| }; | |||||
| // ----------------------------------------------------------------------- | |||||
| class BlendishButton : public BlendishWidget | |||||
| { | { | ||||
| public: | public: | ||||
| class Callback | class Callback | ||||
| @@ -14,7 +14,6 @@ | |||||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
| */ | */ | ||||
| #include "../ImageWidgets.hpp" | |||||
| #include "Common.hpp" | #include "Common.hpp" | ||||
| #include "WidgetPrivateData.hpp" | #include "WidgetPrivateData.hpp" | ||||
| @@ -15,6 +15,7 @@ | |||||
| */ | */ | ||||
| #include "../NanoVG.hpp" | #include "../NanoVG.hpp" | ||||
| #include "Resources.hpp" | |||||
| #include "WidgetPrivateData.hpp" | #include "WidgetPrivateData.hpp" | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -894,6 +895,16 @@ int NanoVG::textBreakLines(const char* string, const char* end, float breakRowWi | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| void NanoVG::loadSharedResources() | |||||
| { | |||||
| if (nvgFindFont(fContext, NANOVG_DEJAVU_SANS_TTF) >= 0) | |||||
| return; | |||||
| using namespace dpf_resources; | |||||
| nvgCreateFontMem(fContext, NANOVG_DEJAVU_SANS_TTF, (const uchar*)dejavusans_ttf, dejavusans_ttf_size, 0); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| struct NanoWidget::PrivateData { | struct NanoWidget::PrivateData { | ||||
| @@ -14,27 +14,39 @@ | |||||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
| */ | */ | ||||
| #include "../NanoWidgets.hpp" | |||||
| #include "Common.hpp" | #include "Common.hpp" | ||||
| #include "Resources.hpp" | |||||
| #define BLENDISH_IMPLEMENTATION | #define BLENDISH_IMPLEMENTATION | ||||
| #include "nanovg/nanovg.h" | #include "nanovg/nanovg.h" | ||||
| #include "oui-blendish/blendish.h" | #include "oui-blendish/blendish.h" | ||||
| #include "oui-blendish/blendish_resources.h" | |||||
| #include "../distrho/extra/String.hpp" | |||||
| START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| static void registerBlendishResourcesIfNeeded(NVGcontext* const context) | |||||
| BlendishWidget::BlendishWidget(Window& parent) | |||||
| : NanoWidget(parent) | |||||
| { | { | ||||
| if (nvgFindFont(context, "__dpf_blendish__") >= 0) | |||||
| loadSharedResources(); | |||||
| } | |||||
| BlendishWidget::BlendishWidget(NanoWidget* widget) | |||||
| : NanoWidget(widget) | |||||
| { | |||||
| loadSharedResources(); | |||||
| } | |||||
| void BlendishWidget::loadSharedResources() | |||||
| { | |||||
| if (nvgFindFont(fContext, NANOVG_DEJAVU_SANS_TTF) >= 0) | |||||
| return; | return; | ||||
| using namespace blendish_resources; | |||||
| using namespace dpf_resources; | |||||
| bndSetFont(nvgCreateFontMem(context, "__dpf_blendish__", (const uchar*)dejavusans_ttf, dejavusans_ttf_size, 0)); | |||||
| bndSetIconImage(nvgCreateImageMem(context, 0, (const uchar*)blender_icons16_png, blender_icons16_png_size)); | |||||
| bndSetFont(nvgCreateFontMem(fContext, NANOVG_DEJAVU_SANS_TTF, (const uchar*)dejavusans_ttf, dejavusans_ttf_size, 0)); | |||||
| bndSetIconImage(nvgCreateImageMem(fContext, 0, (const uchar*)blender_icons16_png, blender_icons16_png_size)); | |||||
| } | } | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -55,18 +67,16 @@ struct BlendishButton::PrivateData { | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| BlendishButton::BlendishButton(Window& parent, const char* text, int iconId) | BlendishButton::BlendishButton(Window& parent, const char* text, int iconId) | ||||
| : NanoWidget(parent), | |||||
| : BlendishWidget(parent), | |||||
| pData(new PrivateData(this, text, iconId)) | pData(new PrivateData(this, text, iconId)) | ||||
| { | { | ||||
| registerBlendishResourcesIfNeeded(getContext()); | |||||
| _updateBounds(); | _updateBounds(); | ||||
| } | } | ||||
| BlendishButton::BlendishButton(NanoWidget* widget, const char* text, int iconId) | BlendishButton::BlendishButton(NanoWidget* widget, const char* text, int iconId) | ||||
| : NanoWidget(widget), | |||||
| : BlendishWidget(widget), | |||||
| pData(new PrivateData(this, text, iconId)) | pData(new PrivateData(this, text, iconId)) | ||||
| { | { | ||||
| registerBlendishResourcesIfNeeded(getContext()); | |||||
| _updateBounds(); | _updateBounds(); | ||||
| } | } | ||||
| @@ -139,6 +149,4 @@ void BlendishButton::_updateBounds() | |||||
| END_NAMESPACE_DGL | END_NAMESPACE_DGL | ||||
| #include "oui-blendish/blendish_resources.cpp" | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -1,6 +1,6 @@ | |||||
| /* (Auto-generated binary data file). */ | /* (Auto-generated binary data file). */ | ||||
| #include "blendish_resources.h" | |||||
| #include "Resources.hpp" | |||||
| static const unsigned char temp1[] = {137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,2,90,0,0,2,128,8,6,0,0,0,68,254,214,163,0,0,0,4,115,66,73, | static const unsigned char temp1[] = {137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,2,90,0,0,2,128,8,6,0,0,0,68,254,214,163,0,0,0,4,115,66,73, | ||||
| 84,8,8,8,8,124,8,100,136,0,0,0,9,112,72,89,115,0,0,13,215,0,0,13,215,1,66,40,155,120,0,0,0,25,116,69,88,116,83,111, | 84,8,8,8,8,124,8,100,136,0,0,0,9,112,72,89,115,0,0,13,215,0,0,13,215,1,66,40,155,120,0,0,0,25,116,69,88,116,83,111, | ||||
| @@ -6270,7 +6270,7 @@ static const unsigned char temp1[] = {137,80,78,71,13,10,26,10,0,0,0,13,73,72,68 | |||||
| 14,240,213,53,106,138,246,238,200,233,43,254,186,60,190,184,78,245,113,54,182,190,78,234,217,40,212,199,217,216,118,255,160,56,225,219,107,228,147,123, | 14,240,213,53,106,138,246,238,200,233,43,254,186,60,190,184,78,245,113,54,182,190,78,234,217,40,212,199,217,216,118,255,160,56,225,219,107,228,147,123, | ||||
| 169,14,167,207,238,165,186,199,187,107,215,174,20,95,114,250,210,58,138,123,235,217,232,235,84,31,167,143,44,80,117,235,217,40,212,199,233,139,103,72, | 169,14,167,207,238,165,186,199,187,107,215,174,20,95,114,250,210,58,138,123,235,217,232,235,84,31,167,143,44,80,117,235,217,40,212,199,233,139,103,72, | ||||
| 83,241,254,149,240,127,22,93,33,203,89,128,128,45,0,0,0,0,73,69,78,68,174,66,96,130,0,0}; | 83,241,254,149,240,127,22,93,33,203,89,128,128,45,0,0,0,0,73,69,78,68,174,66,96,130,0,0}; | ||||
| const char* blendish_resources::blender_icons16_png = (const char*) temp1; | |||||
| const char* dpf_resources::blender_icons16_png = (const char*) temp1; | |||||
| static const unsigned char temp2[] = {0,1,0,0,0,19,1,0,0,4,0,48,70,70,84,77,102,9,29,176,0,0,1,60,0,0,0,28,71,68,69,70,144,48,138,184,0,0,1,88, | static const unsigned char temp2[] = {0,1,0,0,0,19,1,0,0,4,0,48,70,70,84,77,102,9,29,176,0,0,1,60,0,0,0,28,71,68,69,70,144,48,138,184,0,0,1,88, | ||||
| 0,0,2,148,71,80,79,83,63,137,191,2,0,0,3,236,0,0,157,8,71,83,85,66,151,65,114,65,0,0,160,244,0,0,21,114,79,83,47,50, | 0,0,2,148,71,80,79,83,63,137,191,2,0,0,3,236,0,0,157,8,71,83,85,66,151,65,114,65,0,0,160,244,0,0,21,114,79,83,47,50, | ||||
| @@ -24811,5 +24811,5 @@ static const unsigned char temp2[] = {0,1,0,0,0,19,1,0,0,4,0,48,70,70,84,77,102, | |||||
| 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, | 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, | ||||
| 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, | 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, | ||||
| 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,29,0,0}; | 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,29,0,0}; | ||||
| const char* blendish_resources::dejavusans_ttf = (const char*) temp2; | |||||
| const char* dpf_resources::dejavusans_ttf = (const char*) temp2; | |||||
| @@ -1,9 +1,9 @@ | |||||
| /* (Auto-generated binary data file). */ | /* (Auto-generated binary data file). */ | ||||
| #ifndef BINARY_BLENDISH_RESOURCES_H | |||||
| #define BINARY_BLENDISH_RESOURCES_H | |||||
| #ifndef BINARY_DPF_RESOURCES_HPP_INCLUDED | |||||
| #define BINARY_DPF_RESOURCES_HPP_INCLUDED | |||||
| namespace blendish_resources | |||||
| namespace dpf_resources | |||||
| { | { | ||||
| extern const char* blender_icons16_png; | extern const char* blender_icons16_png; | ||||
| const unsigned int blender_icons16_png_size = 250706; | const unsigned int blender_icons16_png_size = 250706; | ||||
| @@ -19,8 +19,6 @@ | |||||
| #include "DistrhoUIMVerb.hpp" | #include "DistrhoUIMVerb.hpp" | ||||
| #include "MVerb.h" | #include "MVerb.h" | ||||
| #include "font/Kh-Kangrey.h" | |||||
| START_NAMESPACE_DISTRHO | START_NAMESPACE_DISTRHO | ||||
| namespace Art = DistrhoArtworkMVerb; | namespace Art = DistrhoArtworkMVerb; | ||||
| @@ -34,7 +32,8 @@ DistrhoUIMVerb::DistrhoUIMVerb() | |||||
| fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR) | fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR) | ||||
| { | { | ||||
| // text | // text | ||||
| fNanoText.createFontFromMemory("kh", (const uchar*)khkangrey_ttf, khkangrey_ttfSize, false); | |||||
| fNanoText.loadSharedResources(); | |||||
| fNanoFont = fNanoText.findFont(NANOVG_DEJAVU_SANS_TTF); | |||||
| // knobs | // knobs | ||||
| Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight); | Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight); | ||||
| @@ -231,8 +230,8 @@ void DistrhoUIMVerb::onDisplay() | |||||
| // text display | // text display | ||||
| fNanoText.beginFrame(this); | fNanoText.beginFrame(this); | ||||
| fNanoText.fontFace("kh"); | |||||
| fNanoText.fontSize(20); | |||||
| fNanoText.fontFaceId(fNanoFont); | |||||
| fNanoText.fontSize(13); | |||||
| fNanoText.textAlign(NanoVG::ALIGN_CENTER|NanoVG::ALIGN_TOP); | fNanoText.textAlign(NanoVG::ALIGN_CENTER|NanoVG::ALIGN_TOP); | ||||
| fNanoText.fillColor(Color(1.0f, 1.0f, 1.0f)); | fNanoText.fillColor(Color(1.0f, 1.0f, 1.0f)); | ||||
| @@ -242,7 +241,7 @@ void DistrhoUIMVerb::onDisplay() | |||||
| for (std::size_t i=0; i<MVerb<float>::NUM_PARAMS; ++i) | for (std::size_t i=0; i<MVerb<float>::NUM_PARAMS; ++i) | ||||
| { | { | ||||
| std::snprintf(strBuf, 32, "%i%%", int(fKnobs[i]->getValue())); | std::snprintf(strBuf, 32, "%i%%", int(fKnobs[i]->getValue())); | ||||
| fNanoText.textBox(58.0f + float(fKnobs[i]->getAbsoluteX()) - 56.0f, 73.0f, 30.0f, strBuf, nullptr); | |||||
| fNanoText.textBox(56.0f + float(fKnobs[i]->getAbsoluteX()) - 56.0f, 76.0f, 34.0f, strBuf, nullptr); | |||||
| } | } | ||||
| fNanoText.endFrame(); | fNanoText.endFrame(); | ||||
| @@ -61,6 +61,7 @@ protected: | |||||
| private: | private: | ||||
| Image fImgBackground; | Image fImgBackground; | ||||
| NanoVG fNanoText; | NanoVG fNanoText; | ||||
| NanoVG::FontId fNanoFont; | |||||
| std::vector<ImageKnob*> fKnobs; | std::vector<ImageKnob*> fKnobs; | ||||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUIMVerb) | DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUIMVerb) | ||||
| @@ -17,8 +17,7 @@ OBJS_DSP = \ | |||||
| OBJS_UI = \ | OBJS_UI = \ | ||||
| DistrhoArtworkMVerb.cpp.o \ | DistrhoArtworkMVerb.cpp.o \ | ||||
| DistrhoUIMVerb.cpp.o \ | |||||
| font/Kh-Kangrey.cpp.o | |||||
| DistrhoUIMVerb.cpp.o | |||||
| # -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
| # Do some magic | # Do some magic | ||||
| @@ -1,9 +0,0 @@ | |||||
| /* binary data of Kh-Kangrey.ttf */ | |||||
| #ifndef BINARY_KH_KANGREY_H | |||||
| #define BINARY_KH_KANGREY_H | |||||
| extern const char* khkangrey_ttf; | |||||
| const int khkangrey_ttfSize = 158316; | |||||
| #endif | |||||
| @@ -1 +0,0 @@ | |||||
| http://openfontlibrary.org/en/font/kh-kangrey | |||||