[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src commands/Gain.cpp commands/Gain.h ...
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src commands/Gain.cpp commands/Gain.h ... |
Date: |
Tue, 12 Feb 2008 20:39:08 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 08/02/12 20:39:08
Modified files:
src/commands : Gain.cpp Gain.h
src/core : Command.cpp Command.h InputEngine.cpp
InputEngine.h ViewPort.cpp
Log message:
* give number collection a shot. Commands using it: Gain.
I'm not to fond of it yet, maybe the 'numerical editing' part should be
done in the hold cursor with a 'line edit like thing' ?
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/Gain.cpp?cvsroot=traverso&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/Gain.h?cvsroot=traverso&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Command.cpp?cvsroot=traverso&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Command.h?cvsroot=traverso&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/InputEngine.cpp?cvsroot=traverso&r1=1.68&r2=1.69
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/InputEngine.h?cvsroot=traverso&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ViewPort.cpp?cvsroot=traverso&r1=1.34&r2=1.35
Patches:
Index: commands/Gain.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/commands/Gain.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- commands/Gain.cpp 12 Feb 2008 11:01:08 -0000 1.25
+++ commands/Gain.cpp 12 Feb 2008 20:39:07 -0000 1.26
@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-$Id: Gain.cpp,v 1.25 2008/02/12 11:01:08 r_sijrier Exp $
+$Id: Gain.cpp,v 1.26 2008/02/12 20:39:07 r_sijrier Exp $
*/
#include "Gain.h"
@@ -139,6 +139,32 @@
undo_action();
}
+void Gain::set_collected_number(const QString & collected)
+{
+ if (collected.size() == 0) {
+ cpointer().get_viewport()->set_holdcursor_text(" dB");
+ return;
+ }
+
+ bool ok;
+ float dbFactor = collected.toDouble(&ok);
+ if (!ok) {
+ PWARN("collected is not a valid float number");
+ return;
+ }
+
+ newGain = dB_to_scale_factor(dbFactor);
+ QMetaObject::invokeMethod(gainObject, "set_gain", Q_ARG(float,
newGain));
+
+ // now we get the new gain value from gainObject, since we don't know
if
+ // gainobject accepted the change or not!
+ get_gain_from_object(newGain);
+
+ // Update the vieport's hold cursor with the _actuall_ gain value!
+
cpointer().get_viewport()->set_holdcursor_text(QByteArray::number(dbFactor,
'f', collected.size()).append(" dB"));
+
+}
+
void Gain::set_cursor_shape(int useX, int useY)
{
@@ -256,6 +282,3 @@
return 1;
}
-
-// eof
-
Index: commands/Gain.h
===================================================================
RCS file: /sources/traverso/traverso/src/commands/Gain.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- commands/Gain.h 21 Jan 2008 16:22:11 -0000 1.14
+++ commands/Gain.h 12 Feb 2008 20:39:08 -0000 1.15
@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- $Id: Gain.h,v 1.14 2008/01/21 16:22:11 r_sijrier Exp $
+ $Id: Gain.h,v 1.15 2008/02/12 20:39:08 r_sijrier Exp $
*/
#ifndef GAIN_H
@@ -46,7 +46,7 @@
int do_action();
int undo_action();
void cancel_action();
-
+ void set_collected_number(const QString & collected);
int jog();
Index: core/Command.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Command.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- core/Command.cpp 17 May 2007 22:50:22 -0000 1.20
+++ core/Command.cpp 12 Feb 2008 20:39:08 -0000 1.21
@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-$Id: Command.cpp,v 1.20 2007/05/17 22:50:22 r_sijrier Exp $
+$Id: Command.cpp,v 1.21 2008/02/12 20:39:08 r_sijrier Exp $
*/
#include "Command.h"
@@ -246,6 +246,21 @@
}
/**
+ * Reimplement this function to receive the so called 'collected number'
of the InputEngine
+
+ The number collection is active during Hold Actions. A Hold type of
command can use it
+ to let the user type in a numerical value, which is then parsed by the
(derived) Command class
+ to set the variable it controls, like the position of an AudioClip, or
the gain value of a Track
+ * @param collected The QString of the collected number so far. Note that it
can include a . (period) and
+ a , (comma), hence the number is supplied as a string,
and not a numerical value.
+ */
+void Command::set_collected_number(const QString & collected)
+{
+ Q_UNUSED(collected);
+ // reimplement me
+}
+
+/**
* Uses the mouse hints specified in the keymap.xml file to set a cursor
to hint the user which movement has to be made on hold type of commands
@@ -290,5 +305,3 @@
m_isHistorable = historible;
}
-//eof
-
Index: core/Command.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Command.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- core/Command.h 17 May 2007 22:50:22 -0000 1.12
+++ core/Command.h 12 Feb 2008 20:39:08 -0000 1.13
@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- $Id: Command.h,v 1.12 2007/05/17 22:50:22 r_sijrier Exp $
+ $Id: Command.h,v 1.13 2008/02/12 20:39:08 r_sijrier Exp $
*/
#ifndef COMMAND_H
@@ -47,6 +47,7 @@
virtual int jog();
virtual void set_cursor_shape(int useX, int useY);
virtual void cancel_action();
+ virtual void set_collected_number(const QString& collected);
void undo() {undo_action();}
void redo() {do_action();}
Index: core/InputEngine.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/InputEngine.cpp,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -b -r1.68 -r1.69
--- core/InputEngine.cpp 11 Feb 2008 10:11:52 -0000 1.68
+++ core/InputEngine.cpp 12 Feb 2008 20:39:08 -0000 1.69
@@ -652,6 +652,12 @@
return;
}
+ // first check if this fact is just a collected number
+ if (check_number_collection(eventcode)) {
+ // another digit was collected.
+ return;
+ }
+
if (is_modifier_keyfact(eventcode)) {
if ( (! isAutoRepeat) && (!
m_activeModifierKeys.contains(eventcode)) ) {
m_activeModifierKeys.append(eventcode);
@@ -878,13 +884,6 @@
fact1_k1 = k1;
fact1_k2 = k2;
- // first check if this fact is just a collected number
- check_number_collection();
- if (isCollecting) {
- // another digit was collected.
- reset();
- return;
- }
int mapIndex = identify_first_fact();
if (mapIndex < 0) {
PMESG3("First fact alone does not match anything in the
map. Waiting for a second fact...");
@@ -1599,29 +1598,46 @@
// Number colector
-void InputEngine::check_number_collection()
+bool InputEngine::check_number_collection(int eventcode)
{
- PENTER3;
- if ((fact1_k1 >= 0x30) && (fact1_k1 <= 0x39)) {
- if (!isCollecting) {
- PMESG3("Starting number collection...");
- sCollectedNumber="";
- }
- isCollecting = true;
- sCollectedNumber.append( QChar(fact1_k1) ); // it had a ",1"
complement after fact1_k1... why?
- PMESG3("Collected %s so far...", QS_C(sCollectedNumber) ) ;
+ if ((eventcode >= Qt::Key_0) && (eventcode <= Qt::Key_9) ||
+ eventcode == Qt::Key_Comma || eventcode == Qt::Key_Period) {
+ sCollectedNumber.append( QChar(eventcode) ); // it had a ",1"
complement after fact1_k1... why?
+ PMESG("Collected %s so far...", QS_C(sCollectedNumber) ) ;
QString sn = "NUMBER " + sCollectedNumber;
collectedNumber = sCollectedNumber.toInt();
- } else
- stop_collecting();
+ if (holdingCommand) {
+ holdingCommand->set_collected_number(sCollectedNumber);
+ }
+ return true;
+ }
+ if (eventcode == Qt::Key_Backspace) {
+ if (sCollectedNumber.size() > 0) {
+ sCollectedNumber =
sCollectedNumber.left(sCollectedNumber.size() - 1);
+ if (holdingCommand) {
+
holdingCommand->set_collected_number(sCollectedNumber);
+ }
+ }
+ return true;
+ }
+ if (eventcode == Qt::Key_Minus) {
+ if (sCollectedNumber.contains("-")) {
+ sCollectedNumber = sCollectedNumber.remove("-");
+ } else {
+ sCollectedNumber.prepend("-");
+ }
+ if (holdingCommand) {
+ holdingCommand->set_collected_number(sCollectedNumber);
+ }
+ }
+ return false;
}
void InputEngine::stop_collecting()
{
PENTER3;
- isCollecting=false;
collectedNumber = sCollectedNumber.toInt();
- sCollectedNumber ="-1";
+ sCollectedNumber = "";
}
int InputEngine::collected_number( )
Index: core/InputEngine.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/InputEngine.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- core/InputEngine.h 8 Jun 2007 18:37:42 -0000 1.27
+++ core/InputEngine.h 12 Feb 2008 20:39:08 -0000 1.28
@@ -193,7 +193,6 @@
bool isFirstFact;
bool isDoubleKey;
bool isJogging;
- bool isCollecting;
bool m_cancelHold;
int fact1_k1;
@@ -230,7 +229,7 @@
void conclusion();
void hold_output();
void stop_collecting();
- void check_number_collection();
+ bool check_number_collection(int eventcode);
//! call the slot that handler a given action
int broadcast_action(IEAction* action, bool autorepeat=false, bool
fromContextMenu=false);
@@ -250,8 +249,6 @@
// allow this function to create one instance
friend InputEngine& ie();
-
-
};
// use this function to get the InputEngine object
Index: core/ViewPort.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ViewPort.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- core/ViewPort.cpp 12 Feb 2008 18:40:06 -0000 1.34
+++ core/ViewPort.cpp 12 Feb 2008 20:39:08 -0000 1.35
@@ -384,4 +384,3 @@
setPos(p);
}
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src commands/Gain.cpp commands/Gain.h ...,
Remon Sijrier <=