| @@ -18,7 +18,7 @@ | |||
| # error We do not want Qt in the engine code! | |||
| #endif | |||
| #include "../CarlaNative.hpp" | |||
| #include "CarlaNative.hpp" | |||
| #include "CarlaString.hpp" | |||
| #include "DistrhoPluginMain.cpp" | |||
| @@ -33,8 +33,6 @@ | |||
| # endif | |||
| #endif | |||
| using juce::ScopedPointer; | |||
| // ----------------------------------------------------------------------- | |||
| START_NAMESPACE_DISTRHO | |||
| @@ -59,8 +57,8 @@ public: | |||
| #endif | |||
| { | |||
| #ifdef DISTRHO_UI_OPENGL | |||
| glWindow.setSize(fUi.getWidth(), fUi.getHeight()); | |||
| glWindow.setWindowTitle(host->uiName); | |||
| //glWindow.setSize(fUi.getWidth(), fUi.getHeight()); | |||
| glWindow.setTitle(host->uiName); | |||
| #else | |||
| CarlaString filename; | |||
| filename += fHost->resourceDir; | |||
| @@ -202,7 +200,7 @@ public: | |||
| void carla_setUiTitle(const char* const uiTitle) | |||
| { | |||
| #ifdef DISTRHO_UI_OPENGL | |||
| glWindow.setWindowTitle(uiTitle); | |||
| glWindow.setTitle(uiTitle); | |||
| #else | |||
| writeMsg("uiTitle\n", 8); | |||
| writeAndFixMsg(uiTitle); | |||
| @@ -321,7 +319,11 @@ public: | |||
| ~PluginCarla() override | |||
| { | |||
| #if DISTRHO_PLUGIN_HAS_UI | |||
| fUiPtr = nullptr; | |||
| if (fUiPtr != nullptr) | |||
| { | |||
| delete fUiPtr; | |||
| fUiPtr = nullptr; | |||
| } | |||
| #endif | |||
| } | |||
| @@ -574,7 +576,7 @@ private: | |||
| #if DISTRHO_PLUGIN_HAS_UI | |||
| // UI | |||
| ScopedPointer<UICarla> fUiPtr; | |||
| UICarla* fUiPtr; | |||
| void createUiIfNeeded() | |||
| { | |||
| @@ -21,6 +21,8 @@ | |||
| START_NAMESPACE_DGL | |||
| class Window; | |||
| // ----------------------------------------------------------------------- | |||
| class App | |||
| @@ -35,9 +37,14 @@ public: | |||
| bool isQuiting() const; | |||
| private: | |||
| class PrivateData; | |||
| struct PrivateData; | |||
| PrivateData* const pData; | |||
| friend class Window; | |||
| void addWindow(Window* const window); | |||
| void removeWindow(Window* const window); | |||
| void oneShown(); | |||
| void oneHidden(); | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| @@ -53,9 +53,9 @@ | |||
| #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE; | |||
| #if DGL_OS_MAC | |||
| # include <OpenGL/glu.h> | |||
| # include <OpenGL/gl.h> | |||
| #else | |||
| # include <GL/glu.h> | |||
| # include <GL/gl.h> | |||
| #endif | |||
| #if defined(GL_BGR_EXT) && ! defined(GL_BGR) | |||
| @@ -27,24 +27,24 @@ template<typename T> | |||
| class Point | |||
| { | |||
| public: | |||
| Point(); | |||
| Point(T x, T y); | |||
| Point(const Point<T>& pos); | |||
| Point() noexcept; | |||
| Point(T x, T y) noexcept; | |||
| Point(const Point<T>& pos) noexcept; | |||
| T getX() const; | |||
| T getY() const; | |||
| T getX() const noexcept; | |||
| T getY() const noexcept; | |||
| void setX(T x); | |||
| void setY(T y); | |||
| void setX(T x) noexcept; | |||
| void setY(T y) noexcept; | |||
| void move(T x, T y); | |||
| void move(const Point<T>& pos); | |||
| void move(T x, T y) noexcept; | |||
| void move(const Point<T>& pos) noexcept; | |||
| Point<T>& operator=(const Point<T>& pos); | |||
| Point<T>& operator+=(const Point<T>& pos); | |||
| Point<T>& operator-=(const Point<T>& pos); | |||
| bool operator==(const Point<T>& pos) const; | |||
| bool operator!=(const Point<T>& pos) const; | |||
| Point<T>& operator=(const Point<T>& pos) noexcept; | |||
| Point<T>& operator+=(const Point<T>& pos) noexcept; | |||
| Point<T>& operator-=(const Point<T>& pos) noexcept; | |||
| bool operator==(const Point<T>& pos) const noexcept; | |||
| bool operator!=(const Point<T>& pos) const noexcept; | |||
| private: | |||
| T fX, fY; | |||
| @@ -57,23 +57,23 @@ template<typename T> | |||
| class Size | |||
| { | |||
| public: | |||
| Size(); | |||
| Size(T width, T height); | |||
| Size(const Size<T>& size); | |||
| Size() noexcept; | |||
| Size(T width, T height) noexcept; | |||
| Size(const Size<T>& size) noexcept; | |||
| T getWidth() const; | |||
| T getHeight() const; | |||
| T getWidth() const noexcept; | |||
| T getHeight() const noexcept; | |||
| void setWidth(T width); | |||
| void setHeight(T height); | |||
| void setWidth(T width) noexcept; | |||
| void setHeight(T height) noexcept; | |||
| Size<T>& operator=(const Size<T>& size); | |||
| Size<T>& operator+=(const Size<T>& size); | |||
| Size<T>& operator-=(const Size<T>& size); | |||
| Size<T>& operator*=(T m); | |||
| Size<T>& operator/=(T d); | |||
| bool operator==(const Size<T>& size) const; | |||
| bool operator!=(const Size<T>& size) const; | |||
| Size<T>& operator=(const Size<T>& size) noexcept; | |||
| Size<T>& operator+=(const Size<T>& size) noexcept; | |||
| Size<T>& operator-=(const Size<T>& size) noexcept; | |||
| Size<T>& operator*=(T m) noexcept; | |||
| Size<T>& operator/=(T d) noexcept; | |||
| bool operator==(const Size<T>& size) const noexcept; | |||
| bool operator!=(const Size<T>& size) const noexcept; | |||
| private: | |||
| T fWidth, fHeight; | |||
| @@ -86,40 +86,40 @@ template<typename T> | |||
| class Rectangle | |||
| { | |||
| public: | |||
| Rectangle(); | |||
| Rectangle(T x, T y, T width, T height); | |||
| Rectangle(T x, T y, const Size<T>& size); | |||
| Rectangle(const Point<T>& pos, T width, T height); | |||
| Rectangle(const Point<T>& pos, const Size<T>& size); | |||
| Rectangle(const Rectangle<T>& rect); | |||
| T getX() const; | |||
| T getY() const; | |||
| T getWidth() const; | |||
| T getHeight() const; | |||
| const Point<T>& getPos() const; | |||
| const Size<T>& getSize() const; | |||
| bool contains(T x, T y) const; | |||
| bool contains(const Point<T>& pos) const; | |||
| bool containsX(T x) const; | |||
| bool containsY(T y) const; | |||
| void setX(T x); | |||
| void setY(T y); | |||
| void setPos(T x, T y); | |||
| void setPos(const Point<T>& pos); | |||
| void move(T x, T y); | |||
| void move(const Point<T>& pos); | |||
| void setWidth(T width); | |||
| void setHeight(T height); | |||
| void setSize(T width, T height); | |||
| void setSize(const Size<T>& size); | |||
| Rectangle<T>& operator=(const Rectangle<T>& rect); | |||
| Rectangle() noexcept; | |||
| Rectangle(T x, T y, T width, T height) noexcept; | |||
| Rectangle(T x, T y, const Size<T>& size) noexcept; | |||
| Rectangle(const Point<T>& pos, T width, T height) noexcept; | |||
| Rectangle(const Point<T>& pos, const Size<T>& size) noexcept; | |||
| Rectangle(const Rectangle<T>& rect) noexcept; | |||
| T getX() const noexcept; | |||
| T getY() const noexcept; | |||
| T getWidth() const noexcept; | |||
| T getHeight() const noexcept; | |||
| const Point<T>& getPos() const noexcept; | |||
| const Size<T>& getSize() const noexcept; | |||
| bool contains(T x, T y) const noexcept; | |||
| bool contains(const Point<T>& pos) const noexcept; | |||
| bool containsX(T x) const noexcept; | |||
| bool containsY(T y) const noexcept; | |||
| void setX(T x) noexcept; | |||
| void setY(T y) noexcept; | |||
| void setPos(T x, T y) noexcept; | |||
| void setPos(const Point<T>& pos) noexcept; | |||
| void move(T x, T y) noexcept; | |||
| void move(const Point<T>& pos) noexcept; | |||
| void setWidth(T width) noexcept; | |||
| void setHeight(T height) noexcept; | |||
| void setSize(T width, T height) noexcept; | |||
| void setSize(const Size<T>& size) noexcept; | |||
| Rectangle<T>& operator=(const Rectangle<T>& rect) noexcept; | |||
| private: | |||
| Point<T> fPos; | |||
| @@ -26,31 +26,31 @@ START_NAMESPACE_DGL | |||
| class Image | |||
| { | |||
| public: | |||
| Image(); | |||
| Image(const char* rawData, int width, int height, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE); | |||
| Image(const char* rawData, const Size<int>& size, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE); | |||
| Image(const Image& image); | |||
| Image() noexcept; | |||
| Image(const char* rawData, int width, int height, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept; | |||
| Image(const char* rawData, const Size<int>& size, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept; | |||
| Image(const Image& image) noexcept; | |||
| void loadFromMemory(const char* rawData, int width, int height, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE); | |||
| void loadFromMemory(const char* rawData, const Size<int>& size, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE); | |||
| void loadFromMemory(const char* rawData, int width, int height, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept; | |||
| void loadFromMemory(const char* rawData, const Size<int>& size, GLenum format = GL_BGRA, GLenum type = GL_UNSIGNED_BYTE) noexcept; | |||
| bool isValid() const; | |||
| bool isValid() const noexcept; | |||
| int getWidth() const; | |||
| int getHeight() const; | |||
| const Size<int>& getSize() const; | |||
| int getWidth() const noexcept; | |||
| int getHeight() const noexcept; | |||
| const Size<int>& getSize() const noexcept; | |||
| const char* getRawData() const; | |||
| GLenum getFormat() const; | |||
| GLenum getType() const; | |||
| const char* getRawData() const noexcept; | |||
| GLenum getFormat() const noexcept; | |||
| GLenum getType() const noexcept; | |||
| void draw() const; | |||
| void draw(int x, int y) const; | |||
| void draw(const Point<int>& pos) const; | |||
| Image& operator=(const Image& image); | |||
| bool operator==(const Image& image) const; | |||
| bool operator!=(const Image& image) const; | |||
| Image& operator=(const Image& image) noexcept; | |||
| bool operator==(const Image& image) const noexcept; | |||
| bool operator!=(const Image& image) const noexcept; | |||
| private: | |||
| const char* fRawData; | |||
| @@ -35,7 +35,7 @@ class ImageAboutWindow : public Window, | |||
| public Widget | |||
| { | |||
| public: | |||
| ImageAboutWindow(App* app, Window* parent, const Image& image = Image()); | |||
| ImageAboutWindow(App& app, Window& parent, const Image& image = Image()); | |||
| ImageAboutWindow(Widget* widget, const Image& image = Image()); | |||
| void setImage(const Image& image); | |||
| @@ -34,9 +34,9 @@ public: | |||
| virtual void imageButtonClicked(ImageButton* imageButton, int button) = 0; | |||
| }; | |||
| ImageButton(Window* parent, const Image& image); | |||
| ImageButton(Window& parent, const Image& image); | |||
| ImageButton(Widget* widget, const Image& image); | |||
| ImageButton(Window* parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown); | |||
| ImageButton(Window& parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown); | |||
| ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown); | |||
| ImageButton(const ImageButton& imageButton); | |||
| @@ -41,7 +41,7 @@ public: | |||
| virtual void imageKnobValueChanged(ImageKnob* imageKnob, float value) = 0; | |||
| }; | |||
| ImageKnob(Window* parent, const Image& image, Orientation orientation = Vertical); | |||
| ImageKnob(Window& parent, const Image& image, Orientation orientation = Vertical); | |||
| ImageKnob(Widget* widget, const Image& image, Orientation orientation = Vertical); | |||
| ImageKnob(const ImageKnob& imageKnob); | |||
| @@ -36,7 +36,7 @@ public: | |||
| virtual void imageSliderValueChanged(ImageSlider* imageSlider, float value) = 0; | |||
| }; | |||
| ImageSlider(Window* parent, const Image& image); | |||
| ImageSlider(Window& parent, const Image& image); | |||
| ImageSlider(Widget* widget, const Image& image); | |||
| ImageSlider(const ImageSlider& imageSlider); | |||
| @@ -34,12 +34,12 @@ public: | |||
| { | |||
| } | |||
| App& getApp() const | |||
| App& getApp() const noexcept | |||
| { | |||
| return fApp; | |||
| } | |||
| Window& getWindow() const | |||
| Window& getWindow() const noexcept | |||
| { | |||
| return fWindow; | |||
| } | |||
| @@ -63,9 +63,9 @@ public: | |||
| fWindow.setSize(width, height); | |||
| } | |||
| void setWindowTitle(const char* title) | |||
| void setTitle(const char* title) | |||
| { | |||
| fWindow.setWindowTitle(title); | |||
| fWindow.setTitle(title); | |||
| } | |||
| private: | |||
| @@ -19,6 +19,12 @@ | |||
| #include "Geometry.hpp" | |||
| #ifdef PROPER_CPP11_SUPPORT | |||
| # include <cstdint> | |||
| #else | |||
| # include <stdint.h> | |||
| #endif | |||
| START_NAMESPACE_DGL | |||
| // ----------------------------------------------------------------------- | |||
| @@ -32,22 +38,15 @@ public: | |||
| Widget(Window& parent); | |||
| virtual ~Widget(); | |||
| bool isVisible() const; | |||
| bool isVisible() const noexcept; | |||
| void setVisible(bool yesNo); | |||
| void show() | |||
| { | |||
| setVisible(true); | |||
| } | |||
| void hide() | |||
| { | |||
| setVisible(false); | |||
| } | |||
| void show(); | |||
| void hide(); | |||
| int getX() const; | |||
| int getY() const; | |||
| const Point<int>& getPos() const; | |||
| int getX() const noexcept; | |||
| int getY() const noexcept; | |||
| const Point<int>& getPos() const noexcept; | |||
| void setX(int x); | |||
| void setY(int y); | |||
| @@ -57,26 +56,28 @@ public: | |||
| void move(int x, int y); | |||
| void move(const Point<int>& pos); | |||
| int getWidth() const; | |||
| int getHeight() const; | |||
| const Size<int>& getSize() const; | |||
| int getWidth() const noexcept; | |||
| int getHeight() const noexcept; | |||
| const Size<int>& getSize() const noexcept; | |||
| void setWidth(int width); | |||
| void setHeight(int height); | |||
| void setSize(int width, int height); | |||
| void setSize(const Size<int>& size); | |||
| const Rectangle<int>& getArea() const; | |||
| const Rectangle<int>& getArea() const noexcept; | |||
| uint32_t getEventTimestamp(); | |||
| int getModifiers(); | |||
| App* getApp() const; | |||
| Window* getParent() const; | |||
| App& getParentApp() const noexcept; | |||
| Window& getParentWindow() const noexcept; | |||
| void repaint(); | |||
| protected: | |||
| virtual void onDisplay(); | |||
| virtual bool onKeyboard(bool press, unsigned key); | |||
| virtual bool onKeyboard(bool press, uint32_t key); | |||
| virtual bool onMouse(int button, bool press, int x, int y); | |||
| virtual bool onMotion(int x, int y); | |||
| virtual bool onScroll(float dx, float dy); | |||
| @@ -17,7 +17,13 @@ | |||
| #ifndef DGL_WINDOW_HPP_INCLUDED | |||
| #define DGL_WINDOW_HPP_INCLUDED | |||
| #include "Base.hpp" | |||
| #include "Geometry.hpp" | |||
| #ifdef PROPER_CPP11_SUPPORT | |||
| # include <cstdint> | |||
| #else | |||
| # include <stdint.h> | |||
| #endif | |||
| START_NAMESPACE_DGL | |||
| @@ -34,31 +40,40 @@ public: | |||
| Window(App& app, intptr_t parentId); | |||
| virtual ~Window(); | |||
| void show(); | |||
| void hide(); | |||
| void close(); | |||
| void exec(bool lockWait = false); | |||
| void focus(); | |||
| void idle(); | |||
| void repaint(); | |||
| bool isVisible(); | |||
| bool isVisible() const noexcept; | |||
| void setVisible(bool yesNo); | |||
| bool isResizable() const noexcept; | |||
| void setResizable(bool yesNo); | |||
| void setSize(unsigned int width, unsigned int height); | |||
| void setWindowTitle(const char* title); | |||
| App& getApp() const; | |||
| int getModifiers() const; | |||
| intptr_t getWindowId() const; | |||
| int getWidth() const noexcept; | |||
| int getHeight() const noexcept; | |||
| Size<int> getSize() const noexcept; | |||
| void setSize(unsigned int width, unsigned int height); | |||
| void addWidget(Widget* widget); | |||
| void removeWidget(Widget* widget); | |||
| void setTitle(const char* title); | |||
| void show(); | |||
| void hide(); | |||
| void close(); | |||
| App& getApp() const noexcept; | |||
| uint32_t getEventTimestamp() const; | |||
| int getModifiers() const; | |||
| intptr_t getWindowId() const; | |||
| private: | |||
| class PrivateData; | |||
| PrivateData* const pData; | |||
| friend class Widget; | |||
| void addWidget(Widget* const widget); | |||
| void removeWidget(Widget* const widget); | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| @@ -14,27 +14,41 @@ | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #include "AppPrivate.hpp" | |||
| #include "../App.hpp" | |||
| #include "../Window.hpp" | |||
| #include <list> | |||
| START_NAMESPACE_DGL | |||
| // ----------------------------------------------------------------------- | |||
| struct App::PrivateData { | |||
| bool doLoop; | |||
| unsigned visibleWindows; | |||
| std::list<Window*> windows; | |||
| PrivateData() | |||
| : doLoop(false), | |||
| visibleWindows(0) {} | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| App::App() | |||
| : pData(new Private()) | |||
| : pData(new PrivateData()) | |||
| { | |||
| } | |||
| App::~App() | |||
| { | |||
| pData->windows.clear(); | |||
| delete pData; | |||
| } | |||
| void App::idle() | |||
| { | |||
| for (std::list<Window*>::iterator it = pData->fWindows.begin(); it != pData->fWindows.end(); ++it) | |||
| for (std::list<Window*>::iterator it = pData->windows.begin(); it != pData->windows.end(); ++it) | |||
| { | |||
| Window* const window(*it); | |||
| window->idle(); | |||
| @@ -43,7 +57,7 @@ void App::idle() | |||
| void App::exec() | |||
| { | |||
| while (pData->fDoLoop) | |||
| while (pData->doLoop) | |||
| { | |||
| idle(); | |||
| msleep(10); | |||
| @@ -52,18 +66,44 @@ void App::exec() | |||
| void App::quit() | |||
| { | |||
| pData->fDoLoop = false; | |||
| pData->doLoop = false; | |||
| for (std::list<Window*>::iterator it = pData->fWindows.begin(); it != pData->fWindows.end(); ++it) | |||
| for (std::list<Window*>::reverse_iterator rit = pData->windows.rbegin(); rit != pData->windows.rend(); ++rit) | |||
| { | |||
| Window* const window(*it); | |||
| Window* const window(*rit); | |||
| window->close(); | |||
| } | |||
| } | |||
| bool App::isQuiting() const | |||
| { | |||
| return !pData->fDoLoop; | |||
| return !pData->doLoop; | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| void App::addWindow(Window* const window) | |||
| { | |||
| if (window != nullptr) | |||
| pData->windows.push_back(window); | |||
| } | |||
| void App::removeWindow(Window* const window) | |||
| { | |||
| if (window != nullptr) | |||
| pData->windows.remove(window); | |||
| } | |||
| void App::oneShown() | |||
| { | |||
| if (++pData->visibleWindows == 1) | |||
| pData->doLoop = true; | |||
| } | |||
| void App::oneHidden() | |||
| { | |||
| if (--pData->visibleWindows == 0) | |||
| pData->doLoop = false; | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| @@ -14,68 +14,36 @@ | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #ifndef DGL_APP_PRIVATE_HPP_INCLUDED | |||
| #define DGL_APP_PRIVATE_HPP_INCLUDED | |||
| #include "../Base.hpp" | |||
| #include "../App.hpp" | |||
| #include <list> | |||
| #if DGL_OS_WINDOWS | |||
| # include <windows.h> | |||
| #else | |||
| # include <unistd.h> | |||
| #endif | |||
| START_NAMESPACE_DGL | |||
| // ----------------------------------------------------------------------- | |||
| class Window; | |||
| class App::PrivateData | |||
| void sleep(unsigned int secs) | |||
| { | |||
| public: | |||
| Private() | |||
| : fDoLoop(true), | |||
| fVisibleWindows(0) | |||
| { | |||
| } | |||
| ~Private() | |||
| { | |||
| fWindows.clear(); | |||
| } | |||
| void addWindow(Window* const window) | |||
| { | |||
| if (window != nullptr) | |||
| fWindows.push_back(window); | |||
| } | |||
| void removeWindow(Window* const window) | |||
| { | |||
| if (window != nullptr) | |||
| fWindows.remove(window); | |||
| } | |||
| void oneShown() | |||
| { | |||
| if (++fVisibleWindows == 1) | |||
| fDoLoop = true; | |||
| } | |||
| void oneHidden() | |||
| { | |||
| if (--fVisibleWindows == 0) | |||
| fDoLoop = false; | |||
| } | |||
| private: | |||
| bool fDoLoop; | |||
| unsigned fVisibleWindows; | |||
| std::list<Window*> fWindows; | |||
| friend class App; | |||
| }; | |||
| #ifdef DGL_OS_WINDOWS | |||
| ::Sleep(secs * 1000); | |||
| #else | |||
| ::sleep(secs); | |||
| #endif | |||
| } | |||
| void msleep(unsigned int msecs) | |||
| { | |||
| #ifdef DGL_OS_WINDOWS | |||
| ::Sleep(msecs); | |||
| #else | |||
| ::usleep(msecs * 1000); | |||
| #endif | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| END_NAMESPACE_DGL | |||
| #endif // DGL_APP_PRIVATE_HPP_INCLUDED | |||
| @@ -22,66 +22,66 @@ START_NAMESPACE_DGL | |||
| // Point | |||
| template<typename T> | |||
| Point<T>::Point() | |||
| Point<T>::Point() noexcept | |||
| : fX(0), | |||
| fY(0) | |||
| { | |||
| } | |||
| template<typename T> | |||
| Point<T>::Point(T x, T y) | |||
| Point<T>::Point(T x, T y) noexcept | |||
| : fX(x), | |||
| fY(y) | |||
| { | |||
| } | |||
| template<typename T> | |||
| Point<T>::Point(const Point& pos) | |||
| Point<T>::Point(const Point& pos) noexcept | |||
| : fX(pos.fX), | |||
| fY(pos.fY) | |||
| { | |||
| } | |||
| template<typename T> | |||
| T Point<T>::getX() const | |||
| T Point<T>::getX() const noexcept | |||
| { | |||
| return fX; | |||
| } | |||
| template<typename T> | |||
| T Point<T>::getY() const | |||
| T Point<T>::getY() const noexcept | |||
| { | |||
| return fY; | |||
| } | |||
| template<typename T> | |||
| void Point<T>::setX(T x) | |||
| void Point<T>::setX(T x) noexcept | |||
| { | |||
| fX = x; | |||
| } | |||
| template<typename T> | |||
| void Point<T>::setY(T y) | |||
| void Point<T>::setY(T y) noexcept | |||
| { | |||
| fY = y; | |||
| } | |||
| template<typename T> | |||
| void Point<T>::move(T x, T y) | |||
| void Point<T>::move(T x, T y) noexcept | |||
| { | |||
| fX += x; | |||
| fY += y; | |||
| } | |||
| template<typename T> | |||
| void Point<T>::move(const Point& pos) | |||
| void Point<T>::move(const Point& pos) noexcept | |||
| { | |||
| fX += pos.fX; | |||
| fY += pos.fY; | |||
| } | |||
| template<typename T> | |||
| Point<T>& Point<T>::operator=(const Point<T>& pos) | |||
| Point<T>& Point<T>::operator=(const Point<T>& pos) noexcept | |||
| { | |||
| fX = pos.fX; | |||
| fY = pos.fY; | |||
| @@ -89,7 +89,7 @@ Point<T>& Point<T>::operator=(const Point<T>& pos) | |||
| } | |||
| template<typename T> | |||
| Point<T>& Point<T>::operator+=(const Point<T>& pos) | |||
| Point<T>& Point<T>::operator+=(const Point<T>& pos) noexcept | |||
| { | |||
| fX += pos.fX; | |||
| fY += pos.fY; | |||
| @@ -97,7 +97,7 @@ Point<T>& Point<T>::operator+=(const Point<T>& pos) | |||
| } | |||
| template<typename T> | |||
| Point<T>& Point<T>::operator-=(const Point<T>& pos) | |||
| Point<T>& Point<T>::operator-=(const Point<T>& pos) noexcept | |||
| { | |||
| fX -= pos.fX; | |||
| fY -= pos.fY; | |||
| @@ -105,13 +105,13 @@ Point<T>& Point<T>::operator-=(const Point<T>& pos) | |||
| } | |||
| template<typename T> | |||
| bool Point<T>::operator==(const Point<T>& pos) const | |||
| bool Point<T>::operator==(const Point<T>& pos) const noexcept | |||
| { | |||
| return (fX == pos.fX && fY== pos.fY); | |||
| } | |||
| template<typename T> | |||
| bool Point<T>::operator!=(const Point<T>& pos) const | |||
| bool Point<T>::operator!=(const Point<T>& pos) const noexcept | |||
| { | |||
| return !operator==(pos); | |||
| } | |||
| @@ -120,52 +120,52 @@ bool Point<T>::operator!=(const Point<T>& pos) const | |||
| // Size | |||
| template<typename T> | |||
| Size<T>::Size() | |||
| Size<T>::Size() noexcept | |||
| : fWidth(0), | |||
| fHeight(0) | |||
| { | |||
| } | |||
| template<typename T> | |||
| Size<T>::Size(T width, T height) | |||
| Size<T>::Size(T width, T height) noexcept | |||
| : fWidth(width), | |||
| fHeight(height) | |||
| { | |||
| } | |||
| template<typename T> | |||
| Size<T>::Size(const Size<T>& size) | |||
| Size<T>::Size(const Size<T>& size) noexcept | |||
| : fWidth(size.fWidth), | |||
| fHeight(size.fHeight) | |||
| { | |||
| } | |||
| template<typename T> | |||
| T Size<T>::getWidth() const | |||
| T Size<T>::getWidth() const noexcept | |||
| { | |||
| return fWidth; | |||
| } | |||
| template<typename T> | |||
| T Size<T>::getHeight() const | |||
| T Size<T>::getHeight() const noexcept | |||
| { | |||
| return fHeight; | |||
| } | |||
| template<typename T> | |||
| void Size<T>::setWidth(T width) | |||
| void Size<T>::setWidth(T width) noexcept | |||
| { | |||
| fWidth = width; | |||
| } | |||
| template<typename T> | |||
| void Size<T>::setHeight(T height) | |||
| void Size<T>::setHeight(T height) noexcept | |||
| { | |||
| fHeight = height; | |||
| } | |||
| template<typename T> | |||
| Size<T>& Size<T>::operator=(const Size<T>& size) | |||
| Size<T>& Size<T>::operator=(const Size<T>& size) noexcept | |||
| { | |||
| fWidth = size.fWidth; | |||
| fHeight = size.fHeight; | |||
| @@ -173,7 +173,7 @@ Size<T>& Size<T>::operator=(const Size<T>& size) | |||
| } | |||
| template<typename T> | |||
| Size<T>& Size<T>::operator+=(const Size<T>& size) | |||
| Size<T>& Size<T>::operator+=(const Size<T>& size) noexcept | |||
| { | |||
| fWidth += size.fWidth; | |||
| fHeight += size.fHeight; | |||
| @@ -181,7 +181,7 @@ Size<T>& Size<T>::operator+=(const Size<T>& size) | |||
| } | |||
| template<typename T> | |||
| Size<T>& Size<T>::operator-=(const Size<T>& size) | |||
| Size<T>& Size<T>::operator-=(const Size<T>& size) noexcept | |||
| { | |||
| fWidth -= size.fWidth; | |||
| fHeight -= size.fHeight; | |||
| @@ -189,7 +189,7 @@ Size<T>& Size<T>::operator-=(const Size<T>& size) | |||
| } | |||
| template<typename T> | |||
| Size<T>& Size<T>::operator*=(T m) | |||
| Size<T>& Size<T>::operator*=(T m) noexcept | |||
| { | |||
| fWidth *= m; | |||
| fHeight *= m; | |||
| @@ -197,7 +197,7 @@ Size<T>& Size<T>::operator*=(T m) | |||
| } | |||
| template<typename T> | |||
| Size<T>& Size<T>::operator/=(T d) | |||
| Size<T>& Size<T>::operator/=(T d) noexcept | |||
| { | |||
| fWidth /= d; | |||
| fHeight /= d; | |||
| @@ -205,13 +205,13 @@ Size<T>& Size<T>::operator/=(T d) | |||
| } | |||
| template<typename T> | |||
| bool Size<T>::operator==(const Size<T>& size) const | |||
| bool Size<T>::operator==(const Size<T>& size) const noexcept | |||
| { | |||
| return (fWidth == size.fWidth && fHeight == size.fHeight); | |||
| } | |||
| template<typename T> | |||
| bool Size<T>::operator!=(const Size<T>& size) const | |||
| bool Size<T>::operator!=(const Size<T>& size) const noexcept | |||
| { | |||
| return !operator==(size); | |||
| } | |||
| @@ -220,172 +220,172 @@ bool Size<T>::operator!=(const Size<T>& size) const | |||
| // Rectangle | |||
| template<typename T> | |||
| Rectangle<T>::Rectangle() | |||
| Rectangle<T>::Rectangle() noexcept | |||
| : fPos(0, 0), | |||
| fSize(0, 0) | |||
| { | |||
| } | |||
| template<typename T> | |||
| Rectangle<T>::Rectangle(T x, T y, T width, T height) | |||
| Rectangle<T>::Rectangle(T x, T y, T width, T height) noexcept | |||
| : fPos(x, y), | |||
| fSize(width, height) | |||
| { | |||
| } | |||
| template<typename T> | |||
| Rectangle<T>::Rectangle(T x, T y, const Size<T>& size) | |||
| Rectangle<T>::Rectangle(T x, T y, const Size<T>& size) noexcept | |||
| : fPos(x, y), | |||
| fSize(size) | |||
| { | |||
| } | |||
| template<typename T> | |||
| Rectangle<T>::Rectangle(const Point<T>& pos, T width, T height) | |||
| Rectangle<T>::Rectangle(const Point<T>& pos, T width, T height) noexcept | |||
| : fPos(pos), | |||
| fSize(width, height) | |||
| { | |||
| } | |||
| template<typename T> | |||
| Rectangle<T>::Rectangle(const Point<T>& pos, const Size<T>& size) | |||
| Rectangle<T>::Rectangle(const Point<T>& pos, const Size<T>& size) noexcept | |||
| : fPos(pos), | |||
| fSize(size) | |||
| { | |||
| } | |||
| template<typename T> | |||
| Rectangle<T>::Rectangle(const Rectangle<T>& rect) | |||
| Rectangle<T>::Rectangle(const Rectangle<T>& rect) noexcept | |||
| : fPos(rect.fPos), | |||
| fSize(rect.fSize) | |||
| { | |||
| } | |||
| template<typename T> | |||
| T Rectangle<T>::getX() const | |||
| T Rectangle<T>::getX() const noexcept | |||
| { | |||
| return fPos.fX; | |||
| } | |||
| template<typename T> | |||
| T Rectangle<T>::getY() const | |||
| T Rectangle<T>::getY() const noexcept | |||
| { | |||
| return fPos.fY; | |||
| } | |||
| template<typename T> | |||
| T Rectangle<T>::getWidth() const | |||
| T Rectangle<T>::getWidth() const noexcept | |||
| { | |||
| return fSize.fWidth; | |||
| } | |||
| template<typename T> | |||
| T Rectangle<T>::getHeight() const | |||
| T Rectangle<T>::getHeight() const noexcept | |||
| { | |||
| return fSize.fHeight; | |||
| } | |||
| template<typename T> | |||
| const Point<T>& Rectangle<T>::getPos() const | |||
| const Point<T>& Rectangle<T>::getPos() const noexcept | |||
| { | |||
| return fPos; | |||
| } | |||
| template<typename T> | |||
| const Size<T>& Rectangle<T>::getSize() const | |||
| const Size<T>& Rectangle<T>::getSize() const noexcept | |||
| { | |||
| return fSize; | |||
| } | |||
| template<typename T> | |||
| bool Rectangle<T>::contains(T x, T y) const | |||
| bool Rectangle<T>::contains(T x, T y) const noexcept | |||
| { | |||
| return (x >= fPos.fX && y >= fPos.fY && x <= fPos.fX+fSize.fWidth && y <= fPos.fY+fSize.fHeight); | |||
| } | |||
| template<typename T> | |||
| bool Rectangle<T>::contains(const Point<T>& pos) const | |||
| bool Rectangle<T>::contains(const Point<T>& pos) const noexcept | |||
| { | |||
| return contains(pos.fX, pos.fY); | |||
| } | |||
| template<typename T> | |||
| bool Rectangle<T>::containsX(T x) const | |||
| bool Rectangle<T>::containsX(T x) const noexcept | |||
| { | |||
| return (x >= fPos.fX && x <= fPos.fX + fSize.fWidth); | |||
| } | |||
| template<typename T> | |||
| bool Rectangle<T>::containsY(T y) const | |||
| bool Rectangle<T>::containsY(T y) const noexcept | |||
| { | |||
| return (y >= fPos.fY && y <= fPos.fY + fSize.fHeight); | |||
| } | |||
| template<typename T> | |||
| void Rectangle<T>::setX(T x) | |||
| void Rectangle<T>::setX(T x) noexcept | |||
| { | |||
| fPos.fX = x; | |||
| } | |||
| template<typename T> | |||
| void Rectangle<T>::setY(T y) | |||
| void Rectangle<T>::setY(T y) noexcept | |||
| { | |||
| fPos.fY = y; | |||
| } | |||
| template<typename T> | |||
| void Rectangle<T>::setPos(T x, T y) | |||
| void Rectangle<T>::setPos(T x, T y) noexcept | |||
| { | |||
| fPos.fX = x; | |||
| fPos.fY = y; | |||
| } | |||
| template<typename T> | |||
| void Rectangle<T>::setPos(const Point<T>& pos) | |||
| void Rectangle<T>::setPos(const Point<T>& pos) noexcept | |||
| { | |||
| fPos = pos; | |||
| } | |||
| template<typename T> | |||
| void Rectangle<T>::move(T x, T y) | |||
| void Rectangle<T>::move(T x, T y) noexcept | |||
| { | |||
| fPos.fX += x; | |||
| fPos.fY += y; | |||
| } | |||
| template<typename T> | |||
| void Rectangle<T>::move(const Point<T>& pos) | |||
| void Rectangle<T>::move(const Point<T>& pos) noexcept | |||
| { | |||
| fPos += pos; | |||
| } | |||
| template<typename T> | |||
| void Rectangle<T>::setWidth(T width) | |||
| void Rectangle<T>::setWidth(T width) noexcept | |||
| { | |||
| fSize.fWidth = width; | |||
| } | |||
| template<typename T> | |||
| void Rectangle<T>::setHeight(T height) | |||
| void Rectangle<T>::setHeight(T height) noexcept | |||
| { | |||
| fSize.fHeight = height; | |||
| } | |||
| template<typename T> | |||
| void Rectangle<T>::setSize(T width, T height) | |||
| void Rectangle<T>::setSize(T width, T height) noexcept | |||
| { | |||
| fSize.fWidth = width; | |||
| fSize.fHeight = height; | |||
| } | |||
| template<typename T> | |||
| void Rectangle<T>::setSize(const Size<T>& size) | |||
| void Rectangle<T>::setSize(const Size<T>& size) noexcept | |||
| { | |||
| fSize = size; | |||
| } | |||
| template<typename T> | |||
| Rectangle<T>& Rectangle<T>::operator=(const Rectangle<T>& rect) | |||
| Rectangle<T>& Rectangle<T>::operator=(const Rectangle<T>& rect) noexcept | |||
| { | |||
| fPos = rect.fPos; | |||
| fSize = rect.fSize; | |||
| @@ -20,7 +20,7 @@ START_NAMESPACE_DGL | |||
| // ----------------------------------------------------------------------- | |||
| Image::Image() | |||
| Image::Image() noexcept | |||
| : fRawData(nullptr), | |||
| fSize(0, 0), | |||
| fFormat(0), | |||
| @@ -28,7 +28,7 @@ Image::Image() | |||
| { | |||
| } | |||
| Image::Image(const char* rawData, int width, int height, GLenum format, GLenum type) | |||
| Image::Image(const char* rawData, int width, int height, GLenum format, GLenum type) noexcept | |||
| : fRawData(rawData), | |||
| fSize(width, height), | |||
| fFormat(format), | |||
| @@ -36,7 +36,7 @@ Image::Image(const char* rawData, int width, int height, GLenum format, GLenum t | |||
| { | |||
| } | |||
| Image::Image(const char* rawData, const Size<int>& size, GLenum format, GLenum type) | |||
| Image::Image(const char* rawData, const Size<int>& size, GLenum format, GLenum type) noexcept | |||
| : fRawData(rawData), | |||
| fSize(size), | |||
| fFormat(format), | |||
| @@ -44,7 +44,7 @@ Image::Image(const char* rawData, const Size<int>& size, GLenum format, GLenum t | |||
| { | |||
| } | |||
| Image::Image(const Image& image) | |||
| Image::Image(const Image& image) noexcept | |||
| : fRawData(image.fRawData), | |||
| fSize(image.fSize), | |||
| fFormat(image.fFormat), | |||
| @@ -52,12 +52,12 @@ Image::Image(const Image& image) | |||
| { | |||
| } | |||
| void Image::loadFromMemory(const char* rawData, int width, int height, GLenum format, GLenum type) | |||
| void Image::loadFromMemory(const char* rawData, int width, int height, GLenum format, GLenum type) noexcept | |||
| { | |||
| loadFromMemory(rawData, Size<int>(width, height), format, type); | |||
| } | |||
| void Image::loadFromMemory(const char* rawData, const Size<int>& size, GLenum format, GLenum type) | |||
| void Image::loadFromMemory(const char* rawData, const Size<int>& size, GLenum format, GLenum type) noexcept | |||
| { | |||
| fRawData = rawData; | |||
| fSize = size; | |||
| @@ -65,37 +65,37 @@ void Image::loadFromMemory(const char* rawData, const Size<int>& size, GLenum fo | |||
| fType = type; | |||
| } | |||
| bool Image::isValid() const | |||
| bool Image::isValid() const noexcept | |||
| { | |||
| return (fRawData != nullptr && getWidth() > 0 && getHeight() > 0); | |||
| } | |||
| int Image::getWidth() const | |||
| int Image::getWidth() const noexcept | |||
| { | |||
| return fSize.getWidth(); | |||
| } | |||
| int Image::getHeight() const | |||
| int Image::getHeight() const noexcept | |||
| { | |||
| return fSize.getHeight(); | |||
| } | |||
| const Size<int>& Image::getSize() const | |||
| const Size<int>& Image::getSize() const noexcept | |||
| { | |||
| return fSize; | |||
| } | |||
| const char* Image::getRawData() const | |||
| const char* Image::getRawData() const noexcept | |||
| { | |||
| return fRawData; | |||
| } | |||
| GLenum Image::getFormat() const | |||
| GLenum Image::getFormat() const noexcept | |||
| { | |||
| return fFormat; | |||
| } | |||
| GLenum Image::getType() const | |||
| GLenum Image::getType() const noexcept | |||
| { | |||
| return fType; | |||
| } | |||
| @@ -121,7 +121,7 @@ void Image::draw(const Point<int>& pos) const | |||
| draw(pos.getX(), pos.getY()); | |||
| } | |||
| Image& Image::operator=(const Image& image) | |||
| Image& Image::operator=(const Image& image) noexcept | |||
| { | |||
| fRawData = image.fRawData; | |||
| fSize = image.fSize; | |||
| @@ -130,12 +130,12 @@ Image& Image::operator=(const Image& image) | |||
| return *this; | |||
| } | |||
| bool Image::operator==(const Image& image) const | |||
| bool Image::operator==(const Image& image) const noexcept | |||
| { | |||
| return (fRawData == image.fRawData); | |||
| } | |||
| bool Image::operator!=(const Image& image) const | |||
| bool Image::operator!=(const Image& image) const noexcept | |||
| { | |||
| return (fRawData != image.fRawData); | |||
| } | |||
| @@ -27,22 +27,22 @@ START_NAMESPACE_DGL | |||
| // ----------------------------------------------------------------------- | |||
| ImageAboutWindow::ImageAboutWindow(App* app, Window* parent, const Image& image) | |||
| ImageAboutWindow::ImageAboutWindow(App& app, Window& parent, const Image& image) | |||
| : Window(app, parent), | |||
| Widget(this), | |||
| Widget((Window&)*this), | |||
| fImgBackground(image) | |||
| { | |||
| Window::setSize(image.getWidth(), image.getHeight() PAD_SIZE); | |||
| Window::setWindowTitle("About"); | |||
| Window::setTitle("About"); | |||
| } | |||
| ImageAboutWindow::ImageAboutWindow(Widget* widget, const Image& image) | |||
| : Window(widget->getApp(), widget->getParent()), | |||
| Widget(this), | |||
| : Window(widget->getParentApp(), widget->getParentWindow()), | |||
| Widget((Window&)*this), | |||
| fImgBackground(image) | |||
| { | |||
| Window::setSize(image.getWidth(), image.getHeight() PAD_SIZE); | |||
| Window::setWindowTitle("About"); | |||
| Window::setTitle("About"); | |||
| } | |||
| void ImageAboutWindow::setImage(const Image& image) | |||
| @@ -69,7 +69,7 @@ bool ImageAboutWindow::onMouse(int, bool press, int, int) | |||
| bool ImageAboutWindow::onKeyboard(bool press, uint32_t key) | |||
| { | |||
| if (press && key == DGL_CHAR_ESCAPE) | |||
| if (press && key == CHAR_ESCAPE) | |||
| { | |||
| Window::close(); | |||
| return true; | |||
| @@ -22,7 +22,7 @@ START_NAMESPACE_DGL | |||
| // ----------------------------------------------------------------------- | |||
| ImageButton::ImageButton(Window* parent, const Image& image) | |||
| ImageButton::ImageButton(Window& parent, const Image& image) | |||
| : Widget(parent), | |||
| fImageNormal(image), | |||
| fImageHover(image), | |||
| @@ -34,7 +34,7 @@ ImageButton::ImageButton(Window* parent, const Image& image) | |||
| } | |||
| ImageButton::ImageButton(Widget* widget, const Image& image) | |||
| : Widget(widget->getParent()), | |||
| : Widget(widget->getParentWindow()), | |||
| fImageNormal(image), | |||
| fImageHover(image), | |||
| fImageDown(image), | |||
| @@ -44,7 +44,7 @@ ImageButton::ImageButton(Widget* widget, const Image& image) | |||
| { | |||
| } | |||
| ImageButton::ImageButton(Window* parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown) | |||
| ImageButton::ImageButton(Window& parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown) | |||
| : Widget(parent), | |||
| fImageNormal(imageNormal), | |||
| fImageHover(imageHover), | |||
| @@ -59,7 +59,7 @@ ImageButton::ImageButton(Window* parent, const Image& imageNormal, const Image& | |||
| } | |||
| ImageButton::ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown) | |||
| : Widget(widget->getParent()), | |||
| : Widget(widget->getParentWindow()), | |||
| fImageNormal(imageNormal), | |||
| fImageHover(imageHover), | |||
| fImageDown(imageDown), | |||
| @@ -73,7 +73,7 @@ ImageButton::ImageButton(Widget* widget, const Image& imageNormal, const Image& | |||
| } | |||
| ImageButton::ImageButton(const ImageButton& imageButton) | |||
| : Widget(imageButton.getParent()), | |||
| : Widget(imageButton.getParentWindow()), | |||
| fImageNormal(imageButton.fImageNormal), | |||
| fImageHover(imageButton.fImageHover), | |||
| fImageDown(imageButton.fImageDown), | |||
| @@ -23,7 +23,7 @@ START_NAMESPACE_DGL | |||
| // ----------------------------------------------------------------------- | |||
| ImageKnob::ImageKnob(Window* parent, const Image& image, Orientation orientation) | |||
| ImageKnob::ImageKnob(Window& parent, const Image& image, Orientation orientation) | |||
| : Widget(parent), | |||
| fImage(image), | |||
| fMinimum(0.0f), | |||
| @@ -45,7 +45,7 @@ ImageKnob::ImageKnob(Window* parent, const Image& image, Orientation orientation | |||
| } | |||
| ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation) | |||
| : Widget(widget->getParent()), | |||
| : Widget(widget->getParentWindow()), | |||
| fImage(image), | |||
| fMinimum(0.0f), | |||
| fMaximum(1.0f), | |||
| @@ -66,7 +66,7 @@ ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation | |||
| } | |||
| ImageKnob::ImageKnob(const ImageKnob& imageKnob) | |||
| : Widget(imageKnob.getParent()), | |||
| : Widget(imageKnob.getParentWindow()), | |||
| fImage(imageKnob.fImage), | |||
| fMinimum(imageKnob.fMinimum), | |||
| fMaximum(imageKnob.fMaximum), | |||
| @@ -286,7 +286,7 @@ bool ImageKnob::onMotion(int x, int y) | |||
| if (movX != 0) | |||
| { | |||
| float d = (getModifiers() & DGL_MODIFIER_SHIFT) ? 2000.0f : 200.0f; | |||
| float d = (getModifiers() & MODIFIER_SHIFT) ? 2000.0f : 200.0f; | |||
| float value = fValue + (float(fMaximum - fMinimum) / d * float(movX)); | |||
| if (value < fMinimum) | |||
| @@ -303,7 +303,7 @@ bool ImageKnob::onMotion(int x, int y) | |||
| if (movY != 0) | |||
| { | |||
| float d = (getModifiers() & DGL_MODIFIER_SHIFT) ? 2000.0f : 200.0f; | |||
| float d = (getModifiers() & MODIFIER_SHIFT) ? 2000.0f : 200.0f; | |||
| float value = fValue + (float(fMaximum - fMinimum) / d * float(movY)); | |||
| if (value < fMinimum) | |||
| @@ -20,7 +20,7 @@ START_NAMESPACE_DGL | |||
| // ----------------------------------------------------------------------- | |||
| ImageSlider::ImageSlider(Window* parent, const Image& image) | |||
| ImageSlider::ImageSlider(Window& parent, const Image& image) | |||
| : Widget(parent), | |||
| fImage(image), | |||
| fMinimum(0.0f), | |||
| @@ -36,7 +36,7 @@ ImageSlider::ImageSlider(Window* parent, const Image& image) | |||
| } | |||
| ImageSlider::ImageSlider(Widget* widget, const Image& image) | |||
| : Widget(widget->getParent()), | |||
| : Widget(widget->getParentWindow()), | |||
| fImage(image), | |||
| fMinimum(0.0f), | |||
| fMaximum(1.0f), | |||
| @@ -51,7 +51,7 @@ ImageSlider::ImageSlider(Widget* widget, const Image& image) | |||
| } | |||
| ImageSlider::ImageSlider(const ImageSlider& imageSlider) | |||
| : Widget(imageSlider.getParent()), | |||
| : Widget(imageSlider.getParentWindow()), | |||
| fImage(imageSlider.fImage), | |||
| fMinimum(imageSlider.fMinimum), | |||
| fMaximum(imageSlider.fMaximum), | |||
| @@ -20,12 +20,6 @@ | |||
| #include <cassert> | |||
| #ifdef PROPER_CPP11_SUPPORT | |||
| # include <cstdint> | |||
| #else | |||
| # include <stdint.h> | |||
| #endif | |||
| START_NAMESPACE_DGL | |||
| // ----------------------------------------------------------------------- | |||
| @@ -35,7 +29,7 @@ Widget::Widget(Window& parent) | |||
| : fParent(parent), | |||
| fVisible(true) | |||
| { | |||
| parent.addWidget(this); | |||
| fParent.addWidget(this); | |||
| } | |||
| Widget::~Widget() | |||
| @@ -43,7 +37,7 @@ Widget::~Widget() | |||
| fParent.removeWidget(this); | |||
| } | |||
| bool Widget::isVisible() const | |||
| bool Widget::isVisible() const noexcept | |||
| { | |||
| return fVisible; | |||
| } | |||
| @@ -57,17 +51,27 @@ void Widget::setVisible(bool yesNo) | |||
| fParent.repaint(); | |||
| } | |||
| int Widget::getX() const | |||
| void Widget::show() | |||
| { | |||
| setVisible(true); | |||
| } | |||
| void Widget::hide() | |||
| { | |||
| setVisible(false); | |||
| } | |||
| int Widget::getX() const noexcept | |||
| { | |||
| return fArea.getX(); | |||
| } | |||
| int Widget::getY() const | |||
| int Widget::getY() const noexcept | |||
| { | |||
| return fArea.getY(); | |||
| } | |||
| const Point<int>& Widget::getPos() const | |||
| const Point<int>& Widget::getPos() const noexcept | |||
| { | |||
| return fArea.getPos(); | |||
| } | |||
| @@ -78,7 +82,7 @@ void Widget::setX(int x) | |||
| return; | |||
| fArea.setX(x); | |||
| repaint(); | |||
| fParent.repaint(); | |||
| } | |||
| void Widget::setY(int y) | |||
| @@ -87,7 +91,7 @@ void Widget::setY(int y) | |||
| return; | |||
| fArea.setY(y); | |||
| repaint(); | |||
| fParent.repaint(); | |||
| } | |||
| void Widget::setPos(int x, int y) | |||
| @@ -101,32 +105,32 @@ void Widget::setPos(const Point<int>& pos) | |||
| return; | |||
| fArea.setPos(pos); | |||
| repaint(); | |||
| fParent.repaint(); | |||
| } | |||
| void Widget::move(int x, int y) | |||
| { | |||
| fArea.move(x, y); | |||
| repaint(); | |||
| fParent.repaint(); | |||
| } | |||
| void Widget::move(const Point<int>& pos) | |||
| { | |||
| fArea.move(pos); | |||
| repaint(); | |||
| fParent.repaint(); | |||
| } | |||
| int Widget::getWidth() const | |||
| int Widget::getWidth() const noexcept | |||
| { | |||
| return fArea.getWidth(); | |||
| } | |||
| int Widget::getHeight() const | |||
| int Widget::getHeight() const noexcept | |||
| { | |||
| return fArea.getHeight(); | |||
| } | |||
| const Size<int>& Widget::getSize() const | |||
| const Size<int>& Widget::getSize() const noexcept | |||
| { | |||
| return fArea.getSize(); | |||
| } | |||
| @@ -163,22 +167,27 @@ void Widget::setSize(const Size<int>& size) | |||
| fParent.repaint(); | |||
| } | |||
| const Rectangle<int>& Widget::getArea() const | |||
| const Rectangle<int>& Widget::getArea() const noexcept | |||
| { | |||
| return fArea; | |||
| } | |||
| uint32_t Widget::getEventTimestamp() | |||
| { | |||
| return fParent.getEventTimestamp(); | |||
| } | |||
| int Widget::getModifiers() | |||
| { | |||
| return fParent.getModifiers(); | |||
| } | |||
| App& Widget::getApp() const | |||
| App& Widget::getParentApp() const noexcept | |||
| { | |||
| return fParent.getApp(); | |||
| } | |||
| Window& Widget::getParent() const | |||
| Window& Widget::getParentWindow() const noexcept | |||
| { | |||
| return fParent; | |||
| } | |||
| @@ -192,7 +201,7 @@ void Widget::onDisplay() | |||
| { | |||
| } | |||
| bool Widget::onKeyboard(bool, unsigned) | |||
| bool Widget::onKeyboard(bool, uint32_t) | |||
| { | |||
| return false; | |||
| } | |||
| @@ -14,11 +14,13 @@ | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #include "AppPrivate.hpp" | |||
| #include "../App.hpp" | |||
| #include "../Widget.hpp" | |||
| #include "../Window.hpp" | |||
| #include <cassert> | |||
| #include <list> | |||
| #include "pugl/pugl.h" | |||
| #if DGL_OS_WINDOWS | |||
| @@ -32,11 +34,9 @@ extern "C" { | |||
| # include "pugl/pugl_x11.c" | |||
| } | |||
| #else | |||
| # error Unsupported platform! | |||
| # error Unsupported platform | |||
| #endif | |||
| #include <cassert> | |||
| #define FOR_EACH_WIDGET(it) \ | |||
| for (std::list<Widget*>::iterator it = fWidgets.begin(); it != fWidgets.end(); ++it) | |||
| @@ -53,15 +53,58 @@ Window* dgl_lastUiParent = nullptr; | |||
| class Window::PrivateData | |||
| { | |||
| public: | |||
| Private(Window& self, App& app, App::PrivateData& appPriv, PrivateData& parent, intptr_t parentId = 0) | |||
| : kApp(app), | |||
| kAppPriv(appPriv), | |||
| kSelf(self), | |||
| kView(puglCreate(parentId, "Window", 100, 100, false, (parentId != 0))), | |||
| fParent(parent), | |||
| fChildFocus(nullptr), | |||
| fVisible((parentId != 0)), | |||
| fOnModal(false), | |||
| PrivateData(App& app, Window* const self) | |||
| : fApp(app), | |||
| fSelf(self), | |||
| fView(puglCreate(0, "Window", 100, 100, true, false)), | |||
| fFirstInit(true), | |||
| fVisible(false), | |||
| fResizable(true), | |||
| #if DGL_OS_WINDOWS | |||
| hwnd(0) | |||
| #elif DGL_OS_LINUX | |||
| xDisplay(nullptr), | |||
| xWindow(0) | |||
| #else | |||
| _dummy('\0') | |||
| #endif | |||
| { | |||
| init(); | |||
| } | |||
| PrivateData(App& app, Window* const self, Window& parent) | |||
| : fApp(app), | |||
| fSelf(self), | |||
| fView(puglCreate(0, "Window", 100, 100, true, false)), | |||
| fFirstInit(true), | |||
| fVisible(false), | |||
| fResizable(true), | |||
| fModal(parent.pData), | |||
| #if DGL_OS_WINDOWS | |||
| hwnd(0) | |||
| #elif DGL_OS_LINUX | |||
| xDisplay(nullptr), | |||
| xWindow(0) | |||
| #else | |||
| _dummy('\0') | |||
| #endif | |||
| { | |||
| init(); | |||
| #if DGL_OS_LINUX | |||
| PuglInternals* const parentImpl = parent.pData->fView->impl; | |||
| XSetTransientForHint(xDisplay, xWindow, parentImpl->win); | |||
| XFlush(xDisplay); | |||
| #endif | |||
| } | |||
| PrivateData(App& app, Window* const self, const intptr_t parentId) | |||
| : fApp(app), | |||
| fSelf(self), | |||
| fView(puglCreate(parentId, "Window", 100, 100, true, true)), | |||
| fFirstInit(true), | |||
| fVisible(true), | |||
| fResizable(false), | |||
| #if DGL_OS_WINDOWS | |||
| hwnd(0) | |||
| @@ -69,118 +112,85 @@ public: | |||
| xDisplay(nullptr), | |||
| xWindow(0) | |||
| #else | |||
| _dummy(0) | |||
| _dummy('\0') | |||
| #endif | |||
| { | |||
| init(); | |||
| // starts visible | |||
| fApp.oneShown(); | |||
| fFirstInit = false; | |||
| } | |||
| void setup() | |||
| void init() | |||
| { | |||
| if (kView == nullptr) | |||
| if (fView == nullptr) | |||
| return; | |||
| // we can't have both | |||
| if (parent != nullptr) | |||
| { | |||
| assert(parentId == 0); | |||
| } | |||
| dgl_lastUiParent = fSelf; | |||
| puglSetHandle(kView, this); | |||
| puglSetDisplayFunc(kView, onDisplayCallback); | |||
| puglSetKeyboardFunc(kView, onKeyboardCallback); | |||
| puglSetMotionFunc(kView, onMotionCallback); | |||
| puglSetMouseFunc(kView, onMouseCallback); | |||
| puglSetScrollFunc(kView, onScrollCallback); | |||
| puglSetSpecialFunc(kView, onSpecialCallback); | |||
| puglSetReshapeFunc(kView, onReshapeCallback); | |||
| puglSetCloseFunc(kView, onCloseCallback); | |||
| puglSetHandle(fView, this); | |||
| puglSetDisplayFunc(fView, onDisplayCallback); | |||
| puglSetKeyboardFunc(fView, onKeyboardCallback); | |||
| puglSetMotionFunc(fView, onMotionCallback); | |||
| puglSetMouseFunc(fView, onMouseCallback); | |||
| puglSetScrollFunc(fView, onScrollCallback); | |||
| puglSetSpecialFunc(fView, onSpecialCallback); | |||
| puglSetReshapeFunc(fView, onReshapeCallback); | |||
| puglSetCloseFunc(fView, onCloseCallback); | |||
| #if DGL_OS_WINDOWS | |||
| PuglInternals* impl = kView->impl; | |||
| PuglInternals* impl = fView->impl; | |||
| hwnd = impl->hwnd; | |||
| #elif DGL_OS_LINUX | |||
| PuglInternals* impl = kView->impl; | |||
| PuglInternals* impl = fView->impl; | |||
| xDisplay = impl->display; | |||
| xWindow = impl->win; | |||
| if (parent != nullptr && parentId == 0) | |||
| { | |||
| PuglInternals* parentImpl = parent->kView->impl; | |||
| XSetTransientForHint(xDisplay, xWindow, parentImpl->win); | |||
| XFlush(xDisplay); | |||
| } | |||
| #endif | |||
| kAppPriv->addWindow(kSelf); | |||
| fApp.addWindow(fSelf); | |||
| } | |||
| ~Private() | |||
| ~PrivateData() | |||
| { | |||
| fOnModal = false; | |||
| //fOnModal = false; | |||
| fWidgets.clear(); | |||
| if (kView != nullptr) | |||
| if (fView != nullptr) | |||
| { | |||
| kAppPriv->removeWindow(kSelf); | |||
| puglDestroy(kView); | |||
| fApp.removeWindow(fSelf); | |||
| puglDestroy(fView); | |||
| } | |||
| } | |||
| void exec_init() | |||
| // ------------------------------------------------------------------- | |||
| void close() | |||
| { | |||
| fOnModal = true; | |||
| assert(fParent != nullptr); | |||
| setVisible(false); | |||
| if (fParent != nullptr) | |||
| if (! fFirstInit) | |||
| { | |||
| fParent->fChildFocus = this; | |||
| #if DGL_OS_WINDOWS | |||
| // Center this window | |||
| PuglInternals* parentImpl = fParent->kView->impl; | |||
| RECT curRect; | |||
| RECT parentRect; | |||
| GetWindowRect(hwnd, &curRect); | |||
| GetWindowRect(parentImpl->hwnd, &parentRect); | |||
| int x = parentRect.left+(parentRect.right-curRect.right)/2; | |||
| int y = parentRect.top+(parentRect.bottom-curRect.bottom)/2; | |||
| SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); | |||
| UpdateWindow(hwnd); | |||
| #endif | |||
| fParent->show(); | |||
| fApp.oneHidden(); | |||
| fFirstInit = true; | |||
| } | |||
| show(); | |||
| } | |||
| void exec_fini() | |||
| { | |||
| fOnModal = false; | |||
| if (fParent != nullptr) | |||
| fParent->fChildFocus = nullptr; | |||
| } | |||
| void exec(bool block) | |||
| void exec(const bool lockWait) | |||
| { | |||
| exec_init(); | |||
| if (block) | |||
| if (lockWait) | |||
| { | |||
| while (fVisible && fOnModal) | |||
| while (fVisible && fModal.enabled) | |||
| { | |||
| // idle() | |||
| puglProcessEvents(kView); | |||
| puglProcessEvents(fView); | |||
| if (fParent != nullptr) | |||
| fParent->idle(); | |||
| if (fModal.parent != nullptr) | |||
| fModal.parent->idle(); | |||
| dgl_msleep(10); | |||
| msleep(10); | |||
| } | |||
| exec_fini(); | |||
| @@ -191,6 +201,8 @@ public: | |||
| } | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| void focus() | |||
| { | |||
| #if DGL_OS_WINDOWS | |||
| @@ -198,7 +210,7 @@ public: | |||
| SetActiveWindow(hwnd); | |||
| SetFocus(hwnd); | |||
| #elif DGL_OS_MAC | |||
| puglImplFocus(kView); | |||
| puglImplFocus(fView); | |||
| #elif DGL_OS_LINUX | |||
| XRaiseWindow(xDisplay, xWindow); | |||
| XSetInputFocus(xDisplay, xWindow, RevertToPointerRoot, CurrentTime); | |||
| @@ -208,60 +220,41 @@ public: | |||
| void idle() | |||
| { | |||
| puglProcessEvents(kView); | |||
| puglProcessEvents(fView); | |||
| if (fVisible && fOnModal && fParent != nullptr) | |||
| fParent->idle(); | |||
| if (fVisible && fModal.enabled && fModal.parent != nullptr) | |||
| fModal.parent->idle(); | |||
| } | |||
| void repaint() | |||
| { | |||
| puglPostRedisplay(kView); | |||
| } | |||
| void show() | |||
| { | |||
| setVisible(true); | |||
| puglPostRedisplay(fView); | |||
| } | |||
| void hide() | |||
| { | |||
| setVisible(false); | |||
| } | |||
| void close() | |||
| { | |||
| setVisible(false, true); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| bool isVisible() | |||
| bool isVisible() const noexcept | |||
| { | |||
| return fVisible; | |||
| } | |||
| void setResizable(bool yesNo) | |||
| { | |||
| if (fResizable == yesNo) | |||
| return; | |||
| fResizable = yesNo; | |||
| //setSize(kView->width, kView->height, true); | |||
| } | |||
| void setVisible(bool yesNo, bool closed = false) | |||
| void setVisible(const bool yesNo) | |||
| { | |||
| if (fVisible == yesNo) | |||
| return; | |||
| fVisible = yesNo; | |||
| if (yesNo && fFirstInit) | |||
| setSize(fView->width, fView->height, true); | |||
| #if DGL_OS_WINDOWS | |||
| if (yesNo) | |||
| { | |||
| ShowWindow(hwnd, WS_VISIBLE); | |||
| ShowWindow(hwnd, SW_RESTORE); | |||
| //SetForegroundWindow(hwnd); | |||
| if (! fFirstInit) | |||
| ShowWindow(hwnd, SW_RESTORE); | |||
| } | |||
| else | |||
| { | |||
| @@ -270,7 +263,7 @@ public: | |||
| UpdateWindow(hwnd); | |||
| #elif DGL_OS_MAC | |||
| puglImplSetVisible(kView, yesNo); | |||
| puglImplSetVisible(fView, yesNo); | |||
| #elif DGL_OS_LINUX | |||
| if (yesNo) | |||
| XMapRaised(xDisplay, xWindow); | |||
| @@ -282,30 +275,62 @@ public: | |||
| if (yesNo) | |||
| { | |||
| kAppPriv->oneShown(); | |||
| if (fFirstInit) | |||
| { | |||
| fApp.oneShown(); | |||
| fFirstInit = false; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| if (fOnModal) | |||
| exec_fini(); | |||
| else if (fModal.enabled) | |||
| exec_fini(); | |||
| } | |||
| if (closed) | |||
| kAppPriv->oneHidden(); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| bool isResizable() const noexcept | |||
| { | |||
| return fResizable; | |||
| } | |||
| void setResizable(const bool yesNo) | |||
| { | |||
| if (fResizable == yesNo) | |||
| return; | |||
| fResizable = yesNo; | |||
| setSize(fView->width, fView->height, true); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| int getWidth() const noexcept | |||
| { | |||
| return fView->width; | |||
| } | |||
| int getHeight() const noexcept | |||
| { | |||
| return fView->height; | |||
| } | |||
| Size<int> getSize() const noexcept | |||
| { | |||
| return Size<int>(fView->width, fView->height); | |||
| } | |||
| void setSize(unsigned int width, unsigned int height /*, bool forced = false*/) | |||
| void setSize(unsigned int width, unsigned int height, const bool forced = false) | |||
| { | |||
| if (width == 0) | |||
| width = 1; | |||
| if (height == 0) | |||
| height = 1; | |||
| kView->width = width; | |||
| kView->height = height; | |||
| fView->width = width; | |||
| fView->height = height; | |||
| //if (kView->width == width && kView->height == height && ! forced) | |||
| // return; | |||
| if (fView->width == (int)width && fView->height == (int)height && ! forced) | |||
| return; | |||
| #if DGL_OS_WINDOWS | |||
| int winFlags = WS_POPUPWINDOW | WS_CAPTION; | |||
| @@ -319,7 +344,7 @@ public: | |||
| SetWindowPos(hwnd, 0, 0, 0, wr.right-wr.left, wr.bottom-wr.top, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER); | |||
| UpdateWindow(hwnd); | |||
| #elif DGL_OS_MAC | |||
| puglImplSetSize(kView, width, height); | |||
| puglImplSetSize(fView, width, height); | |||
| #elif DGL_OS_LINUX | |||
| XResizeWindow(xDisplay, xWindow, width, height); | |||
| @@ -343,43 +368,94 @@ public: | |||
| repaint(); | |||
| } | |||
| void setWindowTitle(const char* title) | |||
| // ------------------------------------------------------------------- | |||
| void setTitle(const char* const title) | |||
| { | |||
| #if DGL_OS_WINDOWS | |||
| SetWindowTextA(hwnd, title); | |||
| #elif DGL_OS_MAC | |||
| puglImplSetTitle(kView, title); | |||
| puglImplSetTitle(fView, title); | |||
| #elif DGL_OS_LINUX | |||
| XStoreName(xDisplay, xWindow, title); | |||
| XFlush(xDisplay); | |||
| #endif | |||
| } | |||
| App* getApp() const | |||
| App& getApp() const noexcept | |||
| { | |||
| return kApp; | |||
| return fApp; | |||
| } | |||
| int getModifiers() const | |||
| { | |||
| return puglGetModifiers(kView); | |||
| return puglGetModifiers(fView); | |||
| } | |||
| uint32_t getEventTimestamp() const | |||
| { | |||
| return puglGetEventTimestamp(fView); | |||
| } | |||
| intptr_t getWindowId() const | |||
| { | |||
| return puglGetNativeWindow(kView); | |||
| return puglGetNativeWindow(fView); | |||
| } | |||
| void addWidget(Widget* widget) | |||
| // ------------------------------------------------------------------- | |||
| void addWidget(Widget* const widget) | |||
| { | |||
| fWidgets.push_back(widget); | |||
| } | |||
| void removeWidget(Widget* widget) | |||
| void removeWidget(Widget* const widget) | |||
| { | |||
| fWidgets.remove(widget); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| void exec_init() | |||
| { | |||
| fModal.enabled = true; | |||
| assert(fModal.parent != nullptr); | |||
| if (fModal.parent == nullptr) | |||
| return setVisible(true); | |||
| fModal.parent->fModal.childFocus = this; | |||
| #if DGL_OS_WINDOWS | |||
| // Center this window | |||
| PuglInternals* const parentImpl = fParent->fView->impl; | |||
| RECT curRect; | |||
| RECT parentRect; | |||
| GetWindowRect(hwnd, &curRect); | |||
| GetWindowRect(parentImpl->hwnd, &parentRect); | |||
| int x = parentRect.left+(parentRect.right-curRect.right)/2; | |||
| int y = parentRect.top +(parentRect.bottom-curRect.bottom)/2; | |||
| SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); | |||
| UpdateWindow(hwnd); | |||
| #endif | |||
| fModal.parent->setVisible(true); | |||
| setVisible(true); | |||
| } | |||
| void exec_fini() | |||
| { | |||
| fModal.enabled = false; | |||
| if (fModal.parent != nullptr) | |||
| fModal.parent->fModal.childFocus = nullptr; | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| protected: | |||
| void onDisplay() | |||
| { | |||
| @@ -388,93 +464,85 @@ protected: | |||
| FOR_EACH_WIDGET(it) | |||
| { | |||
| Widget* const widget(*it); | |||
| if (widget->isVisible()) | |||
| widget->onDisplay(); | |||
| } | |||
| } | |||
| void onKeyboard(bool press, uint32_t key) | |||
| void onKeyboard(const bool press, const uint32_t key) | |||
| { | |||
| if (fChildFocus != nullptr) | |||
| return fChildFocus->focus(); | |||
| if (fModal.childFocus != nullptr) | |||
| return fModal.childFocus->focus(); | |||
| FOR_EACH_WIDGET_INV(rit) | |||
| { | |||
| Widget* const widget(*rit); | |||
| if (widget->isVisible()) | |||
| { | |||
| if (widget->onKeyboard(press, key)) | |||
| break; | |||
| } | |||
| if (widget->isVisible() && widget->onKeyboard(press, key)) | |||
| break; | |||
| } | |||
| } | |||
| void onMouse(int button, bool press, int x, int y) | |||
| void onMouse(const int button, const bool press, const int x, const int y) | |||
| { | |||
| if (fChildFocus != nullptr) | |||
| return fChildFocus->focus(); | |||
| if (fModal.childFocus != nullptr) | |||
| return fModal.childFocus->focus(); | |||
| FOR_EACH_WIDGET_INV(rit) | |||
| { | |||
| Widget* const widget(*rit); | |||
| if (widget->isVisible()) | |||
| { | |||
| if (widget->onMouse(button, press, x, y)) | |||
| break; | |||
| } | |||
| if (widget->isVisible() && widget->onMouse(button, press, x, y)) | |||
| break; | |||
| } | |||
| } | |||
| void onMotion(int x, int y) | |||
| void onMotion(const int x, const int y) | |||
| { | |||
| if (fChildFocus != nullptr) | |||
| if (fModal.childFocus != nullptr) | |||
| return; | |||
| FOR_EACH_WIDGET_INV(rit) | |||
| { | |||
| Widget* const widget(*rit); | |||
| if (widget->isVisible()) | |||
| { | |||
| if (widget->onMotion(x, y)) | |||
| break; | |||
| } | |||
| if (widget->isVisible() && widget->onMotion(x, y)) | |||
| break; | |||
| } | |||
| } | |||
| void onScroll(float dx, float dy) | |||
| void onScroll(const float dx, const float dy) | |||
| { | |||
| if (fChildFocus != nullptr) | |||
| if (fModal.childFocus != nullptr) | |||
| return; | |||
| FOR_EACH_WIDGET_INV(rit) | |||
| { | |||
| Widget* const widget(*rit); | |||
| if (widget->isVisible()) | |||
| { | |||
| if (widget->onScroll(dx, dy)) | |||
| break; | |||
| } | |||
| if (widget->isVisible() && widget->onScroll(dx, dy)) | |||
| break; | |||
| } | |||
| } | |||
| void onSpecial(bool press, Key key) | |||
| void onSpecial(const bool press, const Key key) | |||
| { | |||
| if (fChildFocus != nullptr) | |||
| if (fModal.childFocus != nullptr) | |||
| return; | |||
| FOR_EACH_WIDGET_INV(rit) | |||
| { | |||
| Widget* const widget(*rit); | |||
| if (widget->isVisible()) | |||
| { | |||
| if (widget->onSpecial(press, key)) | |||
| break; | |||
| } | |||
| if (widget->isVisible() && widget->onSpecial(press, key)) | |||
| break; | |||
| } | |||
| } | |||
| void onReshape(int width, int height) | |||
| void onReshape(const int width, const int height) | |||
| { | |||
| printf("resized: %i:%i\n", width, height); | |||
| FOR_EACH_WIDGET(it) | |||
| { | |||
| Widget* const widget(*it); | |||
| @@ -484,10 +552,10 @@ protected: | |||
| void onClose() | |||
| { | |||
| fOnModal = false; | |||
| fModal.enabled = false; | |||
| if (fChildFocus != nullptr) | |||
| fChildFocus->onClose(); | |||
| if (fModal.childFocus != nullptr) | |||
| fModal.childFocus->onClose(); | |||
| FOR_EACH_WIDGET(it) | |||
| { | |||
| @@ -498,31 +566,53 @@ protected: | |||
| close(); | |||
| } | |||
| private: | |||
| App* const kApp; | |||
| App::Private* const kAppPriv; | |||
| Window* const kSelf; | |||
| PuglView* const kView; | |||
| // ------------------------------------------------------------------- | |||
| Private* fParent; | |||
| Private* fChildFocus; | |||
| bool fVisible; | |||
| bool fOnModal; | |||
| bool fResizable; | |||
| private: | |||
| App& fApp; | |||
| Window* const fSelf; | |||
| PuglView* const fView; | |||
| bool fFirstInit; | |||
| bool fVisible; | |||
| bool fResizable; | |||
| std::list<Widget*> fWidgets; | |||
| struct Modal { | |||
| bool enabled; | |||
| PrivateData* parent; | |||
| PrivateData* childFocus; | |||
| Modal() | |||
| : enabled(false), | |||
| parent(nullptr), | |||
| childFocus(nullptr) {} | |||
| Modal(PrivateData* const p) | |||
| : enabled(false), | |||
| parent(p), | |||
| childFocus(nullptr) {} | |||
| ~Modal() | |||
| { | |||
| assert(! enabled); | |||
| assert(childFocus == nullptr); | |||
| } | |||
| } fModal; | |||
| #if DGL_OS_WINDOWS | |||
| HWND hwnd; | |||
| #elif DGL_OS_LINUX | |||
| Display* xDisplay; | |||
| ::Window xWindow; | |||
| #else | |||
| int _dummy; | |||
| char _dummy; | |||
| #endif | |||
| // ------------------------------------------------------------------- | |||
| // Callbacks | |||
| #define handlePtr ((Private*)puglGetHandle(view)) | |||
| #define handlePtr ((PrivateData*)puglGetHandle(view)) | |||
| static void onDisplayCallback(PuglView* view) | |||
| { | |||
| @@ -571,21 +661,18 @@ private: | |||
| // Window | |||
| Window::Window(App& app) | |||
| : pData(new Private(this, app, app->pData, nullptr)) | |||
| : pData(new PrivateData(app, this)) | |||
| { | |||
| dgl_lastUiParent = this; | |||
| } | |||
| Window::Window(App& app, Window& parent) | |||
| : pData(new Private(this, app, app->pData, parent->pData)) | |||
| : pData(new PrivateData(app, this, parent)) | |||
| { | |||
| dgl_lastUiParent = this; | |||
| } | |||
| Window::Window(App*&app, intptr_t parentId) | |||
| : pData(new Private(this, app, app->pData, nullptr, parentId)) | |||
| Window::Window(App& app, intptr_t parentId) | |||
| : pData(new PrivateData(app, this, parentId)) | |||
| { | |||
| dgl_lastUiParent = this; | |||
| } | |||
| Window::~Window() | |||
| @@ -593,9 +680,24 @@ Window::~Window() | |||
| delete pData; | |||
| } | |||
| void Window::exec(bool lock) | |||
| void Window::show() | |||
| { | |||
| pData->setVisible(true); | |||
| } | |||
| void Window::hide() | |||
| { | |||
| pData->setVisible(false); | |||
| } | |||
| void Window::close() | |||
| { | |||
| pData->exec(lock); | |||
| pData->close(); | |||
| } | |||
| void Window::exec(bool lockWait) | |||
| { | |||
| pData->exec(lockWait); | |||
| } | |||
| void Window::focus() | |||
| @@ -613,69 +715,79 @@ void Window::repaint() | |||
| pData->repaint(); | |||
| } | |||
| bool Window::isVisible() | |||
| bool Window::isVisible() const noexcept | |||
| { | |||
| return pData->isVisible(); | |||
| } | |||
| void Window::setVisible(bool yesNo) | |||
| { | |||
| pData->setVisible(yesNo); | |||
| } | |||
| bool Window::isResizable() const noexcept | |||
| { | |||
| return pData->isResizable(); | |||
| } | |||
| void Window::setResizable(bool yesNo) | |||
| { | |||
| pData->setResizable(yesNo); | |||
| } | |||
| void Window::setVisible(bool yesNo) | |||
| int Window::getWidth() const noexcept | |||
| { | |||
| pData->setVisible(yesNo); | |||
| return pData->getWidth(); | |||
| } | |||
| void Window::setSize(unsigned int width, unsigned int height) | |||
| int Window::getHeight() const noexcept | |||
| { | |||
| pData->setSize(width, height); | |||
| return pData->getHeight(); | |||
| } | |||
| void Window::setWindowTitle(const char* title) | |||
| Size<int> Window::getSize() const noexcept | |||
| { | |||
| pData->setWindowTitle(title); | |||
| return pData->getSize(); | |||
| } | |||
| App* Window::getApp() const | |||
| void Window::setSize(unsigned int width, unsigned int height) | |||
| { | |||
| return pData->getApp(); | |||
| pData->setSize(width, height); | |||
| } | |||
| int Window::getModifiers() const | |||
| void Window::setTitle(const char* title) | |||
| { | |||
| return pData->getModifiers(); | |||
| pData->setTitle(title); | |||
| } | |||
| intptr_t Window::getWindowId() const | |||
| App& Window::getApp() const noexcept | |||
| { | |||
| return pData->getWindowId(); | |||
| return pData->getApp(); | |||
| } | |||
| void Window::addWidget(Widget* widget) | |||
| int Window::getModifiers() const | |||
| { | |||
| pData->addWidget(widget); | |||
| return pData->getModifiers(); | |||
| } | |||
| void Window::removeWidget(Widget* widget) | |||
| uint32_t Window::getEventTimestamp() const | |||
| { | |||
| pData->removeWidget(widget); | |||
| return pData->getEventTimestamp(); | |||
| } | |||
| void Window::show() | |||
| intptr_t Window::getWindowId() const | |||
| { | |||
| setVisible(true); | |||
| return pData->getWindowId(); | |||
| } | |||
| void Window::hide() | |||
| void Window::addWidget(Widget* const widget) | |||
| { | |||
| setVisible(false); | |||
| pData->addWidget(widget); | |||
| } | |||
| void Window::close() | |||
| void Window::removeWidget(Widget* const widget) | |||
| { | |||
| pData->close(); | |||
| pData->removeWidget(widget); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| @@ -17,7 +17,7 @@ | |||
| #include "DistrhoUIInternal.hpp" | |||
| #ifdef DISTRHO_UI_EXTERNAL | |||
| # error DSSI always uses external UI, no wrapper neeed! | |||
| # error DSSI always uses external UI, no wrapper needed! | |||
| #endif | |||
| #include <lo/lo.h> | |||
| @@ -134,7 +134,7 @@ public: | |||
| # endif | |||
| } | |||
| #else | |||
| glWindow.setWindowTitle(uiTitle); | |||
| glWindow.setTitle(uiTitle); | |||
| #endif | |||
| } | |||
| @@ -164,7 +164,7 @@ public: | |||
| { | |||
| fOscData.idle(); | |||
| fUI.idle(); | |||
| dgl_msleep(50); | |||
| msleep(50); | |||
| } | |||
| #endif | |||
| } | |||
| @@ -119,7 +119,7 @@ public: | |||
| UIInternal(void* ptr, intptr_t winId, editParamFunc editParamCall, setParamFunc setParamCall, setStateFunc setStateCall, sendNoteFunc sendNoteCall, uiResizeFunc uiResizeCall) | |||
| #ifdef DISTRHO_UI_OPENGL | |||
| : glApp(), | |||
| glWindow(&glApp, winId), | |||
| glWindow(glApp, winId), | |||
| fUi(createUI()), | |||
| #else | |||
| : fUi(createUI()), | |||
| @@ -140,6 +140,7 @@ public: | |||
| #ifdef DISTRHO_UI_OPENGL | |||
| glWindow.setSize(fUi->d_getWidth(), fUi->d_getHeight()); | |||
| glWindow.setResizable(false); | |||
| #else | |||
| assert(winId == 0); | |||
| return; | |||
| @@ -27,7 +27,7 @@ START_NAMESPACE_DISTRHO | |||
| OpenGLUI::OpenGLUI() | |||
| : UI(), | |||
| Widget(DGL::dgl_lastUiParent) | |||
| Widget(*DGL::dgl_lastUiParent) | |||
| { | |||
| assert(DGL::dgl_lastUiParent != nullptr); | |||
| @@ -0,0 +1,88 @@ | |||
| /* | |||
| * Carla Tests | |||
| * Copyright (C) 2013 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| * published by the Free Software Foundation; either version 2 of | |||
| * the License, or any later version. | |||
| * | |||
| * This program is distributed in the hope that it will be useful, | |||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| * GNU General Public License for more details. | |||
| * | |||
| * For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
| */ | |||
| #include "dgl/App.hpp" | |||
| #include "dgl/Geometry.hpp" | |||
| #include "dgl/Image.hpp" | |||
| #include "dgl/ImageAboutWindow.hpp" | |||
| #include "dgl/ImageButton.hpp" | |||
| #include "dgl/ImageKnob.hpp" | |||
| #include "dgl/ImageSlider.hpp" | |||
| #include "dgl/Widget.hpp" | |||
| #include "dgl/Window.hpp" | |||
| #include <cstdio> | |||
| int main() | |||
| { | |||
| USE_NAMESPACE_DGL; | |||
| msleep(1); | |||
| Point<int> pi; | |||
| Point<long> pl; | |||
| Point<float> pf; | |||
| Point<double> pd; | |||
| Point<unsigned> pu; | |||
| Size<int> si; | |||
| Size<long> sl; | |||
| Size<float> sf; | |||
| Size<double> sd; | |||
| Size<unsigned> su; | |||
| Rectangle<int> ri; | |||
| Rectangle<long> rl; | |||
| Rectangle<float> rf; | |||
| Rectangle<double> rd; | |||
| Rectangle<unsigned> ru; | |||
| Image i; | |||
| App app; | |||
| Window win(app); | |||
| win.setSize(500, 500); | |||
| win.show(); | |||
| // for (int i=0; i < 1000; ++i) | |||
| // { | |||
| // app.idle(); | |||
| // | |||
| // if (app.isQuiting()) | |||
| // break; | |||
| // if (i % 30 == 0) | |||
| // printf("SIZE: %i:%i\n", win.getWidth(), win.getHeight()); | |||
| // msleep(10); | |||
| // } | |||
| app.exec(); | |||
| return 0; | |||
| } | |||
| #include "dgl/src/ImageAboutWindow.cpp" | |||
| #include "dgl/src/App.cpp" | |||
| #include "dgl/src/Base.cpp" | |||
| #include "dgl/src/Geometry.cpp" | |||
| #include "dgl/src/Image.cpp" | |||
| #include "dgl/src/ImageButton.cpp" | |||
| #include "dgl/src/ImageKnob.cpp" | |||
| #include "dgl/src/ImageSlider.cpp" | |||
| #include "dgl/src/Widget.cpp" | |||
| #include "dgl/src/Window.cpp" | |||
| @@ -27,7 +27,7 @@ else | |||
| ifeq ($(WIN32),true) | |||
| DGL_LIBS = -lopengl32 -lgdi32 | |||
| else | |||
| DGL_LIBS = -lX11 | |||
| DGL_LIBS = -lGL -lX11 | |||
| endif | |||
| endif | |||
| @@ -44,8 +44,10 @@ CarlaString: CarlaString.cpp ../utils/CarlaString.hpp | |||
| $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | |||
| # valgrind ./CarlaString | |||
| DGL: DGL.cpp | |||
| $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) -o $@ | |||
| DGL: DGL.cpp ../modules/distrho/dgl/src/Window.cpp | |||
| $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) -o $@ | |||
| # ./DGL | |||
| # valgrind ./DGL | |||
| Print: Print.cpp | |||
| $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | |||