@@ -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" | ||||
@@ -16,6 +16,7 @@ | |||||
#include "../NanoVG.hpp" | #include "../NanoVG.hpp" | ||||
#include "WidgetPrivateData.hpp" | #include "WidgetPrivateData.hpp" | ||||
#include "resources/Resources.h" | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -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" | ||||
#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 "resources/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.h" | |||||
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_H | |||||
#define BINARY_DPF_RESOURCES_H | |||||
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; |