New upstream version 0.14.1~dfsg1
authorJaromír Mikeš <mira.mikes@seznam.cz>
Sun, 23 Jul 2017 22:52:26 +0000 (00:52 +0200)
committerJaromír Mikeš <mira.mikes@seznam.cz>
Sun, 23 Jul 2017 22:52:26 +0000 (00:52 +0200)
70 files changed:
ChangeLog
Makefile.am
configure.ac
src/core/conf.cpp
src/core/const.h
src/core/init.cpp
src/core/mixer.cpp
src/core/mixer.h
src/core/pluginHost.cpp
src/core/waveFx.cpp
src/glue/channel.cpp
src/glue/channel.h
src/glue/main.cpp
src/glue/sampleEditor.cpp [new file with mode: 0644]
src/glue/sampleEditor.h [new file with mode: 0644]
src/gui/dialogs/browser/browserBase.cpp
src/gui/dialogs/gd_config.cpp
src/gui/dialogs/gd_mainWindow.cpp
src/gui/dialogs/gd_pluginList.cpp
src/gui/dialogs/gd_pluginWindowGUI.cpp
src/gui/dialogs/gd_warnings.cpp
src/gui/dialogs/sampleEditor.cpp
src/gui/elems/actionEditor/action.cpp
src/gui/elems/actionEditor/actionEditor.cpp
src/gui/elems/actionEditor/baseActionEditor.cpp
src/gui/elems/actionEditor/envelopeEditor.cpp
src/gui/elems/actionEditor/muteEditor.cpp
src/gui/elems/actionEditor/noteEditor.cpp
src/gui/elems/actionEditor/pianoItem.cpp
src/gui/elems/actionEditor/pianoItemOrphaned.cpp
src/gui/elems/actionEditor/pianoItemOrphaned.h
src/gui/elems/actionEditor/pianoRoll.cpp
src/gui/elems/basics/box.cpp
src/gui/elems/basics/boxtypes.cpp
src/gui/elems/basics/button.cpp
src/gui/elems/basics/check.cpp
src/gui/elems/basics/choice.cpp
src/gui/elems/basics/dial.cpp
src/gui/elems/basics/input.cpp
src/gui/elems/basics/liquidScroll.cpp
src/gui/elems/basics/progress.cpp
src/gui/elems/basics/radio.cpp
src/gui/elems/basics/scroll.cpp
src/gui/elems/basics/slider.cpp
src/gui/elems/basics/statusButton.cpp
src/gui/elems/browser.cpp
src/gui/elems/config/tabAudio.cpp
src/gui/elems/config/tabBehaviors.cpp
src/gui/elems/config/tabMidi.cpp
src/gui/elems/config/tabMisc.cpp
src/gui/elems/config/tabPlugins.cpp
src/gui/elems/mainWindow/beatMeter.cpp
src/gui/elems/mainWindow/keyboard/channelButton.cpp
src/gui/elems/mainWindow/keyboard/channelMode.cpp
src/gui/elems/mainWindow/keyboard/channelStatus.cpp
src/gui/elems/mainWindow/keyboard/column.cpp
src/gui/elems/mainWindow/keyboard/keyboard.cpp
src/gui/elems/mainWindow/keyboard/midiChannel.cpp
src/gui/elems/mainWindow/keyboard/sampleChannel.cpp
src/gui/elems/mainWindow/mainMenu.cpp
src/gui/elems/pluginBrowser.cpp
src/gui/elems/sampleEditor/rangeTool.cpp
src/gui/elems/sampleEditor/waveTools.cpp
src/gui/elems/sampleEditor/waveTools.h
src/gui/elems/sampleEditor/waveform.cpp
src/gui/elems/sampleEditor/waveform.h
src/gui/elems/soundMeter.cpp
src/main.cpp
src/utils/fs.cpp
src/utils/gui.cpp

