Skip to content

Commit

Permalink
Fix tests on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
falkTX committed Sep 3, 2021
1 parent 37e6922 commit 6bbe8e8
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 96 deletions.
2 changes: 1 addition & 1 deletion dgl/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Window
Window win(app);
ScopedPointer<MyCustomTopLevelWidget> widget;
{
const ScopedGraphicsContext sgc(win);
const Window::ScopedGraphicsContext sgc(win);
widget = new MyCustomTopLevelWidget(win);
}
app.exec();
Expand Down
2 changes: 1 addition & 1 deletion distrho/src/DistrhoUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static double getDesktopScaleFactor()

XrmInitialize();

if (char* const rms = XResourceManagerString(view->world->impl->display))
if (char* const rms = XResourceManagerString(display))
{
if (const XrmDatabase sdb = XrmGetStringDatabase(rms))
{
Expand Down
13 changes: 13 additions & 0 deletions tests/Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ typedef DGL_NAMESPACE::VulkanImage DemoImage;

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<TopLevelWidget, DemoImage> ExampleImagesTopLevelWidget;
typedef ExampleImagesWidget<StandaloneWindow, DemoImage> ExampleImagesStandaloneWindow;
Expand Down
11 changes: 7 additions & 4 deletions tests/NanoSubWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,13 @@ class NanoExampleWindow : public Window
{
public:
explicit NanoExampleWindow(Application& app)
: Window(app),
container(*this)
: Window(app)
{
{
const ScopedGraphicsContext sgc(*this);
container = new NanoRectanglesContainer(*this);
}

const uint targetWidth = 400;
const uint targetHeight = 400;
const double scaleFactor = getScaleFactor();
Expand All @@ -141,7 +145,7 @@ class NanoExampleWindow : public Window
}

private:
NanoRectanglesContainer container;
ScopedPointer<NanoRectanglesContainer> container;
};

// --------------------------------------------------------------------------------------------------------------------
Expand All @@ -154,7 +158,6 @@ int main()

Application app;
NanoExampleWindow win(app);

win.show();
app.exec();

Expand Down
76 changes: 20 additions & 56 deletions tests/widgets/ExampleImagesWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
// DGL Stuff

#include "../../dgl/ImageBase.hpp"
#include "../../dgl/StandaloneWindow.hpp"
#include "../../dgl/SubWidget.hpp"
#include "../../dgl/TopLevelWidget.hpp"

// ------------------------------------------------------
// Images
Expand Down Expand Up @@ -55,70 +55,34 @@ class ExampleImagesWidget : public BaseWidget,
static constexpr const char* kExampleWidgetName = "Images";

// 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
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
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);
done();
}

protected:
void idleCallback() noexcept override
{
if (img1rev)
Expand Down
46 changes: 29 additions & 17 deletions tests/widgets/ExampleRectanglesWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
// DGL Stuff

#include "../../dgl/Color.hpp"
#include "../../dgl/StandaloneWindow.hpp"
#include "../../dgl/SubWidget.hpp"
#include "../../dgl/TopLevelWidget.hpp"

START_NAMESPACE_DGL

Expand All @@ -38,26 +38,13 @@ class ExampleRectanglesWidget : public BaseWidget
static constexpr const char* const kExampleWidgetName = "Rectangles";

// SubWidget
explicit ExampleRectanglesWidget(Widget* const parentWidget)
: BaseWidget(parentWidget)
{
init();
}
explicit ExampleRectanglesWidget(Widget* const parent);

// TopLevelWidget
explicit ExampleRectanglesWidget(Window& windowToMapTo)
: BaseWidget(windowToMapTo)
{
init();
}
explicit ExampleRectanglesWidget(Window& windowToMapTo);

// StandaloneWindow
explicit ExampleRectanglesWidget(Application& app)
: BaseWidget(app)
{
init();
done();
}
explicit ExampleRectanglesWidget(Application& app);

void init()
{
Expand Down Expand Up @@ -170,6 +157,31 @@ class ExampleRectanglesWidget : public BaseWidget
}
};

// 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<TopLevelWidget> ExampleRectanglesTopLevelWidget;
typedef ExampleRectanglesWidget<StandaloneWindow> ExampleRectanglesStandaloneWindow;
Expand Down
46 changes: 29 additions & 17 deletions tests/widgets/ExampleShapesWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
// DGL Stuff

#include "../../dgl/Color.hpp"
#include "../../dgl/StandaloneWindow.hpp"
#include "../../dgl/SubWidget.hpp"
#include "../../dgl/TopLevelWidget.hpp"

START_NAMESPACE_DGL

Expand All @@ -41,26 +41,13 @@ class ExampleShapesWidget : public BaseWidget
static constexpr const char* const kExampleWidgetName = "Shapes";

// SubWidget
explicit ExampleShapesWidget(Widget* const parentWidget)
: BaseWidget(parentWidget)
{
this->setSize(300, 300);
}
explicit ExampleShapesWidget(Widget* const parent);

// TopLevelWidget
explicit ExampleShapesWidget(Window& windowToMapTo)
: BaseWidget(windowToMapTo)
{
this->setSize(300, 300);
}
explicit ExampleShapesWidget(Window& windowToMapTo);

// StandaloneWindow
explicit ExampleShapesWidget(Application& app)
: BaseWidget(app)
{
this->setSize(300, 300);
done();
}
explicit ExampleShapesWidget(Application& app);

protected:
void onDisplay() override
Expand Down Expand Up @@ -108,6 +95,31 @@ class ExampleShapesWidget : public BaseWidget
}
};

// 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<TopLevelWidget> ExampleShapesTopLevelWidget;
typedef ExampleShapesWidget<StandaloneWindow> ExampleShapesStandaloneWindow;
Expand Down

0 comments on commit 6bbe8e8

Please sign in to comment.