Skip to content

Commit

Permalink
Start Window related tests; comment out all code
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed May 1, 2021
1 parent 711a316 commit 3b1e5d6
Show file tree
Hide file tree
Showing 12 changed files with 589 additions and 372 deletions.
6 changes: 3 additions & 3 deletions dgl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ BUILD_CXX_FLAGS += -Wno-missing-field-initializers -Wno-extra -Wno-narrowing

OBJS_common = \
../build/dgl/Application.cpp.o \
../build/dgl/ApplicationPrivateData.cpp.o
# ../build/dgl/Color.cpp.o \
# ../build/dgl/Geometry.cpp.o \
../build/dgl/ApplicationPrivateData.cpp.o \
../build/dgl/Color.cpp.o \
../build/dgl/Geometry.cpp.o
# ../build/dgl/ImageBase.cpp.o \
# ../build/dgl/Resources.cpp.o\
# ../build/dgl/StandaloneWindow.cpp.o \
Expand Down
110 changes: 60 additions & 50 deletions dgl/Window.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2020 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2021 Filipe Coelho <[email protected]>
*
* 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
Expand All @@ -19,29 +19,59 @@

#include "Geometry.hpp"

#ifdef DISTRHO_DEFINES_H_INCLUDED
START_NAMESPACE_DISTRHO
class UI;
class UIExporter;
END_NAMESPACE_DISTRHO
#endif

START_NAMESPACE_DGL

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

class Application;
class Widget;
class StandaloneWindow;

class Window
{
public:
explicit Window(Application& app);
explicit Window(Application& app, uintptr_t parentWindowHandle, double scaling, bool resizable);
virtual ~Window();

void close();

/**
Get the "native" window handle.
Returned value depends on the platform:
- HaikuOS: This is a pointer to a `BView`.
- MacOS: This is a pointer to an `NSView*`.
- Windows: This is a `HWND`.
- Everything else: This is an [X11] `Window`.
*/
uintptr_t getNativeWindowHandle() const noexcept;

private:
struct PrivateData;
PrivateData* const pData;
friend class Application;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Window);
};

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

END_NAMESPACE_DGL

/* TODO
* add focusEvent with CrossingMode arg
* add eventcrossing/enter-leave event
*/

class Window
{
public:
// class StandaloneWindow;
// class Widget;

// #ifdef DISTRHO_DEFINES_H_INCLUDED
// START_NAMESPACE_DISTRHO
// class UI;
// class UIExporter;
// END_NAMESPACE_DISTRHO
// #endif

#if 0
#ifndef DGL_FILE_BROWSER_DISABLED
/**
File browser options.
Expand Down Expand Up @@ -81,14 +111,10 @@ class Window
};
#endif // DGL_FILE_BROWSER_DISABLED

explicit Window(Application& app);
explicit Window(Window& transientParentWindow);
explicit Window(Application& app, uintptr_t parentWindowHandle, double scaling, bool resizable);
virtual ~Window();
static Window& withTransientParentWindow(Window& transientParentWindow);

void show();
void hide();
void close();
void exec(bool lockWait = false);

void focus();
Expand Down Expand Up @@ -129,21 +155,12 @@ class Window
Application& getApp() const noexcept;
#endif

/**
Get the "native" window handle.
Returned value depends on the platform:
- HaikuOS: This is a pointer to a `BView`.
- MacOS: This is a pointer to an `NSView*`.
- Windows: This is a `HWND`.
- Everything else: This is an [X11] `Window`.
*/
uintptr_t getNativeWindowHandle() const noexcept;

const GraphicsContext& getGraphicsContext() const noexcept;

void addIdleCallback(IdleCallback* const callback);
void removeIdleCallback(IdleCallback* const callback);


protected:
virtual void onDisplayBefore();
virtual void onDisplayAfter();
Expand All @@ -157,38 +174,31 @@ class Window
// internal
void _setAutoScaling(double scaling) noexcept;

private:
struct PrivateData;
PrivateData* const pData;
friend class Application;
friend class Widget;
friend class StandaloneWindow;
#ifdef DISTRHO_DEFINES_H_INCLUDED
friend class DISTRHO_NAMESPACE::UI;
friend class DISTRHO_NAMESPACE::UIExporter;
#endif

virtual void _addWidget(Widget* const widget);
virtual void _removeWidget(Widget* const widget);
void _idle();

bool handlePluginKeyboard(const bool press, const uint key);
bool handlePluginSpecial(const bool press, const Key key);

// friend class Widget;
// friend class StandaloneWindow;
// #ifdef DISTRHO_DEFINES_H_INCLUDED
// friend class DISTRHO_NAMESPACE::UI;
// friend class DISTRHO_NAMESPACE::UIExporter;
// #endif

// Prevent copies
#ifdef DISTRHO_PROPER_CPP11_SUPPORT
Window& operator=(Window&) = delete;
Window& operator=(const Window&) = delete;
#else
Window& operator=(Window&);
Window& operator=(const Window&);
#endif
// #ifdef DISTRHO_PROPER_CPP11_SUPPORT
// Window& operator=(Window&) = delete;
// Window& operator=(const Window&) = delete;
// #else
// Window& operator=(Window&);
// Window& operator=(const Window&);
// #endif

DISTRHO_LEAK_DETECTOR(Window);
};
#endif

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