index 4cd4cf1c4ce5938229d76e974be2d87b743bff0f..d2e15953690ff4ed3417d823d1a08f3228539a1c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 --------------------------------------------------------------------------------
 
 
+0.14.1 --- 2017 . 07 . 16
+- Update JUCE library to 5.0.2
+- Show play head in Sample Editor
+- Refactor pop up menu in Sample Editor
+- Many small fixes and optimizations in waveform drawing routine
+- Makefile cleanup
+- Fix crash while recording with beats/bars greater than 4/1 (GitHub #134)
+
+
 0.14.0 --- 2017 . 05 . 29
 - Sample Editor reorganized and refactored 
 - Removed support for old ini-based patch files
index 91c8b70c03bf0541673d596f75a044620f4a14be..0c0e2da5154270867fe953388d43c862507a1871 100644 (file)
@@ -59,6 +59,8 @@ src/glue/transport.h                   \
 src/glue/transport.cpp                 \
 src/glue/recorder.h                    \
 src/glue/recorder.cpp                  \
+src/glue/sampleEditor.h                \
+src/glue/sampleEditor.cpp              \
 src/gui/dialogs/window.h                                \
 src/gui/dialogs/window.cpp             \
 src/gui/dialogs/gd_keyGrabber.h        \
@@ -251,7 +253,6 @@ endif
 # via AM_CONDITIONAL inside configure.ac.
 # Note: CPPFLAGS = C preprocessor flags, CXXFLAGS = C++ compiler flags.
 
-# TODO add -DNDEBUG for production code
 giada_CXXFLAGS = -std=c++11 -Wall -Werror
 giada_CPPFLAGS =
 
@@ -272,14 +273,15 @@ giada_CPPFLAGS +=                          \
   -DJUCE_STANDALONE_APPLICATION=1          \
   -DJUCE_PLUGINHOST_VST=1                  \
   -DJUCE_PLUGINHOST_VST3=0                 \
-  -DJUCE_PLUGINHOST_AU=0
+  -DJUCE_PLUGINHOST_AU=0                   \
+  -DJUCE_WEB_BROWSER=0 
 endif
 
 if LINUX
 giada_SOURCES += src/deps/rtaudio-mod/RtAudio.h src/deps/rtaudio-mod/RtAudio.cpp
-# -Wno-error=vla: mute rtAudio error on variable length array
-# -Wno-error=misleading-indentation: mute JUCE warnings on GCC6
-giada_CXXFLAGS += -Wno-error=vla -Wno-error=misleading-indentation
+# -Wno-error=misleading-indentation: don't stop on JUCE warnings on GCC6
+# -Wno-error=unused-function: don't stop on JUCE's unused functions
+giada_CXXFLAGS += -Wno-error=misleading-indentation -Wno-error=unused-function
 giada_CPPFLAGS += -D__LINUX_ALSA__ -D__LINUX_PULSE__ -D__UNIX_JACK__
 giada_LDADD = -lsndfile -lfltk -lXext -lX11 -lXft -lXpm -lm -ljack -lasound \
   -lpthread -ldl -lpulse-simple -lpulse -lsamplerate -lrtmidi -ljansson \
@@ -298,11 +300,7 @@ src/deps/rtaudio-mod/include/asiodrivers.h            \
 src/deps/rtaudio-mod/include/asiodrivers.cpp          \
 src/deps/rtaudio-mod/include/iasiothiscallresolver.h  \
 src/deps/rtaudio-mod/include/iasiothiscallresolver.cpp
-# -Wno-error=misleading-indentation: mute JUCE warnings on GCC6
-# -Wno-error=unused-but-set-variable: silence ASIO errors
-giada_CXXFLAGS +=                  \
--Wno-error=misleading-indentation  \
--Wno-error=unused-but-set-variable
+giada_CXXFLAGS += -Wno-error
 giada_CPPFLAGS +=                \
 -I./src/deps/rtaudio-mod/include \
 -D__WINDOWS_ASIO__               \
@@ -317,13 +315,9 @@ giada_SOURCES += resource.rc
 endif
 
 if OSX
-# for 32 bit compilation:
-# export CXXFLAGS="-m32"
-# export LDFLAGS="-m32"
-# -ObjC++: Juce requires to build some Objective C code
-# -Wno-unknown-pragmas: shut up Juce even more
 giada_SOURCES += src/utils/cocoa.mm src/utils/cocoa.h
-giada_CXXFLAGS += -ObjC++ -Wno-unknown-pragmas -Wno-auto-var-id
+# -ObjC++: Juce requires to build some Objective C code
+giada_CXXFLAGS += -ObjC++ -Wno-auto-var-id
 giada_LDADD = -lsndfile -lm -lpthread -lfltk -lrtmidi -lrtaudio \
        -lsamplerate -ljansson
 giada_LDFLAGS = -framework CoreAudio -framework Cocoa -framework Carbon \
@@ -388,7 +382,8 @@ giada_tests_CPPFLAGS =                     \
   -DJUCE_STANDALONE_APPLICATION=1          \
   -DJUCE_PLUGINHOST_VST=1                  \
   -DJUCE_PLUGINHOST_VST3=0                 \
-  -DJUCE_PLUGINHOST_AU=0
+  -DJUCE_PLUGINHOST_AU=0                   \
+  -DJUCE_WEB_BROWSER=0 
 endif
 
 # make rename ------------------------------------------------------------------
index 1833327e6e36740a04aa36cb951a6eff05f93693..c518a2cc4b50ca48cc2c0c11e14056abfd992358 100644 (file)
@@ -4,7 +4,7 @@
 # prereq & init
 
 AC_PREREQ(2.60)
-AC_INIT([giada], [0.13], [giadaloopmachine@gmail.com])
+AC_INIT([giada], [0.14], [giadaloopmachine@gmail.com])
 AC_CONFIG_SRCDIR([src/main.cpp])
 AM_INIT_AUTOMAKE([subdir-objects])
 
index 01e777a73b53377f0f562fa8fb4ffd8201206710..8cfe0f9d2108e2c5d26eb2e93dd0bebefb059e37 100644 (file)
@@ -189,8 +189,8 @@ string samplePath = "";
 
 int mainWindowX = 0;
 int mainWindowY = 0;
-int mainWindowW = GUI_WIDTH;
-int mainWindowH = GUI_HEIGHT;
+int mainWindowW = G_GUI_WIDTH;
+int mainWindowH = G_GUI_HEIGHT;
 
 int browserX         = 0;
 int browserY         = 0;
index 8365854fdb297e6753f09d91e4cee292bdea7ed8..63c6a53c64f92b795c6156886063308575b1cc21 100644 (file)
 #define G_CONST_H
 
 
+/* -- environment ----------------------------------------------------------- */
+#if defined(_WIN32)
+       #define G_OS_WINDOWS
+#elif defined(__APPLE__)
+       #define G_OS_MAC
+#elif defined(__linux__)
+       #define G_OS_LINUX
+#endif
+
+#ifndef BUILD_DATE
+       #define BUILD_DATE __DATE__
+#endif
+
+
+
 /* -- version --------------------------------------------------------------- */
 #define G_APP_NAME      "Giada"
-#define G_VERSION_STR   "0.14.0"
+#define G_VERSION_STR   "0.14.1"
 #define G_VERSION_MAJOR 0
 #define G_VERSION_MINOR 14
-#define G_VERSION_PATCH 0
+#define G_VERSION_PATCH 1
 
 #define CONF_FILENAME "giada.conf"
 
-#ifndef BUILD_DATE
-       #define BUILD_DATE __DATE__
-#endif
-
-#ifdef _WIN32
+#ifdef G_OS_WINDOWS
        #define G_SLASH '\\'
        #define G_SLASH_STR "\\"
 #else
 
 
 /* -- GUI ------------------------------------------------------------------- */
-#ifdef _WIN32
-       #define GUI_SLEEP                       1000/24
+#ifdef G_OS_WINDOWS
+       #define G_GUI_SLEEP                     1000/24
 #else
-       #define GUI_SLEEP                       1000000/24 // == 1.000.000 / 24 == 1/24 sec == 24 Hz
+       #define G_GUI_SLEEP                     1000000/24 // == 1.000.000 / 24 == 1/24 sec == 24 Hz
 #endif
-#define GUI_WIDTH                                 816
-#define GUI_HEIGHT                        510
-#define GUI_PLUGIN_RATE    0.05  // refresh rate for plugin GUIs
-#define GUI_FONT_SIZE_BASE 12
-
-#define COLOR_BD_0     fl_rgb_color(78,  78,  78)                      // border off - TODO duplicate!
-#define COLOR_BD_1     fl_rgb_color(188, 188, 188)    // border on
-#define COLOR_BG_0     fl_rgb_color(37,  37,  37)     // bg off
-#define COLOR_BG_1     fl_rgb_color(78,  78,  78)     // bg on (clicked) - TODO duplicate!
-#define COLOR_BG_2     fl_rgb_color(177, 142, 142)    // bg active (play, for some widgets)
-#define COLOR_BG_3     fl_rgb_color(28,  32,  80)     // bg input rec
-#define COLOR_BG_4     fl_rgb_color(113, 31,  31)     // bg action rec
-#define COLOR_ALERT    fl_rgb_color(239, 75,  53)     // peak meter alert
-#define COLOR_TEXT_0   fl_rgb_color(200, 200, 200)
-#define COLOR_TEXT_1   fl_rgb_color(25,  25,  25)      // TODO duplicate!
-#define COLOR_BG_MAIN  fl_rgb_color(25,  25,  25)                 // windows background - TODO duplicate!
-#define COLOR_BG_RICH  fl_rgb_color(30,  30,  30)                 // lighter background
-#define COLOR_BG_LINE  fl_rgb_color(54,  54,  54)                 // lighter, for bg lines
-#define COLOR_BG_DARK  fl_rgb_color(0,   0,   0)                  // inputs background
+#define G_GUI_WIDTH                               816
+#define G_GUI_HEIGHT                      510
+#define G_GUI_PLUGIN_RATE    0.05  // refresh rate for plugin GUIs
+#define G_GUI_FONT_SIZE_BASE 12
+
+#define G_COLOR_RED       fl_rgb_color(28,  32,  80)
+#define G_COLOR_BLUE      fl_rgb_color(113, 31,  31)
+#define G_COLOR_RED_ALERT fl_rgb_color(239, 75,  53)
+
+#define G_COLOR_LIGHT_2 fl_rgb_color(200, 200, 200)
+#define G_COLOR_LIGHT_1 fl_rgb_color(170, 170, 170)
+#define G_COLOR_GREY_4  fl_rgb_color(78,  78,  78)
+#define G_COLOR_GREY_3  fl_rgb_color(54,  54,  54)
+#define G_COLOR_GREY_2  fl_rgb_color(37,  37,  37)
+#define G_COLOR_GREY_1  fl_rgb_color(25,  25,  25)
+#define G_COLOR_BLACK   fl_rgb_color(0,   0,   0)
 
 
 
@@ -86,7 +94,7 @@
 #define G_MAX_BARS                               32
 #define G_MAX_QUANTIZE      8
 #define G_MAX_PATCHNAME_LEN    32
-#define G_DB_MIN_SCALE      60.0f
+#define G_MIN_DB_SCALE      60.0f
 #define G_MIN_COLUMN_WIDTH  140
 #define G_MAX_BOOST_DB      20.0f
 #define G_MAX_PITCH         4.0f
 
 
 /* -- default system -------------------------------------------------------- */
-#if defined(__linux__)
+#if defined(G_OS_LINUX)
        #define G_DEFAULT_SOUNDSYS      G_SYS_API_NONE
-#elif defined(_WIN32)
+#elif defined(G_OS_WINDOWS)
        #define G_DEFAULT_SOUNDSYS      G_SYS_API_DS
-#elif defined(__APPLE__)
+#elif defined(G_OS_MAC)
        #define G_DEFAULT_SOUNDSYS      G_SYS_API_CORE
 #endif
 
index 681fb82cfa86c53e4d95c83f925fd3eee54fbe70..db18cbcaa9223aaad69afebe72e9eafe94e347e3 100644 (file)
@@ -131,7 +131,7 @@ void init_prepareMidiMap()
 
 void init_startGUI(int argc, char **argv)
 {
-       G_MainWin = new gdMainWindow(GUI_WIDTH, GUI_HEIGHT, "", argc, argv);
+       G_MainWin = new gdMainWindow(G_GUI_WIDTH, G_GUI_HEIGHT, "", argc, argv);
        G_MainWin->resize(conf::mainWindowX, conf::mainWindowY, conf::mainWindowW,
     conf::mainWindowH);
 
index 1f5f6612880c283958b866bd35ed0b2a5f106451..f3ce5b446bcf7ba5b404e591c0edb42054373c69 100644 (file)
@@ -399,12 +399,11 @@ pthread_mutex_t mutex_plugins;
 
 void init(int framesInSeq, int audioBufferSize)
 {
-       /* Allocate virtual input channels. vChanInput relies on clock::totalFrames:
-  it has variable size. */
+       /* Allocate virtual input channels. vChanInput has variable size: it depends
+       on how many frames there are in sequencer. */
+
+  allocVirtualInput(framesInSeq);
 
-  if (vChanInput != nullptr)
-       free(vChanInput);
-  vChanInput = (float*) malloc(framesInSeq * sizeof(float));
   if (vChanInToOut != nullptr)
     free(vChanInToOut);
        vChanInToOut = (float*) malloc(audioBufferSize * 2 * sizeof(float));
@@ -420,6 +419,19 @@ void init(int framesInSeq, int audioBufferSize)
 /* -------------------------------------------------------------------------- */
 
 
+void allocVirtualInput(int frames)
+{
+       if (vChanInput != nullptr)
+               free(vChanInput);
+       vChanInput = (float*) malloc(frames * sizeof(float));
+       if (!vChanInput)
+               gu_log("[Mixer] vChanInput realloc error!\n");  
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
 int masterPlay(void *_outBuf, void *_inBuf, unsigned bufferSize,
        double streamTime, RtAudioStreamStatus status, void *userData)
 {
index 6433ecce72b684b326717b3e763e805bed2acb7d..e1709dc364caba50f3fe47dd7b95d3279eb80aa0 100644 (file)
@@ -42,7 +42,14 @@ namespace m {
 namespace mixer
 {
 void init(int framesInSeq, int audioBufferSize);
-int  close();
+
+/* allocVirtualInput
+Allocates new memory for the virtual input channel. Call this whenever you 
+shrink or resize the sequencer. */
+
+void allocVirtualInput(int frames);
+
+int close();
 
 /* masterPlay
  * core method (callback) */
index ae916f8842d7376f59d25f94c7d6718fe00f6f28..188d41a303f19fd298c1089ce7f627ce3dfc2700 100644 (file)
@@ -302,12 +302,6 @@ pluginHost::PluginInfo getAvailablePluginInfo(int i)
   pi.manufacturerName = pd->manufacturerName.toStdString();
   pi.format = pd->pluginFormatName.toStdString();
   pi.isInstrument = pd->isInstrument;
-/*
-  if (!p) {
-    gu_log("[pluginHost::getAvailablePlugin] unable to create plugin instance!\n");
-    return nullptr;
-  }
-  */
   return pi;
 }
 
index 6358c25419d03b06e3956e0507ac1af4ac7f771e..d31bead32c2fee5af645b9ef62410c25ee6d54e3 100644 (file)
@@ -124,7 +124,8 @@ int wfx_cut(Wave *w, int a, int b)
                return 0;
        }
 
-       gu_log("[wfx] cutting from %d to %d, new size=%d (video=%d)\n", a, b, newSize, newSize/2);
+       gu_log("[wfx] cutting from %d to %d, new size=%d (video=%d)\n", 
+               a, b, newSize, newSize/2);
 
        for (int i=0, k=0; i<w->size; i++) {
                if (i < a || i >= b) {                         // left margin always included, in order to keep
index 742b77f872345b6c6ca1d6caffbd94cb58c1964f..eec216b920b57e0b0d08258e66c25afb808bfa7e 100644 (file)
@@ -363,22 +363,6 @@ void glue_setSoloOff(Channel *ch, bool gui)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_setBeginEndChannel(SampleChannel *ch, int b, int e)
-{
-       ch->setBegin(b);
-       ch->setEnd(e);
-       gdSampleEditor *gdEditor = static_cast<gdSampleEditor*>(gu_getSubwindow(G_MainWin, WID_SAMPLE_EDITOR));
-       if (gdEditor) {
-               Fl::lock();
-               gdEditor->rangeTool->refresh();
-               Fl::unlock();
-       }       
-}
-
-
-/* -------------------------------------------------------------------------- */
-
-
 void glue_setBoost(SampleChannel *ch, float val)
 {
        ch->setBoost(val);
index fe5ca350cfee63647eef22c02c6e52127e648712..b3ac92948da251eb33b021570a15811228bdf41b 100644 (file)
@@ -80,13 +80,6 @@ void glue_setPitch(SampleChannel *ch, float val);
 /* TODO move to glue_sampleEditor */
 void glue_setPanning(SampleChannel *ch, float val);
 
-/* setBeginEndChannel
- * sets start/end points in the sample editor. Recalc=false: don't recalc
- * internal position. check=true: check the points' consistency */
-
-/* TODO move to glue_sampleEditor */
-void glue_setBeginEndChannel(SampleChannel *ch, int b, int e);
-
 /* TODO move to glue_sampleEditor */
 void glue_setBoost(SampleChannel *ch, float val);
 
index f3bd26b2c372c89a00f65f0abd7470e7530d8db9..3abaa5861efdc06dd27138d5551da77fc53cf5c5 100644 (file)
@@ -122,6 +122,7 @@ void glue_setBeats(int beats, int bars, bool expand)
        clock::setBeats(beats);
        clock::setBars(bars);
        clock::updateFrameBars();
+       mixer::allocVirtualInput(clock::getTotalFrames());
 
        /* Update recorded actions, if 'expand' required and an expansion is taking
   place. */
diff --git a/src/glue/sampleEditor.cpp b/src/glue/sampleEditor.cpp
new file mode 100644 (file)
index 0000000..fbbb7ef
--- /dev/null
@@ -0,0 +1,156 @@
+/* -----------------------------------------------------------------------------
+ *
+ * Giada - Your Hardcore Loopmachine
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Copyright (C) 2010-2017 Giovanni A. Zuliani | Monocasual
+ *
+ * This file is part of Giada - Your Hardcore Loopmachine.
+ *
+ * Giada - Your Hardcore Loopmachine 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 3 of the License, or (at your option) any later version.
+ *
+ * Giada - Your Hardcore Loopmachine 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 Giada - Your Hardcore Loopmachine. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * -------------------------------------------------------------------------- */
+
+
+#include <cassert>
+#include <FL/Fl.H>
+#include "../gui/dialogs/gd_mainWindow.h"
+#include "../gui/dialogs/sampleEditor.h"
+#include "../gui/dialogs/gd_warnings.h"
+#include "../gui/elems/sampleEditor/waveTools.h"
+#include "../gui/elems/sampleEditor/volumeTool.h"
+#include "../gui/elems/sampleEditor/boostTool.h"
+#include "../gui/elems/sampleEditor/panTool.h"
+#include "../gui/elems/sampleEditor/pitchTool.h"
+#include "../gui/elems/sampleEditor/rangeTool.h"
+#include "../gui/elems/sampleEditor/waveform.h"
+#include "../core/sampleChannel.h"
+#include "../core/waveFx.h"
+#include "../core/const.h"
+#include "../utils/gui.h"
+#include "channel.h"
+#include "sampleEditor.h"
+
+
+extern gdMainWindow *G_MainWin;
+
+
+using namespace giada::m;
+
+
+namespace giada {
+namespace c     {
+namespace sampleEditor
+{
+gdSampleEditor* getSampleEditorWindow()
+{
+       gdSampleEditor* se = static_cast<gdSampleEditor*>(gu_getSubwindow(G_MainWin, WID_SAMPLE_EDITOR));
+       assert(se != nullptr);
+       return se;
+}
+
+/* -------------------------------------------------------------------------- */
+
+
+void setBeginEndChannel(SampleChannel* ch, int b, int e)
+{
+       ch->setBegin(b);
+       ch->setEnd(e);
+       gdSampleEditor* gdEditor = getSampleEditorWindow();
+       Fl::lock();
+       gdEditor->rangeTool->refresh();
+       Fl::unlock();
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void cut(SampleChannel* ch, int a, int b)
+{
+       if (!wfx_cut(ch->wave, a, b)) {
+               gdAlert("Unable to cut the sample!");
+               return;
+       }
+       setBeginEndChannel(ch, ch->begin, ch->end);
+       gdSampleEditor* gdEditor = getSampleEditorWindow();
+  gdEditor->waveTools->waveform->clearSel();
+  gdEditor->waveTools->waveform->refresh();
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void silence(SampleChannel* ch, int a, int b)
+{
+       wfx_silence(ch->wave, a, b);
+       gdSampleEditor* gdEditor = getSampleEditorWindow();
+       gdEditor->waveTools->waveform->refresh();
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void fade(SampleChannel* ch, int a, int b, int type)
+{
+       wfx_fade(ch->wave, a, b, type);
+       gdSampleEditor* gdEditor = getSampleEditorWindow();
+       gdEditor->waveTools->waveform->refresh();
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void smoothEdges(SampleChannel* ch, int a, int b)
+{
+       wfx_smooth(ch->wave, a, b);
+       gdSampleEditor* gdEditor = getSampleEditorWindow();
+       gdEditor->waveTools->waveform->refresh();
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void setStartEnd(SampleChannel* ch, int a, int b)
+{
+       setBeginEndChannel(ch, a * 2, b * 2);  // stereo values
+       gdSampleEditor* gdEditor = getSampleEditorWindow();
+       gdEditor->waveTools->waveform->recalcPoints();
+       gdEditor->waveTools->waveform->clearSel();
+       gdEditor->waveTools->waveform->redraw();
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void trim(SampleChannel* ch, int a, int b)
+{
+       if (!wfx_trim(ch->wave, a, b)) {
+               gdAlert("Unable to trim the sample!");
+               return;
+       }
+       setBeginEndChannel(ch, ch->begin, ch->end);
+       gdSampleEditor* gdEditor = getSampleEditorWindow();
+  gdEditor->waveTools->waveform->clearSel();
+  gdEditor->waveTools->waveform->refresh();
+}
+
+}}}; // giada::c::sampleEditor::
diff --git a/src/glue/sampleEditor.h b/src/glue/sampleEditor.h
new file mode 100644 (file)
index 0000000..63babff
--- /dev/null
@@ -0,0 +1,56 @@
+/* -----------------------------------------------------------------------------
+ *
+ * Giada - Your Hardcore Loopmachine
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Copyright (C) 2010-2017 Giovanni A. Zuliani | Monocasual
+ *
+ * This file is part of Giada - Your Hardcore Loopmachine.
+ *
+ * Giada - Your Hardcore Loopmachine 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 3 of the License, or (at your option) any later version.
+ *
+ * Giada - Your Hardcore Loopmachine 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 Giada - Your Hardcore Loopmachine. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * -------------------------------------------------------------------------- */
+
+
+#ifndef G_GLUE_SAMPLE_EDITOR_H
+#define G_GLUE_SAMPLE_EDITOR_H
+
+
+class SampleChannel;
+class geWaveform;
+
+
+namespace giada {
+namespace c     {
+namespace sampleEditor 
+{
+
+
+/* setBeginEndChannel
+Sets start/end points in the sample editor. */
+
+void setBeginEndChannel(SampleChannel* ch, int b, int e);
+
+void cut(SampleChannel* ch, int a, int b);
+void trim(SampleChannel* ch, int a, int b);
+void silence(SampleChannel* ch, int a, int b);
+void fade(SampleChannel* ch, int a, int b, int type);
+void smoothEdges(SampleChannel* ch, int a, int b);
+void setStartEnd(SampleChannel* ch, int a, int b);
+
+}}}; // giada::c::sampleEditor::
+
+#endif
index f9bedb9c5acd5aba38ebf1a25b15fb99fc4df1b0..a1435d4cb63eebf6c1c088a8c6d3ec6e184ff859 100644 (file)
@@ -58,7 +58,7 @@ gdBrowserBase::gdBrowserBase(int x, int y, int w, int h, const string &title,
   hiddenFiles->callback(cb_toggleHiddenFiles, (void*) this);
 
        where->readonly(true);
-       where->cursor_color(COLOR_BG_DARK);
+       where->cursor_color(G_COLOR_BLACK);
        where->value(path.c_str());
 
        updir->callback(cb_up, (void*) this);
index 82f998723d1737fda4e1f1275f0993c69ee4c227..6e26b91c9a4b4ac5ac49a89ec8437fba657a4d95 100644 (file)
@@ -51,7 +51,7 @@ gdConfig::gdConfig(int w, int h) : gdWindow(w, h, "Configuration")
 
        Fl_Tabs *tabs = new Fl_Tabs(8, 8, w-16, h-44);
   tabs->box(G_CUSTOM_BORDER_BOX);
-  tabs->labelcolor(COLOR_TEXT_0);
+  tabs->labelcolor(G_COLOR_LIGHT_2);
   tabs->begin();
 
                tabAudio     = new geTabAudio(tabs->x()+10, tabs->y()+20, tabs->w()-20, tabs->h()-40);
index f7fbbe1a1367149c0b68d181a2edba6c7cc9b1b4..d3620b61ed18a3f9650d1ef29f7c9b6f75ed80f4 100644 (file)
@@ -58,7 +58,7 @@ gdMainWindow::gdMainWindow(int W, int H, const char *title, int argc, char **arg
   Fl::set_boxtype(FL_UP_BOX,     G_CUSTOM_UP_BOX);
   Fl::set_boxtype(FL_DOWN_BOX,   G_CUSTOM_DOWN_BOX);
 
-       size_range(GUI_WIDTH, GUI_HEIGHT);
+       size_range(G_GUI_WIDTH, G_GUI_HEIGHT);
 
        mainMenu      = new geMainMenu(8, -1);
        mainIO        = new geMainIO(412, 8);
index 92c91da3edecd4c3b7a8510566362ebed6887da0..063285225e376d5c29e99532379e3764cbf8847b 100644 (file)
@@ -68,9 +68,9 @@ gdPluginList::gdPluginList(int stackType, Channel *ch)
 
        list = new Fl_Scroll(8, 8, 476, 188);
        list->type(Fl_Scroll::VERTICAL);
-       list->scrollbar.color(COLOR_BG_0);
-       list->scrollbar.selection_color(COLOR_BG_1);
-       list->scrollbar.labelcolor(COLOR_BD_1);
+       list->scrollbar.color(G_COLOR_GREY_2);
+       list->scrollbar.selection_color(G_COLOR_GREY_4);
+       list->scrollbar.labelcolor(G_COLOR_LIGHT_1);
        list->scrollbar.slider(G_CUSTOM_BORDER_BOX);
 
        list->begin();
index 263d481a206a94661bfb31b4f85e044a0ec4b043..afd5cb84c62a1e5f227e7cb86e653e2a1f95ca2c 100644 (file)
@@ -75,7 +75,7 @@ gdPluginWindowGUI::gdPluginWindowGUI(Plugin *pPlugin)
 
   resize((Fl::w() - pluginW) / 2, (Fl::h() - pluginH) / 2, pluginW, pluginH);
 
-  Fl::add_timeout(GUI_PLUGIN_RATE, cb_refresh, (void*) this);
+  Fl::add_timeout(G_GUI_PLUGIN_RATE, cb_refresh, (void*) this);
 
   copy_label(pPlugin->getName().c_str());
 
@@ -106,7 +106,7 @@ void gdPluginWindowGUI::__cb_close()
 void gdPluginWindowGUI::__cb_refresh()
 {
   pluginHost::runDispatchLoop();
-  Fl::repeat_timeout(GUI_PLUGIN_RATE, cb_refresh, (void*) this);
+  Fl::repeat_timeout(G_GUI_PLUGIN_RATE, cb_refresh, (void*) this);
 }
 
 
index 75e49e5baa776b61f1566d34298bba66d6497ca8..99b9b13ecbeeda77641cfb903379e93183c61fbf 100644 (file)
@@ -46,7 +46,7 @@ void gdAlert(const char *c)
                geBox *box = new geBox(10, 10, 280, 40, c);
                geButton *b = new geButton(210, 60, 80, 20, "Close");
        modal->end();
-       box->labelsize(GUI_FONT_SIZE_BASE);
+       box->labelsize(G_GUI_FONT_SIZE_BASE);
        b->callback(__cb_window_closer, (void *)modal);
        b->shortcut(FL_Enter);
        gu_setFavicon(modal);
index 987b61e42ba214e5aa61d3a2d905687f5fa8f5c3..1da61abf87d25cc1dd986f1f51f5c6a8eb400489 100644 (file)
@@ -30,6 +30,7 @@
 #include <FL/Fl_Group.H>
 #include <FL/fl_draw.H>
 #include "../../glue/channel.h"
+#include "../../glue/sampleEditor.h"
 #include "../../core/waveFx.h"
 #include "../../core/conf.h"
 #include "../../core/const.h"
@@ -59,6 +60,7 @@
 
 
 using namespace giada::m;
+using namespace giada::c;
 
 
 gdSampleEditor::gdSampleEditor(SampleChannel *ch)
@@ -121,7 +123,10 @@ gdSampleEditor::gdSampleEditor(SampleChannel *ch)
   grid->add("16");
   grid->add("32");
   grid->add("64");
-  grid->value(grid->find_item(gu_itoa(conf::sampleEditorGridVal).c_str()));
+  if (conf::sampleEditorGridVal == 0)
+    grid->value(0);
+  else 
+    grid->value(grid->find_item(gu_itoa(conf::sampleEditorGridVal).c_str()));
   grid->callback(cb_changeGrid, (void*)this);
 
   snap->value(conf::sampleEditorGridOn);
@@ -209,7 +214,7 @@ void gdSampleEditor::__cb_reload()
   waveTools->waveform->stretchToWindow();
   waveTools->updateWaveform();
 
-  glue_setBeginEndChannel(ch, 0, ch->wave->size);
+  sampleEditor::setBeginEndChannel(ch, 0, ch->wave->size);
 
   redraw();
 }
index d13d6d60c1895555d0de700de328bcf90fe334e0..cb1b99a8c25c9d13e5f10ab8d5c743fff5bfe8c3 100644 (file)
@@ -95,9 +95,9 @@ void geAction::draw()
 {
        int color;
        if (selected)  /// && geActionEditor !disabled
-               color = COLOR_BD_1;
+               color = G_COLOR_LIGHT_2;
        else
-               color = COLOR_BG_2;
+               color = G_COLOR_LIGHT_1;
 
        if (ch->mode == SINGLE_PRESS) {
                fl_rectf(x(), y(), w(), h(), (Fl_Color) color);
@@ -108,10 +108,10 @@ void geAction::draw()
                else {
                        fl_rectf(x(), y(), MIN_WIDTH, h(), (Fl_Color) color);
                        if (type == G_ACTION_KEYPRESS)
-                               fl_rectf(x()+3, y()+h()-11, 2, 8, COLOR_BD_0);
+                               fl_rectf(x()+3, y()+h()-11, 2, 8, G_COLOR_GREY_4);
                        else
                        if  (type == G_ACTION_KEYREL)
-                               fl_rectf(x()+3, y()+3, 2, 8, COLOR_BD_0);
+                               fl_rectf(x()+3, y()+3, 2, 8, G_COLOR_GREY_4);
                }
        }
 
index f08f66dc522470ba54ac37ef7bfb33a3a6f6f89b..a9f50034166598bd59d100772b093fc80aef4414 100644 (file)
@@ -147,7 +147,7 @@ void geActionEditor::draw()
 
        /* print label */
 
-       fl_color(COLOR_BG_1);
+       fl_color(G_COLOR_GREY_4);
        fl_font(FL_HELVETICA, 12);
        if (active())
                fl_draw("start/stop", x()+4, y(), w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_CENTER));  /// FIXME h() is too much!
index a740b64a0dddd534b3bbace7160e928fbb0ea456..56aa786a7838a99ec669fb70dded3222e7a600f6 100644 (file)
@@ -55,11 +55,11 @@ void geBaseActionEditor::baseDraw(bool clear) {
        /* clear the screen */
 
        if (clear)
-               fl_rectf(x(), y(), w(), h(), COLOR_BG_MAIN);
+               fl_rectf(x(), y(), w(), h(), G_COLOR_GREY_1);
 
        /* draw the container */
 
-       fl_color(COLOR_BD_0);
+       fl_color(G_COLOR_GREY_4);
        fl_rect(x(), y(), w(), h());
 
        /* grid drawing, if > 1 */
@@ -78,13 +78,13 @@ void geBaseActionEditor::baseDraw(bool clear) {
 
        /* bars and beats drawing */
 
-       fl_color(COLOR_BD_0);
+       fl_color(G_COLOR_GREY_4);
        for (int i=0; i<(int) pParent->gridTool->beats.size(); i++) {
                int px = pParent->gridTool->beats.at(i)+x()-1;
                fl_line(px, y()+1, px, y()+h()-2);
        }
 
-       fl_color(COLOR_BG_2);
+       fl_color(G_COLOR_LIGHT_1);
        for (int i=0; i<(int) pParent->gridTool->bars.size(); i++) {
                int px = pParent->gridTool->bars.at(i)+x()-1;
                fl_line(px, y()+1, px, y()+h()-2);
@@ -95,5 +95,5 @@ void geBaseActionEditor::baseDraw(bool clear) {
 
        int coverWidth = pParent->totalWidth-pParent->coverX;
        if (coverWidth != 0)
-               fl_rectf(pParent->coverX+x(), y()+1, coverWidth, h()-2, COLOR_BG_1);
+               fl_rectf(pParent->coverX+x(), y()+1, coverWidth, h()-2, G_COLOR_GREY_4);
 }
index 19e84c8d977dea065b4379a6e019067f8b0f4847..206a2901813d908d979567692b8082f42f98c9ea 100644 (file)
@@ -101,7 +101,7 @@ void geEnvelopeEditor::draw() {
 
        /* print label */
 
-       fl_color(COLOR_BG_1);
+       fl_color(G_COLOR_GREY_4);
        fl_font(FL_HELVETICA, 12);
        fl_draw(l, x()+4, y(), 80, h(), (Fl_Align) (FL_ALIGN_LEFT));
 
@@ -110,7 +110,7 @@ void geEnvelopeEditor::draw() {
        int pxNew = 0;
        int pyNew = 0;
 
-       fl_color(COLOR_BG_2);
+       fl_color(G_COLOR_LIGHT_1);
 
        for (unsigned i=0; i<points.size(); i++) {
 
@@ -118,9 +118,9 @@ void geEnvelopeEditor::draw() {
                pyNew = points.at(i).y+y();
 
                if (selectedPoint == (int) i) {
-                       fl_color(COLOR_BD_1);
+                       fl_color(G_COLOR_LIGHT_1);
                        fl_rectf(pxNew, pyNew, 7, 7);
-                       fl_color(COLOR_BG_2);
+                       fl_color(G_COLOR_LIGHT_1);
                }
                else
                        fl_rectf(pxNew, pyNew, 7, 7);
index 82f3d1cbc12bc2f98bf09434eb0eb2f730012ccd..c8591e4ed6f32e743299ef5e25951bf61a6b55aa 100644 (file)
@@ -64,13 +64,13 @@ void geMuteEditor::draw()
 
        /* print label */
 
-       fl_color(COLOR_BG_1);
+       fl_color(G_COLOR_GREY_4);
        fl_font(FL_HELVETICA, 12);
        fl_draw("mute", x()+4, y(), w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_CENTER));
 
        /* draw "on" and "off" labels. Must stay in background */
 
-       fl_color(COLOR_BG_1);
+       fl_color(G_COLOR_GREY_4);
        fl_font(FL_HELVETICA, 9);
        fl_draw("on",  x()+4, y(),        w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_TOP));
        fl_draw("off", x()+4, y()+h()-14, w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_TOP));
@@ -78,7 +78,7 @@ void geMuteEditor::draw()
        /* draw on-off points. On = higher rect, off = lower rect. It always
         * starts with a note_off */
 
-       fl_color(COLOR_BG_2);
+       fl_color(G_COLOR_LIGHT_1);
 
        int pxOld = x()+1;
        int pxNew = 0;
@@ -105,9 +105,9 @@ void geMuteEditor::draw()
                fl_line(pxNew, y()+h()-5, pxNew, y()+4);
 
                if (selectedPoint == (int) i) {
-                       fl_color(COLOR_BD_1);
+                       fl_color(G_COLOR_LIGHT_1);
                        fl_rectf(pxNew-3, pyDot, 7, 7);
-                       fl_color(COLOR_BG_2);
+                       fl_color(G_COLOR_LIGHT_1);
                }
                else
                        fl_rectf(pxNew-3, pyDot, 7, 7);
index 2a2531f07503107002d754b5d1495c1ef648d770..dea981060f3d807b618dcdce9068438019cabf3b 100644 (file)
@@ -76,7 +76,7 @@ void geNoteEditor::draw()
 
        /* clear background */
 
-       fl_rectf(x(), y(), w(), h(), COLOR_BG_MAIN);
+       fl_rectf(x(), y(), w(), h(), G_COLOR_GREY_1);
 
        /* clip pianoRoll to pianoRollContainer size */
 
@@ -84,7 +84,7 @@ void geNoteEditor::draw()
        draw_child(*pianoRoll);
        fl_pop_clip();
 
-       fl_color(COLOR_BD_0);
+       fl_color(G_COLOR_GREY_4);
        fl_line_style(0);
        fl_rect(x(), y(), pParent->totalWidth, h());
 }
index 612b467de88601e806cc46a5dc91407457336a17..1cc5b4258226c98bd3919c0c707330f69cb78145 100644 (file)
@@ -127,7 +127,7 @@ bool gePianoItem::overlap()
 void gePianoItem::draw()
 {
        int _w = w() > MIN_WIDTH ? w() : MIN_WIDTH;
-       fl_rectf(x(), y()+2, _w, h()-3, (Fl_Color) selected ? COLOR_BD_1 : COLOR_BG_2);
+       fl_rectf(x(), y()+2, _w, h()-3, (Fl_Color) selected ? G_COLOR_LIGHT_1 : G_COLOR_LIGHT_1);
 }
 
 
index 46420397986f6a2ed619fcdb1bfa81e8761caede..00ffa14c2c8a151d5c4ad23be2dba3b7b0c09d6d 100644 (file)
@@ -42,8 +42,7 @@ using namespace giada::m;
 
 gePianoItemOrphaned::gePianoItemOrphaned(int x, int y, int xRel, int yRel,
   recorder::action *action, gdActionEditor *pParent)
-  : geBasePianoItem(x, y, WIDTH, pParent),
-    action         (action)
+  : geBasePianoItem(x, y, WIDTH, pParent)
 {
   note  = kernelMidi::getB2(action->iValue);
   frame = action->frame;
@@ -99,5 +98,5 @@ void gePianoItemOrphaned::remove()
 
 void gePianoItemOrphaned::draw()
 {
-  fl_rect(x(), y()+2, WIDTH, h()-3, (Fl_Color) selected ? COLOR_BD_1 : COLOR_BG_2);
+  fl_rect(x(), y()+2, WIDTH, h()-3, (Fl_Color) selected ? G_COLOR_LIGHT_1 : G_COLOR_LIGHT_1);
 }
index a41671ad5002966f2ac86c97e143ffe7062d516b..d89abdc6481228f2503dfb6a08286dd994087bd6 100644 (file)
@@ -40,8 +40,6 @@ class gePianoItemOrphaned : public geBasePianoItem
 {
 private:
 
-  struct giada::m::recorder::action *action;
-
        int note;
        int frame;
        int event;
index 13c738de24084a396fafe9e318f21c9a2b306f0d..36746b218a8a6b3b7c2e2adeb3b1e3ac93500bb7 100644 (file)
@@ -148,10 +148,10 @@ void gePianoRoll::drawSurface1()
        /* warning: only w() and h() come from this widget, x and y coordinates
         * are absolute, since we are writing in a memory chunk */
 
-       fl_rectf(0, 0, CELL_W, h(), COLOR_BG_MAIN);
+       fl_rectf(0, 0, CELL_W, h(), G_COLOR_GREY_1);
 
        fl_line_style(FL_DASH, 0, nullptr);
-       fl_font(FL_HELVETICA, GUI_FONT_SIZE_BASE);
+       fl_font(FL_HELVETICA, G_GUI_FONT_SIZE_BASE);
 
        int octave = MAX_OCTAVES;
 
@@ -162,7 +162,7 @@ void gePianoRoll::drawSurface1()
                char note[6];
                switch (i % KEYS) {
                        case (int) Notes::G:
-                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, COLOR_BG_RICH);
+                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, G_COLOR_GREY_2);
                                sprintf(note, "%dG", octave);
                                break;
                        case (int) Notes::FS:
@@ -172,14 +172,14 @@ void gePianoRoll::drawSurface1()
                                sprintf(note, "%dF", octave);
                                break;
                        case (int) Notes::E:
-                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, COLOR_BG_RICH);
+                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, G_COLOR_GREY_2);
                                sprintf(note, "%dE", octave);
                                break;
                        case (int) Notes::DS:
                                sprintf(note, "%dD#", octave);
                                break;
                        case (int) Notes::D:
-                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, COLOR_BG_RICH);
+                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, G_COLOR_GREY_2);
                                sprintf(note, "%dD", octave);
                                break;
                        case (int) Notes::CS:
@@ -189,14 +189,14 @@ void gePianoRoll::drawSurface1()
                                sprintf(note, "%dC", octave);
                                break;
                        case (int) Notes::B:
-                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, COLOR_BG_RICH);
+                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, G_COLOR_GREY_2);
                                sprintf(note, "%dB", octave);
                                break;
                        case (int) Notes::AS:
                                sprintf(note, "%dA#", octave);
                                break;
                        case (int) Notes::A:
-                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, COLOR_BG_RICH);
+                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, G_COLOR_GREY_2);
                                sprintf(note, "%dA", octave);
                                break;
                        case (int) Notes::GS:
@@ -207,7 +207,7 @@ void gePianoRoll::drawSurface1()
 
     /* Print note name */
 
-               fl_color(COLOR_BG_LINE);
+               fl_color(G_COLOR_GREY_3);
                fl_draw(note, 4, ((i-1)*CELL_H)+1, CELL_W, CELL_H,
       (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_CENTER));
 
@@ -229,8 +229,8 @@ void gePianoRoll::drawSurface2()
 {
        surface2 = fl_create_offscreen(CELL_W, h());
        fl_begin_offscreen(surface2);
-       fl_rectf(0, 0, CELL_W, h(), COLOR_BG_MAIN);
-       fl_color(COLOR_BG_LINE);
+       fl_rectf(0, 0, CELL_W, h(), G_COLOR_GREY_1);
+       fl_color(G_COLOR_GREY_3);
        fl_line_style(FL_DASH, 0, nullptr);
        for (int i=1; i<=MAX_KEYS+1; i++) {
                switch (i % KEYS) {
@@ -239,11 +239,11 @@ void gePianoRoll::drawSurface2()
                        case (int) Notes::D:
                        case (int) Notes::B:
                        case (int) Notes::A:
-                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, COLOR_BG_RICH);
+                               fl_rectf(0, i*CELL_H, CELL_W, CELL_H, G_COLOR_GREY_2);
                                break;
                }
                if (i < MAX_KEYS+1) {
-                       fl_color(COLOR_BG_LINE);
+                       fl_color(G_COLOR_GREY_3);
                        fl_line(0, i*CELL_H, CELL_W, i*CELL_H);
                }
        }
index 0de1ec9da7a51831bec0983d53ba20db70da9016..42f448472ceabaca54974bfd26b300fb1eebaaa1 100644 (file)
@@ -33,9 +33,9 @@ geBox::geBox(int x, int y, int w, int h, const char *l, Fl_Align al)
 : Fl_Box(x, y, w, h)
 {
   copy_label(l);
-  labelsize(GUI_FONT_SIZE_BASE);
+  labelsize(G_GUI_FONT_SIZE_BASE);
   box(FL_NO_BOX);
-  labelcolor(COLOR_TEXT_0);
+  labelcolor(G_COLOR_LIGHT_2);
   if (al != 0)
     align(al | FL_ALIGN_INSIDE);
 }
index 87d9c14743571d2d6c0605287c2fce529e6a0452..90a6f7866d77db62deab17c4abfe944f13a038d5 100644 (file)
@@ -36,16 +36,16 @@ void g_customBorderBox(int x, int y, int w, int h, Fl_Color c)
 {
   fl_color(c);
   fl_rectf(x, y, w, h);
-  fl_color(COLOR_BD_0);
+  fl_color(G_COLOR_GREY_4);
   fl_rect(x, y, w, h);
 }
 
 
 void g_customUpBox(int x, int y, int w, int h, Fl_Color c)
 {
-  fl_color(COLOR_BG_0);
+  fl_color(G_COLOR_GREY_2);
   fl_rectf(x, y, w, h);
-  fl_color(COLOR_BG_0);
+  fl_color(G_COLOR_GREY_2);
   fl_rect(x, y, w, h);
 }
 
@@ -54,6 +54,6 @@ void g_customDownBox(int x, int y, int w, int h, Fl_Color c)
 {
   fl_color(c);
   fl_rectf(x, y, w, h);
-  fl_color(COLOR_BG_0);
+  fl_color(G_COLOR_GREY_2);
   fl_rect(x, y, w, h);
 }
index 06230e8f02756fb10365edeac4f0edef72c95190..73be138ad76e3a39e2bb0655d0cd8a0174fa1ef2 100644 (file)
@@ -38,10 +38,10 @@ geButton::geButton(int x, int y, int w, int h, const char *L,
 : geBaseButton(x, y, w, h, L),
   imgOff      (imgOff),
   imgOn       (imgOn),
-  bgColor0    (COLOR_BG_0),
-  bgColor1    (COLOR_BG_1),
-  bdColor     (COLOR_BD_0),
-  txtColor    (COLOR_TEXT_0)
+  bgColor0    (G_COLOR_GREY_2),
+  bgColor1    (G_COLOR_GREY_4),
+  bdColor     (G_COLOR_GREY_4),
+  txtColor    (G_COLOR_LIGHT_2)
 {
 }
 
@@ -52,7 +52,7 @@ geButton::geButton(int x, int y, int w, int h, const char *L,
 void geButton::draw()
 {
   if (!active()) txtColor = bdColor;
-  else           txtColor = COLOR_TEXT_0;
+  else           txtColor = G_COLOR_LIGHT_2;
 
   fl_rect(x(), y(), w(), h(), bdColor);             // borders
   if (value()) {                                    // -- clicked
@@ -70,6 +70,6 @@ void geButton::draw()
     fl_color(FL_INACTIVE_COLOR);
 
   fl_color(txtColor);
-  fl_font(FL_HELVETICA, GUI_FONT_SIZE_BASE);
+  fl_font(FL_HELVETICA, G_GUI_FONT_SIZE_BASE);
   fl_draw(label(), x()+2, y(), w()-2, h(), FL_ALIGN_CENTER);
 }
index 1297e95e9367da7f9a891bacda837e20011a6d73..5902f1d5202da206c118ec53337dabd8b94edccf 100644 (file)
@@ -41,7 +41,7 @@ geCheck::geCheck(int x, int y, int w, int h, const char *l)
 
 void geCheck::draw()
 {
-  int color = !active() ? FL_INACTIVE_COLOR : COLOR_BD_0;
+  int color = !active() ? FL_INACTIVE_COLOR : G_COLOR_GREY_4;
 
   if (value()) {
     fl_rect(x(), y(), 12, 12, (Fl_Color) color);
@@ -53,7 +53,7 @@ void geCheck::draw()
   }
 
   fl_rectf(x()+20, y(), w(), h(), FL_BACKGROUND_COLOR);  // clearer
-  fl_font(FL_HELVETICA, GUI_FONT_SIZE_BASE);
-  fl_color(!active() ? FL_INACTIVE_COLOR : COLOR_TEXT_0);
+  fl_font(FL_HELVETICA, G_GUI_FONT_SIZE_BASE);
+  fl_color(!active() ? FL_INACTIVE_COLOR : G_COLOR_LIGHT_2);
   fl_draw(label(), x()+20, y(), w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_TOP));
 }
index 8c4faa5c68109d2bbf3edd87a4ab50b53506f881..2a2cb93b820342a08d7f8b8136603b5b09591c1a 100644 (file)
 geChoice::geChoice(int x, int y, int w, int h, const char *l, bool ang)
   : Fl_Choice(x, y, w, h, l), angle(ang)
 {
-  labelsize(GUI_FONT_SIZE_BASE);
-  labelcolor(COLOR_TEXT_0);
+  labelsize(G_GUI_FONT_SIZE_BASE);
+  labelcolor(G_COLOR_LIGHT_2);
   box(FL_BORDER_BOX);
-  textsize(GUI_FONT_SIZE_BASE);
-  textcolor(COLOR_TEXT_0);
-  color(COLOR_BG_0);
+  textsize(G_GUI_FONT_SIZE_BASE);
+  textcolor(G_COLOR_LIGHT_2);
+  color(G_COLOR_GREY_2);
 }
 
 
@@ -48,15 +48,15 @@ geChoice::geChoice(int x, int y, int w, int h, const char *l, bool ang)
 
 void geChoice::draw()
 {
-  fl_rectf(x(), y(), w(), h(), COLOR_BG_0);              // bg
-  fl_rect(x(), y(), w(), h(), (Fl_Color) COLOR_BD_0);    // border
+  fl_rectf(x(), y(), w(), h(), G_COLOR_GREY_2);              // bg
+  fl_rect(x(), y(), w(), h(), (Fl_Color) G_COLOR_GREY_4);    // border
   if (angle)
     fl_polygon(x()+w()-8, y()+h()-1, x()+w()-1, y()+h()-8, x()+w()-1, y()+h()-1);
 
   /* pick up the text() from the selected item (value()) and print it in
    * the box and avoid overflows */
 
-  fl_color(!active() ? COLOR_BD_0 : COLOR_TEXT_0);
+  fl_color(!active() ? G_COLOR_GREY_4 : G_COLOR_LIGHT_2);
   if (value() != -1) {
     if (fl_width(text(value())) < w()-8) {
       fl_draw(text(value()), x(), y(), w(), h(), FL_ALIGN_CENTER);
index 0d141e26997506a4dde7853ff1e4bb8b809a9eb9..d8f83b6a3a1fd9ec5adcaac5b8bdb03a4e3abeb3 100644 (file)
 geDial::geDial(int x, int y, int w, int h, const char *l)
 : Fl_Dial(x, y, w, h, l)
 {
-  labelsize(GUI_FONT_SIZE_BASE);
-  labelcolor(COLOR_TEXT_0);
+  labelsize(G_GUI_FONT_SIZE_BASE);
+  labelcolor(G_COLOR_LIGHT_2);
   align(FL_ALIGN_LEFT);
   type(FL_FILL_DIAL);
   angles(0, 360);
-  color(COLOR_BG_0);            // background
-  selection_color(COLOR_BG_1);   // selection
+  color(G_COLOR_GREY_2);            // background
+  selection_color(G_COLOR_GREY_4);   // selection
 }
 
 
@@ -50,10 +50,10 @@ void geDial::draw()
 {
   double angle = (angle2()-angle1())*(value()-minimum())/(maximum()-minimum()) + angle1();
 
-  fl_color(COLOR_BG_0);
+  fl_color(G_COLOR_GREY_2);
   fl_pie(x(), y(), w(), h(), 270-angle1(), angle > angle1() ? 360+270-angle : 270-360-angle);
 
-  fl_color(COLOR_BD_0);
+  fl_color(G_COLOR_GREY_4);
   fl_arc(x(), y(), w(), h(), 0, 360);
   fl_pie(x(), y(), w(), h(), 270-angle, 270-angle1());
 }
index 0a2384cbe60cfffaa5658f602d2965b4effdd29e..7fb318d7b278cf0bdca5fdfa577f9fd1add1aa87 100644 (file)
@@ -35,11 +35,11 @@ geInput::geInput(int x, int y, int w, int h, const char *l)
 {
   //Fl::set_boxtype(G_CUSTOM_BORDER_BOX, gDrawBox, 1, 1, 2, 2);
   box(G_CUSTOM_BORDER_BOX);
-  labelsize(GUI_FONT_SIZE_BASE);
-  labelcolor(COLOR_TEXT_0);
-  color(COLOR_BG_DARK);
-  textcolor(COLOR_TEXT_0);
-  cursor_color(COLOR_TEXT_0);
-  selection_color(COLOR_BD_0);
-  textsize(GUI_FONT_SIZE_BASE);
+  labelsize(G_GUI_FONT_SIZE_BASE);
+  labelcolor(G_COLOR_LIGHT_2);
+  color(G_COLOR_BLACK);
+  textcolor(G_COLOR_LIGHT_2);
+  cursor_color(G_COLOR_LIGHT_2);
+  selection_color(G_COLOR_GREY_4);
+  textsize(G_GUI_FONT_SIZE_BASE);
 }
index c651d14291f7f823ac09092e5710871d8c0c48dd..7645ab696272da2f92def9af5acd20d8dd0f4004 100644 (file)
@@ -39,9 +39,9 @@ geLiquidScroll::geLiquidScroll(int x, int y, int w, int h, const char *l)
   : Fl_Scroll(x, y, w, h, l)
 {
   type(Fl_Scroll::VERTICAL);
-  scrollbar.color(COLOR_BG_0);
-  scrollbar.selection_color(COLOR_BG_1);
-  scrollbar.labelcolor(COLOR_BD_1);
+  scrollbar.color(G_COLOR_GREY_2);
+  scrollbar.selection_color(G_COLOR_GREY_4);
+  scrollbar.labelcolor(G_COLOR_LIGHT_1);
   scrollbar.slider(G_CUSTOM_BORDER_BOX);
 }
 
index 2db4201ee26c2caa3db8b4170c75e39bb80362c4..fcde80cbbfd319e967686b881ab4ad58b1f301f7 100644 (file)
@@ -33,6 +33,6 @@
 geProgress::geProgress(int x, int y, int w, int h, const char *l)
 : Fl_Progress(x, y, w, h, l)
 {
-  color(COLOR_BG_0, COLOR_BD_0);
+  color(G_COLOR_GREY_2, G_COLOR_GREY_4);
   box(G_CUSTOM_BORDER_BOX);
 }
index cca9daf0f39de35eb406c94ee8d96a6c67855849..a4edf439b7d71a5ef813be0e217cf6aeb8d9f7ad 100644 (file)
@@ -41,7 +41,7 @@ geRadio::geRadio(int x, int y, int w, int h, const char *l)
 
 void geRadio::draw()
 {
- int color = !active() ? FL_INACTIVE_COLOR : COLOR_BD_0;
+ int color = !active() ? FL_INACTIVE_COLOR : G_COLOR_GREY_4;
 
  if (value()) {
    fl_rect(x(), y(), 12, 12, (Fl_Color) color);
@@ -53,7 +53,7 @@ void geRadio::draw()
  }
 
  fl_rectf(x()+20, y(), w(), h(), FL_BACKGROUND_COLOR);  // clearer
- fl_font(FL_HELVETICA, GUI_FONT_SIZE_BASE);
- fl_color(COLOR_TEXT_0);
+ fl_font(FL_HELVETICA, G_GUI_FONT_SIZE_BASE);
+ fl_color(G_COLOR_LIGHT_2);
  fl_draw(label(), x()+20, y(), w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_TOP));
 }
index 4d6477bf39c435ffdb88e26df96145dcda6bee35..fdd5fb87c401db95e424efabde33f540bd7660a8 100644 (file)
@@ -38,13 +38,13 @@ geScroll::geScroll(int x, int y, int w, int h, int t)
 {
   type(t);
 
-  scrollbar.color(COLOR_BG_0);
-  scrollbar.selection_color(COLOR_BG_1);
-  scrollbar.labelcolor(COLOR_BD_1);
+  scrollbar.color(G_COLOR_GREY_2);
+  scrollbar.selection_color(G_COLOR_GREY_4);
+  scrollbar.labelcolor(G_COLOR_LIGHT_1);
   scrollbar.slider(G_CUSTOM_BORDER_BOX);
 
-  hscrollbar.color(COLOR_BG_0);
-  hscrollbar.selection_color(COLOR_BG_1);
-  hscrollbar.labelcolor(COLOR_BD_1);
+  hscrollbar.color(G_COLOR_GREY_2);
+  hscrollbar.selection_color(G_COLOR_GREY_4);
+  hscrollbar.labelcolor(G_COLOR_LIGHT_1);
   hscrollbar.slider(G_CUSTOM_BORDER_BOX);
 }
index 03ac86d3cbae2f694840515b37e8d1feca656e1e..0ee6457e8dca4fdcfaab8b7c8e7624af185ee355 100644 (file)
@@ -35,11 +35,11 @@ geSlider::geSlider(int x, int y, int w, int h, const char *l)
 {
  type(FL_HOR_FILL_SLIDER);
 
- labelsize(GUI_FONT_SIZE_BASE);
+ labelsize(G_GUI_FONT_SIZE_BASE);
  align(FL_ALIGN_LEFT);
- labelcolor(COLOR_TEXT_0);
+ labelcolor(G_COLOR_LIGHT_2);
 
  box(G_CUSTOM_BORDER_BOX);
- color(COLOR_BG_0);
- selection_color(COLOR_BD_0);
+ color(G_COLOR_GREY_2);
+ selection_color(G_COLOR_GREY_4);
 }
index dd738f4db6d32ddc1fccd4b155f5038581747466..5a656dd19a3e62dcd2406c42b046a61d41b73c46 100644 (file)
@@ -48,5 +48,5 @@ void geStatusButton::draw()
 {
   geButton::draw();
   if (status)
-    fl_draw_pixmap(imgOn, x()+1, y()+1, COLOR_BD_0);
+    fl_draw_pixmap(imgOn, x()+1, y()+1, G_COLOR_GREY_4);
 }
index 0f0290ced0bc6d710ce1552ce8aab80e9a4a82a8..b6cba42d0c9af756eb14917a1f38d297e838e215 100644 (file)
@@ -40,20 +40,20 @@ geBrowser::geBrowser(int x, int y, int w, int h)
    showHiddenFiles(false)
 {
        box(G_CUSTOM_BORDER_BOX);
-       textsize(GUI_FONT_SIZE_BASE);
-       textcolor(COLOR_TEXT_0);
-       selection_color(COLOR_BG_1);
-       color(COLOR_BG_0);
+       textsize(G_GUI_FONT_SIZE_BASE);
+       textcolor(G_COLOR_LIGHT_2);
+       selection_color(G_COLOR_GREY_4);
+       color(G_COLOR_GREY_2);
   type(FL_SELECT_BROWSER);
 
-       this->scrollbar.color(COLOR_BG_0);
-       this->scrollbar.selection_color(COLOR_BG_1);
-       this->scrollbar.labelcolor(COLOR_BD_1);
+       this->scrollbar.color(G_COLOR_GREY_2);
+       this->scrollbar.selection_color(G_COLOR_GREY_4);
+       this->scrollbar.labelcolor(G_COLOR_LIGHT_1);
        this->scrollbar.slider(G_CUSTOM_BORDER_BOX);
 
-       this->hscrollbar.color(COLOR_BG_0);
-       this->hscrollbar.selection_color(COLOR_BG_1);
-       this->hscrollbar.labelcolor(COLOR_BD_1);
+       this->hscrollbar.color(G_COLOR_GREY_2);
+       this->hscrollbar.selection_color(G_COLOR_GREY_4);
+       this->hscrollbar.labelcolor(G_COLOR_LIGHT_1);
        this->hscrollbar.slider(G_CUSTOM_BORDER_BOX);
 
   take_focus();  // let it have focus on startup
index c566b14fd026e35bcfb2c01d45c668f08072cccd..6049acdc2395d172ab5c465de2bc8921b29df259 100644 (file)
@@ -63,7 +63,7 @@ geTabAudio::geTabAudio(int X, int Y, int W, int H)
                 new geBox(x(), rsmpQuality->y()+rsmpQuality->h()+8, w(), 92,
                                                                                "Restart Giada for the changes to take effect.");
        end();
-       labelsize(GUI_FONT_SIZE_BASE);
+       labelsize(G_GUI_FONT_SIZE_BASE);
 
        soundsys->add("(none)");
 
index e1b6c6ce7d2d222281a8062125007720c5a26f06..e29b5f481bb4b4f4aa9f610cf084826d11559d43 100644 (file)
@@ -60,7 +60,7 @@ geTabBehaviors::geTabBehaviors(int X, int Y, int W, int H)
 
   end();
 
-       labelsize(GUI_FONT_SIZE_BASE);
+       labelsize(G_GUI_FONT_SIZE_BASE);
 
        conf::recsStopOnChanHalt == 1 ? recsStopOnChanHalt_1->value(1) : recsStopOnChanHalt_0->value(1);
        conf::chansStopOnSeqHalt == 1 ? chansStopOnSeqHalt_1->value(1) : chansStopOnSeqHalt_0->value(1);
index 4ffbd54c8a41ec6317be610749592a44aa431edd..39f2d260a9a9b59ba2e611e0dd56b323ca02763a 100644 (file)
@@ -55,7 +55,7 @@ geTabMidi::geTabMidi(int X, int Y, int W, int H)
        new geBox(x(), sync->y()+sync->h()+8, w(), h()-125, "Restart Giada for the changes to take effect.");
        end();
 
-       labelsize(GUI_FONT_SIZE_BASE);
+       labelsize(G_GUI_FONT_SIZE_BASE);
 
        system->callback(cb_changeSystem, (void*)this);
 
index 2be79e80b6331e4397b4569ab85876e686d80354..57a5087b849b9d8b1dd267b024c7589207bc9e46 100644 (file)
@@ -45,7 +45,7 @@ geTabMisc::geTabMisc(int X, int Y, int W, int H)
        debugMsg->add("To standard output");
        debugMsg->add("To file");
 
-       labelsize(GUI_FONT_SIZE_BASE);
+       labelsize(G_GUI_FONT_SIZE_BASE);
 
        switch (conf::logMode) {
                case LOG_MODE_MUTE:
index b992ebd0e61ec2768280e38e197608eadae1e0d4..33b222546ca44a34e29a26cf0d1a1d4157a626d6 100644 (file)
 
 
 #include <FL/Fl.H>
-#include "../../core/const.h"
-#include "../../core/conf.h"
-#include "../../core/pluginHost.h"
-#include "../../utils/string.h"
-#include "../../utils/fs.h"
+#include "../../../core/const.h"
+#include "../../../core/conf.h"
+#include "../../../core/pluginHost.h"
+#include "../../../utils/string.h"
+#include "../../../utils/fs.h"
 #include "../basics/box.h"
 #include "../basics/radio.h"
 #include "../basics/check.h"
@@ -55,7 +55,7 @@ geTabPlugins::geTabPlugins(int X, int Y, int W, int H)
 
        end();
 
-       labelsize(GUI_FONT_SIZE_BASE);
+       labelsize(G_GUI_FONT_SIZE_BASE);
 
        info->label("Scan in progress. Please wait...");
        info->hide();
index 7b9262e892d7dea2ad5575e3cfef1e3106aa3e15..38ac667dfca0754b4341d5f99c277888e412f394 100644 (file)
@@ -49,25 +49,25 @@ void geBeatMeter::draw()
   int cursorW = w() / G_MAX_BEATS;
   int greyX   = clock::getBeats() * cursorW;
 
-  fl_rect(x(), y(), w(), h(), COLOR_BD_0);                            // border
+  fl_rect(x(), y(), w(), h(), G_COLOR_GREY_4);                            // border
   fl_rectf(x()+1, y()+1, w()-2, h()-2, FL_BACKGROUND_COLOR);          // bg
   fl_rectf(x()+(clock::getCurrentBeat()*cursorW)+3, y()+3, cursorW-5, h()-6,
-    COLOR_BG_2); // cursor
+    G_COLOR_LIGHT_1); // cursor
 
   /* beat cells */
 
-  fl_color(COLOR_BD_0);
+  fl_color(G_COLOR_GREY_4);
   for (int i=1; i<=clock::getBeats(); i++)
     fl_line(x()+cursorW*i, y()+1, x()+cursorW*i, y()+h()-2);
 
   /* bar line */
 
-  fl_color(COLOR_BG_2);
+  fl_color(G_COLOR_LIGHT_1);
   int delta = clock::getBeats() / clock::getBars();
   for (int i=1; i<clock::getBars(); i++)
     fl_line(x()+cursorW*(i*delta), y()+1, x()+cursorW*(i*delta), y()+h()-2);
 
   /* unused grey area */
 
-  fl_rectf(x()+greyX+1, y()+1, w()-greyX-1,  h()-2, COLOR_BG_1);
+  fl_rectf(x()+greyX+1, y()+1, w()-greyX-1,  h()-2, G_COLOR_GREY_4);
 }
index e3545002f0dc26e975eb4d432bf74256dcfa50f9..6eb8d625d46666290ea9024c2962585d90b216a3 100644 (file)
@@ -77,7 +77,7 @@ void geChannelButton::draw()
 
   /* draw key */
 
-  fl_color(COLOR_TEXT_0);
+  fl_color(G_COLOR_LIGHT_2);
   fl_font(FL_HELVETICA, 11);
   fl_draw(key.c_str(), x(), y(), 18, h(), FL_ALIGN_CENTER);
 }
@@ -88,7 +88,7 @@ void geChannelButton::draw()
 
 void geChannelButton::setInputRecordMode()
 {
-  bgColor0 = COLOR_BG_3;
+  bgColor0 = G_COLOR_RED;
 }
 
 
@@ -97,8 +97,8 @@ void geChannelButton::setInputRecordMode()
 
 void geChannelButton::setActionRecordMode()
 {
-  bgColor0 = COLOR_BG_4;
-  txtColor = COLOR_TEXT_0;
+  bgColor0 = G_COLOR_BLUE;
+  txtColor = G_COLOR_LIGHT_2;
 }
 
 
@@ -107,9 +107,9 @@ void geChannelButton::setActionRecordMode()
 
 void geChannelButton::setDefaultMode(const char *l)
 {
-  bgColor0 = COLOR_BG_0;
-       bdColor  = COLOR_BD_0;
-       txtColor = COLOR_TEXT_0;
+  bgColor0 = G_COLOR_GREY_2;
+       bdColor  = G_COLOR_GREY_4;
+       txtColor = G_COLOR_LIGHT_2;
   if (l)
     label(l);
 }
@@ -120,9 +120,9 @@ void geChannelButton::setDefaultMode(const char *l)
 
 void geChannelButton::setPlayMode()
 {
-  bgColor0 = COLOR_BG_2;
-  bdColor  = COLOR_BD_1;
-  txtColor = COLOR_TEXT_1;
+  bgColor0 = G_COLOR_LIGHT_1;
+  bdColor  = G_COLOR_LIGHT_1;
+  txtColor = G_COLOR_GREY_1;
 }
 
 
@@ -131,5 +131,5 @@ void geChannelButton::setPlayMode()
 
 void geChannelButton::setEndingMode()
 {
-  bgColor0 = COLOR_BD_0;
+  bgColor0 = G_COLOR_GREY_4;
 }
index 8231291d83cbaf0293c45602ce2c113a45fab227..07c6f335392b30845c180925d187df4472e38b8d 100644 (file)
@@ -41,9 +41,9 @@ geChannelMode::geChannelMode(int x, int y, int w, int h, SampleChannel *ch,
   : Fl_Menu_Button(x, y, w, h, L), ch(ch)
 {
   box(G_CUSTOM_BORDER_BOX);
-  textsize(GUI_FONT_SIZE_BASE);
-  textcolor(COLOR_TEXT_0);
-  color(COLOR_BG_0);
+  textsize(G_GUI_FONT_SIZE_BASE);
+  textcolor(G_COLOR_LIGHT_2);
+  color(G_COLOR_GREY_2);
 
   add("Loop . basic",      0, cb_changeMode, (void *)LOOP_BASIC);
   add("Loop . once",       0, cb_changeMode, (void *)LOOP_ONCE);
@@ -60,7 +60,7 @@ geChannelMode::geChannelMode(int x, int y, int w, int h, SampleChannel *ch,
 
 
 void geChannelMode::draw() {
-  fl_rect(x(), y(), w(), h(), COLOR_BD_0);    // border
+  fl_rect(x(), y(), w(), h(), G_COLOR_GREY_4);    // border
   switch (ch->mode) {
     case LOOP_BASIC:
       fl_draw_pixmap(loopBasic_xpm, x()+1, y()+1);
index bcd3c4708d5c85b1af59be3b48eefde718ea9688..a9b3fc78fba9864c3e83a08bfb18a5215d1dcd5a 100644 (file)
@@ -47,27 +47,27 @@ geChannelStatus::geChannelStatus(int x, int y, int w, int h, SampleChannel *ch,
 
 void geChannelStatus::draw()
 {
-  fl_rect(x(), y(), w(), h(), COLOR_BD_0);              // reset border
-  fl_rectf(x()+1, y()+1, w()-2, h()-2, COLOR_BG_0);     // reset background
+  fl_rect(x(), y(), w(), h(), G_COLOR_GREY_4);              // reset border
+  fl_rectf(x()+1, y()+1, w()-2, h()-2, G_COLOR_GREY_2);     // reset background
 
   if (ch != nullptr) {
     if (ch->status    & (STATUS_WAIT | STATUS_ENDING | REC_ENDING | REC_WAITING) ||
         ch->recStatus & (REC_WAITING | REC_ENDING))
     {
-      fl_rect(x(), y(), w(), h(), COLOR_BD_1);
+      fl_rect(x(), y(), w(), h(), G_COLOR_LIGHT_1);
     }
     else
     if (ch->status == STATUS_PLAY)
-      fl_rect(x(), y(), w(), h(), COLOR_BD_1);
+      fl_rect(x(), y(), w(), h(), G_COLOR_LIGHT_1);
     else
-      fl_rectf(x()+1, y()+1, w()-2, h()-2, COLOR_BG_0);     // status empty
+      fl_rectf(x()+1, y()+1, w()-2, h()-2, G_COLOR_GREY_2);     // status empty
 
 
     if (mixer::recording && ch->armed)
-      fl_rectf(x()+1, y()+1, w()-2, h()-2, COLOR_BG_3);     // take in progress
+      fl_rectf(x()+1, y()+1, w()-2, h()-2, G_COLOR_RED);     // take in progress
     else
     if (recorder::active && recorder::canRec(ch, clock::isRunning(), mixer::recording))
-      fl_rectf(x()+1, y()+1, w()-2, h()-2, COLOR_BG_4);     // action record
+      fl_rectf(x()+1, y()+1, w()-2, h()-2, G_COLOR_BLUE);     // action record
 
     /* equation for the progress bar:
      * ((chanTracker - chanStart) * w()) / (chanEnd - chanStart). */
@@ -77,6 +77,6 @@ void geChannelStatus::draw()
       pos = 0;
     else
       pos = (pos * (w()-1)) / (ch->end - ch->begin);
-    fl_rectf(x()+1, y()+1, pos, h()-2, COLOR_BG_2);
+    fl_rectf(x()+1, y()+1, pos, h()-2, G_COLOR_LIGHT_1);
   }
 }
index 5d94a7c985e95f53edace632bf21b36d3a69173d..6293ae38e58f5b0d420969f5d411009b5eceebc6 100644 (file)
@@ -254,9 +254,9 @@ int geColumn::openTypeMenu()
 
        Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50);
        b->box(G_CUSTOM_BORDER_BOX);
-       b->textsize(GUI_FONT_SIZE_BASE);
-       b->textcolor(COLOR_TEXT_0);
-       b->color(COLOR_BG_0);
+       b->textsize(G_GUI_FONT_SIZE_BASE);
+       b->textcolor(G_COLOR_LIGHT_2);
+       b->color(G_COLOR_GREY_2);
 
        const Fl_Menu_Item *m = rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b);
        if (!m) return 0;
index 088c2fbe7bf05e7fb64fa9a6616a69255def6067..b423196e6978dbedbe18020700e9b6f2a2a86b7c 100644 (file)
@@ -50,15 +50,15 @@ geKeyboard::geKeyboard(int X, int Y, int W, int H)
        spacePressed (false),
        addColumnBtn (nullptr)
 {
-       color(COLOR_BG_MAIN);
+       color(G_COLOR_GREY_1);
        type(Fl_Scroll::BOTH_ALWAYS);
-       scrollbar.color(COLOR_BG_0);
-       scrollbar.selection_color(COLOR_BG_1);
-       scrollbar.labelcolor(COLOR_BD_1);
+       scrollbar.color(G_COLOR_GREY_2);
+       scrollbar.selection_color(G_COLOR_GREY_4);
+       scrollbar.labelcolor(G_COLOR_LIGHT_1);
        scrollbar.slider(G_CUSTOM_BORDER_BOX);
-       hscrollbar.color(COLOR_BG_0);
-       hscrollbar.selection_color(COLOR_BG_1);
-       hscrollbar.labelcolor(COLOR_BD_1);
+       hscrollbar.color(G_COLOR_GREY_2);
+       hscrollbar.selection_color(G_COLOR_GREY_4);
+       hscrollbar.labelcolor(G_COLOR_LIGHT_1);
        hscrollbar.slider(G_CUSTOM_BORDER_BOX);
 
        addColumnBtn = new geButton(8, y(), 200, 20, "Add new column");
index 56bef49ed1b5369a7bb0a4ed20595596c1671bf2..2261bcd511535b3e3edef23660f76d714ec7f29a 100644 (file)
@@ -209,9 +209,9 @@ void geMidiChannel::__cb_openMenu()
 
        Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50);
        b->box(G_CUSTOM_BORDER_BOX);
-       b->textsize(GUI_FONT_SIZE_BASE);
-       b->textcolor(COLOR_TEXT_0);
-       b->color(COLOR_BG_0);
+       b->textsize(G_GUI_FONT_SIZE_BASE);
+       b->textcolor(G_COLOR_LIGHT_2);
+       b->color(G_COLOR_GREY_2);
 
   const Fl_Menu_Item *m = rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b);
   if (m)
index 276a9ff737d17d96df16ec660938099a4cc56404..26f13107d22eb6f6db32b0d49ffb3123f9fb429a 100644 (file)
@@ -94,8 +94,7 @@ void menuCallback(Fl_Widget *w, void *v)
   geSampleChannel *gch = static_cast<geSampleChannel*>(w);
   Menu selectedItem = (Menu) (intptr_t) v;
 
-  switch (selectedItem)
-  {
+  switch (selectedItem) {
     case Menu::INPUT_MONITOR: {
       glue_toggleInputMonitor(gch->ch);
       break;
@@ -298,9 +297,9 @@ void geSampleChannel::__cb_openMenu()
 
        Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50);
        b->box(G_CUSTOM_BORDER_BOX);
-       b->textsize(GUI_FONT_SIZE_BASE);
-       b->textcolor(COLOR_TEXT_0);
-       b->color(COLOR_BG_0);
+       b->textsize(G_GUI_FONT_SIZE_BASE);
+       b->textcolor(G_COLOR_LIGHT_2);
+       b->color(G_COLOR_GREY_2);
 
        const Fl_Menu_Item *m = rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b);
   if (m)
index 9b0dac6aac8608c7ebec9cc08db0cee3aff1617e..85974d3dd813e72f16f95358e642e85a93600d78 100644 (file)
@@ -120,9 +120,9 @@ void geMainMenu::__cb_file()
 
        Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50);
        b->box(G_CUSTOM_BORDER_BOX);
-       b->textsize(GUI_FONT_SIZE_BASE);
-       b->textcolor(COLOR_TEXT_0);
-       b->color(COLOR_BG_0);
+       b->textsize(G_GUI_FONT_SIZE_BASE);
+       b->textcolor(G_COLOR_LIGHT_2);
+       b->color(G_COLOR_GREY_2);
 
        const Fl_Menu_Item *m = menu->popup(Fl::event_x(),      Fl::event_y(), 0, 0, b);
        if (!m) return;
@@ -191,9 +191,9 @@ void geMainMenu::__cb_edit()
 
        Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50);
        b->box(G_CUSTOM_BORDER_BOX);
-       b->textsize(GUI_FONT_SIZE_BASE);
-       b->textcolor(COLOR_TEXT_0);
-       b->color(COLOR_BG_0);
+       b->textsize(G_GUI_FONT_SIZE_BASE);
+       b->textcolor(G_COLOR_LIGHT_2);
+       b->color(G_COLOR_GREY_2);
 
        const Fl_Menu_Item *m = menu->popup(Fl::event_x(),      Fl::event_y(), 0, 0, b);
        if (!m) return;
index 058ae62b4872274b7c2a1dd7505d9b139a742f42..46a8bc57514a3c5d01b09f450c69ded5a743c87d 100644 (file)
@@ -45,19 +45,19 @@ gePluginBrowser::gePluginBrowser(int x, int y, int w, int h)
        : Fl_Browser(x, y, w, h)
 {
        box(G_CUSTOM_BORDER_BOX);
-       textsize(GUI_FONT_SIZE_BASE);
-       textcolor(COLOR_TEXT_0);
-       selection_color(COLOR_BG_1);
-       color(COLOR_BG_0);
-
-       this->scrollbar.color(COLOR_BG_0);
-       this->scrollbar.selection_color(COLOR_BG_1);
-       this->scrollbar.labelcolor(COLOR_BD_1);
+       textsize(G_GUI_FONT_SIZE_BASE);
+       textcolor(G_COLOR_LIGHT_2);
+       selection_color(G_COLOR_GREY_4);
+       color(G_COLOR_GREY_2);
+
+       this->scrollbar.color(G_COLOR_GREY_2);
+       this->scrollbar.selection_color(G_COLOR_GREY_4);
+       this->scrollbar.labelcolor(G_COLOR_LIGHT_1);
        this->scrollbar.slider(G_CUSTOM_BORDER_BOX);
 
-       this->hscrollbar.color(COLOR_BG_0);
-       this->hscrollbar.selection_color(COLOR_BG_1);
-       this->hscrollbar.labelcolor(COLOR_BD_1);
+       this->hscrollbar.color(G_COLOR_GREY_2);
+       this->hscrollbar.selection_color(G_COLOR_GREY_4);
+       this->hscrollbar.labelcolor(G_COLOR_LIGHT_1);
        this->hscrollbar.slider(G_CUSTOM_BORDER_BOX);
 
        type(FL_HOLD_BROWSER);
index c7b34b1a8ec406a5c597d6a54e0aa1ade159d61d..8f411ff9627fb94641cc32035a21a748de7435b7 100644 (file)
@@ -29,6 +29,7 @@
 #include "../../../core/sampleChannel.h"
 #include "../../../core/wave.h"
 #include "../../../glue/channel.h"
+#include "../../../glue/sampleEditor.h"
 #include "../../../utils/gui.h"
 #include "../../../utils/string.h"
 #include "../../dialogs/sampleEditor.h"
@@ -39,6 +40,9 @@
 #include "rangeTool.h"
 
 
+using namespace giada::c;
+
+
 geRangeTool::geRangeTool(int x, int y, SampleChannel *ch)
   : Fl_Group(x, y, 300, 20),
     ch      (ch)
@@ -86,7 +90,7 @@ void geRangeTool::cb_resetStartEnd(Fl_Widget *w, void *p) { ((geRangeTool*)p)->_
 
 void geRangeTool::__cb_setChanPos()
 {
-  glue_setBeginEndChannel(ch, atoi(begin_->value())*2, atoi(end_->value())*2);
+  sampleEditor::setBeginEndChannel(ch, atoi(begin_->value())*2, atoi(end_->value())*2);
   static_cast<gdSampleEditor*>(parent()->parent())->waveTools->updateWaveform();
 }
 
@@ -96,6 +100,6 @@ void geRangeTool::__cb_setChanPos()
 
 void geRangeTool::__cb_resetStartEnd()
 {
-  glue_setBeginEndChannel(ch, 0, ch->wave->size);
+  sampleEditor::setBeginEndChannel(ch, 0, ch->wave->size);
   static_cast<gdSampleEditor*>(parent()->parent())->waveTools->updateWaveform();
 }
index 52c2903fb9170cb812b2e685bdb4780f9a2624d3..e3c0c13207ce1cf5e3613e58f627d301851e8dc4 100644 (file)
@@ -2,8 +2,6 @@
  *
  * Giada - Your Hardcore Loopmachine
  *
- * gg_waveTools
- *
  * -----------------------------------------------------------------------------
  *
  * Copyright (C) 2010-2017 Giovanni A. Zuliani | Monocasual
 
 
 #include "../../../core/const.h"
+#ifdef G_OS_MAC  // our Clang still doesn't know about cstdint (c++11 stuff)
+       #include <stdint.h>
+#else
+       #include <cstdint>
+#endif
+#include <FL/Fl_Menu_Item.H>
+#include <FL/Fl_Menu_Button.H>
+#include "../../../core/sampleChannel.h"
+#include "../../../core/waveFx.h"
+#include "../../../glue/sampleEditor.h"
 #include "../basics/boxtypes.h"
 #include "waveform.h"
 #include "waveTools.h"
 
 
+using namespace giada;
+
+
+namespace
+{
+enum class Menu
+{
+  CUT = 0,
+  TRIM,
+  SILENCE,
+  FADE_IN,
+  FADE_OUT,
+  SMOOTH_EDGES,
+  SET_START_END
+};
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void menuCallback(Fl_Widget* w, void* v)
+{
+  geWaveTools* wavetools = static_cast<geWaveTools*>(w);
+  Menu selectedItem = (Menu) (intptr_t) v;
+
+  int a = wavetools->waveform->getSelectionA();
+  int b = wavetools->waveform->getSelectionB();
+
+  switch (selectedItem) {
+       case Menu::CUT:
+      c::sampleEditor::cut(wavetools->ch, a, b);
+               break;
+       case Menu::TRIM:
+      c::sampleEditor::trim(wavetools->ch, a, b);
+               break;
+       case Menu::SILENCE:
+               c::sampleEditor::silence(wavetools->ch, a, b);
+               break;  
+       case Menu::FADE_IN:
+               c::sampleEditor::fade(wavetools->ch, a, b, 0);
+               break;
+       case Menu::FADE_OUT:
+               c::sampleEditor::fade(wavetools->ch, a, b, 1);
+               break;
+       case Menu::SMOOTH_EDGES:
+               c::sampleEditor::smoothEdges(wavetools->ch, a, b);
+               break;
+       case Menu::SET_START_END:
+               c::sampleEditor::setStartEnd(wavetools->ch, a, b);
+               break;
+  }
+}
+}; // {anonymous}
+
+
+/* -------------------------------------------------------------------------- */
+
+
 geWaveTools::geWaveTools(int x, int y, int w, int h, SampleChannel *ch, const char *l)
-       : Fl_Scroll(x, y, w, h, l)
+       : Fl_Scroll(x, y, w, h, l),
+         ch       (ch)
 {
        type(Fl_Scroll::HORIZONTAL_ALWAYS);
-       hscrollbar.color(COLOR_BG_0);
-       hscrollbar.selection_color(COLOR_BG_1);
-       hscrollbar.labelcolor(COLOR_BD_1);
+       hscrollbar.color(G_COLOR_GREY_2);
+       hscrollbar.selection_color(G_COLOR_GREY_4);
+       hscrollbar.labelcolor(G_COLOR_LIGHT_1);
        hscrollbar.slider(G_CUSTOM_BORDER_BOX);
 
        waveform = new geWaveform(x, y, w, h-24, ch);
-
-
-       //resizable(waveform);
 }
 
 
@@ -55,8 +119,17 @@ geWaveTools::geWaveTools(int x, int y, int w, int h, SampleChannel *ch, const ch
 
 void geWaveTools::updateWaveform()
 {
-       waveform->alloc(w());
-       waveform->redraw();
+       waveform->refresh();
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void geWaveTools::redrawWaveformAsync()
+{
+       if (ch->status & (STATUS_PLAY | STATUS_ENDING))
+               waveform->redraw();
 }
 
 
@@ -83,7 +156,7 @@ void geWaveTools::resize(int x, int y, int w, int h)
 }
 
 
-/* ------------------------------------------------------------------ */
+/* -------------------------------------------------------------------------- */
 
 
 int geWaveTools::handle(int e)
@@ -96,6 +169,51 @@ int geWaveTools::handle(int e)
                        ret = 1;
                        break;
                }
+               case FL_PUSH: {
+                       if (Fl::event_button3()) {  // right button
+                               openMenu();
+                               ret = 1;
+                       }
+                       break;
+               }
        }
        return ret;
 }
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void geWaveTools::openMenu()
+{
+       if (!waveform->isSelected())
+               return;
+
+       Fl_Menu_Item menu[] = {
+               {"Cut",                0, menuCallback, (void*) Menu::CUT},
+    {"Trim",               0, menuCallback, (void*) Menu::TRIM},
+    {"Silence",            0, menuCallback, (void*) Menu::SILENCE},
+    {"Fade in",            0, menuCallback, (void*) Menu::FADE_IN},
+    {"Fade out",           0, menuCallback, (void*) Menu::FADE_OUT},
+    {"Smooth edges",       0, menuCallback, (void*) Menu::SMOOTH_EDGES},
+    {"Set start/end here", 0, menuCallback, (void*) Menu::SET_START_END},
+    {0}
+       };
+
+  if (ch->status == STATUS_PLAY) {
+    menu[(int)Menu::CUT].deactivate();
+    menu[(int)Menu::TRIM].deactivate();
+  }
+
+
+       Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50);
+       b->box(G_CUSTOM_BORDER_BOX);
+       b->textsize(G_GUI_FONT_SIZE_BASE);
+       b->textcolor(G_COLOR_LIGHT_2);
+       b->color(G_COLOR_GREY_2);
+
+       const Fl_Menu_Item *m = menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b);
+  if (m)
+    m->do_callback(this, m->user_data());
+  return;
+}
index 303326bf689c276ece7f89d3cf06ef608c38758d..6c891c9e69be9ce6a173252c73e564dc9a095202 100644 (file)
@@ -1,10 +1,8 @@
-/* ---------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
  *
  * Giada - Your Hardcore Loopmachine
  *
- * gg_waveTools
- *
- * ---------------------------------------------------------------------
+ * -----------------------------------------------------------------------------
  *
  * Copyright (C) 2010-2017 Giovanni A. Zuliani | Monocasual
  *
@@ -24,7 +22,7 @@
  * along with Giada - Your Hardcore Loopmachine. If not, see
  * <http://www.gnu.org/licenses/>.
  *
- * ------------------------------------------------------------------ */
+ * -------------------------------------------------------------------------- */
 
 
 #ifndef GE_WAVE_TOOLS_H
@@ -40,15 +38,31 @@ class geWaveform;
 
 class geWaveTools : public Fl_Scroll
 {
+private:
+
+       void openMenu();
+
 public:
 
+       SampleChannel *ch;
        geWaveform *waveform;
 
        geWaveTools(int X,int Y,int W, int H, SampleChannel *ch, const char *L=0);
        void resize(int x, int y, int w, int h);
        int  handle(int e);
 
+       /* updateWaveform
+       Updates the waveform by realloc-ing new data (i.e. when the waveform has
+       changed). */
+
        void updateWaveform();
+
+       /* redrawWaveformAsync
+       Redraws the waveform, called by the video thread. This is meant to be called
+       repeatedly when you need to update the play head inside the waveform. The
+       method is smart enough to skip painting if the channel is stopped. */
+
+       void redrawWaveformAsync();
 };
 
 #endif
index 860ad591f28aa25f813a3e9eab11880ddb99190b..e315ca18f0232a7704b0827aae342d895e490385 100644 (file)
@@ -2,9 +2,6 @@
  *
  * Giada - Your Hardcore Loopmachine
  *
- * geWaveform
- * An element which represents a waveform.
- *
  * -----------------------------------------------------------------------------
  *
  * Copyright (C) 2010-2017 Giovanni A. Zuliani | Monocasual
@@ -28,6 +25,7 @@
  * -------------------------------------------------------------------------- */
 
 
+#include <cassert>
 #include <cmath>
 #include <FL/fl_draw.H>
 #include <FL/Fl_Menu_Button.H>
 #include "../../../core/waveFx.h"
 #include "../../../core/sampleChannel.h"
 #include "../../../glue/channel.h"
+#include "../../../glue/sampleEditor.h"
 #include "../basics/boxtypes.h"
 #include "waveTools.h"
 #include "waveform.h"
 
 
 using namespace giada::m;
+using namespace giada::c;
 
 
-geWaveform::geWaveform(int x, int y, int w, int h, SampleChannel *ch, const char *l)
-: Fl_Widget(x, y, w, h, l),
-  chan(ch),
-  menuOpen(false),
-  chanStart(0),
+geWaveform::geWaveform(int x, int y, int w, int h, SampleChannel* ch, const char* l)
+: Fl_Widget   (x, y, w, h, l),
+  selection   {},
+  chan        (ch),
+  chanStart   (0),
   chanStartLit(false),
-  chanEnd(0),
-  chanEndLit(false),
-  ratio(0.0f),
-  selectionA(0),
-  selectionB(0),
-  selectionA_abs(0),
-  selectionB_abs(0)
+  chanEnd     (0),
+  chanEndLit  (false),
+  pushed      (false),
+  dragged     (false),
+  resizedA    (false),
+  resizedB    (false),
+  ratio       (0.0f)
 {
   data.sup  = nullptr;
   data.inf  = nullptr;
@@ -67,7 +67,7 @@ geWaveform::geWaveform(int x, int y, int w, int h, SampleChannel *ch, const char
   grid.snap  = conf::sampleEditorGridOn;
   grid.level = conf::sampleEditorGridVal;
 
-  stretchToWindow();
+  alloc(w);
 }
 
 
@@ -85,9 +85,9 @@ geWaveform::~geWaveform()
 
 void geWaveform::freeData()
 {
-  if (data.sup != nullptr) {
-    free(data.sup);
-    free(data.inf);
+  if (data.sup) {
+    delete[] data.sup;
+    delete[] data.inf;
     data.sup  = nullptr;
     data.inf  = nullptr;
     data.size = 0;
@@ -109,8 +109,11 @@ int geWaveform::alloc(int datasize)
   freeData();
 
   data.size = datasize;
-  data.sup  = (int*) malloc(data.size * sizeof(int));
-  data.inf  = (int*) malloc(data.size * sizeof(int));
+  data.sup  = new (std::nothrow) int[data.size];
+  data.inf  = new (std::nothrow) int[data.size];
+
+  if (!data.sup || !data.inf)
+    return 0;
 
   int offset = h() / 2;
   int zero   = y() + offset; // center, zero amplitude (-inf dB)
@@ -186,89 +189,81 @@ int geWaveform::alloc(int datasize)
 
 void geWaveform::recalcPoints()
 {
-  selectionA = relativePoint(selectionA_abs);
-  selectionB = relativePoint(selectionB_abs);
-  chanStart  = relativePoint(chan->begin / 2);
-
-  /* fix the rounding error when chanEnd is set on the very end of the
-   * sample */
-
-  if (chan->end == chan->wave->size)
-    chanEnd = data.size - 2; // 2 px border
-  else
-    chanEnd = relativePoint(chan->end / 2);
+  selection.aPixel = relativePoint(selection.aFrame);
+  selection.bPixel = relativePoint(selection.bFrame);
+  chanStart = relativePoint(chan->begin / 2);
+  chanEnd   = relativePoint(chan->end / 2);
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void geWaveform::draw()
+void geWaveform::drawSelection()
 {
-  /* blank canvas */
-
-  fl_rectf(x(), y(), w(), h(), COLOR_BG_0);
-
-  /* draw selection (if any) */
+  if (!isSelected()) 
+    return;
 
-  if (selectionA != selectionB) {
+  int a_x = selection.aPixel + x(); // - start;
+  int b_x = selection.bPixel + x(); //  - start;
 
-    int a_x = selectionA + x() - BORDER; // - start;
-    int b_x = selectionB + x() - BORDER; //  - start;
+  if (a_x < 0)
+    a_x = 0;
+  if (b_x >= w() + BORDER)
+    b_x = w() + BORDER;
 
-    if (a_x < 0)
-      a_x = 0;
-    if (b_x >= w()-1)
-      b_x = w()-1;
+  if (selection.aPixel < selection.bPixel)
+    fl_rectf(a_x, y(), b_x-a_x, h(), G_COLOR_GREY_4);
+  else
+    fl_rectf(b_x, y(), a_x-b_x, h(), G_COLOR_GREY_4);
+}
 
-    if (selectionA < selectionB)
-      fl_rectf(a_x+BORDER, y(), b_x-a_x, h(), COLOR_BD_0);
-    else
-      fl_rectf(b_x+BORDER, y(), a_x-b_x, h(), COLOR_BD_0);
-  }
 
-  /* draw waveform from x1 (offset driven by the scrollbar) to x2
-   * (width of parent window). We don't draw the entire waveform,
-   * only the visibile part. */
+/* -------------------------------------------------------------------------- */
 
-  int offset = h() / 2;
-  int zero   = y() + offset; // sample zero (-inf dB)
 
-  int wx1 = abs(x() - ((geWaveTools*)parent())->x());
-  int wx2 = wx1 + ((geWaveTools*)parent())->w();
-  if (x()+w() < ((geWaveTools*)parent())->w())
-    wx2 = x() + w() - BORDER;
+void geWaveform::drawWaveform(int from, int to)
+{
+  int zero = y() + (h() / 2); // zero amplitude (-inf dB)
 
-  fl_color(0, 0, 0);
-  for (int i=wx1; i<wx2; i++) {
+  fl_color(G_COLOR_BLACK);
+  for (int i=from; i<to; i++) {
     fl_line(i+x(), zero, i+x(), data.sup[i]);
     fl_line(i+x(), zero, i+x(), data.inf[i]);
+  }
+}
+
+
+/* -------------------------------------------------------------------------- */
 
-    /* print grid */
 
+void geWaveform::drawGrid(int from, int to)
+{
+  fl_color(G_COLOR_GREY_3);
+  fl_line_style(FL_DASH, 1, nullptr);
+  for (int i=from; i<to; i++) {
     for (unsigned k=0; k<grid.points.size(); k++) {
-      if (grid.points.at(k) == i) {
-        //gu_log("draw grid line at %d\n", i);
-        fl_color(fl_rgb_color(54, 54, 54));
-        fl_line_style(FL_DASH, 0, nullptr);
-        fl_line(i+x(), y(), i+x(), y()+h());
-        fl_color(0, 0, 0);
-        fl_line_style(FL_SOLID, 0, nullptr);
-        break;
-      }
+      if (grid.points.at(k) != i) 
+        continue;
+      fl_line(i+x(), y(), i+x(), y()+h());
+      break;
     }
   }
+  fl_line_style(FL_SOLID, 0, nullptr);
+}
+
 
-  /* border box */
+/* -------------------------------------------------------------------------- */
 
-  fl_rect(x(), y(), w(), h(), COLOR_BD_0);
 
+void geWaveform::drawStartEndPoints()
+{
   /* print chanStart */
 
-  int lineX = x()+chanStart+1;
+  int lineX = chanStart + x();
 
-  if (chanStartLit) fl_color(COLOR_BD_1);
-  else              fl_color(COLOR_BD_0);
+  if (chanStartLit) fl_color(G_COLOR_LIGHT_2);
+  else              fl_color(G_COLOR_LIGHT_1);
 
   /* vertical line */
 
@@ -283,9 +278,11 @@ void geWaveform::draw()
 
   /* print chanEnd */
 
-  lineX = x()+chanEnd;
-  if (chanEndLit) fl_color(COLOR_BD_1);
-  else            fl_color(COLOR_BD_0);
+  lineX = chanEnd + x() - 1;
+  if (chanEndLit) fl_color(G_COLOR_LIGHT_2);
+  else            fl_color(G_COLOR_LIGHT_1);
+
+  /* vertical line */
 
   fl_line(lineX, y()+1, lineX, y()+h()-2);
 
@@ -299,6 +296,48 @@ void geWaveform::draw()
 /* -------------------------------------------------------------------------- */
 
 
+void geWaveform::drawPlayHead()
+{
+  if (chan->status == STATUS_OFF)
+    return;
+  int p = ceilf(chan->tracker / ratio) + x();
+  fl_color(G_COLOR_LIGHT_2);
+  fl_line(p, y() + 1, p, y() + h() - 2);
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void geWaveform::draw()
+{
+  assert(data.sup != nullptr);
+  assert(data.inf != nullptr);
+
+  fl_rectf(x(), y(), w(), h(), G_COLOR_GREY_2);  // blank canvas
+
+  /* Draw things from 'from' (offset driven by the scrollbar) to 'to' (width of 
+  parent window). We don't draw the entire waveform, only the visibile part. */
+
+  int from = abs(x() - parent()->x());
+  int to = from + parent()->w();
+  if (x() + w() < parent()->w())
+    to = x() + w() - BORDER;
+
+  drawSelection();
+  drawWaveform(from, to);
+  drawGrid(from, to);
+  drawPlayHead();
+
+  fl_rect(x(), y(), w(), h(), G_COLOR_GREY_4);   // border box
+  
+  drawStartEndPoints();
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
 int geWaveform::handle(int e)
 {
   int ret = 0;
@@ -311,47 +350,50 @@ int geWaveform::handle(int e)
       pushed = true;
 
       if (!mouseOnEnd() && !mouseOnStart()) {
-
-        /* right button? show the menu. Don't set selectionA,B,etc */
-
-        if (Fl::event_button3()) {
-          openEditMenu();
+        if (Fl::event_button3()) {  // let the parent (waveTools) handle this
+          ret = 0;
+          break;
         }
+        if (mouseOnSelectionA())
+          resizedA = true;
         else
-        if (mouseOnSelectionA() || mouseOnSelectionB()) {
-          resized = true;
-        }
+        if(mouseOnSelectionB())
+          resizedB = true;
         else {
           dragged = true;
-          selectionA = Fl::event_x() - x();
-
-          if (selectionA >= data.size) selectionA = data.size;
-
-          selectionB = selectionA;
-          selectionA_abs = absolutePoint(selectionA);
-          selectionB_abs = selectionA_abs;
+          selection.aPixel = Fl::event_x() - x();
+          selection.bPixel = selection.aPixel;
         }
       }
-
       ret = 1;
       break;
     }
 
     case FL_RELEASE: {
 
-      int realChanStart = chan->begin;
-      int realChanEnd   = chan->end;
+      /* If selection has been done (dragged or resized), make sure that point A 
+      is always lower than B. */
 
-      if (chanStartLit)
-        realChanStart = absolutePoint(chanStart)*2;
-      else
-      if (chanEndLit)
-        realChanEnd = absolutePoint(chanEnd)*2;
+      if (dragged || resizedA || resizedB)
+        fixSelection();
+
+      /* Handle begin/end markers interaction. */
 
-      glue_setBeginEndChannel(chan, realChanStart, realChanEnd);
+      if (chanStartLit || chanEndLit) {
+        int realChanStart = chan->begin;
+        int realChanEnd   = chan->end;
+        if (chanStartLit)
+          realChanStart = absolutePoint(chanStart) * 2;
+        else
+        if (chanEndLit)
+          realChanEnd = absolutePoint(chanEnd) * 2;
+        sampleEditor::setBeginEndChannel(chan, realChanStart, realChanEnd);
+      }
 
-      pushed  = false;
-      dragged = false;
+      pushed   = false;
+      dragged  = false;
+      resizedA = false;
+      resizedB = false;
 
       redraw();
       ret = 1;
@@ -397,10 +439,10 @@ int geWaveform::handle(int e)
         redraw();
       }
 
-      if (mouseOnSelectionA())
+      if (mouseOnSelectionA() && isSelected())
         fl_cursor(FL_CURSOR_WE, FL_WHITE, FL_BLACK);
       else
-      if (mouseOnSelectionB())
+      if (mouseOnSelectionB() && isSelected())
         fl_cursor(FL_CURSOR_WE, FL_WHITE, FL_BLACK);
       else
         fl_cursor(FL_CURSOR_DEFAULT, FL_WHITE, FL_BLACK);
@@ -424,7 +466,7 @@ int geWaveform::handle(int e)
           chanStart = 0;
         else
         if (chanStart >= chanEnd)
-          chanStart = chanEnd-2;
+          chanStart = chanEnd - 2;
 
         redraw();
       }
@@ -436,8 +478,8 @@ int geWaveform::handle(int e)
         if (grid.snap)
           chanEnd = applySnap(chanEnd);
 
-        if (chanEnd >= data.size - 2)
-          chanEnd = data.size - 2;
+        if (chanEnd > data.size)
+          chanEnd = data.size;
         else
         if (chanEnd <= chanStart)
           chanEnd = chanStart + 2;
@@ -445,42 +487,27 @@ int geWaveform::handle(int e)
         redraw();
       }
 
-      /* here the mouse is on the waveform, i.e. a selection */
+      /* Here the mouse is on the waveform, i.e. a new selection has started. */
 
       else
       if (dragged) {
-
-        selectionB = Fl::event_x() - x();
-
-        if (selectionB >= data.size)
-          selectionB = data.size;
-
-        if (selectionB <= 0)
-          selectionB = 0;
-
+        selection.bPixel = Fl::event_x() - x();
         if (grid.snap)
-          selectionB = applySnap(selectionB);
-
-        selectionB_abs = absolutePoint(selectionB);
+          selection.bPixel = applySnap(selection.bPixel);
         redraw();
       }
 
       /* here the mouse is on a selection boundary i.e. resize */
 
       else
-      if (resized) {
+      if (resizedA || resizedB) {
         int pos = Fl::event_x() - x();
-        if (mouseOnSelectionA()) {
-          selectionA     = grid.snap ? applySnap(pos) : pos;
-          selectionA_abs = absolutePoint(selectionA);
-        }
-        else
-        if (mouseOnSelectionB()) {
-          selectionB     = grid.snap ? applySnap(pos) : pos;
-          selectionB_abs = absolutePoint(selectionB);
-        }
+        if (grid.snap)
+          pos = applySnap(pos);
+        resizedA ? selection.aPixel = pos : selection.bPixel = pos;
         redraw();
       }
+
       mouseX = Fl::event_x();
       ret = 1;
       break;
@@ -492,12 +519,12 @@ int geWaveform::handle(int e)
 
 /* -------------------------------------------------------------------------- */
 
-/* pixel snap disances (10px) must be equal to those defined in
- * geWaveform::mouseOnSelectionA() and gWaverfrom::mouseOnSelectionB() */
-/* TODO - use constant for 10px */
 
 int geWaveform::applySnap(int pos)
 {
+  /* Pixel snap disances (SNAPPING) must be equal to those defined in 
+  mouseOnSelectionA() and mouseOnSelectionB(). */
+
   for (unsigned i=0; i<grid.points.size(); i++) {
     if (pos >= grid.points.at(i) - SNAPPING &&
         pos <= grid.points.at(i) + SNAPPING)
@@ -514,8 +541,8 @@ int geWaveform::applySnap(int pos)
 
 bool geWaveform::mouseOnStart()
 {
-  return mouseX-10 >  chanStart + x() - BORDER              &&
-         mouseX-10 <= chanStart + x() - BORDER + FLAG_WIDTH &&
+  return mouseX - (FLAG_WIDTH / 2) >  chanStart + x() - BORDER              &&
+         mouseX - (FLAG_WIDTH / 2) <= chanStart + x() - BORDER + FLAG_WIDTH &&
          mouseY    >  h() + y() - FLAG_HEIGHT;
 }
 
@@ -525,8 +552,8 @@ bool geWaveform::mouseOnStart()
 
 bool geWaveform::mouseOnEnd()
 {
-  return mouseX-10 >= chanEnd + x() - BORDER - FLAG_WIDTH &&
-         mouseX-10 <= chanEnd + x() - BORDER              &&
+  return mouseX - (FLAG_WIDTH / 2) >= chanEnd + x() - BORDER - FLAG_WIDTH &&
+         mouseX - (FLAG_WIDTH / 2) <= chanEnd + x() - BORDER              &&
          mouseY    <= y() + FLAG_HEIGHT + 1;
 }
 
@@ -538,17 +565,15 @@ bool geWaveform::mouseOnEnd()
 
 bool geWaveform::mouseOnSelectionA()
 {
-  if (selectionA == selectionB)
-    return false;
-  return mouseX >= selectionA-10+x() && mouseX <= selectionA+10+x();
+  return mouseX >= selection.aPixel - (FLAG_WIDTH / 2) + x() && 
+         mouseX <= selection.aPixel + (FLAG_WIDTH / 2) + x();
 }
 
 
 bool geWaveform::mouseOnSelectionB()
 {
-  if (selectionA == selectionB)
-    return false;
-  return mouseX >= selectionB-10+x() && mouseX <= selectionB+10+x();
+  return mouseX >= selection.bPixel - (FLAG_WIDTH / 2) + x() && 
+         mouseX <= selection.bPixel + (FLAG_WIDTH / 2) + x();
 }
 
 
@@ -579,235 +604,139 @@ int geWaveform::relativePoint(int p)
 /* -------------------------------------------------------------------------- */
 
 
-void geWaveform::openEditMenu()
+void geWaveform::fixSelection()
 {
-  if (selectionA == selectionB)
-    return;
-
-  menuOpen = true;
-
-  Fl_Menu_Item menu[] = {
-    {"Cut"},
-    {"Trim"},
-    {"Silence"},
-    {"Fade in"},
-    {"Fade out"},
-    {"Smooth edges"},
-    {"Set start/end here"},
-    {0}
-  };
-
-  if (chan->status == STATUS_PLAY) {
-    menu[0].deactivate();
-    menu[1].deactivate();
-  }
-
-  Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50);
-  b->box(G_CUSTOM_BORDER_BOX);
-  b->textsize(GUI_FONT_SIZE_BASE);
-  b->textcolor(COLOR_TEXT_0);
-  b->color(COLOR_BG_0);
+  if (selection.aPixel > selection.bPixel) // inverted selection
+    std::swap(selection.aPixel, selection.bPixel);
+  selection.aFrame = absolutePoint(selection.aPixel);
+  selection.bFrame = absolutePoint(selection.bPixel);
+}
 
-  const Fl_Menu_Item *m = menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b);
-  if (!m) {
-    menuOpen = false;
-    return;
-  }
 
-  /* straightSel() to ensure that point A is always lower than B */
+/* -------------------------------------------------------------------------- */
 
-  straightSel();
 
-  if (strcmp(m->label(), "Silence") == 0) {
-    wfx_silence(chan->wave, absolutePoint(selectionA), absolutePoint(selectionB));
+void geWaveform::clearSel()
+{
+  selection.aPixel = 0;
+  selection.bPixel = 0;
+  selection.aFrame = 0;
+  selection.bFrame = 0;  
+}
 
-    selectionA = 0;
-    selectionB = 0;
 
-    stretchToWindow();
-    redraw();
-    menuOpen = false;
-    return;
-  }
-
-  if (strcmp(m->label(), "Set start/end here") == 0) {
+/* -------------------------------------------------------------------------- */
 
-    glue_setBeginEndChannel(chan, absolutePoint(selectionA) * 2, 
-      absolutePoint(selectionB) * 2); // stereo values
 
-    selectionA     = 0;
-    selectionB     = 0;
-    selectionA_abs = 0;
-    selectionB_abs = 0;
+void geWaveform::setZoom(int type)
+{
+  int newSize = type == ZOOM_IN ? data.size * 2 : data.size / 2;
 
-    recalcPoints();
-    redraw();
-    menuOpen = false;
+  if (!alloc(newSize)) 
     return;
-  }
-
-  if (strcmp(m->label(), "Cut") == 0) {
-    wfx_cut(chan->wave, absolutePoint(selectionA), absolutePoint(selectionB));
-
-    /* for convenience reset start/end points */
-
-    glue_setBeginEndChannel(chan, 0, chan->wave->size);
 
-    selectionA     = 0;
-    selectionB     = 0;
-    selectionA_abs = 0;
-    selectionB_abs = 0;
+  size(newSize, h());
 
-    setZoom(0);
+  /* zoom to pointer */
 
-    menuOpen = false;
-    return;
-  }
-
-  if (strcmp(m->label(), "Trim") == 0) {
-    wfx_trim(chan->wave, absolutePoint(selectionA), absolutePoint(selectionB));
-
-    glue_setBeginEndChannel(chan, 0, chan->wave->size);
+  int shift;
+  if (x() > 0)
+    shift = Fl::event_x() - x();
+  else
+  if (type == ZOOM_IN)
+    shift = Fl::event_x() + abs(x());
+  else
+    shift = (Fl::event_x() + abs(x())) / -2;
 
-    selectionA     = 0;
-    selectionB     = 0;
-    selectionA_abs = 0;
-    selectionB_abs = 0;
+  if (x() - shift > BORDER)
+    shift = 0;
 
-    stretchToWindow();
-    menuOpen = false;
-    redraw();
-    return;
-  }
+  position(x() - shift, y());
 
-  if (!strcmp(m->label(), "Fade in") || !strcmp(m->label(), "Fade out")) {
 
-    int type = !strcmp(m->label(), "Fade in") ? 0 : 1;
-    wfx_fade(chan->wave, absolutePoint(selectionA), absolutePoint(selectionB), type);
+  /* avoid overflow when zooming out with scrollbar like that:
+   * |----------[scrollbar]|
+   *
+   * offset vs smaller:
+   * |[wave------------| offset > 0  smaller = false
+   * |[wave----]       | offset < 0, smaller = true
+   * |-------------]   | offset < 0, smaller = false  */
 
-    selectionA = 0;
-    selectionB = 0;
+  int  parentW = parent()->w();
+  int  thisW   = x() + w() - BORDER;           // visible width, not full width
 
+  if (thisW < parentW)
+    position(x() + parentW - thisW, y());
+  if (smaller())
     stretchToWindow();
-    redraw();
-    menuOpen = false;
-    return;
-  }
-
-  if (!strcmp(m->label(), "Smooth edges")) {
-
-    wfx_smooth(chan->wave, absolutePoint(selectionA), absolutePoint(selectionB));
 
-    selectionA = 0;
-    selectionB = 0;
-
-    stretchToWindow();
-    redraw();
-    menuOpen = false;
-    return;
-  }
+  redraw();
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void geWaveform::straightSel()
+void geWaveform::stretchToWindow()
 {
-  if (selectionA > selectionB) {
-    unsigned tmp = selectionB;
-    selectionB = selectionA;
-    selectionA = tmp;
-  }
+  int s = parent()->w();
+  alloc(s);
+  position(BORDER, y());
+  size(s, h());
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void geWaveform::setZoom(int type)
+void geWaveform::refresh()
 {
-  int newSize;
-  if (type == -1) newSize = data.size*2;  // zoom in
-  else            newSize = data.size/2;  // zoom out
-
-  if (alloc(newSize)) {
-    size(data.size, h());
-
-    /* zoom to pointer */
-
-    int shift;
-    if (x() > 0)
-      shift = Fl::event_x() - x();
-    else
-    if (type == -1)
-      shift = Fl::event_x() + abs(x());
-    else
-      shift = (Fl::event_x() + abs(x())) / -2;
-
-    if (x() - shift > BORDER)
-      shift = 0;
-
-    position(x() - shift, y());
-
+  alloc(data.size);
+  redraw();
+}
 
-    /* avoid overflow when zooming out with scrollbar like that:
-     * |----------[scrollbar]|
-     *
-     * offset vs smaller:
-     * |[wave------------| offset > 0  smaller = false
-     * |[wave----]       | offset < 0, smaller = true
-     * |-------------]   | offset < 0, smaller = false  */
 
-    int  parentW = ((geWaveTools*)parent())->w();
-    int  thisW   = x() + w() - BORDER;           // visible width, not full width
+/* -------------------------------------------------------------------------- */
 
-    if (thisW < parentW)
-      position(x() + parentW - thisW, y());
-    if (smaller())
-      stretchToWindow();
 
-    redraw();
-  }
+bool geWaveform::smaller()
+{
+  return w() < parent()->w();
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void geWaveform::stretchToWindow()
+void geWaveform::setGridLevel(int l)
 {
-  int s = ((geWaveTools*)parent())->w();
-  alloc(s);
-  position(BORDER, y());
-  size(s, h());
+  grid.points.clear();
+  grid.level = l;
+  alloc(data.size);
+  redraw();
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-bool geWaveform::smaller()
+bool geWaveform::isSelected()
 {
-  return w() < ((geWaveTools*)parent())->w();
+  return selection.aPixel != selection.bPixel;
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-float geWaveform::displayRatio()
+int geWaveform::getSelectionA()
 {
-    return 1.0f / (data.size / (float) w());
-};
-
-/* -------------------------------------------------------------------------- */
+  return selection.aFrame;
+}
 
 
-void geWaveform::setGridLevel(int l)
+int geWaveform::getSelectionB()
 {
-  grid.points.clear();
-  grid.level = l;
-  alloc(data.size);
-  redraw();
+  return selection.bFrame;
 }
+
index f84ec87738634cd33759a46d0b2ca263d7e0c630..8f7cc8f8cb85a4d7c659365bad0f0b258d6bd75d 100644 (file)
@@ -2,9 +2,6 @@
  *
  * Giada - Your Hardcore Loopmachine
  *
- * ge_waveform
- * an element which represents a waveform.
- *
  * -----------------------------------------------------------------------------
  *
  * Copyright (C) 2010-2017 Giovanni A. Zuliani | Monocasual
@@ -45,89 +42,103 @@ private:
 
        static const int FLAG_WIDTH  = 20;
        static const int FLAG_HEIGHT = 20;
-       static const int BORDER      = 8;                               // window border <-> widget border
+       static const int BORDER      = 8;  // window border <-> widget border
        static const int SNAPPING    = 10;
 
+       /* selection
+       Portion of the selected wave, in pixel and in frames. */
+
+       struct
+       {
+               int aPixel;
+               int bPixel;
+               int aFrame;
+               int bFrame;
+       } selection;
+
        /* data
-        * real graphic stuff from the underlying waveform */
+       Real graphic stuff from the underlying waveform. */
 
-       struct data
+       struct
   {
-               int *sup;
-               int *inf;
-               int  size;
+               int* sup;   // upper part of the waveform
+               int* inf;   // lower ""   "" ""  ""
+               int  size;  // width of the waveform to draw (in pixel)
        } data;
 
-       /* grid */
-
-       struct grid
+       struct
   {
                bool snap;
                int level;
                std::vector<int> points;
        } grid;
 
-       /* chan
-        * chan in use. */
-
-       SampleChannel *chan;
-
-       /* menuOpen
-        * is the menu open? */
-
-       bool menuOpen;
+       SampleChannel* chan;
 
        /* mouseOnStart/end
-        * is mouse on start or end flag? */
+       Is mouse on start or end flag? */
 
        bool mouseOnStart();
        bool mouseOnEnd();
 
        /* mouseOnSelectionA/B
-        * as above, for the selection */
+       As above, for the selection. */
 
        bool mouseOnSelectionA();
        bool mouseOnSelectionB();
 
        /* absolutePoint
-        * from a relative 'p' point (zoom affected) returns the same point
-        * zoom 1:1 based */
+       From a relative 'p' point (zoom affected) returns the same point zoom 1:1 
+       based. */
 
        int absolutePoint(int p);
 
        /* relativePoint
-        * from an absolute 'p' point (1:1 zoom), returns the same point zoom
-        * affected */
+       From an absolute 'p' point (1:1 zoom) returns the same point zoom affected. */
 
        int relativePoint(int p);
 
-       /* straightSel
-        * helper function which flattens the selection if it was made from
-        * right to left (inverse selection) */
+       /* fixSelection
+       Helper function which flattens the selection if it was made from right to left 
+       (inverse selection). It also computes the absolute points. Call this one
+       whenever the selection gesture is done. */
 
-       void straightSel();
+       void fixSelection();
 
        /* freeData
-        * destroy any graphical buffer */
+       Destroys any graphical buffer. */
 
        void freeData();
 
        /* smaller
-        * is the waveform smaller than the parent window? */
+       Is the waveform smaller than the parent window? */
 
        bool smaller();
 
   /* applySnap
-   * snap a point at 'pos' pixel */
+  Snap a point at 'pos' pixel. */
 
   int applySnap(int pos);
 
+  /* draw*
+  Drawing functions. */
+
+  void drawSelection();
+  void drawWaveform(int from, int to);
+  void drawGrid(int from, int to);
+  void drawStartEndPoints();
+  void drawPlayHead();
+
 public:
 
-       geWaveform(int x, int y, int w, int h, SampleChannel *ch, const char *l=0);
+       static const int ZOOM_IN  = -1;
+       static const int ZOOM_OUT = 0;
+
+       geWaveform(int x, int y, int w, int h, SampleChannel* ch, const char* l=0);
        ~geWaveform();
-       void draw();
-       int  handle(int e);
+
+       void draw() override;
+       int  handle(int e) override;
 
        /* alloc
         * allocate memory for the picture */
@@ -139,16 +150,6 @@ public:
 
        void recalcPoints();
 
-       /* openEditMenu
-        * show edit menu on right-click */
-
-       void openEditMenu();
-
-       /* displayRatio
-        * how much of the waveform is being displayed on screen */
-
-       float displayRatio();
-
        /* zoom
         * type == 1 : zoom out, type == -1: zoom in */
 
@@ -159,6 +160,11 @@ public:
 
        void stretchToWindow();
 
+       /* refresh
+       Redraws the waveform. */
+
+       void refresh();
+
        /* setGridLevel
         * set a new frequency level for the grid. 0 means disabled. */
 
@@ -167,7 +173,20 @@ public:
   void setSnap(bool v) { grid.snap = v; }
   bool getSnap()       { return grid.snap; }
 
-       inline int getSize() { return data.size; }
+       int getSize() { return data.size; }
+
+       /* isSelected
+       Tells whether a portion of the waveform has been selected. */
+
+       bool isSelected();
+
+       int getSelectionA();
+       int getSelectionB();
+
+       /* clearSel
+       Removes any active selection. */
+
+       void clearSel();
 
        int  chanStart;
        bool chanStartLit;
@@ -175,22 +194,11 @@ public:
        bool chanEndLit;
        bool pushed;
        bool dragged;
-       bool resized;
-
+       bool resizedA;
+       bool resizedB;
        float ratio;
-
-  /* TODO - useless! use Fl::mouse_x() and Fl::mouse_y() instead */
-       int  mouseX;                                     // mouse pos for drag.n.drop
-       int  mouseY;
-
-       /* selectionA/B  = portion of the selected wave
-        * " " "" " _abs = selectionA/B not affected by zoom */
-       /** TODO - change selectionA to selectionA_rel
-           TODO - change selectionB to selectionB_rel */
-       int selectionA;
-       int selectionB;
-       int selectionA_abs;
-       int selectionB_abs;
+       int mouseX;
+       int mouseY;
 };
 
 
index d0b27fe27f4a7dfaad7ba9f1d045c9c03d1fb2dd..29f9aa9d91c09d69b7ef9211d18f59988e2a2978 100644 (file)
@@ -51,7 +51,7 @@ geSoundMeter::geSoundMeter(int x, int y, int w, int h, const char *L)
 
 void geSoundMeter::draw()
 {
-  fl_rect(x(), y(), w(), h(), COLOR_BD_0);
+  fl_rect(x(), y(), w(), h(), G_COLOR_GREY_4);
 
   /* peak = the highest value inside the frame */
 
@@ -69,7 +69,7 @@ void geSoundMeter::draw()
 
   dbLevel = 20 * log10(peak);
   if (dbLevel < dbLevelOld)
-    if (dbLevelOld > -G_DB_MIN_SCALE)
+    if (dbLevelOld > -G_MIN_DB_SCALE)
       dbLevel = dbLevelOld - 2.0f;
 
   dbLevelOld = dbLevel;
@@ -78,10 +78,10 @@ void geSoundMeter::draw()
 
   float px_level = 0.0f;
   if (dbLevel < 0.0f)
-    px_level = ((w()/G_DB_MIN_SCALE) * dbLevel) + w();
+    px_level = ((w()/G_MIN_DB_SCALE) * dbLevel) + w();
   else
     px_level = w();
 
-  fl_rectf(x()+1, y()+1, w()-2, h()-2, COLOR_BG_0);
-  fl_rectf(x()+1, y()+1, (int) px_level, h()-2, clip || !kernelAudio::getStatus() ? COLOR_ALERT : COLOR_BD_0);
+  fl_rectf(x()+1, y()+1, w()-2, h()-2, G_COLOR_GREY_2);
+  fl_rectf(x()+1, y()+1, (int) px_level, h()-2, clip || !kernelAudio::getStatus() ? G_COLOR_RED_ALERT : G_COLOR_GREY_4);
 }
index f02b575efe155439a7560cbc8a9360ecc26fc348..9e265a4dce2a9e0ec6e847c6d4dd1177af6a3101 100644 (file)
@@ -89,9 +89,9 @@ void *videoThreadCb(void *arg)
                while (!G_quit) {
                        gu_refreshUI();
 #ifdef _WIN32
-                       Sleep(GUI_SLEEP);
+                       Sleep(G_GUI_SLEEP);
 #else
-                       usleep(GUI_SLEEP);
+                       usleep(G_GUI_SLEEP);
 #endif
                }
        pthread_exit(nullptr);
index 5d9e8af95b7a0ff51c0da4cce941fcf202ccfa50..53c166a7b3f8a8805b7cb9d559681c6396c4f323 100644 (file)
@@ -38,7 +38,7 @@
 #include <sys/stat.h>   // stat (gu_dirExists)
 #include <errno.h>
 #include <cstdlib>
-#ifdef __APPLE__  // our Clans still doesn't know about cstdint (c++11 stuff)
+#ifdef __APPLE__  // our Clang still doesn't know about cstdint (c++11 stuff)
        #include <stdint.h>
 #else
        #include <cstdint>
index 1b5a0441f7fe53973c200ccf30714596ef8aa105..b7ea894360e42365d13d10680e24c9ce713f52a6 100644 (file)
 #include "../gui/dialogs/gd_mainWindow.h"
 #include "../gui/dialogs/gd_actionEditor.h"
 #include "../gui/dialogs/window.h"
+#include "../gui/dialogs/sampleEditor.h"
 #include "../gui/elems/mainWindow/mainIO.h"
 #include "../gui/elems/mainWindow/mainTimer.h"
 #include "../gui/elems/mainWindow/mainTransport.h"
 #include "../gui/elems/mainWindow/beatMeter.h"
 #include "../gui/elems/mainWindow/keyboard/keyboard.h"
 #include "../gui/elems/mainWindow/keyboard/channel.h"
+#include "../gui/elems/sampleEditor/waveTools.h"
 #include "log.h"
 #include "string.h"
 #include "gui.h"
@@ -82,6 +84,12 @@ void gu_refreshUI()
        if (blinker > 12)
                blinker = 0;
 
+       /* If Sample Editor is open, repaint it (for dynamic play head). */
+
+       gdSampleEditor* se = static_cast<gdSampleEditor*>(gu_getSubwindow(G_MainWin, WID_SAMPLE_EDITOR));
+       if (se)
+               se->waveTools->redrawWaveformAsync();
+
        /* redraw GUI */
 
        Fl::unlock();