summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/Makefile.am.plugingui1
-rw-r--r--plugingui/filebrowser.cc32
-rw-r--r--plugingui/plugingui.cc34
-rw-r--r--plugingui/plugingui.h3
-rw-r--r--plugingui/progressbar.cc77
-rw-r--r--plugingui/progressbar.h54
6 files changed, 197 insertions, 4 deletions
diff --git a/plugingui/Makefile.am.plugingui b/plugingui/Makefile.am.plugingui
index c020fc6..c617524 100644
--- a/plugingui/Makefile.am.plugingui
+++ b/plugingui/Makefile.am.plugingui
@@ -24,6 +24,7 @@ PLUGIN_GUI_SOURCES = \
$(top_srcdir)/plugingui/filebrowser.cc \
$(top_srcdir)/plugingui/image.cc \
$(top_srcdir)/plugingui/combobox.cc \
+ $(top_srcdir)/plugingui/progressbar.cc \
$(top_srcdir)/plugingui/resource.cc \
$(top_srcdir)/plugingui/resource_data.cc
diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc
index afd6518..7efd050 100644
--- a/plugingui/filebrowser.cc
+++ b/plugingui/filebrowser.cc
@@ -38,6 +38,8 @@
#include <sys/stat.h>
#include <unistd.h>
+#include <hugin.hpp>
+
#ifdef WIN32
#include <direct.h>
#endif
@@ -189,9 +191,33 @@ GUI::FileBrowser::~FileBrowser()
void GUI::FileBrowser::setPath(std::string path)
{
- int i = chdir(path.c_str());
- (void)i;
- changeDir(prv);
+ std::string dirname = path;
+
+ while(dirname != "") {
+
+ DEBUG(filebrowser, "dirname: %s\n", dirname.c_str());
+
+ struct stat st;
+ if(stat(dirname.c_str(), &st) == 0) {
+ if((st.st_mode & S_IFDIR) != 0) {
+ dirname += "/.";
+ int i = chdir(dirname.c_str());
+ (void)i;
+ changeDir(prv);
+
+ DEBUG(filebrowser, "chdir to: %s\n", dirname.c_str());
+
+ return;
+ }
+ }
+
+ dirname = dirname.substr(0, dirname.length() - 1);
+ while(dirname[dirname.length() - 1] != '/' &&
+ dirname[dirname.length() - 1] != '\\' &&
+ dirname != "") {
+ dirname = dirname.substr(0, dirname.length() - 1);
+ }
+ }
}
void GUI::FileBrowser::resize(size_t w, size_t h)
diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc
index 3fb5984..e1de5b5 100644
--- a/plugingui/plugingui.cc
+++ b/plugingui/plugingui.cc
@@ -36,6 +36,7 @@
#include <drumgizmo.h>
#include "../src/configuration.h"
#else
+#include "../src/message.h"
class DrumGizmo {
public:
void loadkit(std::string) {}
@@ -88,6 +89,7 @@ static void kitBrowseClick(void *ptr)
{
PluginGUI *gui = (PluginGUI*)ptr;
+ fb->setPath(gui->lineedit->text());
fb->registerFileSelectHandler(selectKitFile, gui);
fb->show();
}
@@ -109,6 +111,7 @@ static void midimapBrowseClick(void *ptr)
{
PluginGUI *gui = (PluginGUI*)ptr;
+ fb->setPath(gui->lineedit2->text());
fb->registerFileSelectHandler(selectMapFile, gui);
fb->show();
}
@@ -168,7 +171,32 @@ void PluginGUI::thread_main()
#else
usleep(50);
#endif/*WIN32*/
- // printf("."); fflush(stdout);
+ Message *msg;
+ while((msg = drumgizmo->receiveMessage()) != NULL) {
+ switch(msg->type()) {
+ case Message::LoadStatus:
+ {
+ Message *pmsg;
+ while( (pmsg = drumgizmo->peekMessage()) != NULL) {
+ if(pmsg->type() != Message::LoadStatus) break;
+ delete msg;
+ msg = drumgizmo->receiveMessage();
+ }
+ LoadStatus *ls = (LoadStatus*)msg;
+ DEBUG(gui, "%d of %d (%s)\n",
+ ls->numer_of_files_loaded,
+ ls->number_of_files,
+ ls->current_file.c_str());
+ progress->setProgress((float)ls->numer_of_files_loaded /
+ (float)ls->number_of_files);
+ }
+ break;
+ default:
+ break;
+ }
+
+ delete msg;
+ }
}
}
@@ -274,6 +302,10 @@ void PluginGUI::init()
lbl3->move(120, 180);
lbl3->resize(70, 20);
+ progress = new GUI::ProgressBar(window);
+ progress->move(200, window->height() - 17);
+ progress->resize(window->width() - 400, 16);
+
// Create filebrowser
filebrowser = new GUI::FileBrowser(window);
filebrowser->move(0, 0);
diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h
index 1085601..d78e480 100644
--- a/plugingui/plugingui.h
+++ b/plugingui/plugingui.h
@@ -36,6 +36,7 @@
#include "checkbox.h"
#include "button.h"
#include "knob.h"
+#include "progressbar.h"
#include "filebrowser.h"
@@ -82,6 +83,8 @@ public:
FileLineEdit *lineedit2;
GUI::LED *led2;
+ GUI::ProgressBar *progress;
+
void (*windowClosedHandler)(void *);
void *windowClosedPtr;
diff --git a/plugingui/progressbar.cc b/plugingui/progressbar.cc
new file mode 100644
index 0000000..d7048a4
--- /dev/null
+++ b/plugingui/progressbar.cc
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * progressbar.cc
+ *
+ * Fri Mar 22 22:07:57 CET 2013
+ * Copyright 2013 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 General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 "progressbar.h"
+
+#include "painter.h"
+
+GUI::ProgressBar::ProgressBar(GUI::Widget *parent) : GUI::Widget(parent)
+{
+ _progress = 0;
+}
+
+float GUI::ProgressBar::progress()
+{
+ return _progress;
+}
+
+void GUI::ProgressBar::setProgress(float progress)
+{
+ _progress = progress;
+ repaintEvent(NULL);
+}
+
+void GUI::ProgressBar::repaintEvent(GUI::RepaintEvent *e)
+{
+ Painter p(this);
+
+ int max = width() - 1;
+
+ p.clear();
+
+ p.setColour(Colour(0, 0, 1, 0.3));
+ p.drawFilledRectangle(1, 1, max * _progress - 2, height() - 1);
+
+ p.setColour(Colour(1));
+ p.drawRectangle(0,0,max,height()-1);
+}
+
+#ifdef TEST_PROGRESSBAR
+//Additional dependency files
+//deps:
+//Required cflags (autoconf vars may be used)
+//cflags:
+//Required link options (autoconf vars may be used)
+//libs:
+#include "test.h"
+
+TEST_BEGIN;
+
+// TODO: Put some testcode here (see test.h for usable macros).
+
+TEST_END;
+
+#endif/*TEST_PROGRESSBAR*/
diff --git a/plugingui/progressbar.h b/plugingui/progressbar.h
new file mode 100644
index 0000000..9ab4109
--- /dev/null
+++ b/plugingui/progressbar.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * progressbar.h
+ *
+ * Fri Mar 22 22:07:57 CET 2013
+ * Copyright 2013 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 General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ */
+#ifndef __DRUMGIZMO_PROGRESSBAR_H__
+#define __DRUMGIZMO_PROGRESSBAR_H__
+
+#include "widget.h"
+
+#include <string>
+
+#include "guievent.h"
+
+namespace GUI {
+
+class ProgressBar : public Widget {
+public:
+ ProgressBar(Widget *parent);
+
+ float progress();
+ void setProgress(float progress);
+
+ //protected:
+ virtual void repaintEvent(RepaintEvent *e);
+
+private:
+ float _progress;
+};
+
+};
+
+#endif/*__DRUMGIZMO_PROGRESSBAR_H__*/