END_NAMESPACE_DGL

#endif // DGL_WINDOW_HPP_INCLUDED
14 changes: 7 additions & 7 deletions dgl/src/ApplicationPrivateData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ void Application::PrivateData::idle(const uint timeoutInMs)
puglUpdate(world, timeoutInSeconds);
}

#ifndef DPF_TEST_APPLICATION_CPP
for (std::list<Window*>::iterator it = windows.begin(), ite = windows.end(); it != ite; ++it)
{
Window* const window(*it);
window->_idle();
}
#endif
// #ifndef DPF_TEST_APPLICATION_CPP
// for (std::list<Window*>::iterator it = windows.begin(), ite = windows.end(); it != ite; ++it)
// {
// Window* const window(*it);
// window->_idle();
// }
// #endif

for (std::list<IdleCallback*>::iterator it = idleCallbacks.begin(), ite = idleCallbacks.end(); it != ite; ++it)
{
Expand Down
2 changes: 1 addition & 1 deletion dgl/src/ApplicationPrivateData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct Application::PrivateData {
/** Set flag indicating application is quitting, and closes all windows in reverse order of registration. */
void quit();

DISTRHO_DECLARE_NON_COPY_STRUCT(PrivateData)
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData)
};

// --------------------------------------------------------------------------------------------------------------------
Expand Down
32 changes: 18 additions & 14 deletions dgl/src/Window.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2020 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2021 Filipe Coelho <[email protected]>
*
* 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
Expand All @@ -16,17 +16,19 @@

#include "WindowPrivateData.hpp"

#include "pugl.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------
// Window

// Window::Window(Window& transientParentWindow)
// : pData(new PrivateData(transientParentWindow.pData->fAppData, this, transientParentWindow)) {}

Window::Window(Application& app)
: pData(new PrivateData(app.pData, this)) {}

Window::Window(Window& transientParentWindow)
: pData(new PrivateData(transientParentWindow.pData->fAppData, this, transientParentWindow)) {}

Window::Window(Application& app, const uintptr_t parentWindowHandle, const double scaling, const bool resizable)
: pData(new PrivateData(app.pData, this, parentWindowHandle, scaling, resizable)) {}

Expand All @@ -35,6 +37,17 @@ Window::~Window()
delete pData;
}

void Window::close()
{
pData->close();
}

uintptr_t Window::getNativeWindowHandle() const noexcept
{
return puglGetNativeWindow(pData->view);
}

#if 0
void Window::show()
{
pData->setVisible(true);
Expand All @@ -45,11 +58,6 @@ void Window::hide()
pData->setVisible(false);
}

void Window::close()
{
pData->close();
}

#if 0
void Window::exec(bool lockWait)
{
Expand Down Expand Up @@ -191,11 +199,6 @@ Application& Window::getApp() const noexcept
}
#endif

uintptr_t Window::getNativeWindowHandle() const noexcept
{
return puglGetNativeWindow(pData->fView);
}

#if 0
const GraphicsContext& Window::getGraphicsContext() const noexcept
{
Expand Down Expand Up @@ -285,6 +288,7 @@ bool Window::handlePluginSpecial(const bool press, const Key key)
return false;
// return pData->handlePluginSpecial(press, key);
}
#endif

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

Expand Down
Loading

0 comments on commit 3b1e5d6

Please sign in to comment.