From 256c76213d44c158577707a3ffd394bf0e94e65a Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 20:23:14 +0200 Subject: Added config parse. --- plugingui/Makefile.am | 1 + plugingui/Makefile.am.plugingui | 1 + plugingui/directory.cc | 40 +++++++--- plugingui/pluginconfig.cc | 165 ++++++++++++++++++++++++++++++++++++++++ plugingui/pluginconfig.h | 48 ++++++++++++ plugingui/plugingui.cc | 28 +++++++ plugingui/plugingui.h | 3 + 7 files changed, 275 insertions(+), 11 deletions(-) create mode 100644 plugingui/pluginconfig.cc create mode 100644 plugingui/pluginconfig.h diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index 3cf60a5..3d09bb2 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -46,6 +46,7 @@ EXTRA_DIST = \ nativewindow_x11.h \ painter.h \ pixelbuffer.h \ + pluginconfig.h \ plugingui.h \ progressbar.h \ resource.h \ diff --git a/plugingui/Makefile.am.plugingui b/plugingui/Makefile.am.plugingui index 0b4f2d2..f475db6 100644 --- a/plugingui/Makefile.am.plugingui +++ b/plugingui/Makefile.am.plugingui @@ -32,6 +32,7 @@ PLUGIN_GUI_SOURCES = \ $(top_srcdir)/plugingui/knob.cc \ $(top_srcdir)/plugingui/filebrowser.cc \ $(top_srcdir)/plugingui/directory.cc \ + $(top_srcdir)/plugingui/pluginconfig.cc \ $(top_srcdir)/plugingui/image.cc \ $(top_srcdir)/plugingui/combobox.cc \ $(top_srcdir)/plugingui/progressbar.cc \ diff --git a/plugingui/directory.cc b/plugingui/directory.cc index 9ebfe70..1465c86 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -34,9 +34,7 @@ #include #ifdef WIN32 -#ifdef __MINGW32__ #include -#endif #include #endif @@ -153,7 +151,7 @@ Directory::EntryList Directory::listFiles(std::string path, unsigned char filter if(Directory::isRoot(path) && name == "..") continue; unsigned char entryinfo = 0; - if(isHidden(name)) { + if(isHidden(path + SEP + name)) { entryinfo |= DIRECTORY_HIDDEN; } @@ -183,8 +181,8 @@ Directory::EntryList Directory::listFiles(std::string path, unsigned char filter #ifdef WIN32 - DEBUG(directory, "root is %s\n", Directory::root(path).c_str()); - DEBUG(directory, "current path %s is root? %d", path.c_str(), Directory::isRoot(path)); + DEBUG(directory, "Root is %s\n", Directory::root(path).c_str()); + DEBUG(directory, "Current path %s is root? %d", path.c_str(), Directory::isRoot(path)); if(Directory::isRoot(path)) entries.push_back(".."); #endif @@ -291,15 +289,15 @@ bool Directory::isDir() bool Directory::isDir(std::string path) { - DEBUG(directory, "Is '%s' dir?\n", path.c_str()); + DEBUG(directory, "Is '%s' a directory?\n", path.c_str()); struct stat st; if(stat(path.c_str(), &st) == 0) { if((st.st_mode & S_IFDIR) != 0) { - DEBUG(directory, "Yes\n"); + DEBUG(directory, "\t...yes!\n"); return true; } } - DEBUG(directory, "No\n"); + DEBUG(directory, "\t...no!\n"); return false; } @@ -320,19 +318,39 @@ bool Directory::exists(std::string path) bool Directory::isHidden(std::string path) { - // TODO: Handle hidden and system files in windows + DEBUG(directory, "Is '%s' hidden?\n", path.c_str()); #ifdef WIN32 - return false; -#else + // We dont want to filter out '..' pointing to root of a partition unsigned pos = path.find_last_of("/\\"); std::string entry = path.substr(pos+1); + if(entry == "..") { + return false; + } + DWORD fattribs = GetFileAttributes(path.c_str()); + if(fattribs & FILE_ATTRIBUTE_HIDDEN) { + DEBUG(directory, "\t...yes!\n"); + return true; + } + else if(fattribs & FILE_ATTRIBUTE_SYSTEM) { + DEBUG(directory, "\t...yes!\n"); + return true; + } + else { + DEBUG(directory, "\t...no!\n"); + return false; + } +#else + unsigned pos = path.find_last_of("/\\"); + std::string entry = path.substr(pos+1); if(entry.size() > 1 && entry.at(0) == '.' && entry.at(1) != '.') { + DEBUG(directory, "\t...yes!\n"); return true; } else { + DEBUG(directory, "\t...no!\n"); return false; } #endif diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc new file mode 100644 index 0000000..d57d9df --- /dev/null +++ b/plugingui/pluginconfig.cc @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * config.cc + * + * Tue Jun 3 13:54:05 CEST 2014 + * Copyright 2014 Jonas Suhr Christensen + * jsc@umbraculum.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 "pluginconfig.h" + +#include +#include +#include +#include + +#include "directory.h" + +#ifdef WIN32 +#include +#include +#include +#include +#else +#endif + +#include + +#define CONFIGFILENAME "plugingui.conf" + +#ifdef WIN32 + #define SEP "\\" + #define CONFIGDIRNAME ".drumgizmo" +#else + #define SEP "/" + #define CONFIGDIRNAME ".drumgizmo" +#endif + +Config::Config() +{ + +} + +Config::~Config() +{ + +} + +static std::string configPath() { + #ifdef WIN32 + std::string configpath; + TCHAR szPath[256]; + if(SUCCEEDED(SHGetFolderPath(NULL, + CSIDL_APPDATA | CSIDL_FLAG_CREATE, + NULL, + 0, + szPath))); { + configpath = szPath; + } +#else + std::string configpath = strdup(getenv("HOME")); +#endif + configpath += SEP; + configpath += CONFIGDIRNAME; + + return configpath; +} + +static bool createConfigPath() { + std::string configpath = configPath(); + + if(!Directory::exists(configpath)) { + DEBUG(pluginconfig, "No configuration exists, creating directory '%s'\n", configpath.c_str()); +#ifdef WIN32 + if( (mkdir(configpath.c_str())) < 0) { +#else + if( (mkdir(configpath.c_str(), 0755)) < 0) { +#endif + DEBUG(pluginconfig, "Could not create config directory\n"); + } + return false; + } + + return true; +} + +static FILE* openConfigFile(std::string mode) { + + std::string configpath = configPath(); + + FILE *fp; + std::string configfile = configpath; + configfile += SEP; + configfile += CONFIGFILENAME; + + DEBUG(pluginconfig, "Opening config file '%s'\n", configfile.c_str()); + if(! (fp = fopen(configfile.c_str(), mode.c_str())) ) { + return NULL; + } + + return fp; +} + +void Config::load() +{ + DEBUG(pluginconfig, "Loading config file...\n"); + FILE *fp = openConfigFile("r"); + if(!fp) return; + + lastkit.clear(); + lastmidimap.clear(); + + char buf[4096]; + while( fgets(buf, 4096, fp) ) { + if(!strncmp(buf, "lastkit:", 8)) { + DEBUG(pluginconfig, "Loading last kit path\n"); + // Dont copy newline + if(strlen(buf) > 8 + 1) { + lastkit.append(buf+8, strlen(buf+8) - 1); + DEBUG(pluginconfig, "\t path is %s\n", lastkit.c_str()); + } + } + if(!strncmp(buf, "lastmidimap:", 12)) { + DEBUG(pluginconfig, "Loading lastmidimap path\n"); + // Dont copy newline + if(strlen(buf) > 12+1) lastmidimap.append(buf+12, strlen(buf+12) - 1); + DEBUG(pluginconfig, "\t path is %s\n", lastmidimap.c_str()); + } + } +} + +void Config::save() +{ + DEBUG(pluginconfig, "Saving configuration...\n"); + + createConfigPath(); + + FILE *fp = openConfigFile("w"); + if(!fp) return; + + std::string buf; + buf.append("lastkit:" + lastkit + '\n'); + buf.append("lastmidimap:" + lastmidimap + '\n'); + + fputs(buf.c_str(), fp); + + fclose(fp); +} diff --git a/plugingui/pluginconfig.h b/plugingui/pluginconfig.h new file mode 100644 index 0000000..d0e9bcd --- /dev/null +++ b/plugingui/pluginconfig.h @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * config.h + * + * Tue Jun 3 13:51:29 CEST 2014 + * Copyright 2014 Jonas Suhr Christensen + * jsc@umbraculum.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_CONFIG_H__ +#define __DRUMGIZMO_CONFIG_H__ + +#include +#include + +#define DIRECTORY_HIDDEN 1 + +class Config { + + public: + Config(); + ~Config(); + + void load(); + void save(); + + std::string lastkit; + std::string lastmidimap; +}; + +#endif/*__DRUMGIZMO_CONFIG_H__*/ diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 6601be7..b235af3 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -33,6 +33,7 @@ #include "verticalline.h" #include "../version.h" +#include "pluginconfig.h" #include "messagehandler.h" static void checkClick(void *ptr) @@ -81,6 +82,12 @@ static void knobChange2(void *ptr) #endif } +//static void quit(void *ptr) { +// PluginGUI *gui = (PluginGUI*)ptr; +// +// gui->stopThread(); +//} + GUI::FileBrowser *fb; static void selectKitFile(void *ptr, std::string filename) { @@ -91,6 +98,8 @@ static void selectKitFile(void *ptr, std::string filename) std::string drumkit = gui->lineedit->text(); + gui->config->lastkit = drumkit; + gui->progress->setProgress(0); gui->progress->setState(GUI::ProgressBar::blue); @@ -105,6 +114,7 @@ static void kitBrowseClick(void *ptr) PluginGUI *gui = (PluginGUI*)ptr; std::string path = gui->lineedit->text(); + if(path == "") path = gui->config->lastkit; if(path == "") path = gui->lineedit2->text(); fb->setPath(path); @@ -121,6 +131,8 @@ static void selectMapFile(void *ptr, std::string filename) std::string midimap = gui->lineedit2->text(); + gui->config->lastmidimap = midimap; + LoadMidimapMessage *msg = new LoadMidimapMessage(); msg->midimapfile = midimap; msghandler.sendMessage(MSGRCV_ENGINE, msg); @@ -137,6 +149,7 @@ static void midimapBrowseClick(void *ptr) PluginGUI *gui = (PluginGUI*)ptr; std::string path = gui->lineedit2->text(); + if(path == "") path = gui->config->lastmidimap; if(path == "") path = gui->lineedit->text(); fb->setPath(path); @@ -268,6 +281,10 @@ void PluginGUI::thread_main() void PluginGUI::deinit() { + if(config) { + config->save(); + delete config; + } if(window) delete window; } @@ -280,6 +297,10 @@ void closeEventHandler(void *ptr) void PluginGUI::init() { DEBUG(gui, "init"); + + config = new Config(); + config->load(); + window = new GUI::Window(); window->eventHandler()->registerCloseHandler(closeEventHandler, (void*)&closing); @@ -428,6 +449,13 @@ void PluginGUI::init() filebrowser->hide(); fb = filebrowser; + // Enable quit button +// GUI::Button *btn_quit = new GUI::Button(window); +// btn_quit->setText("Quit"); +// btn_quit->move(50,280); +// btn_quit->resize(80,80); +// btn_quit->registerClickHandler(quit, this); + window->show(); sem.post(); diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h index 7ec5e77..f94a062 100644 --- a/plugingui/plugingui.h +++ b/plugingui/plugingui.h @@ -36,6 +36,7 @@ #include "button.h" #include "knob.h" #include "progressbar.h" +#include "pluginconfig.h" #include "filebrowser.h" @@ -80,6 +81,8 @@ public: GUI::LineEdit *lineedit2; GUI::ProgressBar *progress2; + Config *config; + void (*windowClosedHandler)(void *); void *windowClosedPtr; -- cgit v1.2.3 From 1856dc57704c127901839714da46cb73603fe3f8 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 20:25:01 +0200 Subject: Removed pugl related code. --- plugingui/Makefile.am.plugingui | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugingui/Makefile.am.plugingui b/plugingui/Makefile.am.plugingui index f475db6..b1698e4 100644 --- a/plugingui/Makefile.am.plugingui +++ b/plugingui/Makefile.am.plugingui @@ -1,9 +1,5 @@ -if ENABLE_PUGL -puglsources = $(top_srcdir)/pugl/pugl/pugl_x11.c $(top_srcdir)/plugingui/nativewindow_pugl.cc -else puglsources = -endif PLUGIN_GUI_SOURCES = \ $(top_srcdir)/hugin/hugin.c \ -- cgit v1.2.3 From e1aeab0b62474e8a291237f82b151448dd39c577 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 20:35:09 +0200 Subject: Added pluginconfig.cc to resource. --- plugingui/Makefile.mingw32 | 1 + 1 file changed, 1 insertion(+) diff --git a/plugingui/Makefile.mingw32 b/plugingui/Makefile.mingw32 index 3a9542a..b16535b 100644 --- a/plugingui/Makefile.mingw32 +++ b/plugingui/Makefile.mingw32 @@ -13,6 +13,7 @@ CXX_SOURCES = \ $(top_srcdir)/plugingui/nativewindow_x11.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/eventhandler.cc \ $(top_srcdir)/plugingui/font.cc \ -- cgit v1.2.3 From 03174415207996a70cab47f6d2eab6ffc182a24f Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 20:43:54 +0200 Subject: Testing branch. --- plugingui/lineedit.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugingui/lineedit.cc b/plugingui/lineedit.cc index d6e717a..9c14ab6 100644 --- a/plugingui/lineedit.cc +++ b/plugingui/lineedit.cc @@ -175,6 +175,8 @@ void GUI::LineEdit::repaintEvent(GUI::RepaintEvent *e) p.drawLine(px + BORDER - 1 - 4 + 3, 6, px + BORDER - 1 - 4 + 3, height() - 7); } + + DEBUG(lineedit, "Weeeh!\n"); } #ifdef TEST_LINEEDIT -- cgit v1.2.3 From 5b4b2178dfdc7c91a59c3bc5c60e61e48aae0492 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 20:52:44 +0200 Subject: Saving lastkit and lastmidimap instantly when file is selected from filebrowser. --- plugingui/plugingui.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index b235af3..f345660 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -94,11 +94,13 @@ static void selectKitFile(void *ptr, std::string filename) PluginGUI *gui = (PluginGUI*)ptr; gui->lineedit->setText(filename); + fb->hide(); std::string drumkit = gui->lineedit->text(); gui->config->lastkit = drumkit; + gui->config->save(); gui->progress->setProgress(0); gui->progress->setState(GUI::ProgressBar::blue); @@ -132,6 +134,7 @@ static void selectMapFile(void *ptr, std::string filename) std::string midimap = gui->lineedit2->text(); gui->config->lastmidimap = midimap; + gui->config->save(); LoadMidimapMessage *msg = new LoadMidimapMessage(); msg->midimapfile = midimap; @@ -334,7 +337,8 @@ void PluginGUI::init() lineedit = new GUI::LineEdit(window); lineedit->move(XOFFSET, y); lineedit->resize(243, 29); - + lineedit->setReadOnly(true); + GUI::Button *btn_brw = new GUI::Button(window); btn_brw->setText("Browse..."); btn_brw->move(266, y - 6 + 4); @@ -364,7 +368,8 @@ void PluginGUI::init() lineedit2 = new GUI::LineEdit(window); lineedit2->move(XOFFSET, y); lineedit2->resize(243, 29); - + lineedit2->setReadOnly(true); + GUI::Button *btn_brw = new GUI::Button(window); btn_brw->setText("Browse..."); btn_brw->move(266, y - 6 + 4); -- cgit v1.2.3 From 34e995deca7545e43920e6105b3ce2ab2d6d5dae Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 23 Sep 2014 21:03:07 +0200 Subject: Added missing source to to makefile. --- vst/Makefile.mingw32.in | 1 + 1 file changed, 1 insertion(+) diff --git a/vst/Makefile.mingw32.in b/vst/Makefile.mingw32.in index 76154f9..f8aab4d 100644 --- a/vst/Makefile.mingw32.in +++ b/vst/Makefile.mingw32.in @@ -39,6 +39,7 @@ GUI_SRC = \ @top_srcdir@/plugingui/nativewindow_x11.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/eventhandler.cc \ @top_srcdir@/plugingui/font.cc \ -- cgit v1.2.3 From a5873ae2b89d7ac8fc650a0f75778f8dad07a102 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Tue, 30 Sep 2014 11:49:37 +0200 Subject: Following marker. --- plugingui/lineedit.cc | 75 +++++++++++++++++++++++++++++++++++++++++++-------- plugingui/lineedit.h | 9 +++++++ 2 files changed, 73 insertions(+), 11 deletions(-) diff --git a/plugingui/lineedit.cc b/plugingui/lineedit.cc index 9c14ab6..46354bb 100644 --- a/plugingui/lineedit.cc +++ b/plugingui/lineedit.cc @@ -30,6 +30,8 @@ #include "window.h" +#include + #include #define BORDER 10 @@ -38,6 +40,7 @@ GUI::LineEdit::LineEdit(Widget *parent) : GUI::Widget(parent) { pos = 0; + offsetpos = 0; setReadOnly(false); box.topLeft = new Image(":widget_tl.png"); @@ -72,7 +75,8 @@ bool GUI::LineEdit::readOnly() void GUI::LineEdit::setText(std::string text) { _text = text; - if(_text.size() < pos) pos = text.size(); + pos = text.size(); +// if(_text.size() < pos) pos = text.size(); repaintEvent(NULL); textChanged(); @@ -87,14 +91,16 @@ void GUI::LineEdit::buttonEvent(ButtonEvent *e) { if(readOnly()) return; + if(e->direction == 1) { - for(int i = 0; i < (int)_text.length(); i++) { - if(e->x < (int)(font.textWidth(_text.substr(0, i)) + BORDER)) { - pos = i; + for(int i = 0; i < (int)_visibletext.length(); i++) { + if(e->x < (int)(font.textWidth(_visibletext.substr(0, i)) + BORDER)) { + printf("i, Offset: %d, %d\n", i, offsetpos); + pos = i + offsetpos; break; } } - if(e->x >= (int)(font.textWidth(_text) + BORDER)) pos = _text.length(); +// if(e->x >= (int)(font.textWidth(_visibletext) + BORDER)) pos = _visibletext.length(); repaintEvent(NULL); } } @@ -111,7 +117,9 @@ void GUI::LineEdit::keyEvent(GUI::KeyEvent *e) if(e->keycode == GUI::KeyEvent::KEY_LEFT) { if(pos) pos--; - + if(offsetpos >= pos) walkstate = WALK_LEFT; +// else walkstate = NOOP; + } else if(e->keycode == GUI::KeyEvent::KEY_HOME) { pos = 0; @@ -120,7 +128,9 @@ void GUI::LineEdit::keyEvent(GUI::KeyEvent *e) } else if(e->keycode == GUI::KeyEvent::KEY_RIGHT) { if(pos < _text.length()) pos++; - + if(offsetpos + _visibletext.length() <= pos) walkstate = WALK_RIGHT; +// else walkstate = NOOP; + } else if(e->keycode == GUI::KeyEvent::KEY_DELETE) { if(pos < _text.length()) { std::string t = _text.substr(0, pos); @@ -144,6 +154,7 @@ void GUI::LineEdit::keyEvent(GUI::KeyEvent *e) _text = pre + e->text + post; change = true; pos++; + } else if(e->keycode == GUI::KeyEvent::KEY_ENTER) { if(handler) handler(ptr); } @@ -165,18 +176,60 @@ void GUI::LineEdit::repaintEvent(GUI::RepaintEvent *e) p.drawBox(0, 0, &box, w, h); p.setColour(GUI::Colour(183.0/255.0, 219.0/255.0 , 255.0/255.0, 1)); - p.drawText(BORDER - 4 + 3, height()/2+5 + 1 + 1 + 1, font, _text); + + if(walkstate == WALK_LEFT) { + _visibletext = _text.substr(pos, std::string::npos); + offsetpos = pos; + } + else if(walkstate == WALK_RIGHT) { + int d = (offsetpos < _text.length()) ? 1 : 0; + _visibletext = _text.substr(offsetpos + d); + offsetpos = offsetpos + d; + } + else { + _visibletext = _text; + offsetpos = 0; + } + while(true) { + int textwidth = font.textWidth(_visibletext); + if(textwidth > w - BORDER - 4 + 3) { + if(walkstate == WALK_LEFT) { + _visibletext = _visibletext.substr(0, _visibletext.length()-1); + } + else if(walkstate == WALK_RIGHT) { + _visibletext = _visibletext.substr(0, _visibletext.length()-1); + } + else { + if(offsetpos < pos) { + _visibletext = _visibletext.substr(1); + offsetpos++; + } + else { + _visibletext = _visibletext.substr(0, _visibletext.length() - 1); + } + } + } + else { + DEBUG(lienedit, "Full text: '%s'\n", _text.c_str()); + DEBUG(lineedit, "Drawing text in lineedit '%s'\n", _visibletext.c_str()); + DEBUG(lineedit, "Offset, pos: %d, %d\n", offsetpos, pos); + break; + } + } + + walkstate = NOOP; + + p.drawText(BORDER - 4 + 3, height()/2+5 + 1 + 1 + 1, font, _visibletext); if(readOnly()) return; if(hasKeyboardFocus()) { - size_t px = font.textWidth(_text.substr(0, pos)); +// size_t px = font.textWidth(_text.substr(0, pos - offsetpos)); + size_t px = font.textWidth(_visibletext.substr(0, pos - offsetpos)); //p.setColour(Colour(0.8)); p.drawLine(px + BORDER - 1 - 4 + 3, 6, px + BORDER - 1 - 4 + 3, height() - 7); } - - DEBUG(lineedit, "Weeeh!\n"); } #ifdef TEST_LINEEDIT diff --git a/plugingui/lineedit.h b/plugingui/lineedit.h index 2c37522..f85e9bd 100644 --- a/plugingui/lineedit.h +++ b/plugingui/lineedit.h @@ -65,6 +65,15 @@ private: std::string _text; size_t pos; + std::string _visibletext; + size_t offsetpos; + + enum state_t { + NOOP = 0, + WALK_LEFT = 1, + WALK_RIGHT = 2 + }; + state_t walkstate; bool readonly; -- cgit v1.2.3 From 3e819cf15ed4e495bd616abdd721521656f56211 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 4 Oct 2014 13:04:25 +0200 Subject: Fix hugin submodule check. --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index c027031..c0b9008 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,7 @@ #!/bin/sh -e # Check if hugin has been obtained: -if [ ! -d hugin ] +if [ ! -f hugin/hugin.c ] then echo "You are missing the hugin submodule." echo "Run" -- cgit v1.2.3 From c7af1c332447e5fb25f37d4738458a5d7106a6fc Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 4 Oct 2014 17:45:54 +0200 Subject: Fix crash bug. --- src/drumgizmo.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 1abbb10..0337fae 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -333,6 +333,7 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz) if(evt->offset > (size_t)pos) n = evt->offset - pos; size_t end = sz; if(evt->t + end - n > af->size) end = af->size - evt->t + n; + if(end > sz) end = sz; if(evt->rampdown == NO_RAMPDOWN) { #ifdef SSE -- cgit v1.2.3