@@ -113,7 +113,7 @@ public: | |||||
Window win(app); | Window win(app); | ||||
ScopedPointer<MyCustomTopLevelWidget> widget; | ScopedPointer<MyCustomTopLevelWidget> widget; | ||||
{ | { | ||||
const ScopedGraphicsContext sgc(win); | |||||
const Window::ScopedGraphicsContext sgc(win); | |||||
widget = new MyCustomTopLevelWidget(win); | widget = new MyCustomTopLevelWidget(win); | ||||
} | } | ||||
app.exec(); | app.exec(); | ||||
@@ -89,7 +89,7 @@ static double getDesktopScaleFactor() | |||||
XrmInitialize(); | XrmInitialize(); | ||||
if (char* const rms = XResourceManagerString(view->world->impl->display)) | |||||
if (char* const rms = XResourceManagerString(display)) | |||||
{ | { | ||||
if (const XrmDatabase sdb = XrmGetStringDatabase(rms)) | if (const XrmDatabase sdb = XrmGetStringDatabase(rms)) | ||||
{ | { | ||||
@@ -42,6 +42,19 @@ typedef DGL_NAMESPACE::VulkanImage DemoImage; | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
// Partial specialization is not allowed in C++, so we need to define these here | |||||
template<> inline | |||||
ExampleImagesWidget<SubWidget, DemoImage>::ExampleImagesWidget(Widget* const parentWidget) | |||||
: SubWidget(parentWidget) { init(parentWidget->getApp()); } | |||||
template<> inline | |||||
ExampleImagesWidget<TopLevelWidget, DemoImage>::ExampleImagesWidget(Window& windowToMapTo) | |||||
: TopLevelWidget(windowToMapTo) { init(windowToMapTo.getApp()); } | |||||
template<> | |||||
ExampleImagesWidget<StandaloneWindow, DemoImage>::ExampleImagesWidget(Application& app) | |||||
: StandaloneWindow(app) { init(app); done(); } | |||||
typedef ExampleImagesWidget<SubWidget, DemoImage> ExampleImagesSubWidget; | typedef ExampleImagesWidget<SubWidget, DemoImage> ExampleImagesSubWidget; | ||||
typedef ExampleImagesWidget<TopLevelWidget, DemoImage> ExampleImagesTopLevelWidget; | typedef ExampleImagesWidget<TopLevelWidget, DemoImage> ExampleImagesTopLevelWidget; | ||||
typedef ExampleImagesWidget<StandaloneWindow, DemoImage> ExampleImagesStandaloneWindow; | typedef ExampleImagesWidget<StandaloneWindow, DemoImage> ExampleImagesStandaloneWindow; | ||||
@@ -127,9 +127,13 @@ class NanoExampleWindow : public Window | |||||
{ | { | ||||
public: | public: | ||||
explicit NanoExampleWindow(Application& app) | explicit NanoExampleWindow(Application& app) | ||||
: Window(app), | |||||
container(*this) | |||||
: Window(app) | |||||
{ | { | ||||
{ | |||||
const ScopedGraphicsContext sgc(*this); | |||||
container = new NanoRectanglesContainer(*this); | |||||
} | |||||
const uint targetWidth = 400; | const uint targetWidth = 400; | ||||
const uint targetHeight = 400; | const uint targetHeight = 400; | ||||
const double scaleFactor = getScaleFactor(); | const double scaleFactor = getScaleFactor(); | ||||
@@ -141,7 +145,7 @@ public: | |||||
} | } | ||||
private: | private: | ||||
NanoRectanglesContainer container; | |||||
ScopedPointer<NanoRectanglesContainer> container; | |||||
}; | }; | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
@@ -154,7 +158,6 @@ int main() | |||||
Application app; | Application app; | ||||
NanoExampleWindow win(app); | NanoExampleWindow win(app); | ||||
win.show(); | win.show(); | ||||
app.exec(); | app.exec(); | ||||
@@ -21,8 +21,8 @@ | |||||
// DGL Stuff | // DGL Stuff | ||||
#include "../../dgl/ImageBase.hpp" | #include "../../dgl/ImageBase.hpp" | ||||
#include "../../dgl/StandaloneWindow.hpp" | |||||
#include "../../dgl/SubWidget.hpp" | #include "../../dgl/SubWidget.hpp" | ||||
#include "../../dgl/TopLevelWidget.hpp" | |||||
// ------------------------------------------------------ | // ------------------------------------------------------ | ||||
// Images | // Images | ||||
@@ -55,70 +55,34 @@ public: | |||||
static constexpr const char* kExampleWidgetName = "Images"; | static constexpr const char* kExampleWidgetName = "Images"; | ||||
// SubWidget | // SubWidget | ||||
ExampleImagesWidget(Widget* const parent) | |||||
: BaseWidget(parent), | |||||
imgTop1st(1), | |||||
imgTop2nd(2), | |||||
imgTop3rd(3), | |||||
img1x(0), | |||||
img2x(kImg2max), | |||||
img3y(kImg3max), | |||||
img1rev(false), | |||||
img2rev(true), | |||||
img3rev(true), | |||||
img1(CatPics::cat1Data, CatPics::cat1Width, CatPics::cat1Height, kImageFormatBGR), | |||||
img2(CatPics::cat2Data, CatPics::cat2Width, CatPics::cat2Height, kImageFormatBGR), | |||||
img3(CatPics::cat3Data, CatPics::cat3Width, CatPics::cat3Height, kImageFormatBGR) | |||||
{ | |||||
BaseWidget::setSize(500, 400); | |||||
parent->getApp().addIdleCallback(this); | |||||
} | |||||
explicit ExampleImagesWidget(Widget* const parent); | |||||
// TopLevelWidget | // TopLevelWidget | ||||
ExampleImagesWidget(Window& windowToMapTo) | |||||
: BaseWidget(windowToMapTo), | |||||
imgTop1st(1), | |||||
imgTop2nd(2), | |||||
imgTop3rd(3), | |||||
img1x(0), | |||||
img2x(kImg2max), | |||||
img3y(kImg3max), | |||||
img1rev(false), | |||||
img2rev(true), | |||||
img3rev(true), | |||||
img1(CatPics::cat1Data, CatPics::cat1Width, CatPics::cat1Height, kImageFormatBGR), | |||||
img2(CatPics::cat2Data, CatPics::cat2Width, CatPics::cat2Height, kImageFormatBGR), | |||||
img3(CatPics::cat3Data, CatPics::cat3Width, CatPics::cat3Height, kImageFormatBGR) | |||||
{ | |||||
BaseWidget::setSize(500, 400); | |||||
windowToMapTo.getApp().addIdleCallback(this); | |||||
} | |||||
explicit ExampleImagesWidget(Window& windowToMapTo); | |||||
// StandaloneWindow | // StandaloneWindow | ||||
ExampleImagesWidget(Application& app) | |||||
: BaseWidget(app), | |||||
imgTop1st(1), | |||||
imgTop2nd(2), | |||||
imgTop3rd(3), | |||||
img1x(0), | |||||
img2x(kImg2max), | |||||
img3y(kImg3max), | |||||
img1rev(false), | |||||
img2rev(true), | |||||
img3rev(true), | |||||
img1(CatPics::cat1Data, CatPics::cat1Width, CatPics::cat1Height, kImageFormatBGR), | |||||
img2(CatPics::cat2Data, CatPics::cat2Width, CatPics::cat2Height, kImageFormatBGR), | |||||
img3(CatPics::cat3Data, CatPics::cat3Width, CatPics::cat3Height, kImageFormatBGR) | |||||
explicit ExampleImagesWidget(Application& app); | |||||
protected: | |||||
void init(Application& app) | |||||
{ | { | ||||
BaseWidget::setSize(500, 400); | |||||
imgTop1st = 1; | |||||
imgTop2nd = 2; | |||||
imgTop3rd = 3; | |||||
img1x = 0; | |||||
img2x = kImg2max; | |||||
img3y = kImg3max; | |||||
img1rev = false; | |||||
img2rev = true; | |||||
img3rev = true; | |||||
img1 = BaseImage(CatPics::cat1Data, CatPics::cat1Width, CatPics::cat1Height, kImageFormatBGR); | |||||
img2 = BaseImage(CatPics::cat2Data, CatPics::cat2Width, CatPics::cat2Height, kImageFormatBGR); | |||||
img3 = BaseImage(CatPics::cat3Data, CatPics::cat3Width, CatPics::cat3Height, kImageFormatBGR); | |||||
BaseWidget::setSize(500, 400); | |||||
app.addIdleCallback(this); | app.addIdleCallback(this); | ||||
done(); | |||||
} | } | ||||
protected: | |||||
void idleCallback() noexcept override | void idleCallback() noexcept override | ||||
{ | { | ||||
if (img1rev) | if (img1rev) | ||||
@@ -21,8 +21,8 @@ | |||||
// DGL Stuff | // DGL Stuff | ||||
#include "../../dgl/Color.hpp" | #include "../../dgl/Color.hpp" | ||||
#include "../../dgl/StandaloneWindow.hpp" | |||||
#include "../../dgl/SubWidget.hpp" | #include "../../dgl/SubWidget.hpp" | ||||
#include "../../dgl/TopLevelWidget.hpp" | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
@@ -38,26 +38,13 @@ public: | |||||
static constexpr const char* const kExampleWidgetName = "Rectangles"; | static constexpr const char* const kExampleWidgetName = "Rectangles"; | ||||
// SubWidget | // SubWidget | ||||
explicit ExampleRectanglesWidget(Widget* const parentWidget) | |||||
: BaseWidget(parentWidget) | |||||
{ | |||||
init(); | |||||
} | |||||
explicit ExampleRectanglesWidget(Widget* const parent); | |||||
// TopLevelWidget | // TopLevelWidget | ||||
explicit ExampleRectanglesWidget(Window& windowToMapTo) | |||||
: BaseWidget(windowToMapTo) | |||||
{ | |||||
init(); | |||||
} | |||||
explicit ExampleRectanglesWidget(Window& windowToMapTo); | |||||
// StandaloneWindow | // StandaloneWindow | ||||
explicit ExampleRectanglesWidget(Application& app) | |||||
: BaseWidget(app) | |||||
{ | |||||
init(); | |||||
done(); | |||||
} | |||||
explicit ExampleRectanglesWidget(Application& app); | |||||
void init() | void init() | ||||
{ | { | ||||
@@ -170,6 +157,31 @@ protected: | |||||
} | } | ||||
}; | }; | ||||
// SubWidget | |||||
template<> inline | |||||
ExampleRectanglesWidget<SubWidget>::ExampleRectanglesWidget(Widget* const parentWidget) | |||||
: SubWidget(parentWidget) | |||||
{ | |||||
init(); | |||||
} | |||||
// TopLevelWidget | |||||
template<> inline | |||||
ExampleRectanglesWidget<TopLevelWidget>::ExampleRectanglesWidget(Window& windowToMapTo) | |||||
: TopLevelWidget(windowToMapTo) | |||||
{ | |||||
init(); | |||||
} | |||||
// StandaloneWindow | |||||
template<> inline | |||||
ExampleRectanglesWidget<StandaloneWindow>::ExampleRectanglesWidget(Application& app) | |||||
: StandaloneWindow(app) | |||||
{ | |||||
init(); | |||||
done(); | |||||
} | |||||
typedef ExampleRectanglesWidget<SubWidget> ExampleRectanglesSubWidget; | typedef ExampleRectanglesWidget<SubWidget> ExampleRectanglesSubWidget; | ||||
typedef ExampleRectanglesWidget<TopLevelWidget> ExampleRectanglesTopLevelWidget; | typedef ExampleRectanglesWidget<TopLevelWidget> ExampleRectanglesTopLevelWidget; | ||||
typedef ExampleRectanglesWidget<StandaloneWindow> ExampleRectanglesStandaloneWindow; | typedef ExampleRectanglesWidget<StandaloneWindow> ExampleRectanglesStandaloneWindow; | ||||
@@ -21,8 +21,8 @@ | |||||
// DGL Stuff | // DGL Stuff | ||||
#include "../../dgl/Color.hpp" | #include "../../dgl/Color.hpp" | ||||
#include "../../dgl/StandaloneWindow.hpp" | |||||
#include "../../dgl/SubWidget.hpp" | #include "../../dgl/SubWidget.hpp" | ||||
#include "../../dgl/TopLevelWidget.hpp" | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
@@ -41,26 +41,13 @@ public: | |||||
static constexpr const char* const kExampleWidgetName = "Shapes"; | static constexpr const char* const kExampleWidgetName = "Shapes"; | ||||
// SubWidget | // SubWidget | ||||
explicit ExampleShapesWidget(Widget* const parentWidget) | |||||
: BaseWidget(parentWidget) | |||||
{ | |||||
this->setSize(300, 300); | |||||
} | |||||
explicit ExampleShapesWidget(Widget* const parent); | |||||
// TopLevelWidget | // TopLevelWidget | ||||
explicit ExampleShapesWidget(Window& windowToMapTo) | |||||
: BaseWidget(windowToMapTo) | |||||
{ | |||||
this->setSize(300, 300); | |||||
} | |||||
explicit ExampleShapesWidget(Window& windowToMapTo); | |||||
// StandaloneWindow | // StandaloneWindow | ||||
explicit ExampleShapesWidget(Application& app) | |||||
: BaseWidget(app) | |||||
{ | |||||
this->setSize(300, 300); | |||||
done(); | |||||
} | |||||
explicit ExampleShapesWidget(Application& app); | |||||
protected: | protected: | ||||
void onDisplay() override | void onDisplay() override | ||||
@@ -108,6 +95,31 @@ protected: | |||||
} | } | ||||
}; | }; | ||||
// SubWidget | |||||
template<> inline | |||||
ExampleShapesWidget<SubWidget>::ExampleShapesWidget(Widget* const parentWidget) | |||||
: SubWidget(parentWidget) | |||||
{ | |||||
setSize(300, 300); | |||||
} | |||||
// TopLevelWidget | |||||
template<> inline | |||||
ExampleShapesWidget<TopLevelWidget>::ExampleShapesWidget(Window& windowToMapTo) | |||||
: TopLevelWidget(windowToMapTo) | |||||
{ | |||||
setSize(300, 300); | |||||
} | |||||
// StandaloneWindow | |||||
template<> inline | |||||
ExampleShapesWidget<StandaloneWindow>::ExampleShapesWidget(Application& app) | |||||
: StandaloneWindow(app) | |||||
{ | |||||
setSize(300, 300); | |||||
done(); | |||||
} | |||||
typedef ExampleShapesWidget<SubWidget> ExampleShapesSubWidget; | typedef ExampleShapesWidget<SubWidget> ExampleShapesSubWidget; | ||||
typedef ExampleShapesWidget<TopLevelWidget> ExampleShapesTopLevelWidget; | typedef ExampleShapesWidget<TopLevelWidget> ExampleShapesTopLevelWidget; | ||||
typedef ExampleShapesWidget<StandaloneWindow> ExampleShapesStandaloneWindow; | typedef ExampleShapesWidget<StandaloneWindow> ExampleShapesStandaloneWindow; | ||||