@@ -1,18 +1,22 @@ | |||
*.a | |||
*.d | |||
*.o | |||
*.exe | |||
*.dll | |||
*.dylib | |||
*.so | |||
*.zip | |||
.kdev_include_paths | |||
*.kdev4 | |||
examples/app | |||
examples/blendish | |||
examples/color | |||
examples/demo | |||
examples/demo-multi | |||
examples/demo-subwidgets | |||
examples/file-browser | |||
examples/images | |||
examples/nanovg | |||
@@ -1 +1 @@ | |||
Subproject commit 3a77a1144f4cb53ded4fb9194eded380bdfa9316 | |||
Subproject commit c6789d1889cfdb9fef784f19ab452ff70723ffc2 |
@@ -8,7 +8,7 @@ include ../dpf/dgl/Makefile.mk | |||
# -------------------------------------------------------------- | |||
BUILD_CXX_FLAGS += -I../dpf/dgl | |||
BUILD_CXX_FLAGS += -I../dpf/distrho -I../dpf/dgl | |||
LINK_FLAGS += -L../dpf -ldgl $(DGL_LIBS) | |||
WINDRES ?= windres | |||
@@ -16,9 +16,10 @@ WINDRES ?= windres | |||
# -------------------------------------------------------------- | |||
ifeq ($(WIN32),true) | |||
TARGETS = app.exe color.exe demo.exe demo-multi images.exe nanovg.exe rectangles.exe shapes.exe text.exe | |||
TARGETS = app.exe color.exe demo.exe demo-multi demo-subwidgets,exe images.exe nanovg.exe rectangles.exe shapes.exe text.exe | |||
else | |||
TARGETS = app blendish color demo demo-multi images nanovg nanovg2 rectangles shapes text | |||
TARGETS = app blendish color demo demo-multi demo-subwidgets images nanovg nanovg2 rectangles shapes text | |||
# TARGETS = blendish demo-subwidgets | |||
endif | |||
# -------------------------------------------------------------- | |||
@@ -54,6 +55,9 @@ demo: demo.cpp widgets/* ../dpf/dgl/* | |||
demo-multi: demo-multi.cpp widgets/* ../dpf/dgl/* | |||
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | |||
demo-subwidgets: demo-subwidgets.cpp widgets/* ../dpf/dgl/* | |||
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | |||
images: images.cpp widgets/ExampleImagesWidget.hpp images_res/* ../dpf/dgl/* | |||
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | |||
@@ -18,14 +18,138 @@ | |||
// DGL Stuff | |||
#include "NanoVG.hpp" | |||
#include "Widget.hpp" | |||
#include "StandaloneWindow.hpp" | |||
#include "extra/ScopedPointer.hpp" | |||
#include "src/nanovg/nanovg.h" | |||
#include "src/oui-blendish/blendish.h" | |||
// ------------------------------------------------------ | |||
// use namespace | |||
using DGL::NanoWidget; | |||
using DGL::StandaloneWindow; | |||
using DGL::Window; | |||
USE_NAMESPACE_DISTRHO; | |||
USE_NAMESPACE_DGL; | |||
// ------------------------------------------------------ | |||
// Test | |||
class BlenderOption : public NanoWidget | |||
{ | |||
public: | |||
BlenderOption(NanoWidget* groupWidget) | |||
: NanoWidget(groupWidget), | |||
state(BND_DEFAULT), | |||
area(10, 10, 200, BND_WIDGET_HEIGHT) {} | |||
protected: | |||
bool onMouse(const MouseEvent& e) | |||
{ | |||
if (! e.press) | |||
return false; | |||
if (! area.contains(e.pos)) | |||
return false; | |||
if (state == BND_ACTIVE) | |||
state = BND_HOVER; | |||
else | |||
state = BND_ACTIVE; | |||
repaint(); | |||
return true; | |||
} | |||
bool onMotion(const MotionEvent& e) | |||
{ | |||
if (! area.contains(e.pos)) | |||
{ | |||
if (state == BND_HOVER) | |||
{ | |||
state = BND_DEFAULT; | |||
repaint(); | |||
return true; | |||
} | |||
return false; | |||
} | |||
if (state == BND_DEFAULT) | |||
{ | |||
state = BND_HOVER; | |||
repaint(); | |||
} | |||
return true; | |||
} | |||
void onNanoDisplay() override | |||
{ | |||
bndOptionButton(getContext(), 10, 10, 200, BND_WIDGET_HEIGHT, state, "checkbox whoohoo!"); | |||
} | |||
private: | |||
BNDwidgetState state; | |||
Rectangle<int> area; | |||
}; | |||
class BlenderRadioBox : public NanoWidget | |||
{ | |||
public: | |||
BlenderRadioBox(NanoWidget* groupWidget) | |||
: NanoWidget(groupWidget), | |||
state(BND_DEFAULT), | |||
area(10, 40, 200, BND_WIDGET_HEIGHT) {} | |||
protected: | |||
bool onMouse(const MouseEvent& e) | |||
{ | |||
if (! e.press) | |||
return false; | |||
if (! area.contains(e.pos)) | |||
return false; | |||
if (state == BND_ACTIVE) | |||
state = BND_HOVER; | |||
else | |||
state = BND_ACTIVE; | |||
repaint(); | |||
return true; | |||
} | |||
bool onMotion(const MotionEvent& e) | |||
{ | |||
if (! area.contains(e.pos)) | |||
{ | |||
if (state == BND_HOVER) | |||
{ | |||
state = BND_DEFAULT; | |||
repaint(); | |||
return true; | |||
} | |||
return false; | |||
} | |||
if (state == BND_DEFAULT) | |||
{ | |||
state = BND_HOVER; | |||
repaint(); | |||
} | |||
return true; | |||
} | |||
void onNanoDisplay() override | |||
{ | |||
bndRadioButton(getContext(), 10, 40, 200, BND_WIDGET_HEIGHT, 0, state, BND_ICON_NONE, "radio blender style yeah"); | |||
} | |||
private: | |||
BNDwidgetState state; | |||
Rectangle<int> area; | |||
}; | |||
// ------------------------------------------------------ | |||
// Test | |||
@@ -34,14 +158,26 @@ class TestWidget : public NanoWidget | |||
{ | |||
public: | |||
TestWidget(Window& parent) | |||
: NanoWidget(parent) | |||
: NanoWidget(parent, NanoVG::CREATE_ANTIALIAS|NanoVG::CREATE_STENCIL_STROKES), | |||
opt(this), | |||
rb(this) | |||
{ | |||
NVGcontext* const context(getContext()); | |||
bndSetFont(nvgCreateFont(context, "system", "./blendish_res/DejaVuSans.ttf")); | |||
bndSetIconImage(nvgCreateImage(context, "./blendish_res/blender_icons16.png", 0)); | |||
} | |||
protected: | |||
void onNanoDisplay() override | |||
{ | |||
glClearColor(0.3f, 0.3f, 0.32f, 1.0f); | |||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); | |||
} | |||
private: | |||
BlenderOption opt; | |||
BlenderRadioBox rb; | |||
}; | |||
// ------------------------------------------------------ | |||
@@ -0,0 +1,94 @@ | |||
/* | |||
* DISTRHO Plugin Framework (DPF) | |||
* Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
* or without fee is hereby granted, provided that the above copyright notice and this | |||
* permission notice appear in all copies. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | |||
// ------------------------------------------------------ | |||
// DGL Stuff | |||
#include "StandaloneWindow.hpp" | |||
#include "widgets/ExampleColorWidget.hpp" | |||
#include "widgets/ExampleRectanglesWidget.hpp" | |||
#include "widgets/ExampleShapesWidget.hpp" | |||
#include "widgets/ExampleTextWidget.hpp" | |||
// ------------------------------------------------------ | |||
// use namespace | |||
using DGL::Size; | |||
using DGL::StandaloneWindow; | |||
using DGL::Widget; | |||
using DGL::Window; | |||
// ------------------------------------------------------ | |||
// SubWidgets | |||
class SubWidgets : public Widget | |||
{ | |||
public: | |||
SubWidgets(Window& parent) | |||
: Widget(parent), | |||
wColor(this), | |||
wRects(this), | |||
wShapes(this), | |||
wText(this) | |||
{ | |||
} | |||
protected: | |||
void onDisplay() override | |||
{ | |||
} | |||
void onResize(const ResizeEvent& e) override | |||
{ | |||
const uint w = e.size.getWidth()/2; | |||
const uint h = e.size.getHeight()/2; | |||
wColor.setAbsolutePos(0, 0); | |||
wColor.setSize(w, h); | |||
wRects.setAbsolutePos(w, 0); | |||
wRects.setSize(w, h); | |||
wShapes.setAbsolutePos(0, h); | |||
wShapes.setSize(w, h); | |||
wText.setAbsolutePos(w, h); | |||
wText.setSize(w, h); | |||
} | |||
private: | |||
ExampleColorWidget wColor; | |||
ExampleRectanglesWidget wRects; | |||
ExampleShapesWidget wShapes; | |||
ExampleTextWidget wText; | |||
}; | |||
// ------------------------------------------------------ | |||
// main entry point | |||
int main() | |||
{ | |||
StandaloneWindow swin; | |||
SubWidgets swid(swin); | |||
swin.setSize(600, 600); | |||
swin.setTitle("SubWidgets"); | |||
swin.exec(); | |||
return 0; | |||
} | |||
// ------------------------------------------------------ |
@@ -49,6 +49,17 @@ public: | |||
parent.addIdleCallback(this); | |||
} | |||
ExampleColorWidget(Widget* groupWidget) | |||
: Widget(groupWidget), | |||
cur('r'), | |||
reverse(false), | |||
r(0), g(0), b(0) | |||
{ | |||
setSize(300, 300); | |||
groupWidget->getParentWindow().addIdleCallback(this); | |||
} | |||
protected: | |||
void idleCallback() noexcept override | |||
{ | |||
@@ -45,6 +45,15 @@ public: | |||
fClicked[i] = false; | |||
} | |||
ExampleRectanglesWidget(Widget* groupWidget) | |||
: Widget(groupWidget) | |||
{ | |||
setSize(300, 300); | |||
for (int i=0; i<9; ++i) | |||
fClicked[i] = false; | |||
} | |||
protected: | |||
void onDisplay() override | |||
{ | |||
@@ -44,6 +44,12 @@ public: | |||
setSize(300, 300); | |||
} | |||
ExampleShapesWidget(Widget* groupWidget) | |||
: Widget(groupWidget) | |||
{ | |||
setSize(300, 300); | |||
} | |||
protected: | |||
void onDisplay() override | |||
{ | |||
@@ -41,6 +41,13 @@ public: | |||
setSize(500, 300); | |||
} | |||
ExampleTextWidget(Widget* groupWidget) | |||
: NanoWidget(groupWidget), | |||
fFont(createFontFromFile("sans", "./nanovg_res/Roboto-Regular.ttf")) | |||
{ | |||
setSize(500, 300); | |||
} | |||
protected: | |||
void onNanoDisplay() override | |||
{ | |||