Browse Source

Move resources to new dir, make it possible to get internal font

pull/6/head
falkTX 8 years ago
parent
commit
2344ca0615
12 changed files with 59 additions and 22 deletions
  1. +9
    -0
      dgl/NanoVG.hpp
  2. +12
    -2
      dgl/NanoWidgets.hpp
  3. +0
    -1
      dgl/src/ImageWidgets.cpp
  4. +11
    -0
      dgl/src/NanoVG.cpp
  5. +21
    -13
      dgl/src/NanoWidgets.cpp
  6. +0
    -0
      dgl/src/resources/DejaVuSans.ttf
  7. +0
    -0
      dgl/src/resources/LICENSE-DejaVuSans.ttf.txt
  8. +0
    -0
      dgl/src/resources/LICENSE-blender_icons.svg.txt
  9. +3
    -3
      dgl/src/resources/Resources.cpp
  10. +3
    -3
      dgl/src/resources/Resources.h
  11. +0
    -0
      dgl/src/resources/blender_icons.svg
  12. +0
    -0
      dgl/src/resources/blender_icons16.png

+ 9
- 0
dgl/NanoVG.hpp View File

@@ -20,6 +20,8 @@
#include "Color.hpp"
#include "Widget.hpp"

#define NANOVG_DEJAVU_SANS_TTF "__dpf_dejavusans_ttf__"

struct NVGcontext;
struct NVGpaint;

@@ -28,6 +30,7 @@ START_NAMESPACE_DGL
// -----------------------------------------------------------------------
// Forward class names

class BlendishWidget;
class NanoVG;

// -----------------------------------------------------------------------
@@ -841,10 +844,16 @@ public:
*/
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:
NVGcontext* const fContext;
bool fInFrame;
bool fIsSubWidget;
friend class BlendishWidget;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NanoVG)
};


+ 12
- 2
dgl/NanoWidgets.hpp View File

@@ -18,13 +18,23 @@
#define DGL_NANO_WIDGETS_HPP_INCLUDED

#include "NanoVG.hpp"
#include "../distrho/extra/String.hpp"

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:
class Callback


+ 0
- 1
dgl/src/ImageWidgets.cpp View File

@@ -14,7 +14,6 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../ImageWidgets.hpp"
#include "Common.hpp"
#include "WidgetPrivateData.hpp"



+ 11
- 0
dgl/src/NanoVG.cpp View File

@@ -16,6 +16,7 @@

#include "../NanoVG.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;
}

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 {


+ 21
- 13
dgl/src/NanoWidgets.cpp View File

@@ -14,27 +14,39 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../NanoWidgets.hpp"
#include "Common.hpp"

#define BLENDISH_IMPLEMENTATION
#include "nanovg/nanovg.h"
#include "oui-blendish/blendish.h"
#include "oui-blendish/blendish_resources.h"
#include "resources/Resources.h"
#include "../distrho/extra/String.hpp"

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;

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)
: NanoWidget(parent),
: BlendishWidget(parent),
pData(new PrivateData(this, text, iconId))
{
registerBlendishResourcesIfNeeded(getContext());
_updateBounds();
}

BlendishButton::BlendishButton(NanoWidget* widget, const char* text, int iconId)
: NanoWidget(widget),
: BlendishWidget(widget),
pData(new PrivateData(this, text, iconId))
{
registerBlendishResourcesIfNeeded(getContext());
_updateBounds();
}

@@ -139,6 +149,4 @@ void BlendishButton::_updateBounds()

END_NAMESPACE_DGL

#include "oui-blendish/blendish_resources.cpp"

// -----------------------------------------------------------------------

dgl/src/oui-blendish/resources/DejaVuSans.ttf → dgl/src/resources/DejaVuSans.ttf View File


dgl/src/oui-blendish/resources/LICENSE-DejaVuSans.ttf.txt → dgl/src/resources/LICENSE-DejaVuSans.ttf.txt View File


dgl/src/oui-blendish/resources/LICENSE-blender_icons.svg.txt → dgl/src/resources/LICENSE-blender_icons.svg.txt View File


dgl/src/oui-blendish/blendish_resources.cpp → dgl/src/resources/Resources.cpp View File

@@ -1,6 +1,6 @@
/* (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,
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,
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};
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,
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,29,0,0};
const char* blendish_resources::dejavusans_ttf = (const char*) temp2;
const char* dpf_resources::dejavusans_ttf = (const char*) temp2;

dgl/src/oui-blendish/blendish_resources.h → dgl/src/resources/Resources.h View File

@@ -1,9 +1,9 @@
/* (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;
const unsigned int blender_icons16_png_size = 250706;

dgl/src/oui-blendish/resources/blender_icons.svg → dgl/src/resources/blender_icons.svg View File


dgl/src/oui-blendish/resources/blender_icons16.png → dgl/src/resources/blender_icons16.png View File


Loading…
Cancel
Save