diff options
-rw-r--r-- | plugin/Makefile.mingw32.in | 67 | ||||
-rw-r--r-- | plugingui/Makefile.am | 69 | ||||
-rw-r--r-- | plugingui/dialog.cc | 54 | ||||
-rw-r--r-- | plugingui/dialog.h | 63 | ||||
-rw-r--r-- | plugingui/eventhandler.cc | 41 | ||||
-rw-r--r-- | plugingui/eventhandler.h | 7 |
6 files changed, 235 insertions, 66 deletions
diff --git a/plugin/Makefile.mingw32.in b/plugin/Makefile.mingw32.in index b7fde40..787f46c 100644 --- a/plugin/Makefile.mingw32.in +++ b/plugin/Makefile.mingw32.in @@ -47,50 +47,51 @@ DG_CFLAGS = -I@top_srcdir@ -I@top_srcdir@/include -I@top_srcdir@/src \ # -DDISABLE_HUGIN GUI_SRC = \ + @top_srcdir@/plugingui/button.cc \ + @top_srcdir@/plugingui/checkbox.cc \ + @top_srcdir@/plugingui/colour.cc \ + @top_srcdir@/plugingui/combobox.cc \ @top_srcdir@/plugingui/dgwindow.cc \ - @top_srcdir@/plugingui/nativewindow_win32.cc \ - @top_srcdir@/plugingui/plugingui.cc \ - @top_srcdir@/plugingui/pluginconfig.cc \ - @top_srcdir@/plugingui/label.cc \ + @top_srcdir@/plugingui/dialog.cc \ + @top_srcdir@/plugingui/directory.cc \ + @top_srcdir@/plugingui/diskstreamingframecontent.cc \ + @top_srcdir@/plugingui/drumkitframecontent.cc \ @top_srcdir@/plugingui/eventhandler.cc \ + @top_srcdir@/plugingui/filebrowser.cc \ @top_srcdir@/plugingui/font.cc \ - @top_srcdir@/plugingui/window.cc \ - @top_srcdir@/plugingui/widget.cc \ - @top_srcdir@/plugingui/colour.cc \ + @top_srcdir@/plugingui/frame.cc \ + @top_srcdir@/plugingui/humanizerframecontent.cc \ + @top_srcdir@/plugingui/image.cc \ + @top_srcdir@/plugingui/imagecache.cc \ + @top_srcdir@/plugingui/knob.cc \ + @top_srcdir@/plugingui/label.cc \ + @top_srcdir@/plugingui/layout.cc \ + @top_srcdir@/plugingui/led.cc \ + @top_srcdir@/plugingui/lineedit.cc \ + @top_srcdir@/plugingui/listbox.cc \ + @top_srcdir@/plugingui/listboxbasic.cc \ + @top_srcdir@/plugingui/listboxthin.cc \ + @top_srcdir@/plugingui/maintab.cc \ + @top_srcdir@/plugingui/nativewindow_win32.cc \ @top_srcdir@/plugingui/painter.cc \ - @top_srcdir@/plugingui/button.cc \ @top_srcdir@/plugingui/pixelbuffer.cc \ - @top_srcdir@/plugingui/lineedit.cc \ - @top_srcdir@/plugingui/led.cc \ - @top_srcdir@/plugingui/layout.cc \ - @top_srcdir@/plugingui/checkbox.cc \ - @top_srcdir@/plugingui/slider.cc \ + @top_srcdir@/plugingui/pluginconfig.cc \ + @top_srcdir@/plugingui/plugingui.cc \ + @top_srcdir@/plugingui/powerbutton.cc \ + @top_srcdir@/plugingui/progressbar.cc \ + @top_srcdir@/plugingui/resource.cc \ + @top_srcdir@/plugingui/resource_data.cc \ @top_srcdir@/plugingui/scrollbar.cc \ + @top_srcdir@/plugingui/slider.cc \ @top_srcdir@/plugingui/stackedwidget.cc \ + @top_srcdir@/plugingui/statusframecontent.cc \ @top_srcdir@/plugingui/textedit.cc \ @top_srcdir@/plugingui/texture.cc \ @top_srcdir@/plugingui/texturedbox.cc \ - @top_srcdir@/plugingui/listbox.cc \ - @top_srcdir@/plugingui/listboxthin.cc \ - @top_srcdir@/plugingui/listboxbasic.cc \ - @top_srcdir@/plugingui/knob.cc \ - @top_srcdir@/plugingui/filebrowser.cc \ - @top_srcdir@/plugingui/directory.cc \ - @top_srcdir@/plugingui/image.cc \ - @top_srcdir@/plugingui/imagecache.cc \ - @top_srcdir@/plugingui/combobox.cc \ - @top_srcdir@/plugingui/progressbar.cc \ - @top_srcdir@/plugingui/verticalline.cc \ - @top_srcdir@/plugingui/resource.cc \ - @top_srcdir@/plugingui/resource_data.cc \ @top_srcdir@/plugingui/toggle.cc \ - @top_srcdir@/plugingui/powerbutton.cc \ - @top_srcdir@/plugingui/drumkitframecontent.cc \ - @top_srcdir@/plugingui/statusframecontent.cc \ - @top_srcdir@/plugingui/humanizerframecontent.cc \ - @top_srcdir@/plugingui/diskstreamingframecontent.cc \ - @top_srcdir@/plugingui/maintab.cc \ - @top_srcdir@/plugingui/frame.cc \ + @top_srcdir@/plugingui/verticalline.cc \ + @top_srcdir@/plugingui/widget.cc \ + @top_srcdir@/plugingui/window.cc \ @top_srcdir@/plugingui/lodepng/lodepng.cpp GUI_CPPFLAGS=-I@top_srcdir@/plugingui/ -DUSE_THREAD @GUI_CPPFLAGS@ diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index 133c71f..8795acd 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -20,53 +20,54 @@ libdggui_la_LIBADD = \ $(GUI_LIBS) $(PTHREAD_LIBS) nodist_libdggui_la_SOURCES = \ + button.cc \ + button_base.cc \ + checkbox.cc \ + colour.cc \ + combobox.cc \ dgwindow.cc \ - plugingui.cc \ - label.cc \ + dialog.cc \ + directory.cc \ + diskstreamingframecontent.cc \ + drumkitframecontent.cc \ eventhandler.cc \ + filebrowser.cc \ font.cc \ - window.cc \ - widget.cc \ - colour.cc \ + frame.cc \ + humanizerframecontent.cc \ + image.cc \ + imagecache.cc \ + knob.cc \ + label.cc \ + layout.cc \ + led.cc \ + lineedit.cc \ + listbox.cc \ + listboxbasic.cc \ + listboxthin.cc \ + maintab.cc \ + mainwindow.cc \ painter.cc \ - button_base.cc \ - button.cc \ pixelbuffer.cc \ - lineedit.cc \ - led.cc \ - checkbox.cc \ - toggle.cc \ + pluginconfig.cc \ + plugingui.cc \ powerbutton.cc \ - mainwindow.cc \ - drumkitframecontent.cc \ - statusframecontent.cc \ - humanizerframecontent.cc \ - diskstreamingframecontent.cc \ - slider.cc \ + progressbar.cc \ + resource.cc \ + resource_data.cc \ scrollbar.cc \ + slider.cc \ stackedwidget.cc \ + statusframecontent.cc \ tabbutton.cc \ tabwidget.cc \ textedit.cc \ texture.cc \ texturedbox.cc \ - layout.cc \ - listbox.cc \ - listboxthin.cc \ - listboxbasic.cc \ - maintab.cc \ - knob.cc \ - filebrowser.cc \ - directory.cc \ - pluginconfig.cc \ - imagecache.cc \ - image.cc \ - combobox.cc \ - progressbar.cc \ + toggle.cc \ verticalline.cc \ - resource.cc \ - resource_data.cc \ - frame.cc \ + widget.cc \ + window.cc \ lodepng/lodepng.cpp if ENABLE_X11 @@ -106,12 +107,14 @@ rcgen_SOURCES = rcgen.cc EXTRA_DIST = \ button.h \ + button_base.h \ canvas.h \ checkbox.h \ colour.h \ combobox.h \ dgwindow.h \ drawable.h \ + dialog.h \ directory.h \ eventhandler.h \ filebrowser.h \ diff --git a/plugingui/dialog.cc b/plugingui/dialog.cc new file mode 100644 index 0000000..9ba579d --- /dev/null +++ b/plugingui/dialog.cc @@ -0,0 +1,54 @@ +/* -*- Mode: c++ -*- */ +/*************************************************************************** + * dialog.cc + * + * Sun Apr 16 10:31:04 CEST 2017 + * Copyright 2017 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DrumGizmo 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "dialog.h" + +namespace GUI +{ + +Dialog::Dialog(Widget* parent, bool modal) + : parent(parent) +{ + parent->window()->eventHandler()->registerDialog(this); + setModal(modal); +} + +Dialog::~Dialog() +{ + parent->window()->eventHandler()->unregisterDialog(this); +} + +void Dialog::setModal(bool modal) +{ + is_modal = modal; +} + +bool Dialog::isModal() const +{ + return is_modal; +} + +} // GUI:: diff --git a/plugingui/dialog.h b/plugingui/dialog.h new file mode 100644 index 0000000..1b0c6da --- /dev/null +++ b/plugingui/dialog.h @@ -0,0 +1,63 @@ +/* -*- Mode: c++ -*- */ +/*************************************************************************** + * dialog.h + * + * Sun Apr 16 10:31:04 CEST 2017 + * Copyright 2017 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DrumGizmo 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#pragma once + +#include "window.h" + +namespace GUI +{ + +//! This class is used the base window for pop-up dialogs, such as a file +//! browser. +class Dialog + : public Window +{ +public: + //! - The dialog is placed near the parent window. + //! - The parent window event handler will call the dialog event handler + //! - While the dialog is visible, all mouse click and keyboard events + //! are ignored by the parent event handler. + //! - The Dialog registers itself in the parent event handler when contructed + //! and removes itself when destructed. + //! - The parent event handler will delete all registered Dialogs when itself + //! deleted. + Dialog(Widget* parent, bool modal = false); + + ~Dialog(); + + //! Change modality. + void setModal(bool modal); + + //! Get current modality state. + bool isModal() const; + +private: + bool is_modal{false}; + Widget* parent{nullptr}; +}; + +} // GUI:: diff --git a/plugingui/eventhandler.cc b/plugingui/eventhandler.cc index a57e74b..decca01 100644 --- a/plugingui/eventhandler.cc +++ b/plugingui/eventhandler.cc @@ -28,6 +28,7 @@ #include "window.h" #include "painter.h" +#include "dialog.h" namespace GUI { @@ -63,6 +64,16 @@ std::shared_ptr<Event> EventHandler::getNextEvent() void EventHandler::processEvents() { + bool block_interaction{false}; + for(auto dialog : dialogs) + { + if(dialog->visible()) + { + block_interaction |= dialog->isModal(); + dialog->eventHandler()->processEvents(); + } + } + events = nativeWindow.getEvents(); while(hasEvent()) @@ -147,6 +158,11 @@ void EventHandler::processEvents() case EventType::button: { + if(block_interaction) + { + continue; + } + auto buttonEvent = static_cast<ButtonEvent*>(event.get()); if(lastWasDoubleClick && (buttonEvent->direction == Direction::down)) { @@ -195,6 +211,11 @@ void EventHandler::processEvents() case EventType::scroll: { + if(block_interaction) + { + continue; + } + auto scrollEvent = static_cast<ScrollEvent*>(event.get()); auto widget = window.find(scrollEvent->x, scrollEvent->y); @@ -210,6 +231,10 @@ void EventHandler::processEvents() case EventType::key: { + if(block_interaction) + { + continue; + } // TODO: Filter out multiple arrow events. @@ -222,6 +247,11 @@ void EventHandler::processEvents() break; case EventType::close: + if(block_interaction) + { + continue; + } + closeNotifier(); break; } @@ -232,4 +262,15 @@ void EventHandler::processEvents() window.updateBuffer(); } +void EventHandler::registerDialog(Dialog* dialog) +{ + dialogs.push_back(dialog); +} + +void EventHandler::unregisterDialog(Dialog* dialog) +{ + dialogs.remove(dialog); +} + + } // GUI:: diff --git a/plugingui/eventhandler.h b/plugingui/eventhandler.h index bd79084..8d6f492 100644 --- a/plugingui/eventhandler.h +++ b/plugingui/eventhandler.h @@ -29,6 +29,7 @@ #include <notifier.h> #include <memory> #include <queue> +#include <list> #include "guievent.h" #include "nativewindow.h" @@ -37,6 +38,7 @@ namespace GUI { class Window; +class Dialog; class EventHandler { @@ -56,6 +58,9 @@ public: //! \return A pointer to the event or nullptr if there are none. std::shared_ptr<Event> getNextEvent(); + void registerDialog(Dialog* dialog); + void unregisterDialog(Dialog* dialog); + Notifier<> closeNotifier; private: @@ -66,6 +71,8 @@ private: bool lastWasDoubleClick; EventQueue events; + + std::list<Dialog*> dialogs; }; } // GUI:: |