summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/Makefile.am8
-rw-r--r--plugingui/Makefile.mingw328
-rw-r--r--plugingui/checkbox.cc1
-rw-r--r--plugingui/diskstreamingframecontent.cc62
-rw-r--r--plugingui/diskstreamingframecontent.h55
-rw-r--r--plugingui/drumkitframecontent.cc73
-rw-r--r--plugingui/drumkitframecontent.h103
-rw-r--r--plugingui/frame.cc119
-rw-r--r--plugingui/frame.h95
-rw-r--r--plugingui/humanizerframecontent.cc61
-rw-r--r--plugingui/humanizerframecontent.h77
-rw-r--r--plugingui/maintab.cc54
-rw-r--r--plugingui/maintab.h58
-rw-r--r--plugingui/mainwindow.cc38
-rw-r--r--plugingui/mainwindow.h11
-rw-r--r--plugingui/statusframecontent.cc46
-rw-r--r--plugingui/statusframecontent.h46
-rw-r--r--plugingui/tests/Makefile.am11
-rw-r--r--plugingui/tests/framewidgettest.cc194
19 files changed, 1114 insertions, 6 deletions
diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am
index 2a9d453..83a4411 100644
--- a/plugingui/Makefile.am
+++ b/plugingui/Makefile.am
@@ -37,6 +37,10 @@ nodist_libdggui_la_SOURCES = \
toggle.cc \
powerbutton.cc \
mainwindow.cc \
+ drumkitframecontent.cc \
+ statusframecontent.cc \
+ humanizerframecontent.cc \
+ diskstreamingframecontent.cc \
slider.cc \
scrollbar.cc \
stackedwidget.cc \
@@ -49,6 +53,7 @@ nodist_libdggui_la_SOURCES = \
listbox.cc \
listboxthin.cc \
listboxbasic.cc \
+ maintab.cc \
knob.cc \
filebrowser.cc \
directory.cc \
@@ -60,6 +65,7 @@ nodist_libdggui_la_SOURCES = \
verticalline.cc \
resource.cc \
resource_data.cc \
+ frame.cc \
lodepng/lodepng.cpp
if ENABLE_X11
@@ -142,4 +148,4 @@ EXTRA_DIST = \
verticalline.h \
widget.h \
window.h \
- lodepng/lodepng.h \ No newline at end of file
+ lodepng/lodepng.h
diff --git a/plugingui/Makefile.mingw32 b/plugingui/Makefile.mingw32
index 7f5b191..39ff2d0 100644
--- a/plugingui/Makefile.mingw32
+++ b/plugingui/Makefile.mingw32
@@ -34,9 +34,17 @@ GUI_SRC = \
texturedbox.cc \
tabbutton.cc \
tabwidget.cc \
+ toggle.cc \
listbox.cc \
listboxthin.cc \
listboxbasic.cc \
+ powerbutton.cc \
+ drumkitframecontent.cc \
+ statusframecontent.cc \
+ humanizerframecontent.cc \
+ diskstreamingframecontent.cc \
+ maintab.cc \
+ frame.cc \
knob.cc \
filebrowser.cc \
directory.cc \
diff --git a/plugingui/checkbox.cc b/plugingui/checkbox.cc
index 499b2c1..0f101ec 100644
--- a/plugingui/checkbox.cc
+++ b/plugingui/checkbox.cc
@@ -42,7 +42,6 @@ CheckBox::CheckBox(Widget* parent)
void CheckBox::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
-
p.clear();
p.drawImage(0, (knob.height() - bg_on.height()) / 2, state ? bg_on : bg_off);
diff --git a/plugingui/diskstreamingframecontent.cc b/plugingui/diskstreamingframecontent.cc
new file mode 100644
index 0000000..0d17aaf
--- /dev/null
+++ b/plugingui/diskstreamingframecontent.cc
@@ -0,0 +1,62 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * diskstreamingframecontent.cc
+ *
+ * Fri Mar 24 21:50:07 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "diskstreamingframecontent.h"
+
+namespace GUI {
+
+DiskstreamingframeContent::DiskstreamingframeContent(Widget* parent)
+ : Widget(parent)
+ , slider_width{250}
+{
+ label_text.setText("Cache limit (max memory usage):");
+ label_text.setAlignment(TextAlignment::center);
+
+ button.setText("Apply"); // TODO connect
+
+ label_size.setText("600 MB"); // TODO connect
+ label_size.setAlignment(TextAlignment::center);
+}
+
+void DiskstreamingframeContent::resize(std::size_t width, std::size_t height)
+{
+ Widget::resize(width, height);
+
+ slider_width = 0.8 * width;
+ button_width = width - slider_width;
+
+ label_text.move(0,0);
+ slider.move(0, 20);
+ button.move(slider_width, 10);
+ label_size.move(0, 40);
+
+ label_text.resize(slider_width, 15);
+ slider.resize(slider_width, 15);
+ button.resize(button_width, 30);
+ label_size.resize(slider_width, 15);
+}
+
+} // GUI::
diff --git a/plugingui/diskstreamingframecontent.h b/plugingui/diskstreamingframecontent.h
new file mode 100644
index 0000000..33afcf8
--- /dev/null
+++ b/plugingui/diskstreamingframecontent.h
@@ -0,0 +1,55 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * diskstreamingframecontent.h
+ *
+ * Fri Mar 24 21:50:07 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "widget.h"
+#include "slider.h"
+#include "label.h"
+#include "button.h"
+
+namespace GUI {
+
+class DiskstreamingframeContent : public Widget
+{
+public:
+ DiskstreamingframeContent(Widget* parent);
+
+ // From Widget
+ virtual void resize(std::size_t width, std::size_t height) override;
+
+private:
+ Label label_text{this};
+ Label label_size{this};
+
+ Slider slider{this};
+ Button button{this};
+
+ std::size_t slider_width;
+ std::size_t button_width;
+};
+
+} // GUI::
diff --git a/plugingui/drumkitframecontent.cc b/plugingui/drumkitframecontent.cc
new file mode 100644
index 0000000..8b2b828
--- /dev/null
+++ b/plugingui/drumkitframecontent.cc
@@ -0,0 +1,73 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * drumkitframecontent.cc
+ *
+ * Fri Mar 24 21:49:42 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "drumkitframecontent.h"
+
+#include "label.h"
+
+namespace GUI {
+
+DrumkitframeContent::DrumkitframeContent(Widget* parent)
+ : Widget(parent)
+{
+ layout.setHAlignment(HAlignment::left);
+
+ drumkitCaption.setText("Drumkit file:");
+ midimapCaption.setText("Midimap file:");
+
+ layout.addItem(&drumkitCaption);
+ layout.addItem(&drumkitFile);
+ layout.addItem(&drumkitFileProgress);
+ layout.addItem(&midimapCaption);
+ layout.addItem(&midimapFile);
+ layout.addItem(&midimapFileProgress);
+
+ // TODO:
+ // CONNECT(&drumkitFile.browseButton, clickNotifier,
+ // this, &DGWindow::kitBrowseClick);
+ // TODO:
+ // CONNECT(&midimapFile.browseButton, clickNotifier,
+ // this, &DGWindow::midimapBrowseClick);
+
+ midimapFileProgress.setTotal(2);
+}
+
+void DrumkitframeContent::resize(std::size_t width, std::size_t height)
+{
+ Widget::resize(width, height);
+
+ drumkitCaption.resize(width, 15);
+ drumkitFile.resize(width, 37);
+ drumkitFileProgress.resize(drumkitFile.getLineEditWidth(), 11);
+
+ midimapCaption.resize(width, 15);
+ midimapFile.resize(width, 37);
+ midimapFileProgress.resize(drumkitFile.getLineEditWidth(), 11);
+
+ layout.layout();
+}
+
+} // GUI::
diff --git a/plugingui/drumkitframecontent.h b/plugingui/drumkitframecontent.h
new file mode 100644
index 0000000..b5b929c
--- /dev/null
+++ b/plugingui/drumkitframecontent.h
@@ -0,0 +1,103 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * drumkitframecontent.h
+ *
+ * Fri Mar 24 21:49:42 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "widget.h"
+#include "lineedit.h"
+#include "progressbar.h"
+#include "button.h"
+#include "label.h"
+
+namespace GUI
+{
+
+// TODO: move to own class?
+class File
+ : public Widget
+{
+public:
+ File(Widget* parent)
+ : Widget(parent)
+ {
+ layout.setResizeChildren(false);
+ layout.setVAlignment(VAlignment::center);
+
+ layout.addItem(&lineedit);
+ layout.addItem(&browse_button);
+
+ browse_button.setText("Browse...");
+ }
+
+ // From Widget
+ virtual void resize(std::size_t width, std::size_t height) override
+ {
+ Widget::resize(width, height);
+
+ lineedit_width = 0.8 * width;
+ button_width = width - lineedit_width;
+
+ lineedit.resize(lineedit_width, 29);
+ browse_button.resize(button_width, 41);
+
+ layout.layout();
+ }
+
+ std::size_t getLineEditWidth() { return lineedit_width; }
+ std::size_t getButtonWidth() { return button_width; }
+
+private:
+ HBoxLayout layout{this};
+
+ LineEdit lineedit{this};
+ Button browse_button{this};
+
+ std::size_t lineedit_width;
+ std::size_t button_width;
+
+ LineEdit& getLineEdit() { return lineedit; }
+};
+
+class DrumkitframeContent : public Widget
+{
+public:
+ DrumkitframeContent(Widget* parent);
+
+ // From Widget
+ virtual void resize(std::size_t width, std::size_t height) override;
+
+private:
+ VBoxLayout layout{this};
+
+ Label drumkitCaption{this};
+ Label midimapCaption{this};
+ File drumkitFile{this};
+ File midimapFile{this};
+ ProgressBar drumkitFileProgress{this};
+ ProgressBar midimapFileProgress{this};
+};
+
+} // GUI::
diff --git a/plugingui/frame.cc b/plugingui/frame.cc
new file mode 100644
index 0000000..f34eecf
--- /dev/null
+++ b/plugingui/frame.cc
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * frame.cc
+ *
+ * Tue Feb 7 21:07:56 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "frame.h"
+
+#include "painter.h"
+
+// TODO: fix all the segfaults
+// TODO: change look to what it is in the fake GUI
+// TODO: replace CheckBox by some other name
+// TODO: maybe refactor the Toggle thingy
+// TODO: make it possible to use layouts recursively
+// TODO: make it possible to add layouts to tabs
+
+namespace GUI
+{
+
+FrameWidget::FrameWidget(Widget *parent, bool has_switch)
+ : Widget(parent)
+ , has_switch(has_switch)
+ , is_switched_on(!has_switch)
+ , bar_height(24)
+{
+ if (has_switch) {
+ // We only have to set this once as nothing happens on a resize
+ power_button.move(4, 4);
+ power_button.resize(16, 16);
+
+ CONNECT(&power_button, stateChangedNotifier, this, &FrameWidget::powerButtonClicked);
+ }
+ power_button.setVisible(has_switch);
+
+ CONNECT(this, sizeChangeNotifier, this, &FrameWidget::sizeChanged);
+}
+
+void FrameWidget::repaintEvent(RepaintEvent* repaintEvent)
+{
+ Painter p(*this);
+ p.clear();
+
+ int center_x = width() / 2;
+ auto title_buf = title.c_str();
+
+ // draw the dark grey box
+ p.setColour(grey_box_colour);
+ p.drawFilledRectangle(1, 1, width() - 2, bar_height);
+
+ // frame
+ p.setColour(frame_colour);
+ p.drawRectangle(0, 0, width() - 1, height() - 1);
+
+ // background
+ p.setColour(background_colour);
+ p.drawFilledRectangle(1, bar_height, width() - 2, height() - 2);
+
+ // draw the label
+ p.setColour(label_colour);
+ p.drawText(center_x - label_width, bar_height - 4, font, title_buf);
+}
+
+void FrameWidget::powerButtonClicked(bool clicked)
+{
+ is_switched_on = !is_switched_on;
+
+ if (content) {
+ content->setVisible(true);
+ }
+}
+
+void FrameWidget::setTitle(std::string const& title)
+{
+ this->title = title;
+ label_width = font.textWidth(title.c_str()) / 2 + 1;
+}
+
+void FrameWidget::setContent(Widget* content)
+{
+ this->content = content;
+ content->reparent(this);
+ content->setVisible(true);
+}
+
+void FrameWidget::sizeChanged(int width, int height)
+{
+ if (content) {
+ content_start_x = content_margin;
+ content_start_y = bar_height + content_margin;
+ content_width = width - 2*content_margin;
+ content_height = height - (bar_height + 2*content_margin);
+
+ content->move(content_start_x, content_start_y);
+ content->resize(content_width, content_height);
+ }
+}
+
+} // GUI::
diff --git a/plugingui/frame.h b/plugingui/frame.h
new file mode 100644
index 0000000..1e900ee
--- /dev/null
+++ b/plugingui/frame.h
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * frame.h
+ *
+ * Tue Feb 7 21:07:56 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "widget.h"
+#include "font.h"
+#include "powerbutton.h"
+
+namespace GUI {
+
+class FrameWidget : public Widget {
+public:
+ FrameWidget(Widget* parent, bool has_switch = false);
+ virtual ~FrameWidget() = default;
+
+ // From Widget:
+ virtual bool isFocusable() override { return false; }
+ virtual bool catchMouse() override { return false; }
+
+ bool isSwitchedOn() { return is_switched_on; }
+ void setTitle(std::string const& title);
+ void setContent(Widget* content);
+
+protected:
+ // From Widget:
+ virtual void repaintEvent(RepaintEvent* repaintEvent) override;
+
+ //! Callback for Widget::sizeChangeNotifier
+ void sizeChanged(int width, int height);
+
+private:
+ //
+ // upper bar
+ //
+
+ // label
+ Font font;
+ std::string title;
+ GUI::Colour label_colour{0.1};
+ std::size_t label_width;
+
+ // switch
+ bool has_switch;
+ bool is_switched_on;
+ PowerButton power_button{this};
+
+ void powerButtonClicked(bool clicked);
+
+ // grey box
+ std::size_t bar_height;
+ GUI::Colour grey_box_colour{0.7};
+ GUI::Colour background_colour{0.85, 0.8};
+
+ //
+ // content
+ //
+
+ // content frame
+ GUI::Colour frame_colour{0};
+
+ // content box
+ Widget* content{nullptr};
+ std::size_t content_margin{5};
+
+ std::size_t content_start_x;
+ std::size_t content_start_y;
+ std::size_t content_width;
+ std::size_t content_height;
+};
+
+} // GUI::
diff --git a/plugingui/humanizerframecontent.cc b/plugingui/humanizerframecontent.cc
new file mode 100644
index 0000000..aaa1167
--- /dev/null
+++ b/plugingui/humanizerframecontent.cc
@@ -0,0 +1,61 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * humanizerframecontent.cc
+ *
+ * Fri Mar 24 21:49:58 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "humanizerframecontent.h"
+
+#include "painter.h"
+
+namespace GUI {
+
+HumanizerframeContent::HumanizerframeContent(Widget* parent)
+ : Widget(parent)
+{
+ // FIXME, is resizeChildren broken?
+ layout.setResizeChildren(true);
+ layout.setVAlignment(VAlignment::center);
+
+ attack.resize(80, 80);
+ attackKnob.resize(60, 60);
+ attack.setControl(&attackKnob);
+ layout.addItem(&attack);
+
+ falloff.resize(80, 80);
+ falloffKnob.resize(60, 60);
+ falloff.setControl(&falloffKnob);
+ layout.addItem(&falloff);
+
+ // TODO: connect the knobs to the right functions
+ // CONNECT(&humanizeControls->velocityCheck, stateChangedNotifier,
+ // this, &DGWindow::velocityCheckClick);
+ //
+ // CONNECT(&humanizeControls->attackKnob, valueChangedNotifier,
+ // this, &DGWindow::attackValueChanged);
+ //
+ // CONNECT(&humanizeControls->falloffKnob, valueChangedNotifier,
+ // this, &DGWindow::falloffValueChanged);
+}
+
+} // GUI::
diff --git a/plugingui/humanizerframecontent.h b/plugingui/humanizerframecontent.h
new file mode 100644
index 0000000..29f76ab
--- /dev/null
+++ b/plugingui/humanizerframecontent.h
@@ -0,0 +1,77 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * humanizerframecontent.h
+ *
+ * Fri Mar 24 21:49:58 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "widget.h"
+#include "knob.h"
+#include "label.h"
+
+namespace GUI {
+
+// TODO move this to an own file?
+class LabeledControl
+ : public Widget
+{
+public:
+ LabeledControl(Widget* parent, const std::string& name)
+ : Widget(parent)
+ {
+ layout.setResizeChildren(false);
+ layout.setHAlignment(HAlignment::center);
+
+ caption.setText(name);
+ caption.resize(100, 20);
+ caption.setAlignment(TextAlignment::center);
+ layout.addItem(&caption);
+ }
+
+ void setControl(Widget* control)
+ {
+ layout.addItem(control);
+ }
+
+ VBoxLayout layout{this};
+
+ Label caption{this};
+};
+
+class HumanizerframeContent : public Widget
+{
+public:
+ HumanizerframeContent(Widget* parent);
+
+private:
+ HBoxLayout layout{this};
+
+ LabeledControl attack{this, "Attack"};
+ LabeledControl falloff{this, "Release"};
+
+ Knob attackKnob{&attack};
+ Knob falloffKnob{&falloff};
+};
+
+} // GUI::
diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc
new file mode 100644
index 0000000..b6dc448
--- /dev/null
+++ b/plugingui/maintab.cc
@@ -0,0 +1,54 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * maintab.cc
+ *
+ * Fri Mar 24 20:39:59 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "maintab.h"
+
+namespace GUI {
+
+MainTab::MainTab(Widget* parent)
+ : Widget(parent)
+{
+ layout.setSpacing(10);
+ layout.setResizeChildren(true);
+ layout.setHAlignment(GUI::HAlignment::center);
+
+ layout.addItem(&drumkit_frame);
+ layout.addItem(&status_frame);
+ layout.addItem(&humanizer_frame);
+ layout.addItem(&diskstreaming_frame);
+
+ drumkit_frame.setTitle("Drumkit");
+ status_frame.setTitle("Status");
+ humanizer_frame.setTitle("Humanizer");
+ diskstreaming_frame.setTitle("Disk streaming");
+
+ drumkit_frame.setContent(&drumkitframe_content);
+ status_frame.setContent(&statusframe_content);
+ humanizer_frame.setContent(&humanizerframe_content);
+ diskstreaming_frame.setContent(&diskstreamingframe_content);
+}
+
+} // GUI::
diff --git a/plugingui/maintab.h b/plugingui/maintab.h
new file mode 100644
index 0000000..1ab30d7
--- /dev/null
+++ b/plugingui/maintab.h
@@ -0,0 +1,58 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * maintab.h
+ *
+ * Fri Mar 24 20:39:59 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "widget.h"
+#include "layout.h"
+#include "frame.h"
+#include "drumkitframecontent.h"
+#include "statusframecontent.h"
+#include "humanizerframecontent.h"
+#include "diskstreamingframecontent.h"
+
+namespace GUI {
+
+class MainTab : public Widget
+{
+public:
+ MainTab(Widget* parent);
+
+private:
+ VBoxLayout layout{this};
+
+ FrameWidget drumkit_frame{this, false};
+ FrameWidget status_frame{this, false};
+ FrameWidget humanizer_frame{this, true};
+ FrameWidget diskstreaming_frame{this, true};
+
+ DrumkitframeContent drumkitframe_content{this};
+ StatusframeContent statusframe_content{this};
+ HumanizerframeContent humanizerframe_content{this};
+ DiskstreamingframeContent diskstreamingframe_content{this};
+};
+
+} // GUI::
diff --git a/plugingui/mainwindow.cc b/plugingui/mainwindow.cc
index 3b951f5..51fd3a3 100644
--- a/plugingui/mainwindow.cc
+++ b/plugingui/mainwindow.cc
@@ -30,6 +30,31 @@
#include "painter.h"
+#include <string>
+
+namespace
+{
+
+std::string getGPLText()
+{
+ return
+ "DrumGizmo is free software; you can redistribute it and/or modify\n"
+ "it under the terms of the GNU Lesser General Public License as published by\n"
+ "the Free Software Foundation; either version 3 of the License, or\n"
+ "(at your option) any later version.\n"
+ "\n"
+ "DrumGizmo is distributed in the hope that it will be useful,\n"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+ "GNU Lesser General Public License for more details.\n"
+ "\n"
+ "You should have received a copy of the GNU Lesser General Public License\n"
+ "along with DrumGizmo; if not, write to the Free Software\n"
+ "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.\n";
+}
+
+} // anonymous namespace
+
namespace GUI
{
@@ -39,8 +64,19 @@ MainWindow::MainWindow(Settings& settings, void* native_window)
{
CONNECT(this, sizeChangeNotifier, this, &MainWindow::sizeChanged);
CONNECT(eventHandler(), closeNotifier, this, &MainWindow::closeEventHandler);
- tabs.move(16, 0); // x-offset to make room for the left side bar.
+
+ // TODO: use fixed size?
+ // setFixedSize(450, 600);
setCaption("DrumGizmo v" VERSION);
+
+ tabs.move(16, 0); // x-offset to make room for the left side bar.
+
+ tabs.addTab("Main", &main_tab);
+ tabs.addTab("GPL", &gpl_text_field);
+
+ gpl_text_field.setText(getGPLText());
+ gpl_text_field.preprocessText();
+ gpl_text_field.setReadOnly(true);
}
bool MainWindow::processEvents()
diff --git a/plugingui/mainwindow.h b/plugingui/mainwindow.h
index 886dc3e..89e323a 100644
--- a/plugingui/mainwindow.h
+++ b/plugingui/mainwindow.h
@@ -28,10 +28,13 @@
#include <settings.h>
-#include "window.h"
+#include "frame.h"
+#include "image.h"
+#include "textedit.h"
#include "tabwidget.h"
#include "texturedbox.h"
-#include "image.h"
+#include "window.h"
+#include "maintab.h"
namespace GUI
{
@@ -57,6 +60,10 @@ private:
void repaintEvent(RepaintEvent* repaintEvent) override final;
TabWidget tabs{this};
+
+ MainTab main_tab{this};
+ // TODO use some nice textfield widget here
+ TextEdit gpl_text_field{&tabs};
Image back{":bg.png"};
Image logo{":logo.png"};
diff --git a/plugingui/statusframecontent.cc b/plugingui/statusframecontent.cc
new file mode 100644
index 0000000..2f87dec
--- /dev/null
+++ b/plugingui/statusframecontent.cc
@@ -0,0 +1,46 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * statusframecontent.cc
+ *
+ * Fri Mar 24 21:49:50 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "statusframecontent.h"
+
+namespace GUI {
+
+StatusframeContent::StatusframeContent(Widget* parent)
+ : Widget(parent)
+{
+ text_field.move(0, 0);
+ text_field.setText("This is a status message.");
+ text_field.setReadOnly(true);
+ text_field.show();
+}
+
+void StatusframeContent::resize(std::size_t width, std::size_t height)
+{
+ Widget::resize(width, height);
+ text_field.resize(width, height);
+}
+
+} // GUI::
diff --git a/plugingui/statusframecontent.h b/plugingui/statusframecontent.h
new file mode 100644
index 0000000..c61f716
--- /dev/null
+++ b/plugingui/statusframecontent.h
@@ -0,0 +1,46 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * statusframecontent.h
+ *
+ * Fri Mar 24 21:49:50 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 "widget.h"
+#include "textedit.h"
+
+namespace GUI {
+
+class StatusframeContent : public Widget
+{
+public:
+ StatusframeContent(Widget* parent);
+
+ // From Widget
+ virtual void resize(std::size_t width, std::size_t height) override;
+
+private:
+ TextEdit text_field{this};
+};
+
+} // GUI::
diff --git a/plugingui/tests/Makefile.am b/plugingui/tests/Makefile.am
index 8af96ee..28c5cfa 100644
--- a/plugingui/tests/Makefile.am
+++ b/plugingui/tests/Makefile.am
@@ -1,4 +1,4 @@
-noinst_PROGRAMS = resizetest tabwidgettest dgwindowtest
+noinst_PROGRAMS = resizetest tabwidgettest dgwindowtest framewidgettest
resizetest_LDADD = $(top_srcdir)/plugingui/libdggui.la
resizetest_CXXFLAGS = \
@@ -28,3 +28,12 @@ dgwindowtest_CXXFLAGS = \
dgwindowtest_SOURCES = \
dgwindowtest.cc \
$(top_srcdir)/hugin/hugin.c
+
+framewidgettest_LDADD = $(top_srcdir)/plugingui/libdggui.la
+framewidgettest_CXXFLAGS = \
+ -I$(top_srcdir)/plugingui \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/hugin
+framewidgettest_SOURCES = \
+ framewidgettest.cc \
+ $(top_srcdir)/hugin/hugin.c
diff --git a/plugingui/tests/framewidgettest.cc b/plugingui/tests/framewidgettest.cc
new file mode 100644
index 0000000..38656b7
--- /dev/null
+++ b/plugingui/tests/framewidgettest.cc
@@ -0,0 +1,194 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * framewidgettest.cc
+ *
+ * Sat Feb 11 23:36:04 CET 2017
+ * Copyright 2017 André Nusser
+ * andre.nusser@googlemail.com
+ ****************************************************************************/
+
+/*
+ * 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 <iostream>
+
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+#include <unistd.h>
+
+#include <hugin.hpp>
+#include <window.h>
+#include <frame.h>
+#include <label.h>
+#include <layout.h>
+#include <button.h>
+#include <checkbox.h>
+
+// TODO: fix segfault on close
+
+class Widget1
+ : public GUI::Widget
+{
+public:
+ Widget1(GUI::Widget* parent)
+ : GUI::Widget(parent)
+ {
+ layout.setResizeChildren(true);
+ layout.setHAlignment(GUI::HAlignment::center);
+
+ label1.setText("Label1");
+ label1.setAlignment(GUI::TextAlignment::left);
+ layout.addItem(&label1);
+
+ label2.setText("Label2");
+ label2.setAlignment(GUI::TextAlignment::center);
+ layout.addItem(&label2);
+
+ label3.setText("Label3");
+ label3.setAlignment(GUI::TextAlignment::right);
+ layout.addItem(&label3);
+ }
+
+private:
+ GUI::VBoxLayout layout{this};
+ GUI::Label label1{this};
+ GUI::Label label2{this};
+ GUI::Label label3{this};
+};
+
+class Widget2
+ : public GUI::Widget
+{
+public:
+ Widget2(GUI::Widget* parent)
+ : GUI::Widget(parent)
+ {
+ layout.setSpacing(10);
+ layout.setResizeChildren(true);
+ layout.setVAlignment(GUI::VAlignment::top);
+
+ label1.setText("Label1");
+ label1.setAlignment(GUI::TextAlignment::right);
+ layout.addItem(&label1);
+
+ label2.setText("Label2");
+ label2.setAlignment(GUI::TextAlignment::left);
+ layout.addItem(&label2);
+
+ layout.addItem(&checkbox);
+ }
+
+private:
+ GUI::HBoxLayout layout{this};
+ GUI::Label label1{this};
+ GUI::Label label2{this};
+ GUI::CheckBox checkbox{this};
+};
+
+class TestWindow
+ : public GUI::Window
+{
+public:
+ TestWindow()
+ : GUI::Window(nullptr)
+ {
+ setCaption("FrameWidgetTest Window");
+ CONNECT(eventHandler(), closeNotifier,
+ this, &TestWindow::closeEventHandler);
+ CONNECT(this, sizeChangeNotifier, this, &TestWindow::sizeChanged);
+
+ layout.setSpacing(10);
+ layout.setResizeChildren(true);
+ layout.setHAlignment(GUI::HAlignment::center);
+
+ layout.addItem(&frame1);
+ layout.addItem(&frame2);
+ layout.addItem(&frame3);
+ layout.addItem(&frame4);
+
+ frame1.setTitle("Frame 1 Title");
+ frame2.setTitle("Frame 2 Title");
+ frame3.setTitle("Frame 3 Title");
+ frame4.setTitle("Frame 4 Title");
+
+ frame1.setContent(&w1_1);
+ frame2.setContent(&w1_2);
+ frame3.setContent(&w2_1);
+ frame4.setContent(&w2_2);
+ }
+
+ void sizeChanged(std::size_t width, std::size_t height)
+ {
+ // TODO: Do we have to do anything here?
+ }
+
+ void closeEventHandler()
+ {
+ closing = true;
+ }
+
+ bool processEvents()
+ {
+ eventHandler()->processEvents();
+ return !closing;
+ }
+
+ void repaintEvent(GUI::RepaintEvent* repaintEvent) override
+ {
+ GUI::Painter painter(*this);
+ painter.setColour(GUI::Colour(0.85));
+ painter.drawFilledRectangle(0, 0, width() - 1, height() - 1);
+ }
+
+private:
+ bool closing{false};
+
+ GUI::VBoxLayout layout{this};
+
+ GUI::FrameWidget frame1{this, true};
+ GUI::FrameWidget frame2{this, false};
+ GUI::FrameWidget frame3{this, true};
+ GUI::FrameWidget frame4{this, false};
+
+ Widget1 w1_1{this};
+ Widget1 w1_2{this};
+
+ Widget2 w2_1{this};
+ Widget2 w2_2{this};
+};
+
+int main()
+{
+ INFO(example, "We are up and running");
+
+ TestWindow test_window;
+ test_window.show();
+ test_window.resize(300,300);
+
+ while(test_window.processEvents())
+ {
+#ifdef WIN32
+ SleepEx(50, FALSE);
+#else
+ usleep(50000);
+#endif
+ }
+
+ return 0;
+}