diff options
author | Robert Jonsson <spamatica@gmail.com> | 2011-03-07 19:01:11 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2011-03-07 19:01:11 +0000 |
commit | e40fc849149dd97c248866a4a1d026dda5e57b62 (patch) | |
tree | b12b358f3b3a0608001d30403358f8443118ec5f /attic/muse2-oom/muse2/muse/widgets | |
parent | 1bd4f2e8d9745cabb667b043171cad22c8577768 (diff) |
clean3
Diffstat (limited to 'attic/muse2-oom/muse2/muse/widgets')
166 files changed, 35118 insertions, 0 deletions
diff --git a/attic/muse2-oom/muse2/muse/widgets/CMakeLists.txt b/attic/muse2-oom/muse2/muse/widgets/CMakeLists.txt new file mode 100644 index 00000000..1feb1ae4 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/CMakeLists.txt @@ -0,0 +1,236 @@ +#============================================================================= +# MusE +# Linux Music Editor +# $Id:$ +# +# Copyright (C) 2002-2006 by Werner Schweer and others +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2. +# +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#============================================================================= + +## +## Expand Qt macros in source files +## +QT4_WRAP_CPP (widget_mocs + aboutbox_impl.h + action.h + bigtime.h + canvas.h + checkbox.h + comboQuant.h + combobox.h + comment.h + ctrlcombo.h + dentry.h + didyouknow.h + doublelabel.h + filedialog.h + gatetime.h + genset.h + header.h + hitscale.h + intlabel.h + knob.h + lcombo.h + metronome.h + midisyncimpl.h + mixdowndialog.h + mlabel.h + mtscale.h + pcscale.h + tvieweditor.h + pctablemodel.h + pctable.h + mtrackinfo.h + nentry.h + noteinfo.h + pitchedit.h + pitchlabel.h + popupmenu.h + # posedit.h + poslabel.h + projectcreateimpl.h + scrollscale.h + shortcutcapturedialog.h + shortcutconfig.h + # sigedit.h + siglabel.h + sigscale.h + slider.h + sliderbase.h + songinfo.h + spinbox.h + spinboxFP.h + splitter.h + swidget.h + tb1.h + tempolabel.h + tools.h + # ttoolbar.h + ttoolbutton.h + velocity.h + view.h + vscale.h + ) + +## +## UI files +## +file (GLOB widgets_ui_files + aboutbox.ui + appearancebase.ui + cliplisteditorbase.ui + commentbase.ui + configmidifilebase.ui + didyouknow.ui + editnotedialogbase.ui + editsysexdialogbase.ui + fdialogbuttons.ui + gatetimebase.ui + gensetbase.ui + itransformbase.ui + metronomebase.ui + midisync.ui + mittransposebase.ui + mixdowndialogbase.ui + mtrackinfobase.ui + projectcreate.ui + shortcutcapturedialogbase.ui + shortcutconfigbase.ui + songinfo.ui + synthconfigbase.ui + transformbase.ui + transposebase.ui + velocitybase.ui + trackvieweditorbase.ui + ) +QT4_WRAP_UI (widget_ui_headers ${widgets_ui_files}) + +## +## List of source files to compile +## +file (GLOB widgets_source_files + aboutbox_impl.cpp + bigtime.cpp + canvas.cpp + checkbox.cpp + citem.cpp + comboQuant.cpp + combobox.cpp + comment.cpp + ctrlcombo.cpp + dentry.cpp + dimap.cpp + doublelabel.cpp + drange.cpp + filedialog.cpp + gatetime.cpp + genset.cpp + header.cpp + hitscale.cpp + intlabel.cpp + knob.cpp + lcombo.cpp + metronome.cpp + midisyncimpl.cpp + mixdowndialog.cpp + mlabel.cpp + mmath.cpp + mtrackinfo.cpp + tvieweditor.cpp + mtscale.cpp + pcscale.cpp + pctablemodel.cpp + pctable.cpp + nentry.cpp + noteinfo.cpp + pitchedit.cpp + pitchlabel.cpp + popupmenu.cpp + # posedit.cpp + poslabel.cpp + projectcreateimpl.cpp + scldiv.cpp + scldraw.cpp + sclif.cpp + scrollscale.cpp + shortcutcapturedialog.cpp + shortcutconfig.cpp + # sigedit.cpp + siglabel.cpp + sigscale.cpp + slider.cpp + sliderbase.cpp + spinbox.cpp + spinboxFP.cpp + splitter.cpp + swidget.cpp + tb1.cpp + tempolabel.cpp + tools.cpp + ttoolbar.cpp + ttoolbutton.cpp + utils.cpp + velocity.cpp + view.cpp + vscale.cpp + ) + +## +## Define target +## +add_library ( widgets SHARED + ${widget_ui_headers} + ${widget_mocs} + ${widgets_source_files} + ) + +## +## Append to the list of translations +## +set (FILES_TO_TRANSLATE + ${FILES_TO_TRANSLATE} + ${widgets_source_files} + ${widgets_ui_files} + CACHE INTERNAL "" + ) + +## +## Compilation flags and target name +## +set_target_properties( widgets + # PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h ${MUSECXXFLAGS} -I../ -I${PROJECT_SOURCE_DIR}/synti " + PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h ${MUSECXXFLAGS} -I../ -I${PROJECT_SOURCE_DIR}/synti -fPIC" + OUTPUT_NAME muse_widgets + ) + +## +## Linkage +## +target_link_libraries ( widgets + ${QT_LIBRARIES} + icons + ) + +## +## Install location +## +install(TARGETS widgets + DESTINATION + ${MusE_MODULES_DIR} + ) + + + + + diff --git a/attic/muse2-oom/muse2/muse/widgets/aboutbox.ui b/attic/muse2-oom/muse2/muse/widgets/aboutbox.ui new file mode 100644 index 00000000..250f656f --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/aboutbox.ui @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>AboutBox</class> + <widget class="QDialog" name="AboutBox"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>350</width> + <height>160</height> + </rect> + </property> + <property name="windowTitle"> + <string>AboutBox</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QFrame" name="imageFrame"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout1"> + <item> + <widget class="QLabel" name="imageLabel"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <property name="lineWidth"> + <number>4</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QLabel" name="versionLabel"> + <property name="text"> + <string>Version 2 pre-alpha</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="textLabel1"> + <property name="text"> + <string>(C) Copyright 1999-2010 Werner Schweer and others. +See http://www.muse-sequencer.org for new versions and +more information. + +Published under the GNU Public License</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="doneHere"> + <property name="text"> + <string>&Keep On Rocking!</string> + </property> + <property name="shortcut"> + <string>Alt+K</string> + </property> + </widget> + </item> + </layout> + <zorder>versionLabel</zorder> + <zorder>textLabel1</zorder> + <zorder>doneHere</zorder> + <zorder>imageFrame</zorder> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections> + <connection> + <sender>doneHere</sender> + <signal>clicked()</signal> + <receiver>AboutBox</receiver> + <slot>close()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.cpp b/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.cpp new file mode 100644 index 00000000..bf370ab7 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.cpp @@ -0,0 +1,12 @@ +#include "aboutbox_impl.h" +#include "config.h" +#include "icons.h" + +AboutBoxImpl::AboutBoxImpl() +{ + setupUi(this); + imageLabel->setPixmap(*aboutMuseImage); + QString version(VERSION); + QString svnrevision(SVNVERSION); + versionLabel->setText("Version: " + version + " (svn revision: "+ svnrevision +")"); +} diff --git a/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.h b/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.h new file mode 100644 index 00000000..de75bfc9 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.h @@ -0,0 +1,16 @@ +#ifndef ABOUTBOXIMPL_H +#define ABOUTBOXIMPL_H + +#include "ui_aboutbox.h" + +class AboutBoxImpl : public QDialog, public Ui::AboutBox +{ + Q_OBJECT + +public: + AboutBoxImpl(); + + +}; + +#endif // ABOUTBOXIMPL_H diff --git a/attic/muse2-oom/muse2/muse/widgets/action.h b/attic/muse2-oom/muse2/muse/widgets/action.h new file mode 100644 index 00000000..7fa040c4 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/action.h @@ -0,0 +1,33 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: action.h,v 1.1.1.1.2.1 2008/01/19 13:33:46 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __ACTION_H__ +#define __ACTION_H__ + +#include <QAction> + +//--------------------------------------------------------- +// Action +//--------------------------------------------------------- + +class Action : public QAction { + Q_OBJECT + int _id; + + public: + Action(QObject* parent, int i, const char* name = 0, bool toggle = false) + : QAction(name, parent) { + _id = i; + setCheckable(toggle); + } + void setId(int i) { _id = i; } + int id() const { return _id; } + }; + + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/appearancebase.ui b/attic/muse2-oom/muse2/muse/widgets/appearancebase.ui new file mode 100644 index 00000000..92ab0c84 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/appearancebase.ui @@ -0,0 +1,1890 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>AppearanceDialogBase</class> + <widget class="QDialog" name="AppearanceDialogBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>538</width> + <height>531</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Appearance settings</string> + </property> + <layout class="QVBoxLayout"> + <item> + <widget class="QTabWidget" name="TabWidget2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab1"> + <attribute name="title"> + <string>Arranger</string> + </attribute> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="0"> + <widget class="QGroupBox" name="ButtonGroup3"> + <property name="title"> + <string>Parts</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QCheckBox" name="partShownames"> + <property name="text"> + <string>show names</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="partShowevents"> + <property name="text"> + <string>show events</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="partShowCakes"> + <property name="text"> + <string>show Cakewalk Style</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="1"> + <widget class="QGroupBox" name="eventButtonGroup"> + <property name="title"> + <string>Events</string> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="0"> + <widget class="QCheckBox" name="eventNoteon"> + <property name="text"> + <string>note on</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QCheckBox" name="eventPolypressure"> + <property name="text"> + <string>poly pressure</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="eventController"> + <property name="text"> + <string>controller</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="eventAftertouch"> + <property name="text"> + <string>aftertouch</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="eventPitchbend"> + <property name="text"> + <string>pitch bend</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QCheckBox" name="eventProgramchange"> + <property name="text"> + <string>program change</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QCheckBox" name="eventSpecial"> + <property name="text"> + <string>special</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QGroupBox" name="GroupBox2"> + <property name="title"> + <string>Background picture</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QTreeWidget" name="backgroundTree"> + <property name="uniformRowHeights"> + <bool>true</bool> + </property> + <property name="itemsExpandable"> + <bool>true</bool> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <attribute name="headerVisible"> + <bool>false</bool> + </attribute> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QPushButton" name="addBgButton"> + <property name="text"> + <string>add</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="removeBgButton"> + <property name="text"> + <string>remove</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="clearBgButton"> + <property name="text"> + <string>clear</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QCheckBox" name="arrGrid"> + <property name="text"> + <string>show snap grid</string> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab2" > + <attribute name="title"> + <string>Colors</string> + </attribute> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0" rowspan="2"> + <widget class="QTreeWidget" name="itemList"> + <property name="rootIsDecorated"> + <bool>true</bool> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <column> + <property name="text"> + <string>Items</string> + </property> + </column> + </widget> + </item> + <item row="0" column="1"> + <widget class="QGroupBox" name="aPaletteBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="title"> + <string>Palette</string> + </property> + <property name="selectedId" stdset="0"> + <number>0</number> + </property> + <layout class="QGridLayout" name="gridLayout_1"> + <item row="0" column="0"> + <widget class="QPushButton" name="palette0"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="palette1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QPushButton" name="palette2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QPushButton" name="palette3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QPushButton" name="palette4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QPushButton" name="palette5"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QPushButton" name="palette6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QPushButton" name="palette7"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QPushButton" name="palette8"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QPushButton" name="palette9"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QPushButton" name="palette10"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QPushButton" name="palette11"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QPushButton" name="palette12"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QPushButton" name="palette13"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QPushButton" name="palette14"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QPushButton" name="palette15"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="2"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QFrame" name="colorframe"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="addToPalette"> + <property name="text"> + <string>add to palette</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="1" colspan="2"> + <layout class="QGridLayout"> + <item row="0" column="1"> + <widget class="QSpinBox" name="rval"> + <property name="maximum"> + <number>255</number> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QSlider" name="hslider"> + <property name="maximum"> + <number>255</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="textLabel3_2"> + <property name="text"> + <string>B</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="textLabel5_2"> + <property name="text"> + <string>S</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="textLabel4_2"> + <property name="text"> + <string>H</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QSpinBox" name="bval"> + <property name="maximum"> + <number>255</number> + </property> + </widget> + </item> + <item row="5" column="2"> + <widget class="QSlider" name="vslider"> + <property name="maximum"> + <number>255</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="textLabel6_2"> + <property name="text"> + <string>V</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="textLabel2_2"> + <property name="text"> + <string>G</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QSpinBox" name="sval"> + <property name="maximum"> + <number>255</number> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QSlider" name="gslider"> + <property name="maximum"> + <number>255</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QSlider" name="sslider"> + <property name="maximum"> + <number>255</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QSlider" name="bslider"> + <property name="maximum"> + <number>255</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="gval"> + <property name="maximum"> + <number>255</number> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QSlider" name="rslider"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>255</number> + </property> + <property name="tracking"> + <bool>true</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::NoTicks</enum> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QSpinBox" name="vval"> + <property name="maximum"> + <number>255</number> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QSpinBox" name="hval"> + <property name="maximum"> + <number>255</number> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="textLabel1"> + <property name="text"> + <string>R</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Color name:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="colorNameLineEdit"/> + </item> + </layout> + </item> + <item row="2" column="1" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="textLabel1_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Global opacity</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="globalAlphaVal"> + <property name="maximum"> + <number>255</number> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="globalAlphaSlider"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>255</number> + </property> + <property name="tracking"> + <bool>true</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::NoTicks</enum> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab3"> + <attribute name="title"> + <string>Style/Fonts</string> + </attribute> + <layout class="QVBoxLayout"> + <item> + <widget class="QGroupBox" name="GroupBox18"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>QT Theme</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <layout class="QHBoxLayout"> + <item> + <spacer name="Spacer2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>190</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QLabel" name="label_41"> + <property name="text"> + <string>Style Sheet:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="styleSheetPath"/> + </item> + <item> + <widget class="QToolButton" name="openStyleSheet"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="defaultStyleSheet"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="spacer3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="GroupBox6"> + <property name="title"> + <string>Fonts</string> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="1"> + <widget class="QLabel" name="textLabel2"> + <property name="text"> + <string>Family</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="TextLabel1_1"> + <property name="text"> + <string>Size</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="textLabel4"> + <property name="text"> + <string>Font 1</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="textLabel5"> + <property name="text"> + <string>Font 2</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="textLabel6"> + <property name="text"> + <string>Font 3</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="fontName0"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="fontName1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="fontName2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="fontName3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="textLabel3"> + <property name="text"> + <string>Font 0</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QSpinBox" name="fontSize0"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QSpinBox" name="fontSize1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QSpinBox" name="fontSize2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QSpinBox" name="fontSize3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QCheckBox" name="bold1"> + <property name="text"> + <string>Bold</string> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QCheckBox" name="bold2"> + <property name="text"> + <string>Bold</string> + </property> + </widget> + </item> + <item row="4" column="3"> + <widget class="QCheckBox" name="bold3"> + <property name="text"> + <string>Bold</string> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QCheckBox" name="bold0"> + <property name="text"> + <string>Bold</string> + </property> + </widget> + </item> + <item row="3" column="4"> + <widget class="QCheckBox" name="italic2"> + <property name="text"> + <string>Italic</string> + </property> + </widget> + </item> + <item row="4" column="4"> + <widget class="QCheckBox" name="italic3"> + <property name="text"> + <string>Italic</string> + </property> + </widget> + </item> + <item row="2" column="4"> + <widget class="QCheckBox" name="italic1"> + <property name="text"> + <string>Italic</string> + </property> + </widget> + </item> + <item row="1" column="4"> + <widget class="QCheckBox" name="italic0"> + <property name="text"> + <string>Italic</string> + </property> + </widget> + </item> + <item row="1" column="5"> + <widget class="QToolButton" name="fontBrowse0"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="2" column="5"> + <widget class="QToolButton" name="fontBrowse1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="3" column="5"> + <widget class="QToolButton" name="fontBrowse2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="4" column="5"> + <widget class="QToolButton" name="fontBrowse3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="textLabel7"> + <property name="text"> + <string>Font 4</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLineEdit" name="fontName4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="textLabel7_2"> + <property name="text"> + <string>Font 5</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QLineEdit" name="fontName5"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="textLabel7_3"> + <property name="text"> + <string>Font 6</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="QLineEdit" name="fontName6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="7" column="2"> + <widget class="QSpinBox" name="fontSize6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="7" column="3"> + <widget class="QCheckBox" name="bold6"> + <property name="text"> + <string>Bold</string> + </property> + </widget> + </item> + <item row="7" column="4"> + <widget class="QCheckBox" name="italic6"> + <property name="text"> + <string>Italic</string> + </property> + </widget> + </item> + <item row="7" column="5"> + <widget class="QToolButton" name="fontBrowse6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="5" column="2"> + <widget class="QSpinBox" name="fontSize4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="6" column="2"> + <widget class="QSpinBox" name="fontSize5"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="5" column="3"> + <widget class="QCheckBox" name="bold4"> + <property name="text"> + <string>Bold</string> + </property> + </widget> + </item> + <item row="6" column="3"> + <widget class="QCheckBox" name="bold5"> + <property name="text"> + <string>Bold</string> + </property> + </widget> + </item> + <item row="5" column="4"> + <widget class="QCheckBox" name="italic4"> + <property name="text"> + <string>Italic</string> + </property> + </widget> + </item> + <item row="6" column="4"> + <widget class="QCheckBox" name="italic5"> + <property name="text"> + <string>Italic</string> + </property> + </widget> + </item> + <item row="5" column="5"> + <widget class="QToolButton" name="fontBrowse4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="6" column="5"> + <widget class="QToolButton" name="fontBrowse5"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <spacer name="Spacer1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="applyButton"> + <property name="text"> + <string>Apply</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="okButton"> + <property name="text"> + <string>Ok</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton"> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <tabstops> + <tabstop>TabWidget2</tabstop> + <tabstop>itemList</tabstop> + <tabstop>palette0</tabstop> + <tabstop>palette1</tabstop> + <tabstop>palette2</tabstop> + <tabstop>palette3</tabstop> + <tabstop>palette4</tabstop> + <tabstop>palette5</tabstop> + <tabstop>palette6</tabstop> + <tabstop>palette7</tabstop> + <tabstop>palette8</tabstop> + <tabstop>palette9</tabstop> + <tabstop>palette10</tabstop> + <tabstop>palette11</tabstop> + <tabstop>palette12</tabstop> + <tabstop>palette13</tabstop> + <tabstop>palette14</tabstop> + <tabstop>palette15</tabstop> + <tabstop>addToPalette</tabstop> + <tabstop>rval</tabstop> + <tabstop>rslider</tabstop> + <tabstop>gval</tabstop> + <tabstop>gslider</tabstop> + <tabstop>bval</tabstop> + <tabstop>bslider</tabstop> + <tabstop>hval</tabstop> + <tabstop>hslider</tabstop> + <tabstop>sval</tabstop> + <tabstop>sslider</tabstop> + <tabstop>vval</tabstop> + <tabstop>vslider</tabstop> + <tabstop>applyButton</tabstop> + <tabstop>okButton</tabstop> + <tabstop>cancelButton</tabstop> + <tabstop>partShownames</tabstop> + <tabstop>partShowevents</tabstop> + <tabstop>partShowCakes</tabstop> + <tabstop>eventNoteon</tabstop> + <tabstop>eventPolypressure</tabstop> + <tabstop>eventController</tabstop> + <tabstop>eventAftertouch</tabstop> + <tabstop>eventPitchbend</tabstop> + <tabstop>eventProgramchange</tabstop> + <tabstop>eventSpecial</tabstop> + <tabstop>arrGrid</tabstop> + <tabstop>themeComboBox</tabstop> + <tabstop>styleSheetPath</tabstop> + <tabstop>openStyleSheet</tabstop> + <tabstop>fontName0</tabstop> + <tabstop>fontName1</tabstop> + <tabstop>fontName2</tabstop> + <tabstop>fontName3</tabstop> + <tabstop>fontSize0</tabstop> + <tabstop>fontSize1</tabstop> + <tabstop>fontSize2</tabstop> + <tabstop>fontSize3</tabstop> + <tabstop>bold1</tabstop> + <tabstop>bold2</tabstop> + <tabstop>bold3</tabstop> + <tabstop>bold0</tabstop> + <tabstop>italic2</tabstop> + <tabstop>italic3</tabstop> + <tabstop>italic1</tabstop> + <tabstop>italic0</tabstop> + <tabstop>fontName4</tabstop> + <tabstop>fontName5</tabstop> + <tabstop>fontSize4</tabstop> + <tabstop>fontSize5</tabstop> + <tabstop>bold4</tabstop> + <tabstop>bold5</tabstop> + <tabstop>italic4</tabstop> + <tabstop>italic5</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>rslider</sender> + <signal>valueChanged(int)</signal> + <receiver>rval</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>gslider</sender> + <signal>valueChanged(int)</signal> + <receiver>gval</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>bslider</sender> + <signal>valueChanged(int)</signal> + <receiver>bval</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>hslider</sender> + <signal>valueChanged(int)</signal> + <receiver>hval</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>sslider</sender> + <signal>valueChanged(int)</signal> + <receiver>sval</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>vslider</sender> + <signal>valueChanged(int)</signal> + <receiver>vval</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>rval</sender> + <signal>valueChanged(int)</signal> + <receiver>rslider</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>gval</sender> + <signal>valueChanged(int)</signal> + <receiver>gslider</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>bval</sender> + <signal>valueChanged(int)</signal> + <receiver>bslider</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>hval</sender> + <signal>valueChanged(int)</signal> + <receiver>hslider</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>sval</sender> + <signal>valueChanged(int)</signal> + <receiver>sslider</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>vval</sender> + <signal>valueChanged(int)</signal> + <receiver>vslider</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/bigtime.cpp b/attic/muse2-oom/muse2/muse/widgets/bigtime.cpp new file mode 100644 index 00000000..479f4103 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/bigtime.cpp @@ -0,0 +1,448 @@ +#include <stdio.h> +#include <values.h> + +#include <QCheckBox> +#include <QLabel> +#include <QResizeEvent> + +#include "globals.h" +#include "bigtime.h" +#include "song.h" +#include "app.h" +#include "gconfig.h" + +extern int mtcType; + +// +// the bigtime widget +// display is split into several parts to avoid flickering. +// + +//--------------------------------------------------------- +// BigTime +//--------------------------------------------------------- + +BigTime::BigTime(QWidget* parent) + : QWidget(parent, Qt::Window | Qt::WindowStaysOnTopHint) // Possibly also Qt::X11BypassWindowManagerHint + { + + tickmode = true; + dwin = new QWidget(this, Qt::WindowStaysOnTopHint); // Possibly also Qt::X11BypassWindowManagerHint + dwin->setObjectName("bigtime-dwin"); + dwin->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + fmtButton = new QCheckBox(QString(""), this); + fmtButton->resize(18,18); + fmtButton->setChecked(true); + fmtButton->setToolTip(tr("format display")); + fmtButton->setFocusPolicy(Qt::NoFocus); + barLabel = new QLabel(dwin); + beatLabel = new QLabel(dwin); + tickLabel = new QLabel(dwin); + //hourLabel = new QLabel(dwin); + minLabel = new QLabel(dwin); + secLabel = new QLabel(dwin); + frameLabel = new QLabel(dwin); + subFrameLabel = new QLabel(dwin); + sep1 = new QLabel(QString("."), dwin); + sep2 = new QLabel(QString("."), dwin); + sep3 = new QLabel(QString(":"), dwin); + sep4 = new QLabel(QString(":"), dwin); + sep5 = new QLabel(QString(":"), dwin); + absTickLabel = new QLabel(dwin); + absFrameLabel = new QLabel(dwin); + barLabel->setToolTip(tr("bar")); + beatLabel->setToolTip(tr("beat")); + tickLabel->setToolTip(tr("tick")); + //hourLabel->setToolTip(tr("hour")); + minLabel->setToolTip(tr("minute")); + secLabel->setToolTip(tr("second")); + frameLabel->setToolTip(tr("frame")); + subFrameLabel->setToolTip(tr("subframe")); + absTickLabel->setToolTip(tr("tick")); + absFrameLabel->setToolTip(tr("frame")); + fmtButtonToggled(true); + connect(fmtButton, SIGNAL(toggled(bool)), SLOT(fmtButtonToggled(bool))); + //oldbar = oldbeat = oldtick = oldhour = oldmin = oldsec = oldframe = -1; + oldbar = oldbeat = oldtick = oldmin = oldsec = oldframe = oldsubframe = -1; + oldAbsTick = oldAbsFrame = -1; + setString(MAXINT); + + dwin->setStyleSheet("font-size:10px; font-family:'Courier'; "); // Tim p4.0.8 + + configChanged(); + + //QFont f(QString("Courier")); + //f.setPixelSize(10); + //dwin->setFont(f); + + setWindowTitle(tr("MusE: Bigtime")); + } + + +//--------------------------------------------------------- +// fmtButtonToggled +//--------------------------------------------------------- + +void BigTime::fmtButtonToggled(bool v) +{ + if(v) + { + tickmode = true; + + barLabel->setEnabled(true); + beatLabel->setEnabled(true); + tickLabel->setEnabled(true); + //hourLabel->setEnabled(true); + minLabel->setEnabled(true); + secLabel->setEnabled(true); + frameLabel->setEnabled(true); + subFrameLabel->setEnabled(true); + sep1->setEnabled(true); + sep2->setEnabled(true); + sep3->setEnabled(true); + sep4->setEnabled(true); + sep5->setEnabled(true); + absTickLabel->setEnabled(false); + absFrameLabel->setEnabled(false); + + barLabel->show(); + beatLabel->show(); + tickLabel->show(); + //hourLabel->show(); + minLabel->show(); + secLabel->show(); + frameLabel->show(); + subFrameLabel->show(); + sep1->show(); + sep2->show(); + sep3->show(); + sep4->show(); + sep5->show(); + absTickLabel->hide(); + absFrameLabel->hide(); + } + else + { + tickmode = false; + + barLabel->setEnabled(false); + beatLabel->setEnabled(false); + tickLabel->setEnabled(false); + //hourLabel->setEnabled(false); + minLabel->setEnabled(false); + secLabel->setEnabled(false); + frameLabel->setEnabled(false); + subFrameLabel->setEnabled(false); + sep1->setEnabled(false); + sep2->setEnabled(false); + sep3->setEnabled(false); + sep4->setEnabled(false); + sep5->setEnabled(false); + absTickLabel->setEnabled(true); + absFrameLabel->setEnabled(true); + + barLabel->hide(); + beatLabel->hide(); + tickLabel->hide(); + //hourLabel->hide(); + minLabel->hide(); + secLabel->hide(); + frameLabel->hide(); + subFrameLabel->hide(); + sep1->hide(); + sep2->hide(); + sep3->hide(); + sep4->hide(); + sep5->hide(); + absTickLabel->show(); + absFrameLabel->show(); + } +} + +//--------------------------------------------------------- +// configChanged +//--------------------------------------------------------- + +void BigTime::configChanged() + { + setBgColor(config.bigTimeBackgroundColor); + setFgColor(config.bigTimeForegroundColor); + } + +//--------------------------------------------------------- +// closeEvent +//--------------------------------------------------------- + +void BigTime::closeEvent(QCloseEvent *ev) + { + emit closed(); + QWidget::closeEvent(ev); + } + +//--------------------------------------------------------- +// setString +//--------------------------------------------------------- + +bool BigTime::setString(unsigned v) + { + if (v == MAXINT) { + barLabel->setText(QString("----")); + beatLabel->setText(QString("--")); + tickLabel->setText(QString("---")); + //hourLabel->setText(QString("--")); + //minLabel->setText(QString("--")); + minLabel->setText(QString("---")); + secLabel->setText(QString("--")); + frameLabel->setText(QString("--")); + subFrameLabel->setText(QString("--")); + + absTickLabel->setText(QString("----------")); + absFrameLabel->setText(QString("----------")); + oldAbsTick = oldAbsFrame = -1; + //oldbar = oldbeat = oldtick = oldhour = oldmin = oldsec = oldframe = -1; + oldbar = oldbeat = oldtick = oldmin = oldsec = oldframe = oldsubframe = -1; + return true; + } + + unsigned absFrame = tempomap.tick2frame(v); + int bar, beat; + unsigned tick; + AL::sigmap.tickValues(v, &bar, &beat, &tick); + double time = double(absFrame)/double(sampleRate); + //int hour = int(time) / 3600; + //int min = (int(time) / 60) % 60; + int min = int(time) / 60; + int sec = int(time) % 60; + double rest = time - (min * 60 + sec); + switch(mtcType) { + case 0: // 24 frames sec + rest *= 24; + break; + case 1: // 25 + rest *= 25; + break; + case 2: // 30 drop frame + rest *= 30; + break; + case 3: // 30 non drop frame + rest *= 30; + break; + } + int frame = int(rest); + int subframe = int((rest-frame)*100); + + QString s; + + if(oldAbsTick != v) { + s.sprintf("%010d", v); + absTickLabel->setText(s); + oldAbsTick = v; + } + if(oldAbsFrame != absFrame) { + s.sprintf("%010d", absFrame); + absFrameLabel->setText(s); + oldAbsFrame = absFrame; + } + if(oldbar != bar) { + s.sprintf("%04d", bar+1); + barLabel->setText(s); + oldbar = bar; + } + if(oldbeat != beat) { + s.sprintf("%02d", beat+1); + beatLabel->setText(s); + oldbeat = beat; + } + + if(oldtick != tick) { + s.sprintf("%03d", tick); + tickLabel->setText(s); + oldtick = tick; + } + + //if(oldhour != hour) { + // s.sprintf("%02d", hour); + // hourLabel->setText(s); + // oldhour = hour; + //} + + if(oldmin != min) { + //s.sprintf("%02d", min); + s.sprintf("%03d", min); + minLabel->setText(s); + oldmin = min; + } + + if(oldsec != sec) { + s.sprintf("%02d", sec); + secLabel->setText(s); + oldsec = sec; + } + + if(oldframe != frame) { + s.sprintf("%02d", frame); + frameLabel->setText(s); + oldframe = frame; + } + + if(oldsubframe != subframe) { + s.sprintf("%02u", subframe); + subFrameLabel->setText(s); + oldsubframe = subframe; + } + + return false; + } + +//--------------------------------------------------------- +// setPos +//--------------------------------------------------------- + +void BigTime::setPos(int idx, unsigned v, bool) + { + if (idx == 0) + setString(v); + } + +//--------------------------------------------------------- +// resizeEvent +//--------------------------------------------------------- + +void BigTime::resizeEvent(QResizeEvent *ev) + { + dwin->resize(ev->size()); + QFont f = dwin->font(); + QFontMetrics fm(f); + int fs = f.pixelSize(); + int hspace = 20; + //int tw = fm.width(QString("00:00:00:00")); + int tw = fm.width(QString("000:00:00:00")); + + fs = ((ev->size().width() - hspace*2)*fs) / tw; + + // set min/max + if (fs < 10) + fs = 10; + else if (fs > 256) + fs = 256; + + //if(debugMsg) + // printf("resize BigTime: Font name:%s CurSize:%d NewSize:%d, NewWidth:%d\n", + // f.family().toLatin1().constData(), fs, nfs, ev->size().width()); + + //f.setPixelSize(fs); + + //dwin->setFont(f); + QString fstr = QString("font-size:%1px; font-family:'Courier'; ").arg(fs); // Tim p4.0.8 + dwin->setStyleSheet(fstr); + setBgColor(config.bigTimeBackgroundColor); + setFgColor(config.bigTimeForegroundColor); + + int digitWidth = dwin->fontMetrics().width(QString("0")); + int vspace = (ev->size().height() - (fs*2)) / 3; + int tickY = vspace; + + int timeY = vspace*2 + fs; + int absTickY = tickY; + int absFrameY = timeY; + barLabel->resize(digitWidth*4, fs); + beatLabel->resize(digitWidth*2, fs); + tickLabel->resize(digitWidth*3, fs); + //hourLabel->resize(digitWidth*2, fs); + //minLabel->resize(digitWidth*2, fs); + minLabel->resize(digitWidth*3, fs); + secLabel->resize(digitWidth*2, fs); + frameLabel->resize(digitWidth*2, fs); + subFrameLabel->resize(digitWidth*2, fs); + + absTickLabel->resize(digitWidth*10, fs); + absFrameLabel->resize(digitWidth*10, fs); + sep1->resize(digitWidth, fs); + sep2->resize(digitWidth, fs); + sep3->resize(digitWidth, fs); + sep4->resize(digitWidth, fs); + sep5->resize(digitWidth, fs); + + barLabel->move( hspace + (digitWidth*0), tickY); + sep1->move( hspace + (digitWidth*4), tickY); + beatLabel->move( hspace + (digitWidth*5), tickY); + sep2->move( hspace + (digitWidth*7), tickY); + tickLabel->move( hspace + (digitWidth*8), tickY); + + //hourLabel->move( hspace + (digitWidth*0), timeY); + //sep3->move( hspace + (digitWidth*2), timeY); + //minLabel->move( hspace + (digitWidth*3), timeY); + //sep4->move( hspace + (digitWidth*5), timeY); + //secLabel->move( hspace + (digitWidth*6), timeY); + //sep5->move( hspace + (digitWidth*8), timeY); + //frameLabel->move( hspace + (digitWidth*9), timeY); + minLabel->move( hspace + (digitWidth*0), timeY); + sep3->move( hspace + (digitWidth*3), timeY); + secLabel->move( hspace + (digitWidth*4), timeY); + sep4->move( hspace + (digitWidth*6), timeY); + frameLabel->move( hspace + (digitWidth*7), timeY); + sep5->move( hspace + (digitWidth*9), timeY); + subFrameLabel->move( hspace + (digitWidth*10), timeY); + + absTickLabel->move( hspace + (digitWidth*0), absTickY); + absFrameLabel->move( hspace + (digitWidth*0), absFrameY); + } + +//--------------------------------------------------------- +// setForegroundColor +//--------------------------------------------------------- + +void BigTime::setFgColor(QColor c) + { + QPalette newpalette(palette()); + newpalette.setColor(QPalette::Foreground, c); + setPalette(newpalette); + + barLabel->setPalette(newpalette); + beatLabel->setPalette(newpalette); + tickLabel->setPalette(newpalette); + //hourLabel->setPalette(newpalette); + minLabel->setPalette(newpalette); + secLabel->setPalette(newpalette); + frameLabel->setPalette(newpalette); + subFrameLabel->setPalette(newpalette); + + absTickLabel->setPalette(newpalette); + absFrameLabel->setPalette(newpalette); + sep1->setPalette(newpalette); + sep2->setPalette(newpalette); + sep3->setPalette(newpalette); + sep4->setPalette(newpalette); + sep5->setPalette(newpalette); + } + +//--------------------------------------------------------- +// setBackgroundColor +//--------------------------------------------------------- + +void BigTime::setBgColor(QColor c) + { + QPalette newpalette(palette()); + newpalette.setColor(QPalette::Window, c); + setPalette(newpalette); + + barLabel->setPalette(newpalette); + beatLabel->setPalette(newpalette); + tickLabel->setPalette(newpalette); + //hourLabel->setPalette(newpalette); + minLabel->setPalette(newpalette); + secLabel->setPalette(newpalette); + frameLabel->setPalette(newpalette); + subFrameLabel->setPalette(newpalette); + + absTickLabel->setPalette(newpalette); + absFrameLabel->setPalette(newpalette); + sep1->setPalette(newpalette); + sep2->setPalette(newpalette); + sep3->setPalette(newpalette); + sep4->setPalette(newpalette); + sep5->setPalette(newpalette); + + setPalette(newpalette); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/bigtime.h b/attic/muse2-oom/muse2/muse/widgets/bigtime.h new file mode 100644 index 00000000..bb32cedc --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/bigtime.h @@ -0,0 +1,53 @@ +#ifndef __BIGTIME_H__ +#define __BIGTIME_H__ + +#include <QWidget> + +class QCheckBox; +class QLabel; + +class MusE; + +//--------------------------------------------------------- +// BigTime +//--------------------------------------------------------- + +class BigTime : public QWidget { + bool tickmode; + MusE* seq; + Q_OBJECT + + bool setString(unsigned); + + QWidget *dwin; + QCheckBox *fmtButton; + QLabel *absTickLabel; + QLabel *absFrameLabel; + QLabel *barLabel, *beatLabel, *tickLabel, + //*hourLabel, *minLabel, *secLabel, *frameLabel, + *minLabel, *secLabel, *frameLabel, *subFrameLabel, + *sep1, *sep2, *sep3, *sep4, *sep5; + + //int oldbar, oldbeat, oldhour, oldmin, oldsec, oldframe; + int oldbar, oldbeat, oldmin, oldsec, oldframe, oldsubframe; + unsigned oldtick; + unsigned oldAbsTick, oldAbsFrame; + void setFgColor(QColor c); + void setBgColor(QColor c); + + protected: + virtual void resizeEvent(QResizeEvent*); + virtual void closeEvent(QCloseEvent*); + + public slots: + void setPos(int, unsigned, bool); + void configChanged(); + void fmtButtonToggled(bool); + signals: + void closed(); + + public: + BigTime(QWidget* parent); + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/canvas.cpp b/attic/muse2-oom/muse2/muse/widgets/canvas.cpp new file mode 100644 index 00000000..4ea5f568 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/canvas.cpp @@ -0,0 +1,1463 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: canvas.cpp,v 1.10.2.17 2009/05/03 04:14:01 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> + +#include "canvas.h" + +#include <QApplication> +#include <QMenu> +#include <QPainter> +#include <QCursor> +#include <QTimer> +#include <QKeyEvent> +#include <QMouseEvent> +#include <QWheelEvent> + +#include "song.h" +#include "event.h" +#include "citem.h" +#include "icons.h" +#include "../marker/marker.h" +#include "part.h" + +#define ABS(x) ((x) < 0) ? -(x) : (x) + +//--------------------------------------------------------- +// Canvas +//--------------------------------------------------------- + +Canvas::Canvas(QWidget* parent, int sx, int sy, const char* name) + : View(parent, sx, sy, name) + { + canvasTools = 0; + itemPopupMenu = 0; + + button = Qt::NoButton; + keyState = 0; + + canScrollLeft = true; + canScrollRight = true; + canScrollUp = true; + canScrollDown = true; + hscrollDir = HSCROLL_NONE; + vscrollDir = VSCROLL_NONE; + scrollTimer=NULL; + + scrollSpeed=10; // hardcoded scroll jump + + drag = DRAG_OFF; + _tool = PointerTool; + pos[0] = song->cpos(); + pos[1] = song->lpos(); + pos[2] = song->rpos(); + curPart = NULL; + curPartId = -1; + curItem = NULL; + connect(song, SIGNAL(posChanged(int, unsigned, bool)), this, SLOT(setPos(int, unsigned, bool))); + } + +//--------------------------------------------------------- +// setPos +// set one of three markers +// idx - 0-cpos 1-lpos 2-rpos +// flag - emit followEvent() +//--------------------------------------------------------- + +void Canvas::setPos(int idx, unsigned val, bool adjustScrollbar) + { + //if (pos[idx] == val) // Seems to be some refresh problems here, pos[idx] might be val but the gui not updated. + // return; // skipping this return forces update even if values match. Matching values only seem + // to occur when initializing + int opos = mapx(pos[idx]); + int npos = mapx(val); + + if (adjustScrollbar && idx == 0) { + switch (song->follow()) { + case Song::NO: + break; + case Song::JUMP: + if (npos >= width()) { + int ppos = val - xorg - rmapxDev(width()/8); + if (ppos < 0) + ppos = 0; + emit followEvent(ppos); + opos = mapx(pos[idx]); + npos = mapx(val); + } + else if (npos < 0) { + int ppos = val - xorg - rmapxDev(width()*3/4); + if (ppos < 0) + ppos = 0; + emit followEvent(ppos); + opos = mapx(pos[idx]); + npos = mapx(val); + } + break; + case Song::CONTINUOUS: + if (npos > (width()/2)) { + int ppos = pos[idx] - xorg - rmapxDev(width()/2); + if (ppos < 0) + ppos = 0; + emit followEvent(ppos); + opos = mapx(pos[idx]); + npos = mapx(val); + } + else if (npos < (width()/2)) { + int ppos = pos[idx] - xorg - rmapxDev(width()/2); + if (ppos < 0) + ppos = 0; + emit followEvent(ppos); + opos = mapx(pos[idx]); + npos = mapx(val); + } + break; + } + } + + int x; + int w = 1; + if (opos > npos) { + w += opos - npos; + x = npos; + } + else { + w += npos - opos; + x = opos; + } + pos[idx] = val; + redraw(QRect(x-1, 0, w+2, height())); + } + +//--------------------------------------------------------- +// draw +//--------------------------------------------------------- + +void Canvas::draw(QPainter& p, const QRect& rect) +{ +// printf("draw canvas %x virt %d\n", this, virt()); + + int x = rect.x(); + int y = rect.y(); + int w = rect.width(); + int h = rect.height(); + int x2 = x + w; + + if (virt()) { + drawCanvas(p, rect); + + //--------------------------------------------------- + // draw Canvas Items + //--------------------------------------------------- + + iCItem to(items.lower_bound(x2)); + + // Draw items from other parts behind all others. + // Only for items with events (not arranger parts). + for(iCItem i = items.begin(); i != to; ++i) + { + CItem* ci = i->second; + if(!ci->event().empty() && ci->part() != curPart) + { + drawItem(p, ci, rect); + } + } + + for (iCItem i = items.begin(); i != to; ++i) + { + CItem* ci = i->second; + // Draw unselected parts behind selected. + if(!ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart)) + { + drawItem(p, ci, rect); + } + } + + // Draw selected parts in front of unselected. + for (iCItem i = items.begin(); i != to; ++i) + { + CItem* ci = i->second; + if(ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart)) + { + drawItem(p, ci, rect); + } + } + to = moving.lower_bound(x2); + for (iCItem i = moving.begin(); i != to; ++i) + { + drawItem(p, i->second, rect); + } + } + else { + p.save(); + setPainter(p); + + if (xmag <= 0) { + x -= 1; + w += 2; + x = (x + xpos + rmapx(xorg)) * (-xmag); + w = w * (-xmag); + } + else { + x = (x + xpos + rmapx(xorg)) / xmag; + w = (w + xmag - 1) / xmag; + x -= 1; + w += 2; + } + if (ymag <= 0) { + y -= 1; + h += 2; + y = (y + ypos + rmapy(yorg)) * (-ymag); + h = h * (-ymag); + } + else { + y = (rect.y() + ypos + rmapy(yorg))/ymag; + h = (rect.height()+ymag-1)/ymag; + y -= 1; + h += 2; + } + + if (x < 0) + x = 0; + if (y < 0) + y = 0; + x2 = x + w; + + drawCanvas(p, QRect(x, y, w, h)); + p.restore(); + + //--------------------------------------------------- + // draw Canvas Items + //--------------------------------------------------- + + // Draw items from other parts behind all others. + // Only for items with events (not arranger parts). + for(iCItem i = items.begin(); i != items.end(); ++i) + { + CItem* ci = i->second; + if(!ci->event().empty() && ci->part() != curPart) + { + drawItem(p, ci, rect); + } + } + + for (iCItem i = items.begin(); i != items.end(); ++i) { + CItem* ci = i->second; + // Draw unselected parts behind selected. + if(!ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart)) + { + drawItem(p, ci, rect); + } + } + + // Draw selected parts in front of unselected. + for (iCItem i = items.begin(); i != items.end(); ++i) { + CItem* ci = i->second; + if(ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart)) + { + drawItem(p, ci, rect); + } + } + for (iCItem i = moving.begin(); i != moving.end(); ++i) + { + drawItem(p, i->second, rect); + } + p.save(); + setPainter(p); + } + + //--------------------------------------------------- + // draw marker + //--------------------------------------------------- + + int y2 = y + h; + MarkerList* marker = song->marker(); + for (iMarker m = marker->begin(); m != marker->end(); ++m) { + int xp = m->second.tick(); + if (xp >= x && xp < x+w) { + p.setPen(Qt::green); + p.drawLine(xp, y, xp, y2); + } + } + + // //--------------------------------------------------- + // // draw location marker + // //--------------------------------------------------- + + // p.setPen(Qt::blue); + // if (pos[1] >= unsigned(x) && pos[1] < unsigned(x2)) + // { + // p.drawLine(pos[1], y, pos[1], y2); + // } + // if (pos[2] >= unsigned(x) && pos[2] < unsigned(x2)) + // p.drawLine(pos[2], y, pos[2], y2); + // + // QPen playbackPen(QColor(51,56,55), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + // p.setPen(playbackPen); + // //p.setPen(Qt::red); + + // if (pos[0] >= unsigned(x) && pos[0] < unsigned(x2)) + // { + // p.drawLine(pos[0], y, pos[0], y2); + // } + // + + //--------------------------------------------------- + // draw lasso + //--------------------------------------------------- + + if (drag == DRAG_LASSO) + { + p.setPen(QColor(181,109,16)); + p.setBrush(Qt::NoBrush); + p.drawRect(lasso); + } + + //--------------------------------------------------- + // draw moving items + //--------------------------------------------------- + + if(virt()) + { + for(iCItem i = moving.begin(); i != moving.end(); ++i) + drawMoving(p, i->second, rect); + } + else + { + p.restore(); + for(iCItem i = moving.begin(); i != moving.end(); ++i) + drawMoving(p, i->second, rect); + setPainter(p); + } + //--------------------------------------------------- + // draw location marker + //--------------------------------------------------- + + //p.setPen(Qt::blue); + p.setPen(QColor(139,225,69)); + if (pos[1] >= unsigned(x) && pos[1] < unsigned(x2)) + { + p.drawLine(pos[1], y, pos[1], y2); + } + if (pos[2] >= unsigned(x) && pos[2] < unsigned(x2)) + p.drawLine(pos[2], y, pos[2], y2); + + //QPen playbackPen(QColor(8,193,156), 1); + //p.setPen(playbackPen); + //p.setPen(Qt::green); + p.setPen(QColor(0,186,255)); + + if (pos[0] >= unsigned(x) && pos[0] < unsigned(x2)) + { + p.drawLine(pos[0], y, pos[0], y2); + } + +} + +#define WHEEL_STEPSIZE 40 +#define WHEEL_DELTA 120 + +//--------------------------------------------------------- +// wheelEvent +//--------------------------------------------------------- +void Canvas::wheelEvent(QWheelEvent* ev) + { + int delta = ev->delta() / WHEEL_DELTA; + int ypixelscale = rmapyDev(1); + + if (ypixelscale <= 0) + ypixelscale = 1; + + int scrollstep = WHEEL_STEPSIZE * (-delta); + ///if (ev->state() == Qt::ShiftModifier) + if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier) + scrollstep = scrollstep / 10; + + int newYpos = ypos + ypixelscale * scrollstep; + + if (newYpos < 0) + newYpos = 0; + + //setYPos(newYpos); + emit verticalScroll((unsigned)newYpos); + +} + +void Canvas::redirectedWheelEvent(QWheelEvent* ev) +{ + wheelEvent(ev); +} + +//--------------------------------------------------------- +// deselectAll +//--------------------------------------------------------- + +void Canvas::deselectAll() +{ + for (iCItem i = items.begin(); i != items.end(); ++i) + i->second->setSelected(false); +} + +//--------------------------------------------------------- +// selectItem +//--------------------------------------------------------- + +void Canvas::selectItem(CItem* e, bool flag) +{ + e->setSelected(flag); +} + +//--------------------------------------------------------- +// startMoving +// copy selection-List to moving-List +//--------------------------------------------------------- + +void Canvas::startMoving(const QPoint& pos, DragType) +{ + for (iCItem i = items.begin(); i != items.end(); ++i) { + if (i->second->isSelected()) { + i->second->setMoving(true); + moving.add(i->second); + } + } + moveItems(pos, 0); +} + +//--------------------------------------------------------- +// moveItems +// dir = 0 move in all directions +// 1 move only horizontal +// 2 move only vertical +//--------------------------------------------------------- + +void Canvas::moveItems(const QPoint& pos, int dir = 0, bool rasterize) +{ + int dp; + if(rasterize) + dp = y2pitch(pos.y()) - y2pitch(start.y()); + else + dp = pos.y() - start.y(); + int dx = pos.x() - start.x(); + if (dir == 1) + dp = 0; + else if (dir == 2) + dx = 0; + for (iCItem i = moving.begin(); i != moving.end(); ++i) { + int x = i->second->pos().x(); + int y = i->second->pos().y(); + int nx = x + dx; + int ny; + QPoint mp; + if(rasterize) + { + ny = pitch2y(y2pitch(y) + dp); + mp = raster(QPoint(nx, ny)); + } + else + { + ny = y + dp; + mp = QPoint(nx, ny); + } + if (i->second->mp() != mp) + { + i->second->setMp(mp); + itemMoved(i->second, mp); + } + } + redraw(); +} + +//--------------------------------------------------------- +// viewKeyPressEvent +//--------------------------------------------------------- + +void Canvas::viewKeyPressEvent(QKeyEvent* event) + { + keyPress(event); + } + +//--------------------------------------------------------- +// viewMousePressEvent +//--------------------------------------------------------- + +void Canvas::viewMousePressEvent(QMouseEvent* event) + { + ///keyState = event->state(); + keyState = ((QInputEvent*)event)->modifiers(); + button = event->button(); + + //printf("viewMousePressEvent buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button()); + + // special events if right button is clicked while operations + // like moving or drawing lasso is performed. + ///if (event->stateAfter() & Qt::RightButton) { + if (event->buttons() & Qt::RightButton & ~(event->button())) { + //printf("viewMousePressEvent special buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button()); + switch (drag) { + case DRAG_LASSO: + drag = DRAG_OFF; + redraw(); + return; + case DRAG_MOVE: + drag = DRAG_OFF; + endMoveItems (start, MOVE_MOVE, 0); + return; + default: + break; + } + } + + // ignore event if (another) button is already active: + ///if (keyState & (Qt::LeftButton|Qt::RightButton|Qt::MidButton)) { + if (event->buttons() & (Qt::LeftButton|Qt::RightButton|Qt::MidButton) & ~(event->button())) { + //printf("viewMousePressEvent ignoring buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button()); + return; + } + bool shift = keyState & Qt::ShiftModifier; + bool alt = keyState & Qt::AltModifier; + bool ctrl = keyState & Qt::ControlModifier; + start = event->pos(); + + //--------------------------------------------------- + // set curItem to item mouse is pointing + // (if any) + //--------------------------------------------------- + + if (virt()) + curItem = items.find(start); + else { + curItem = 0; + iCItem ius; + bool usfound = false; + for (iCItem i = items.begin(); i != items.end(); ++i) { + QRect box = i->second->bbox(); + int x = rmapxDev(box.x()); + int y = rmapyDev(box.y()); + int w = rmapxDev(box.width()); + int h = rmapyDev(box.height()); + QRect r(x, y, w, h); + ///r.moveBy(i->second->pos().x(), i->second->pos().y()); + r.translate(i->second->pos().x(), i->second->pos().y()); + if (r.contains(start)) { + if(i->second->isSelected()) + { + curItem = i->second; + break; + } + else + if(!usfound) + { + ius = i; + usfound = true; + } + } + } + if(!curItem && usfound) + curItem = ius->second; + } + + if (curItem && (event->button() == Qt::MidButton)) { + if (!curItem->isSelected()) { + selectItem(curItem, true); + updateSelection(); + redraw(); + } + startDrag(curItem, shift); + } + else if (event->button() == Qt::RightButton) { + if (curItem) { + if (shift) { + drag = DRAG_RESIZE; + setCursor(); + int dx = start.x() - curItem->x(); + curItem->setWidth(dx); + start.setX(curItem->x()); + deselectAll(); + selectItem(curItem, true); + updateSelection(); + redraw(); + } + else { + itemPopupMenu = genItemPopup(curItem); + if (itemPopupMenu) { + QAction *act = itemPopupMenu->exec(QCursor::pos()); + if (act) + itemPopup(curItem, act->data().toInt(), start); + delete itemPopupMenu; + } + } + } + else { + canvasPopupMenu = genCanvasPopup(); + if (canvasPopupMenu) { + QAction *act = canvasPopupMenu->exec(QCursor::pos(), 0); + if (act) + canvasPopup(act->data().toInt()); + delete canvasPopupMenu; + } + } + } + else if (event->button() == Qt::LeftButton) { + switch (_tool) { + case PointerTool: + if (curItem) { + if (curItem->part() != curPart) { + curPart = curItem->part(); + curPartId = curPart->sn(); + curPartChanged(); + } + itemPressed(curItem); + // Changed by T356. Alt is default reserved for moving the whole window in KDE. Changed to Shift-Alt. + // Hmm, nope, shift-alt is also reserved sometimes. Must find a way to bypass, + // why make user turn off setting? Left alone for now... + if (shift) + drag = DRAG_COPY_START; + else if (alt) { + drag = DRAG_CLONE_START; + } + // + //if (shift) + //{ + // if (alt) + // drag = DRAG_CLONE_START; + // else + // drag = DRAG_COPY_START; + //} + else if (ctrl) { //Select all on the same pitch (e.g. same y-value) + deselectAll(); + //printf("Yes, ctrl and press\n"); + for (iCItem i = items.begin(); i != items.end(); ++i) { + if (i->second->y() == curItem->y() ) + selectItem(i->second, true); + } + updateSelection(); + redraw(); + } + else + drag = DRAG_MOVE_START; + } + else + drag = DRAG_LASSO_START; + setCursor(); + break; + + case RubberTool: + deleteItem(start); + drag = DRAG_DELETE; + setCursor(); + break; + + case PencilTool: + if (curItem) { + drag = DRAG_RESIZE; + setCursor(); + int dx = start.x() - curItem->x(); + curItem->setWidth(dx); + start.setX(curItem->x()); + } + else { + drag = DRAG_NEW; + setCursor(); + curItem = newItem(start, event->modifiers()); + if (curItem) + items.add(curItem); + else { + drag = DRAG_OFF; + setCursor(); + } + } + deselectAll(); + if (curItem) + selectItem(curItem, true); + updateSelection(); + redraw(); + break; + + default: + break; + } + } + mousePress(event); + } + +void Canvas::scrollTimerDone() +{ + //printf("Canvas::scrollTimerDone drag:%d doScroll:%d\n", drag, doScroll); + + if (drag != DRAG_OFF && doScroll) + { + //printf("Canvas::scrollTimerDone drag != DRAG_OFF && doScroll\n"); + + bool doHMove = false; + bool doVMove = false; + int hoff = rmapx(xOffset())+mapx(xorg)-1; + int curxpos; + switch(hscrollDir) + { + case HSCROLL_RIGHT: + hoff += scrollSpeed; + switch(drag) + { + case DRAG_NEW: + case DRAG_RESIZE: + case DRAGX_MOVE: + case DRAGX_COPY: + case DRAGX_CLONE: + case DRAGY_MOVE: + case DRAGY_COPY: + case DRAGY_CLONE: + case DRAG_MOVE: + case DRAG_COPY: + case DRAG_CLONE: + emit horizontalScrollNoLimit(hoff); + canScrollLeft = true; + ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) + scrollSpeed)); + doHMove = true; + break; + default: + if(canScrollRight) + { + curxpos = xpos; + emit horizontalScroll(hoff); + if(xpos <= curxpos) + { + canScrollRight = false; + } + else + { + canScrollLeft = true; + ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) + scrollSpeed)); + doHMove = true; + } + } + else + { + } + break; + } + break; + case HSCROLL_LEFT: + if(canScrollLeft) + { + curxpos = xpos; + hoff -= scrollSpeed; + emit horizontalScroll(hoff); + if(xpos >= curxpos) + { + canScrollLeft = false; + } + else + { + canScrollRight = true; + ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) - scrollSpeed)); + doHMove = true; + } + } + else + { + } + break; + default: + break; + } + int voff = rmapy(yOffset())+mapy(yorg); + int curypos; + switch(vscrollDir) + { + case VSCROLL_DOWN: + if(canScrollDown) + { + curypos = ypos; + voff += scrollSpeed; + emit verticalScroll(voff); + if(ypos <= curypos) + { + canScrollDown = false; + } + else + { + canScrollUp = true; + ev_pos.setY(rmapyDev(rmapy(ev_pos.y()) + scrollSpeed)); + doVMove = true; + } + } + else + { + } + break; + case VSCROLL_UP: + if(canScrollUp) + { + curypos = ypos; + voff -= scrollSpeed; + emit verticalScroll(voff); + if(ypos >= curypos) + { + canScrollUp = false; + } + else + { + canScrollDown = true; + ev_pos.setY(rmapyDev(rmapy(ev_pos.y()) - scrollSpeed)); + doVMove = true; + } + } + else + { + } + break; + default: + break; + } + + //printf("Canvas::scrollTimerDone doHMove:%d doVMove:%d\n", doHMove, doVMove); + + if(!doHMove && !doVMove) + { + delete scrollTimer; + scrollTimer=NULL; + doScroll = false; + return; + } + QPoint dist = ev_pos - start; + switch(drag) + { + case DRAG_MOVE: + case DRAG_COPY: + case DRAG_CLONE: + moveItems(ev_pos, 0, false); + break; + case DRAGX_MOVE: + case DRAGX_COPY: + case DRAGX_CLONE: + moveItems(ev_pos, 1, false); + break; + case DRAGY_MOVE: + case DRAGY_COPY: + case DRAGY_CLONE: + moveItems(ev_pos, 2, false); + break; + case DRAG_LASSO: + lasso = QRect(start.x(), start.y(), dist.x(), dist.y()); + redraw(); + break; + case DRAG_NEW: + case DRAG_RESIZE: + if (dist.x()) { + if (dist.x() < 1) + curItem->setWidth(1); + else + curItem->setWidth(dist.x()); + redraw(); + } + break; + default: + break; + } + //printf("Canvas::scrollTimerDone starting scrollTimer: Currently active?%d\n", scrollTimer->isActive()); + + // p3.3.43 Make sure to yield to other events (for up to 3 seconds), otherwise other events + // take a long time to reach us, causing scrolling to take a painfully long time to stop. + // FIXME: Didn't help at all. + //qApp->processEvents(); + // No, try up to 100 ms for each yield. + //qApp->processEvents(100); + // + //scrollTimer->start( 40, TRUE ); // X ms single-shot timer + // OK, changing the timeout from 40 to 80 helped. + //scrollTimer->start( 80, TRUE ); // X ms single-shot timer + scrollTimer->setSingleShot(true); + scrollTimer->start(80); + } + else + { + //printf("Canvas::scrollTimerDone !(drag != DRAG_OFF && doScroll) deleting scrollTimer\n"); + + delete scrollTimer; + scrollTimer=NULL; + } +} + + +//--------------------------------------------------------- +// viewMouseMoveEvent +//--------------------------------------------------------- + +void Canvas::viewMouseMoveEvent(QMouseEvent* event) + { + + ev_pos = event->pos(); + QPoint dist = ev_pos - start; + int ax = ABS(rmapx(dist.x())); + int ay = ABS(rmapy(dist.y())); + bool moving = (ax >= 2) || (ay > 2); + + // set scrolling variables: doScroll, scrollRight + if (drag != DRAG_OFF) { + + + int ex = rmapx(event->x())+mapx(0); + if(ex < 40 && canScrollLeft) + hscrollDir = HSCROLL_LEFT; + else + if(ex > (width() - 40)) + switch(drag) + { + case DRAG_NEW: + case DRAG_RESIZE: + case DRAGX_MOVE: + case DRAGX_COPY: + case DRAGX_CLONE: + case DRAGY_MOVE: + case DRAGY_COPY: + case DRAGY_CLONE: + case DRAG_MOVE: + case DRAG_COPY: + case DRAG_CLONE: + hscrollDir = HSCROLL_RIGHT; + break; + default: + if(canScrollRight) + hscrollDir = HSCROLL_RIGHT; + else + hscrollDir = HSCROLL_NONE; + break; + } + else + hscrollDir = HSCROLL_NONE; + int ey = rmapy(event->y())+mapy(0); + if(ey < 15 && canScrollUp) + vscrollDir = VSCROLL_UP; + else + if(ey > (height() - 15) && canScrollDown) + vscrollDir = VSCROLL_DOWN; + else + vscrollDir = VSCROLL_NONE; + if(hscrollDir != HSCROLL_NONE || vscrollDir != VSCROLL_NONE) + { + doScroll=true; + if (!scrollTimer) + { + scrollTimer= new QTimer(this); + connect( scrollTimer, SIGNAL(timeout()), SLOT(scrollTimerDone()) ); + //scrollTimer->start( 0, TRUE ); // single-shot timer + scrollTimer->setSingleShot(true); // single-shot timer + scrollTimer->start(0); + } + } + else + doScroll=false; + + } + else + { + doScroll=false; + + canScrollLeft = true; + canScrollRight = true; + canScrollUp = true; + canScrollDown = true; + } + + switch (drag) { + case DRAG_LASSO_START: + if (!moving) + break; + drag = DRAG_LASSO; + setCursor(); + // proceed with DRAG_LASSO: + + case DRAG_LASSO: + { + lasso = QRect(start.x(), start.y(), dist.x(), dist.y()); + + // printf("xorg=%d xmag=%d event->x=%d, mapx(xorg)=%d rmapx0=%d xOffset=%d rmapx(xOffset()=%d\n", + // xorg, xmag, event->x(),mapx(xorg), rmapx(0), xOffset(),rmapx(xOffset())); + + } + redraw(); + break; + + case DRAG_MOVE_START: + case DRAG_COPY_START: + case DRAG_CLONE_START: + if (!moving) + break; + if (keyState & Qt::ControlModifier) { + if (ax > ay) { + if (drag == DRAG_MOVE_START) + drag = DRAGX_MOVE; + else if (drag == DRAG_COPY_START) + drag = DRAGX_COPY; + else + drag = DRAGX_CLONE; + } + else { + if (drag == DRAG_MOVE_START) + drag = DRAGY_MOVE; + else if (drag == DRAG_COPY_START) + drag = DRAGY_COPY; + else + drag = DRAGY_CLONE; + } + } + else { + if (drag == DRAG_MOVE_START) + drag = DRAG_MOVE; + else if (drag == DRAG_COPY_START) + drag = DRAG_COPY; + else + drag = DRAG_CLONE; + } + setCursor(); + if (!curItem->isSelected()) { + if (drag == DRAG_MOVE) + deselectAll(); + selectItem(curItem, true); + updateSelection(); + redraw(); + } + DragType dt; + if (drag == DRAG_MOVE) + dt = MOVE_MOVE; + else if (drag == DRAG_COPY) + dt = MOVE_COPY; + else + dt = MOVE_CLONE; + + startMoving(ev_pos, dt); + break; + + case DRAG_MOVE: + case DRAG_COPY: + case DRAG_CLONE: + + if(!scrollTimer) + moveItems(ev_pos, 0); + break; + + case DRAGX_MOVE: + case DRAGX_COPY: + case DRAGX_CLONE: + if(!scrollTimer) + moveItems(ev_pos, 1); + break; + + case DRAGY_MOVE: + case DRAGY_COPY: + case DRAGY_CLONE: + if(!scrollTimer) + moveItems(ev_pos, 2); + break; + + case DRAG_NEW: + case DRAG_RESIZE: + if (dist.x()) { + if (dist.x() < 1) + curItem->setWidth(1); + else + curItem->setWidth(dist.x()); + redraw(); + } + break; + case DRAG_DELETE: + deleteItem(ev_pos); + break; + + case DRAG_OFF: + break; + } + + mouseMove(ev_pos); + } + +//--------------------------------------------------------- +// viewMouseReleaseEvent +//--------------------------------------------------------- + +void Canvas::viewMouseReleaseEvent(QMouseEvent* event) + { +// printf("release %x %x\n", event->state(), event->button()); + + doScroll = false; + canScrollLeft = true; + canScrollRight = true; + canScrollUp = true; + canScrollDown = true; + ///if (event->state() & (Qt::LeftButton|Qt::RightButton|Qt::MidButton) & ~(event->button())) { + if (event->buttons() & (Qt::LeftButton|Qt::RightButton|Qt::MidButton) & ~(event->button())) { + ///printf("ignore %x %x\n", keyState, event->button()); + //printf("viewMouseReleaseEvent ignore buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button()); + return; + } + + QPoint pos = event->pos(); + ///bool shift = event->state() & Qt::ShiftModifier; + bool shift = ((QInputEvent*)event)->modifiers() & Qt::ShiftModifier; + bool redrawFlag = false; + + switch (drag) { + case DRAG_MOVE_START: + case DRAG_COPY_START: + case DRAG_CLONE_START: + if (!shift) + deselectAll(); + selectItem(curItem, !(shift && curItem->isSelected())); + updateSelection(); + redrawFlag = true; + itemReleased(curItem, curItem->pos()); + break; + case DRAG_COPY: + endMoveItems(pos, MOVE_COPY, 0); + break; + case DRAGX_COPY: + endMoveItems(pos, MOVE_COPY, 1); + break; + case DRAGY_COPY: + endMoveItems(pos, MOVE_COPY, 2); + break; + case DRAG_MOVE: + endMoveItems(pos, MOVE_MOVE, 0); + break; + case DRAGX_MOVE: + endMoveItems(pos, MOVE_MOVE, 1); + break; + case DRAGY_MOVE: + endMoveItems(pos, MOVE_MOVE, 2); + break; + case DRAG_CLONE: + endMoveItems(pos, MOVE_CLONE, 0); + break; + case DRAGX_CLONE: + endMoveItems(pos, MOVE_CLONE, 1); + break; + case DRAGY_CLONE: + endMoveItems(pos, MOVE_CLONE, 2); + break; + case DRAG_OFF: + break; + case DRAG_RESIZE: + resizeItem(curItem, false); + break; + case DRAG_NEW: + newItem(curItem, false); + redrawFlag = true; + break; + case DRAG_LASSO_START: + lasso.setRect(-1, -1, -1, -1); + if (!shift) + deselectAll(); + updateSelection(); + redrawFlag = true; + break; + + case DRAG_LASSO: + if (!shift) + deselectAll(); + lasso = lasso.normalized(); + selectLasso(shift); + updateSelection(); + redrawFlag = true; + break; + + case DRAG_DELETE: + break; + } + //printf("Canvas::viewMouseReleaseEvent setting drag to DRAG_OFF\n"); + + drag = DRAG_OFF; + if (redrawFlag) + redraw(); + setCursor(); + } + +//--------------------------------------------------------- +// selectLasso +//--------------------------------------------------------- + +void Canvas::selectLasso(bool toggle) + { + int n = 0; + if (virt()) { + for (iCItem i = items.begin(); i != items.end(); ++i) { + if (i->second->intersects(lasso)) { + selectItem(i->second, !(toggle && i->second->isSelected())); + ++n; + } + } + } + else { + for (iCItem i = items.begin(); i != items.end(); ++i) { + QRect box = i->second->bbox(); + int x = rmapxDev(box.x()); + int y = rmapyDev(box.y()); + int w = rmapxDev(box.width()); + int h = rmapyDev(box.height()); + QRect r(x, y, w, h); + ///r.moveBy(i->second->pos().x(), i->second->pos().y()); + r.translate(i->second->pos().x(), i->second->pos().y()); + if (r.intersects(lasso)) { + selectItem(i->second, !(toggle && i->second->isSelected())); + ++n; + } + } + } + + + + if (n) { + updateSelection(); + redraw(); + } + } + +//--------------------------------------------------------- +// endMoveItems +// dir = 0 move in all directions +// 1 move only horizontal +// 2 move only vertical +//--------------------------------------------------------- + +void Canvas::endMoveItems(const QPoint& pos, DragType dragtype, int dir) + { + startUndo(dragtype); + + int dp = y2pitch(pos.y()) - y2pitch(start.y()); + int dx = pos.x() - start.x(); + + if (dir == 1) + dp = 0; + else if (dir == 2) + dx = 0; + + + + int modified = 0; + + // Removed by T356. + /* + for (iCItem i = moving.begin(); i != moving.end(); ++i) { + int x = i->second->pos().x(); + int y = i->second->pos().y(); + int nx = x + dx; + int ny = pitch2y(y2pitch(y) + dp); + QPoint newpos = raster(QPoint(nx, ny)); + selectItem(i->second, true); + + if (moveItem(i->second, newpos, dragtype, &modified)) + i->second->move(newpos); + if (moving.size() == 1) { + itemReleased(curItem, newpos); + } + if (dragtype == MOVE_COPY || dragtype == MOVE_CLONE) + selectItem(i->second, false); + } + */ + + moveCanvasItems(moving, dp, dx, dragtype, &modified); + + endUndo(dragtype, modified); + moving.clear(); + updateSelection(); + redraw(); + } + +//--------------------------------------------------------- +// getCurrentDrag +// returns 0 if there is no drag operation +//--------------------------------------------------------- + +int Canvas::getCurrentDrag() + { + //printf("getCurrentDrag=%d\n", drag); + return drag; + } + +//--------------------------------------------------------- +// deleteItem +//--------------------------------------------------------- + +void Canvas::deleteItem(const QPoint& p) + { + if (virt()) { + for (iCItem i = items.begin(); i != items.end(); ++i) { + if (i->second->contains(p)) { + selectItem(i->second, false); + if (!deleteItem(i->second)) { + if (drag == DRAG_DELETE) + drag = DRAG_OFF; + } + break; + } + } + } + else { + for (iCItem i = items.begin(); i != items.end(); ++i) { + QRect box = i->second->bbox(); + int x = rmapxDev(box.x()); + int y = rmapyDev(box.y()); + int w = rmapxDev(box.width()); + int h = rmapyDev(box.height()); + QRect r(x, y, w, h); + ///r.moveBy(i->second->pos().x(), i->second->pos().y()); + r.translate(i->second->pos().x(), i->second->pos().y()); + if (r.contains(p)) { + if (deleteItem(i->second)) { + selectItem(i->second, false); + } + break; + } + } + } + } + +//--------------------------------------------------------- +// setTool +//--------------------------------------------------------- + +void Canvas::setTool(int t) + { + if (_tool == Tool(t)) + return; + _tool = Tool(t); + setCursor(); + } + +//--------------------------------------------------------- +// setCursor +//--------------------------------------------------------- + +void Canvas::setCursor() + { + switch (drag) { + case DRAGX_MOVE: + case DRAGX_COPY: + case DRAGX_CLONE: + QWidget::setCursor(QCursor(Qt::SizeHorCursor)); + break; + + case DRAGY_MOVE: + case DRAGY_COPY: + case DRAGY_CLONE: + QWidget::setCursor(QCursor(Qt::SizeVerCursor)); + break; + + case DRAG_MOVE: + case DRAG_COPY: + case DRAG_CLONE: + QWidget::setCursor(QCursor(Qt::SizeAllCursor)); + break; + + case DRAG_RESIZE: + QWidget::setCursor(QCursor(Qt::SizeHorCursor)); + break; + + case DRAG_DELETE: + case DRAG_COPY_START: + case DRAG_CLONE_START: + case DRAG_MOVE_START: + case DRAG_NEW: + case DRAG_LASSO_START: + case DRAG_LASSO: + case DRAG_OFF: + switch(_tool) { + case PencilTool: + QWidget::setCursor(QCursor(*pencilIcon, 4, 15)); + break; + case RubberTool: + QWidget::setCursor(QCursor(*deleteIcon, 4, 15)); + break; + case GlueTool: + QWidget::setCursor(QCursor(*glueIcon, 4, 15)); + break; + case CutTool: + QWidget::setCursor(QCursor(*cutIcon, 4, 15)); + break; + case MuteTool: + QWidget::setCursor(QCursor(*editmuteIcon, 4, 15)); + break; + default: + QWidget::setCursor(QCursor(Qt::ArrowCursor)); + break; + } + break; + } + } + +//--------------------------------------------------------- +// keyPress +//--------------------------------------------------------- + +void Canvas::keyPress(QKeyEvent* event) + { + event->ignore(); + } + +//--------------------------------------------------------- +// isSingleSelection +//--------------------------------------------------------- + +bool Canvas::isSingleSelection() + { + return selectionSize() == 1; + } + +//--------------------------------------------------------- +// selectionSize +//--------------------------------------------------------- + +int Canvas::selectionSize() + { + int n = 0; + for (iCItem i = items.begin(); i != items.end(); ++i) { + if (i->second->isSelected()) + ++n; + } + return n; + } + +//--------------------------------------------------------- +// genCanvasPopup +//--------------------------------------------------------- + +QMenu* Canvas::genCanvasPopup() + { + if (canvasTools == 0) + return 0; + QMenu* canvasPopup = new QMenu(this); + QAction* act0 = 0; + + for (unsigned i = 0; i < 9; ++i) { + if ((canvasTools & (1 << i))==0) + continue; + QAction* act = canvasPopup->addAction(QIcon(**toolList[i].icon), tr(toolList[i].tip)); + act->setData(1<<i); // ddskrjo + if (!act0) + act0 = act; + } + canvasPopup->setActiveAction(act0); + return canvasPopup; + } + +//--------------------------------------------------------- +// canvasPopup +//--------------------------------------------------------- + +void Canvas::canvasPopup(int n) + { + setTool(n); + emit toolChanged(n); + } + +void Canvas::setCurrentPart(Part* part) +{ + curItem = NULL; + deselectAll(); + curPart = part; + curPartId = curPart->sn(); + curPartChanged(); +} diff --git a/attic/muse2-oom/muse2/muse/widgets/canvas.h b/attic/muse2-oom/muse2/muse/widgets/canvas.h new file mode 100644 index 00000000..595fe04e --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/canvas.h @@ -0,0 +1,185 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: canvas.h,v 1.3.2.8 2009/02/02 21:38:01 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __CANVAS_H__ +#define __CANVAS_H__ + +#include "citem.h" +#include "view.h" +#include "tools.h" + +#include <QWheelEvent> +#include <QMouseEvent> +#include <QKeyEvent> + +class QMenu; + +//--------------------------------------------------------- +// Canvas +//--------------------------------------------------------- + +class Canvas : public View { + Q_OBJECT + int canvasTools; + QTimer *scrollTimer; + + bool doScroll; + int scrollSpeed; + + QPoint ev_pos; + bool canScrollLeft; + bool canScrollRight; + bool canScrollUp; + bool canScrollDown; + protected: + enum DragMode { + DRAG_OFF, DRAG_NEW, + DRAG_MOVE_START, DRAG_MOVE, + DRAG_COPY_START, DRAG_COPY, + DRAG_CLONE_START, DRAG_CLONE, + DRAGX_MOVE, DRAGY_MOVE, + DRAGX_COPY, DRAGY_COPY, + DRAGX_CLONE, DRAGY_CLONE, + DRAG_DELETE, + DRAG_RESIZE, DRAG_LASSO_START, DRAG_LASSO, + }; + + enum DragType { + MOVE_MOVE, MOVE_COPY, MOVE_CLONE + }; + + enum HScrollDir { + HSCROLL_NONE, HSCROLL_LEFT, HSCROLL_RIGHT + }; + enum VScrollDir { + VSCROLL_NONE, VSCROLL_UP, VSCROLL_DOWN + }; + + CItemList items; + CItemList moving; + CItem* curItem; + Part* curPart; + int curPartId; + + DragMode drag; + QRect lasso; + QPoint start; + Tool _tool; + unsigned pos[3]; + + HScrollDir hscrollDir; + VScrollDir vscrollDir; + int button; + Qt::KeyboardModifiers keyState; + QMenu* itemPopupMenu; + QMenu* canvasPopupMenu; + + void setCursor(); + virtual void viewKeyPressEvent(QKeyEvent* event); + virtual void viewMousePressEvent(QMouseEvent* event); + virtual void viewMouseMoveEvent(QMouseEvent*); + virtual void viewMouseReleaseEvent(QMouseEvent*); + virtual void draw(QPainter&, const QRect&); + virtual void wheelEvent(QWheelEvent* e); + + virtual void mousePress(QMouseEvent*) {} + virtual void keyPress(QKeyEvent*); + virtual void mouseMove(const QPoint&) = 0; + virtual void mouseRelease(const QPoint&) {} + virtual void drawCanvas(QPainter&, const QRect&) = 0; + virtual void drawItem(QPainter&, const CItem*, const QRect&) = 0; + virtual void drawMoving(QPainter&, const CItem*, const QRect&) = 0; + virtual void updateSelection() = 0; + virtual QPoint raster(const QPoint&) const = 0; + virtual int y2pitch(int) const = 0; //CDW + virtual int pitch2y(int) const = 0; //CDW + + virtual void moveCanvasItems(CItemList&, int, int, DragType, int*) = 0; + // Changed by T356. + //virtual bool moveItem(CItem*, const QPoint&, DragType, int*) = 0; + virtual bool moveItem(CItem*, const QPoint&, DragType) = 0; + virtual CItem* newItem(const QPoint&, int state) = 0; + virtual void resizeItem(CItem*, bool noSnap=false) = 0; + virtual void newItem(CItem*, bool noSnap=false) = 0; + virtual bool deleteItem(CItem*) = 0; + virtual void startUndo(DragType) = 0; + + virtual void endUndo(DragType, int flags) = 0; + int getCurrentDrag(); + + /*! + \brief Virtual member + + Implementing class is responsible for creating a popup to be shown when the user rightclicks an item on the Canvas + \param item The canvas item that is rightclicked + \return A QPopupMenu* + */ + virtual QMenu* genItemPopup(CItem* /*item*/) { return 0; } + + /*! + \brief Pure virtual member + + Implementing class is responsible for creating a popup to be shown when the user rightclicks an empty region of the canvas + \return A QPopupMenu* + */ + QMenu* genCanvasPopup(); + + /*! + \brief Virtual member + + This is the function called when the user has selected an option in the popupmenu generated by genItemPopup() + \param item the canvas item the whole thing is about + \param n Command type + \param pt I think this is the position of the pointer when right mouse button was pressed + */ + virtual void itemPopup(CItem* /*item */, int /*n*/, const QPoint& /*pt*/) {} + void canvasPopup(int); + + virtual void startDrag(CItem*, bool) {} + + // selection + virtual void deselectAll(); + virtual void selectItem(CItem* e, bool); + + virtual void deleteItem(const QPoint&); + + // moving + void startMoving(const QPoint&, DragType); + + void moveItems(const QPoint&, int dir, bool rasterize = true); + void endMoveItems(const QPoint&, DragType, int dir); + + virtual void selectLasso(bool toggle); + + virtual void itemPressed(const CItem*) {} + virtual void itemReleased(const CItem*, const QPoint&) {} + virtual void itemMoved(const CItem*, const QPoint&) {} + virtual void curPartChanged() {} + + public slots: + void setTool(int t); + void setPos(int, unsigned, bool adjustScrollbar); + void scrollTimerDone(void); + void redirectedWheelEvent(QWheelEvent*); + + signals: + void followEvent(int); + void toolChanged(int); + void verticalScroll(unsigned); + void horizontalScroll(unsigned); + void horizontalScrollNoLimit(unsigned); + public: + Canvas(QWidget* parent, int sx, int sy, const char* name = 0); + bool isSingleSelection(); + int selectionSize(); + Tool tool() const { return _tool; } + Part* part() const { return curPart; } + void setCurrentPart(Part*); + void setCanvasTools(int n) { canvasTools = n; } + }; +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/checkbox.cpp b/attic/muse2-oom/muse2/muse/widgets/checkbox.cpp new file mode 100644 index 00000000..8f706361 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/checkbox.cpp @@ -0,0 +1,59 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: checkbox.cpp,v 1.2.2.2 2006/10/29 07:54:52 terminator356 Exp $ +// (C) Copyright 2004 Werner Schweer (ws@seh.de) +//========================================================= + +#include "checkbox.h" + +#include <QMouseEvent> + +//--------------------------------------------------------- +// CheckBox +//--------------------------------------------------------- + +CheckBox::CheckBox(QWidget* parent, int i, const char* name) + : QCheckBox(parent) + { + setObjectName(name); + _id = i; + connect(this, SIGNAL(toggled(bool)), SLOT(hasToggled(bool))); + } + +void CheckBox::hasToggled(bool val) + { + emit toggleChanged(val, _id); + } + +//------------------------------------------------------------ +// mousePressEvent +//------------------------------------------------------------ + +void CheckBox::mousePressEvent(QMouseEvent *e) +{ + if(e->button() == Qt::RightButton) + emit checkboxRightClicked(e->globalPos(), _id); + else + { + if(isChecked()) + setChecked(false); + else + setChecked(true); + emit checkboxPressed(_id); + } +} + +//------------------------------------------------------------ +// mouseReleaseEvent +//------------------------------------------------------------ + +void CheckBox::mouseReleaseEvent(QMouseEvent *e) +{ + if(e->button() == Qt::RightButton) + return; + + emit checkboxReleased(_id); +} + + diff --git a/attic/muse2-oom/muse2/muse/widgets/checkbox.h b/attic/muse2-oom/muse2/muse/widgets/checkbox.h new file mode 100644 index 00000000..f9b58ad1 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/checkbox.h @@ -0,0 +1,44 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: checkbox.h,v 1.2.2.2 2006/10/29 07:54:52 terminator356 Exp $ +// (C) Copyright 2004 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __CHECKBOX_H__ +#define __CHECKBOX_H__ + +#include <QCheckBox> + + +//--------------------------------------------------------- +// CheckBox +//--------------------------------------------------------- + +class CheckBox : public QCheckBox { + Q_OBJECT + Q_PROPERTY( int id READ id WRITE setId ) + + int _id; + + protected: + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + + private slots: + void hasToggled(bool val); + + signals: + void toggleChanged(bool, int); + void checkboxPressed(int); + void checkboxReleased(int); + void checkboxRightClicked(const QPoint &, int); + + public: + CheckBox(QWidget* parent, int i, const char* name = 0); + int id() const { return _id; } + void setId(int i) { _id = i; } + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/citem.cpp b/attic/muse2-oom/muse2/muse/widgets/citem.cpp new file mode 100644 index 00000000..2974196d --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/citem.cpp @@ -0,0 +1,93 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: citem.cpp,v 1.2.2.3 2008/01/26 07:23:21 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include "part.h" +#include "citem.h" +#include <stdio.h> + +//--------------------------------------------------------- +// CItem +//--------------------------------------------------------- + +CItem::CItem() + { + _isMoving = false; + } + +CItem::CItem(const QPoint&p, const QRect& r) + { + _pos = p; + _bbox = r; + _isMoving = false; + } + +// Changed by Tim. p3.3.20 +//CItem::CItem(Event e, Part* p) +CItem::CItem(const Event& e, Part* p) + { + _event = e; + _part = p; + _isMoving = false; + } + +//--------------------------------------------------------- +// isSelected +//--------------------------------------------------------- + +bool CItem::isSelected() const + { + return _event.empty() ? _part->selected() : _event.selected(); + } + +//--------------------------------------------------------- +// setSelected +//--------------------------------------------------------- + +void CItem::setSelected(bool f) + { + _event.empty() ? _part->setSelected(f) : _event.setSelected(f); + } + +//--------------------------------------------------------- +// CItemList +//--------------------------------------------------------- + +CItem* CItemList::find(const QPoint& pos) const + { + rciCItem ius; + bool usfound = false; + for (rciCItem i = rbegin(); i != rend(); ++i) { + if (i->second->contains(pos)) + { + if(i->second->isSelected()) + return i->second; + + else + { + if(!usfound) + { + ius = i; + usfound = true; + } + } + } + } + if(usfound) + return ius->second; + else + return 0; + } + +//--------------------------------------------------------- +// CItemList +//--------------------------------------------------------- + +void CItemList::add(CItem* item) + { + std::multimap<int, CItem*, std::less<int> >::insert(std::pair<const int, CItem*> (item->bbox().x(), item)); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/citem.h b/attic/muse2-oom/muse2/muse/widgets/citem.h new file mode 100644 index 00000000..cd77f51d --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/citem.h @@ -0,0 +1,90 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: citem.h,v 1.2.2.1 2006/10/04 18:45:35 spamatica Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __CITEM_H__ +#define __CITEM_H__ + +#include <map> +#include <QPoint> +#include <QRect> + +#include "event.h" + +class Event; +class Part; + +//--------------------------------------------------------- +// CItem +// virtuelle Basisklasse fr alle Canvas Item's +//--------------------------------------------------------- + +class CItem { + private: + Event _event; + Part* _part; + + protected: + bool _isMoving; + QPoint moving; + QRect _bbox; + QPoint _pos; + + public: + CItem(const QPoint& p, const QRect& r); + CItem(); + // Changed by Tim. p3.3.20 + //CItem(Event e, Part* p); + CItem(const Event& e, Part* p); + + bool isMoving() const { return _isMoving; } + void setMoving(bool f) { _isMoving = f; } + bool isSelected() const; + void setSelected(bool f); + + int width() const { return _bbox.width(); } + void setWidth(int l) { _bbox.setWidth(l); } + void setHeight(int l) { _bbox.setHeight(l); } + void setMp(const QPoint&p) { moving = p; } + const QPoint mp() const { return moving; } + int x() const { return _pos.x(); } + int y() const { return _pos.y(); } + void setY(int y) { _bbox.setY(y); } + QPoint pos() const { return _pos; } + void setPos(const QPoint& p) { _pos = p; } + int height() const { return _bbox.height(); } + const QRect& bbox() const { return _bbox; } + void setBBox(const QRect& r) { _bbox = r; } + void move(const QPoint& tl) { + _bbox.moveTopLeft(tl); + _pos = tl; + } + bool contains(const QPoint& p) const { return _bbox.contains(p); } + bool intersects(const QRect& r) const { return r.intersects(_bbox); } + + Event event() const { return _event; } + void setEvent(Event& e) { _event = e; } + Part* part() const { return _part; } + void setPart(Part* p) { _part = p; } + }; + +typedef std::multimap<int, CItem*, std::less<int> >::iterator iCItem; +//typedef std::multimap<int, CItem*, std::less<int> >::const_iterator ciCItem; +typedef std::multimap<int, CItem*, std::less<int> >::const_reverse_iterator rciCItem; + +//--------------------------------------------------------- +// CItemList +// Canvas Item List +//--------------------------------------------------------- + +class CItemList: public std::multimap<int, CItem*, std::less<int> > { + public: + void add(CItem*); + CItem* find(const QPoint& pos) const; + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/cliplisteditorbase.ui b/attic/muse2-oom/muse2/muse/widgets/cliplisteditorbase.ui new file mode 100644 index 00000000..c07e722f --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/cliplisteditorbase.ui @@ -0,0 +1,167 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0" stdsetdef="1"> + <author></author> + <comment></comment> + <exportmacro></exportmacro> + <class>ClipListEditorBase</class> + <widget class="QWidget" name="ClipListEditorBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>600</width> + <height>480</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: ClipList</string> + </property> + <layout class="QVBoxLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item> + <widget class="QTreeWidget" name="view"> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <property name="rootIsDecorated"> + <bool>true</bool> + </property> + <column> + <property name="text"> + <string>Name</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizeable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Refs</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizeable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Start</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizeable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Len</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizeable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Data</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizeable"> + <bool>true</bool> + </property> + </column> + </widget> + </item> + <item> + <widget class="QGroupBox" name="GroupBox1"> + <property name="title"> + <string>Clip Properties</string> + </property> + <layout class="QHBoxLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> + <string>Pos:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="Awl::PosEdit" name="start"> + <property name="smpte"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>Len:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="Awl::PosEdit" name="len"> + <property name="smpte"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="Spacer1"> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <customwidgets> + <customwidget> + <class>Awl::PosEdit</class> + <extends>QWidget</extends> + <header>awl/posedit.h</header> + <container>0</container> + </customwidget> + </customwidgets> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/comboQuant.cpp b/attic/muse2-oom/muse2/muse/widgets/comboQuant.cpp new file mode 100644 index 00000000..87d88fca --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/comboQuant.cpp @@ -0,0 +1,94 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: comboQuant.cpp,v 1.1.1.1 2003/10/27 18:54:52 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> + +#include <QTableWidget> +#include <QTableWidgetItem> +#include <QHeaderView> + +#include "comboQuant.h" + +static int quantTable[] = { + 1, 16, 32, 64, 128, 256, 512, 1024, + 1, 24, 48, 96, 192, 384, 768, 1536, + 1, 36, 72, 144, 288, 576, 1152, 2304 + }; + +static const char* quantStrings[] = { + QT_TRANSLATE_NOOP("@default", "Off"), "64T", "32T", "16T", "8T", "4T", "2T", "1T", + QT_TRANSLATE_NOOP("@default", "Off"), "64", "32", "16", "8", "4", "2", "1", + QT_TRANSLATE_NOOP("@default", "Off"), "64.", "32.", "16.", "8.", "4.", "2.", "1." + }; + +//--------------------------------------------------------- +// ComboQuant +//--------------------------------------------------------- + +ComboQuant::ComboQuant(QWidget* parent) + : QComboBox(parent) + { + ///Q3ListBox* qlist = new Q3ListBox(this); + ///qlist->setMinimumWidth(95); + //setListBox(qlist); ddskrjo + ///qlist->setColumnMode(3); + + + qlist = new QTableWidget(8, 3); + qlist->verticalHeader()->setDefaultSectionSize(22); + qlist->horizontalHeader()->setDefaultSectionSize(32); + qlist->setSelectionMode(QAbstractItemView::SingleSelection); + qlist->verticalHeader()->hide(); + qlist->horizontalHeader()->hide(); + + qlist->setMinimumWidth(96); + + setView(qlist); + + ///for (int i = 0; i < 24; i++) + /// qlist->insertItem(tr(quantStrings[i]), i); + for (int j = 0; j < 3; j++) + for (int i = 0; i < 8; i++) + qlist->setItem(i, j, new QTableWidgetItem(tr(quantStrings[i + j * 8]))); + + + connect(this, SIGNAL(activated(int)), SLOT(activated(int))); + } + +//--------------------------------------------------------- +// activated +//--------------------------------------------------------- + +void ComboQuant::activated(int /*index*/) + { + ///emit valueChanged(quantTable[index]); + emit valueChanged(quantTable[qlist->currentRow() + qlist->currentColumn() * 8]); + } + +//--------------------------------------------------------- +// setQuant +//--------------------------------------------------------- + +void ComboQuant::setValue(int val) + { + for (int i = 0; i < 24; i++) { + if (val == quantTable[i]) { + setCurrentIndex(i); + return; + } + } + + for (unsigned i = 0; i < sizeof(quantTable)/sizeof(*quantTable); i++) { + if (val == quantTable[i]) { + setCurrentIndex(i); + return; + } + } + printf("ComboQuant::setValue(%d) not defined\n", val); + setCurrentIndex(0); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/comboQuant.h b/attic/muse2-oom/muse2/muse/widgets/comboQuant.h new file mode 100644 index 00000000..501f0a14 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/comboQuant.h @@ -0,0 +1,39 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: comboQuant.h,v 1.1.1.1 2003/10/27 18:54:30 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __COMBOQUANT_H__ +#define __COMBOQUANT_H__ + +#include <QComboBox> +//#include <QWidget> +//#include <QTableWidget> + +class QWidget; +class QTableWidget; + +//--------------------------------------------------------- +// ComboQuant +//--------------------------------------------------------- + +class ComboQuant : public QComboBox { + Q_OBJECT + + QTableWidget* qlist; + + private slots: + void activated(int); + + signals: + void valueChanged(int); + + public: + ComboQuant(QWidget* parent = 0); + void setValue(int val); + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/combobox.cpp b/attic/muse2-oom/muse2/muse/widgets/combobox.cpp new file mode 100644 index 00000000..9e278376 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/combobox.cpp @@ -0,0 +1,80 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: combobox.cpp,v 1.4 2004/05/06 15:08:07 wschweer Exp $ +// (C) Copyright 2004 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QMenu> + +#include "combobox.h" + +//--------------------------------------------------------- +// ComboBox +//--------------------------------------------------------- + +ComboBox::ComboBox(QWidget* parent, const char* name) + : QLabel(parent) + { + setObjectName(name); + _currentItem = 0; + _id = -1; + list = new QMenu(0); + connect(list, SIGNAL(triggered(QAction*)), SLOT(activatedIntern(QAction*))); + setFrameStyle(QFrame::Panel | QFrame::Raised); + setLineWidth(2); + } + +ComboBox::~ComboBox() + { + delete list; + } + +//--------------------------------------------------------- +// mousePressEvent +//--------------------------------------------------------- + +void ComboBox::mousePressEvent(QMouseEvent*) + { + list->exec(QCursor::pos()); + } + +//--------------------------------------------------------- +// activated +//--------------------------------------------------------- + +void ComboBox::activatedIntern(QAction* act) + { + _currentItem = act->data().toInt(); + emit activated(_currentItem, _id); + setText(act->text()); + } + +//--------------------------------------------------------- +// setCurrentItem +//--------------------------------------------------------- + +void ComboBox::setCurrentItem(int i) + { + _currentItem = i; + // ORCAN - CHECK + QList<QAction *> actions = list->actions(); + for (QList<QAction *>::iterator it = actions.begin(); it != actions.end(); ++it) { + QAction* act = *it; + if (act->data().toInt() == i) { + setText(act->text()); + break; + } + } + } + +//--------------------------------------------------------- +// insertItem +//--------------------------------------------------------- + +void ComboBox::insertItem(const QString& s, int id) + { + QAction *act = list->addAction(s); + act->setData(id); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/combobox.h b/attic/muse2-oom/muse2/muse/widgets/combobox.h new file mode 100644 index 00000000..305ad0b3 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/combobox.h @@ -0,0 +1,46 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: combobox.h,v 1.3 2004/02/29 12:12:36 wschweer Exp $ +// (C) Copyright 2004 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __COMBOBOX_H__ +#define __COMBOBOX_H__ + +#include <QLabel> + +class QMenu; + +//--------------------------------------------------------- +// ComboBox +//--------------------------------------------------------- + +class ComboBox : public QLabel { + Q_OBJECT + Q_PROPERTY( int id READ id WRITE setId ) + + int _id; + int _currentItem; + QMenu* list; + virtual void mousePressEvent(QMouseEvent*); + + private slots: + void activatedIntern(QAction*); + + signals: + void activated(int val, int id); + + public: + ComboBox(QWidget* parent, const char* name = 0); + ~ComboBox(); + void setCurrentItem(int); + void insertItem(const QString& s, int id = -1); + int id() const { return _id; } + void setId(int i) { _id = i; } + }; + +#endif + + + diff --git a/attic/muse2-oom/muse2/muse/widgets/comment.cpp b/attic/muse2-oom/muse2/muse/widgets/comment.cpp new file mode 100644 index 00000000..36298330 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/comment.cpp @@ -0,0 +1,89 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: comment.cpp,v 1.2 2004/02/08 18:30:00 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include "comment.h" +#include "song.h" +#include "track.h" + +#include <QWidget> + +//--------------------------------------------------------- +// Comment +//--------------------------------------------------------- + +Comment::Comment(QWidget* parent) + : QWidget(parent) + { + setupUi(this); + } + +//--------------------------------------------------------- +// textChanged +//--------------------------------------------------------- + +void Comment::textChanged() + { + setText(textentry->toPlainText()); + } + +//--------------------------------------------------------- +// TrackComment +//--------------------------------------------------------- + +TrackComment::TrackComment(Track* t, QWidget* parent) + : Comment(parent) + { + setAttribute(Qt::WA_DeleteOnClose); + setWindowTitle(tr("MusE: Track Comment")); + track = t; + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + textentry->setText(track->comment()); + textentry->moveCursor(QTextCursor::End); + connect(textentry, SIGNAL(textChanged()), SLOT(textChanged())); + label1->setText(tr("Track Comment:")); + label2->setText(track->name()); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void TrackComment::songChanged(int flags) + { + if ((flags & (SC_TRACK_INSERTED|SC_TRACK_REMOVED|SC_TRACK_MODIFIED)) == 0) + return; + + // check if track still exists: + TrackList* tl = song->tracks(); + iTrack it; + for (it = tl->begin(); it != tl->end(); ++it) { + if (track == *it) + break; + } + if (it == tl->end()) { + close(); + return; + } + label2->setText(track->name()); + if (track->comment() != textentry->toPlainText()) { + disconnect(textentry, SIGNAL(textChanged()), this, SLOT(textChanged())); + textentry->setText(track->comment()); + textentry->moveCursor(QTextCursor::End); + connect(textentry, SIGNAL(textChanged()), this, SLOT(textChanged())); + } + } + +//--------------------------------------------------------- +// setText +//--------------------------------------------------------- + +void TrackComment::setText(const QString& s) + { + track->setComment(s); + song->update(SC_TRACK_MODIFIED); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/comment.h b/attic/muse2-oom/muse2/muse/widgets/comment.h new file mode 100644 index 00000000..688d7b2f --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/comment.h @@ -0,0 +1,53 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: comment.h,v 1.2 2004/02/08 18:30:00 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __COMMENT_H__ +#define __COMMENT_H__ + +#include "ui_commentbase.h" + +class Xml; +class Track; +class QWidget; + +//--------------------------------------------------------- +// Comment +//--------------------------------------------------------- + +class Comment : public QWidget, public Ui::CommentBase { + Q_OBJECT + + private: + virtual void setText(const QString& s) = 0; + + private slots: + void textChanged(); + + public: + Comment(QWidget* parent); + }; + +//--------------------------------------------------------- +// TrackComment +//--------------------------------------------------------- + +class TrackComment : public Comment { + Track* track; + Q_OBJECT + + private: + virtual void setText(const QString& s); + + private slots: + void songChanged(int); + + public: + TrackComment(Track*, QWidget*); + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/commentbase.ui b/attic/muse2-oom/muse2/muse/widgets/commentbase.ui new file mode 100644 index 00000000..dc82585d --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/commentbase.ui @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CommentBase</class> + <widget class="QWidget" name="CommentBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>387</width> + <height>205</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form1</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <layout class="QHBoxLayout" name="hbox"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Track Comment</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label2"> + <property name="font"> + <font> + <pointsize>12</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="frameShape"> + <enum>QFrame::Box</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + <property name="midLineWidth"> + <number>1</number> + </property> + <property name="text"> + <string>Track 1</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QTextEdit" name="textentry" native="true"> + <property name="font"> + <font> + <pointsize>12</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/configmidifilebase.ui b/attic/muse2-oom/muse2/muse/widgets/configmidifilebase.ui new file mode 100644 index 00000000..920596ec --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/configmidifilebase.ui @@ -0,0 +1,238 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0" stdsetdef="1"> + <author></author> + <comment></comment> + <exportmacro></exportmacro> + <class>ConfigMidiFileBase</class> + <widget class="QDialog" name="ConfigMidiFileBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>548</width> + <height>353</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Config Midi File Import/Export</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout"> + <item> + <widget class="QGroupBox" name="midiImportGroupBox"> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Import:</string> + </property> + <layout class="QGridLayout"> + <item row="0" column="0"> + <widget class="QCheckBox" name="splitPartsCheckBox"> + <property name="text"> + <string>Split tracks into &parts</string> + </property> + <property name="shortcut"> + <string>Alt+P</string> + </property> + <property name="toolTip" stdset="0"> + <string>Split tracks into parts, or one single part</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="midiExportGroupBox"> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Export:</string> + </property> + <layout class="QGridLayout"> + <item row="2" column="1"> + <widget class="QLineEdit" name="copyrightEdit"/> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="divisionCombo"> + <item> + <property name="text"> + <string>96</string> + </property> + </item> + <item> + <property name="text"> + <string>192</string> + </property> + </item> + <item> + <property name="text"> + <string>384</string> + </property> + </item> + </widget> + </item> + <item row="3" column="0" rowspan="1" colspan="2"> + <widget class="QCheckBox" name="extendedFormat"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Enable extended smf format (currently not implemented)</string> + </property> + </widget> + </item> + <item row="4" column="0" rowspan="1" colspan="2"> + <widget class="QCheckBox" name="twoByteTimeSigs"> + <property name="text"> + <string>Use &2-byte time signatures instead of standard 4</string> + </property> + <property name="shortcut"> + <string>Alt+2</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="textLabel2"> + <property name="text"> + <string>Copyright:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="textLabel3"> + <property name="text"> + <string>Format:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="textLabel1"> + <property name="text"> + <string>Division:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="5" column="0" rowspan="1" colspan="2"> + <widget class="QCheckBox" name="optNoteOffs"> + <property name="text"> + <string>Save space by replacing note-offs with &zero velocity note-ons</string> + </property> + <property name="shortcut"> + <string>Alt+Z</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="formatCombo"> + <item> + <property name="text"> + <string>0 (single track)</string> + </property> + </item> + <item> + <property name="text"> + <string>1 (multiple tracks)</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item> + <spacer name="Horizontal Spacing2"> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonOk"> + <property name="text"> + <string>&OK</string> + </property> + <property name="shortcut"> + <string/> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonCancel"> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="shortcut"> + <string/> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>ConfigMidiFileBase</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>ConfigMidiFileBase</receiver> + <slot>reject()</slot> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cpp b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cpp new file mode 100644 index 00000000..911357ee --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cpp @@ -0,0 +1,56 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: ctrlcombo.cpp,v 1.1.1.1 2003/10/27 18:55:02 wschweer Exp $ +// +// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include "ctrlcombo.h" + +//--------------------------------------------------------- +// CtrlComboBox +//--------------------------------------------------------- + +CtrlComboBox::CtrlComboBox(QWidget* parent) + : QComboBox(parent) + { + const char* ctxt[] = { + "No Ctrl", "BankSelMSB", "Modulation", "BreathCtrl", + "Control 3", "Foot Ctrl", "Porta Time", "DataEntMSB", + "MainVolume", "Balance", "Control 9", "Pan", + "Expression", "Control 12", "Control 13", "Control 14", + "Control 15", "Gen.Purp.1", "Gen.Purp.2", "Gen.Purp.3", + "Gen.Purp.4", "Control 20", "Control 21", "Control 22", + "Control 23", "Control 24", "Control 25", "Control 26", + "Control 27", "Control 28", "Control 29", "Control 30", + "Control 31", "BankSelLSB", "Modul. LSB", "BrthCt.LSB", + "Control 35", "FootCt.LSB", "Port.T LSB", "DataEntLSB", + "MainVolLSB", "BalanceLSB", "Control 41", "Pan LSB", + "Expr. LSB", "Control 44", "Control 45", "Control 46", + "Control 47", "Gen.P.1LSB", "Gen.P.2LSB", "Gen.P.3LSB", + "Gen.P.4LSB", "Control 52", "Control 53", "Control 54", + "Control 55", "Control 56", "Control 57", "Control 58", + "Control 59", "Control 60", "Control 61", "Control 62", + "Control 63", "Sustain", "Porta Ped", "Sostenuto", + "Soft Pedal", "Control 68", "Hold 2", "Control 70", + "HarmonicCo", "ReleaseTime", "Attack Time", "Brightness", + "Control 75", "Control 76", "Control 77", "Control 78", + "Control 79", "Gen.Purp.5", "Gen.Purp.6", "Gen.Purp.7", + "Gen.Purp.8", "Porta Ctrl", "Control 85", "Control 86", + "Control 87", "Control 88", "Control 89", "Control 90", + "Effect1Dep", "Effect2Dep", "Effect3Dep", "Effect4Dep", + "Phaser Dep", "Data Incr", "Data Decr", "NRPN LSB", + "NRPN MSB", "RPN LSB", "RPN MSB", "Control102", + "Control103", "Control104", "Control105", "Control106", + "Control107", "Control108", "Control109", "Control110", + "Control111", "Control112", "Control113", "Control114", + "Control115", "Control116", "Control117", "Control118", + "Control119", "AllSndOff", "Reset Ctrl", "Local Ctrl", + "AllNoteOff", "OmniModOff", "OmniModeOn", "MonoModeOn", + "PolyModeOn" + }; + for (unsigned int i = 0; i < sizeof(ctxt)/sizeof(*ctxt); ++i) + insertItem(i, QString(ctxt[i])); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cw b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cw new file mode 100644 index 00000000..f4f5b2ac --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cw @@ -0,0 +1,22 @@ +<!DOCTYPE CW><CW> +<customwidgets> + <customwidget> + <class>CtrlComboBox</class> + <header location="global">ctrlcombo.h</header> + <sizehint> + <width>50</width> + <height>20</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + </sizepolicy> + <pixmap> + <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> + </pixmap> + <signal>activated(int index)</signal> + <signal>activated(const QString&)</signal> + </customwidget> +</customwidgets> +</CW> diff --git a/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.h b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.h new file mode 100644 index 00000000..2feff096 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.h @@ -0,0 +1,22 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: ctrlcombo.h,v 1.1.1.1 2003/10/27 18:54:30 wschweer Exp $ +// +// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __CTRLGRP_H__ +#define __CTRLGRP_H__ + +#include <QComboBox> + +class CtrlComboBox : public QComboBox { + Q_OBJECT + public: + CtrlComboBox(QWidget* parent); + }; + + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/dentry.cpp b/attic/muse2-oom/muse2/muse/widgets/dentry.cpp new file mode 100644 index 00000000..c7aa3c1b --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/dentry.cpp @@ -0,0 +1,242 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: dentry.cpp,v 1.1.1.1.2.3 2008/08/18 00:15:26 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> + +#include <QContextMenuEvent> +#include <QTimer> + +#include "dentry.h" +#include "globals.h" + +#define TIMER1 400 +#define TIMER2 200 +#define TIMEC 7 +#define TIMER3 100 +#define TIMEC2 20 +#define TIMER4 50 + +//--------------------------------------------------------- +// Dentry +// lineedit double values +//--------------------------------------------------------- + +Dentry::Dentry(QWidget* parent, const char* name) : QLineEdit(parent) + { + setObjectName(name); + _slider = 0; + _id = -1; + drawFrame = false; + QLineEdit::setFrame(drawFrame); + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), SLOT(repeat())); + val = 0.01; + connect(this, SIGNAL(returnPressed()), SLOT(endEdit())); + setCursor(QCursor(Qt::ArrowCursor)); + evx = 1.0; + } + +//--------------------------------------------------------- +// contextMenuEvent +//--------------------------------------------------------- + +void Dentry::contextMenuEvent(QContextMenuEvent * e) +{ + e->accept(); +} + +//--------------------------------------------------------- +// setFrame +//--------------------------------------------------------- + +void Dentry::setFrame(bool flag) + { + drawFrame = flag; + QLineEdit::setFrame(drawFrame); + update(); + } + +//--------------------------------------------------------- +// endEdit +//--------------------------------------------------------- + +void Dentry::endEdit() + { + if (isModified()) { + if (setSValue(text())) { + setString(val); + return; + } + } + setString(val); + clearFocus(); + if (!drawFrame) + QLineEdit::setFrame(false); + } + +//--------------------------------------------------------- +// mousePressEvent +//--------------------------------------------------------- + +void Dentry::mousePressEvent(QMouseEvent* event) + { + button = event->button(); + starty = event->y(); + evx = double(event->x()); + timecount = 0; + repeat(); + timer->start(TIMER1); + } + +//--------------------------------------------------------- +// wheelEvent +//--------------------------------------------------------- + +void Dentry::wheelEvent(QWheelEvent* event) + { + // Avoid unwanted wheel events from outside the control. + // Tested: No go, can't seem to determine where event came from. + /* + const QPoint gp = mapToGlobal(event->pos()); + const QRect gr = QRect(mapToGlobal(rect().topLeft()), mapToGlobal(rect().bottomRight())); + if(!gr.contains(gp)) + */ + //if(sender() != this) + //{ + // event->ignore(); + // return; + //} + + event->accept(); + + int delta = event->delta(); + + if (delta < 0) + { + if(_slider) + _slider->stepPages(-1); + else + decValue(-1.0); + } + else if (delta > 0) + { + if(_slider) + _slider->stepPages(1); + else + incValue(1.0); + } + } + +//--------------------------------------------------------- +// repeat +//--------------------------------------------------------- + +void Dentry::repeat() + { + if (timecount == 1) { + ++timecount; + timer->stop(); + timer->start(TIMER2); + return; + } + ++timecount; + if (timecount == TIMEC) { + timer->stop(); + timer->start(TIMER3); + } + if (timecount == TIMEC2) { + timer->stop(); + timer->start(TIMER4); + } + + switch (button) { + case Qt::LeftButton: + return; + case Qt::MidButton: + if(_slider) + _slider->stepPages(-1); + else + decValue(evx); + break; + case Qt::RightButton: + if(_slider) + _slider->stepPages(1); + else + incValue(evx); + break; + default: + break; + } + } + +//--------------------------------------------------------- +// mouseReleaseEvent +//--------------------------------------------------------- + +void Dentry::mouseReleaseEvent(QMouseEvent*) + { + button = Qt::NoButton; + timer->stop(); + } + +//--------------------------------------------------------- +// mouseMoveEvent +//--------------------------------------------------------- + +void Dentry::mouseMoveEvent(QMouseEvent*) + { + switch (button) { + case Qt::LeftButton: + break; + case Qt::MidButton: + break; + case Qt::RightButton: + break; + default: + break; + } + } + +//--------------------------------------------------------- +// mouseDoubleClickEvent +//--------------------------------------------------------- + +void Dentry::mouseDoubleClickEvent(QMouseEvent* event) + { + if (event->button() != Qt::LeftButton) { + mousePressEvent(event); + return; + } + setFocus(); + QLineEdit::setFrame(true); + update(); + emit doubleClicked(_id); + } + +//--------------------------------------------------------- +// setValue +//--------------------------------------------------------- + +void Dentry::setValue(double v) + { + if (v == val) + return; + setString(v); +#if 0 + if (setString(v)) { + clearFocus(); + if (!drawFrame) + QLineEdit::setFrame(false); + setEnabled(false); + } + else { + setEnabled(true); + } +#endif + val = v; + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/dentry.h b/attic/muse2-oom/muse2/muse/widgets/dentry.h new file mode 100644 index 00000000..21c9ff38 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/dentry.h @@ -0,0 +1,73 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: dentry.h,v 1.1.1.1.2.3 2008/08/18 00:15:26 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __DENTRY_H__ +#define __DENTRY_H__ + +#include <QLineEdit> + +#include "sliderbase.h" + +//--------------------------------------------------------- +// Dentry +//--------------------------------------------------------- + +class Dentry : public QLineEdit { + Q_OBJECT + + Q_PROPERTY( int id READ id WRITE setId ) + Q_PROPERTY( double value READ value WRITE setValue ) + Q_PROPERTY( bool frame READ frame WRITE setFrame ) + + SliderBase* _slider; + int button; + int starty; + bool drawFrame; + QTimer* timer; + double evx; + int timecount; + + virtual void wheelEvent(QWheelEvent*); + virtual void mousePressEvent(QMouseEvent*); + virtual void mouseMoveEvent(QMouseEvent*); + virtual void mouseDoubleClickEvent(QMouseEvent*); + virtual void mouseReleaseEvent(QMouseEvent*); + void contextMenuEvent(QContextMenuEvent*); + + protected: + int _id; + double val; + + virtual void incValue(double x) = 0; + virtual void decValue(double x) = 0; + virtual bool setString(double) = 0; + virtual bool setSValue(const QString&) = 0; + + private slots: + void repeat(); + + protected slots: + void endEdit(); + + signals: + void valueChanged(double, int); + void doubleClicked(int); + + public slots: + virtual void setValue(double); + + public: + Dentry(QWidget*, const char* name=0); + double value() const { return val; } + bool frame() const { return drawFrame; } + void setFrame(bool); + int id() const { return _id; } + void setId(int i) { _id = i; } + SliderBase* slider() const { return _slider; } + void setSlider(SliderBase* s) { _slider = s; } + }; +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/didyouknow.h b/attic/muse2-oom/muse2/muse/widgets/didyouknow.h new file mode 100644 index 00000000..7dbc03c5 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/didyouknow.h @@ -0,0 +1,37 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id: didyouknow.h,v 1.0.0.0 2010/11/21 01:01:01 ogetbilo Exp $ +// +// Copyright (C) 1999-2010 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// This program 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 this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#include "ui_didyouknow.h" + +class QDialog; + + +//--------------------------------------------------------- +// DidYouKnowWidget +// Wrapper around Ui::DidYouKnow +//--------------------------------------------------------- + +class DidYouKnowWidget : public QDialog, public Ui::DidYouKnow +{ + Q_OBJECT + + public: + DidYouKnowWidget(QDialog *parent = 0) : QDialog(parent) { setupUi(this); } +}; diff --git a/attic/muse2-oom/muse2/muse/widgets/didyouknow.ui b/attic/muse2-oom/muse2/muse/widgets/didyouknow.ui new file mode 100644 index 00000000..5051ad3c --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/didyouknow.ui @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>DidYouKnow</class> + <widget class="QDialog" name="DidYouKnow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>494</width> + <height>249</height> + </rect> + </property> + <property name="windowTitle"> + <string>Did you know?</string> + </property> + <layout class="QVBoxLayout"> + <item> + <layout class="QVBoxLayout"> + <item> + <widget class="QTextEdit" name="tipText"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QCheckBox" name="dontShowCheckBox"> + <property name="text"> + <string>Don't show on startup</string> + </property> + </widget> + </item> + <item> + <spacer name="spacer7"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>121</width> + <height>31</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="nextButton"> + <property name="text"> + <string>Next tip</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="closeButton"> + <property name="text"> + <string>Close</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections> + <connection> + <sender>closeButton</sender> + <signal>clicked()</signal> + <receiver>DidYouKnow</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/dimap.cpp b/attic/muse2-oom/muse2/muse/widgets/dimap.cpp new file mode 100644 index 00000000..1f87358c --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/dimap.cpp @@ -0,0 +1,308 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: dimap.cpp,v 1.1.1.1 2003/10/27 18:55:11 wschweer Exp $ + +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include <cmath> +#include "dimap.h" +#include "mmath.h" + +const double DiMap::LogMin = 1.0e-150; +const double DiMap::LogMax = 1.0e150; + +// DiMap - Map a double interval into an integer interval +// +// The DiMap class maps an interval of type double into an interval of +// type integer. It consists +// of two intervals D = [d1, d2] (double) and I = [i1, i2] (int), which are +// specified with the @DiMap::setDblRange@ and @DiMap::setIntRange@ +// members. The point d1 is mapped to the point i1, and d2 is mapped to i2. +// Any point inside or outside D can be mapped to a point inside or outside +// I using @DiMap::transform@ or @DiMap::limTransform@ or vice versa +// using @QwtPlot::invTransform@. D can be scaled linearly or +// logarithmically, as specified with @DiMap::setDblRange@. + +//------------------------------------------------------------ +//.F DiMap::DiMap (1) +// Construct a DiMap instance. +// +//.u Syntax +//.f DiMap::DiMap() +// +//.u Description +// The double and integer intervals are both set to [0,1]. +//------------------------------------------------------------ + +DiMap::DiMap() + { + d_x1 = 0.0; + d_x2 = 1.0; + d_y1 = 0; + d_y2 = 1; + d_cnv = 1.0; + } + +//------------------------------------------------------------ +//.F DiMap::DiMap (2) +// Construct a DiMap instance with initial integer +// and double intervals +// +//.u Syntax +//.f DiMap::DiMap(int i1, int i2, double d1, double d2, bool logarithmic) +// +//.u Parameters +//.p int i1 -- first border of integer interval +// int i2 -- second border of integer interval +// double d1 -- first border of double interval +// double d2 -- second border of double interval +// bool logarithmic -- logarithmic mapping, TRUE or FALSE. Defaults +// to FALSE. +//------------------------------------------------------------ + +DiMap::DiMap(int i1, int i2, double d1, double d2, bool logarithmic) + { + d_log = logarithmic; + setIntRange(i1,i2); + setDblRange(d1, d2); + } + +//------------------------------------------------------------ +//.F DiMap::~DiMap +// Destroy a DiMap instance. +// +//.u Syntax +//.f DiMap::~DiMap() +//------------------------------------------------------------ + +DiMap::~DiMap() + { + } + +//------------------------------------------------------------ +//.F DiMap::contains (1) +// Returns TRUE if a value x lies inside or at the border of the +// map's double range. +// +//.u Syntax +//.f bool DiMap::contains(double x) +// +//.u Parameters +//.p double x -- value +//------------------------------------------------------------ + +bool DiMap::contains(double x) const + { + return ( (x >= qwtMin(d_x1, d_x1)) && (x <= qwtMax(d_x1, d_x2))); + } + +//------------------------------------------------------------ +//.F DiMap::contains (2) +// Returns TRUE if a value x lies inside or at the border of the +// map's integer range +// +//.u Syntax +//.f bool DiMap::contains(int x) +// +//.u Parameters +//.p int x -- value +//------------------------------------------------------------ + +bool DiMap::contains(int x) const + { + return ( (x >= qwtMin(d_y1, d_y1)) && (x <= qwtMax(d_y1, d_y2))); + } + +//------------------------------------------------------------ +//.F DiMap::setDblRange +// Specify the borders of the double interval +// +//.u Syntax +//.f void DiMap::setDblRange(double d1, double d2, bool lg = FALSE) +// +//.u Parameters +//.p double d1 -- first border +// double d2 -- second border +// bool lg -- logarithmic (TRUE) or linear (FALSE) +// scaling. Defaults to FALSE. +//------------------------------------------------------------ + +void DiMap::setDblRange(double d1, double d2, bool lg) + { + if (lg) { + d_log = true; + if (d1 < LogMin) + d1 = LogMin; + else if (d1 > LogMax) + d1 = LogMax; + + if (d2 < LogMin) + d2 = LogMin; + else if (d2 > LogMax) + d2 = LogMax; + + d_x1 = log(d1); + d_x2 = log(d2); + } + else { + d_log = FALSE; + d_x1 = d1; + d_x2 = d2; + } + newFactor(); + } + +//------------------------------------------------------------ +//.F DiMap::setIntRange +// Specify the borders of the integer interval +// +//.u Syntax +//.f void DiMap::setIntRange(int i1, int i2) +// +//.u Parameters +//.p int i1 -- first border +// int i2 -- second border +//------------------------------------------------------------ + +void DiMap::setIntRange(int i1, int i2) + { + d_y1 = i1; + d_y2 = i2; + newFactor(); + } + +//------------------------------------------------------------ +//.F DiMap::transform +// Transform a point in double interval into an point in the +// integer interval +// +//.u Syntax +//.f int DiMap::transform(double x) +// +//.u Parameters +//.p double x +// +//.u Return Value +//.t +// linear mapping: -- rint(i1 + (i2 - i1) / (d2 - d1) * (x - d1)) +// logarithmic mapping: -- rint(i1 + (i2 - i1) / log(d2 / d1) * log(x / d1)) +// +//.u Note +// The specified point is allowed to lie outside the intervals. If you +// want to limit the returned value, use @DiMap::limTransform@. +//------------------------------------------------------------ + +int DiMap::transform(double x) const + { + if (d_log) + return (d_y1 + int(rint( (log(x) - d_x1) * d_cnv ))); + else + return (d_y1 + int(rint( (x - d_x1) * d_cnv ))); + } + +//------------------------------------------------------------ +//.F DiMap::invTransform +// Transform an integer value into a double value +// +//.u Syntax +//.f double DiMap::invTransform(int y) +// +//.u Parameters +//.p int y -- integer value to be transformed +// +//.u Return Value +//.t +// linear mapping: -- d1 + (d2 - d1) / (i2 - i1) * (y - i1) +// logarithmic mapping: -- d1 + (d2 - d1) / log(i2 / i1) * log(y / i1) +//------------------------------------------------------------ + +double DiMap::invTransform(int y) const + { + if (d_cnv == 0.0) + return 0.0; + else { + if (d_log) + return exp(d_x1 + double(y - d_y1) / d_cnv ); + else + return ( d_x1 + double(y - d_y1) / d_cnv ); + } + } + +//------------------------------------------------------------ +//.F DiMap::limTransform +// Transform and limit +// +//.u Syntax +//.f int DiMap::limTransform(double x) +// +//.u Parameters +//.p double x +// +//.u Return Value +// transformed value +// +//.u Description +// The function is similar to @DiMap::transform@, but limits the input value +// to the nearest border of the map's double interval if it lies outside +// that interval. +//------------------------------------------------------------ + +int DiMap::limTransform(double x) const + { + if ( x > qwtMax(d_x1, d_x2) ) + x = qwtMax(d_x1, d_x2); + else if ( x < qwtMin(d_x1, d_x2)) + x = qwtMin(d_x1, d_x2); + return transform(x); + } + +//------------------------------------------------------------ +//.F DiMap::xTransform +// Exact transformation +// +//.u Syntax +//.f double DiMap::dTransform(double x) +// +//.u Parameters +//.p double x -- value to be transformed +// +//.u Return Value +//.t +// linear mapping: -- i1 + (i2 - i1) / (d2 - d1) * (x - d1) +// logarithmic mapping: -- i1 + (i2 - i1) / log(d2 / d1) * log(x / d1) +// +//.u Description +// This function is similar to @DiMap::transform@, but +// makes the integer interval appear to be double. +//------------------------------------------------------------ + +double DiMap::xTransform(double x) const + { + double rv; + + if (d_log) + rv = double(d_y1) + (log(x) - d_x1) * d_cnv; + else + rv = double(d_y1) + (x - d_x1) * d_cnv; + return rv; + } + +//------------------------------------------------------------ +//.F DiMap::newFactor +// Re-calculate the conversion factor. +//------------------------------------------------------------ + +void DiMap::newFactor() + { + if (d_x2 != d_x1) + d_cnv = double(d_y2 - d_y1) / (d_x2 - d_x1); + else + d_cnv = 0.0; + } diff --git a/attic/muse2-oom/muse2/muse/widgets/dimap.h b/attic/muse2-oom/muse2/muse/widgets/dimap.h new file mode 100644 index 00000000..cf51dee2 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/dimap.h @@ -0,0 +1,55 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: dimap.h,v 1.1.1.1 2003/10/27 18:54:28 wschweer Exp $ +// +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __DIMAP_H__ +#define __DIMAP_H__ + +#include <QtGlobal> + +class DiMap + { + double d_x1, d_x2; // double interval boundaries + int d_y1,d_y2; // integer interval boundaries + double d_cnv; // conversion factor + bool d_log; // logarithmic scale? + + void newFactor(); + + public: + static const double LogMin; + static const double LogMax; + + DiMap(); + DiMap(int, int, double, double, bool lg = FALSE); + ~DiMap(); + + + bool contains(double x) const; + bool contains(int x) const; + + void setIntRange(int i1, int i2); + void setDblRange(double d1, double d2, bool lg = FALSE); + + int transform(double x) const; + double invTransform(int i) const; + int limTransform(double x) const; + double xTransform(double x) const; + + double d1() const { return d_x1;} + double d2() const { return d_x2;} + int i1() const { return d_y1;} + int i2() const { return d_y2;} + bool logarithmic() const { return d_log;} + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/doublelabel.cpp b/attic/muse2-oom/muse2/muse/widgets/doublelabel.cpp new file mode 100644 index 00000000..fe2bfc6a --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/doublelabel.cpp @@ -0,0 +1,193 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: doublelabel.cpp,v 1.1.1.1.2.2 2008/08/18 00:15:26 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <cmath> + +#include "doublelabel.h" + +//--------------------------------------------------------- +// DoubleLabel +//--------------------------------------------------------- + +DoubleLabel::DoubleLabel(QWidget* parent, const char* name) + : Dentry(parent, name), _specialText("---") + { + min = 0.0; + max = 1.0; + _off = -1.0; + _precision = 3; + setValue(0.0); + } + +DoubleLabel::DoubleLabel(double _val, double m, double mx, QWidget* parent) + : Dentry(parent), _specialText("---") + { + min = m; + max = mx; + _off = m - 1.0; + _precision = 3; + setValue(_val); + } + +//--------------------------------------------------------- +// setOff +//--------------------------------------------------------- + +void DoubleLabel::setOff(double v) +{ + _off = v; + setString(val); +} + +//--------------------------------------------------------- +// calcIncrement() +//--------------------------------------------------------- + +double DoubleLabel::calcIncrement() const +{ + double dif; + if(max - min > 0) + dif = max - min; + else + dif = min - max; + + if(dif <= 10.0) + return 0.1; + else + if(dif <= 100.0) + return 1.0; + else + return 10.0; +} + +//--------------------------------------------------------- +// setString +//--------------------------------------------------------- + +bool DoubleLabel::setString(double v) + { + if(v <= _off || v > max) + { + setText(_specialText); + return true; + } + else + if(v < min) + { + setText(QString("---")); + return true; + } + else + { + QString s; + s.setNum(v, 'f', _precision); + if (!_suffix.isEmpty()) { + s += " "; + s += _suffix; + } + + setText(s); + } + return false; + } + +//--------------------------------------------------------- +// setSValue +//--------------------------------------------------------- + +bool DoubleLabel::setSValue(const QString& s) + { + bool ok; + double v = s.toDouble(&ok); + if (ok && (v != val)) { + if (v < min) + v = min; + if (v > max) + v = max; + setValue(v); + emit valueChanged(val, _id); + } + return false; + } + +//--------------------------------------------------------- +// incValue +//--------------------------------------------------------- + +void DoubleLabel::incValue(double) + { + if(val >= max) + return; + double inc = calcIncrement(); + if(val + inc >= max) + setValue(max); + else + setValue(val + inc); + emit valueChanged(val, _id); + } + +//--------------------------------------------------------- +// decValue +//--------------------------------------------------------- + +void DoubleLabel::decValue(double) + { + if(val <= min) + return; + double inc = calcIncrement(); + if(val - inc <= min) + setValue(min); + else + setValue(val - inc); + emit valueChanged(val, _id); + } + +//--------------------------------------------------------- +// setPrecision +//--------------------------------------------------------- + +void DoubleLabel::setPrecision(int v) + { + _precision = v; + setString(val); + } + +//--------------------------------------------------------- +// sizeHint +//--------------------------------------------------------- + +QSize DoubleLabel::sizeHint() const + { + QFontMetrics fm = fontMetrics(); + int h = fm.height() + 4; + int n = _precision; + + ++n; // For some reason I have to add one digit. Shouldn't have to. + double aval = fmax(fabs(max), fabs(min)); + if (aval >= 10.0) + ++n; + if (aval >= 100.0) + ++n; + if (aval >= 1000.0) + ++n; + if (aval >= 10000.0) + ++n; + if (aval >= 100000.0) + ++n; + + int w = fm.width(QString("-0.")) + fm.width('0') * n + 6; + if(!_suffix.isEmpty()) + { + w += fm.width(QString(" ")) + fm.width(_suffix); + } + return QSize(w, h); + } + +QSize DoubleLabel::minimumSizeHint() const +{ + return sizeHint(); +} diff --git a/attic/muse2-oom/muse2/muse/widgets/doublelabel.h b/attic/muse2-oom/muse2/muse/widgets/doublelabel.h new file mode 100644 index 00000000..b5e40597 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/doublelabel.h @@ -0,0 +1,61 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: doublelabel.h,v 1.2.2.3 2008/08/18 00:15:26 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __DOUBLELABEL_H__ +#define __DOUBLELABEL_H__ + +#include "dentry.h" + +//--------------------------------------------------------- +// DoubleLabel +//--------------------------------------------------------- + +class DoubleLabel : public Dentry { + Q_OBJECT + + Q_PROPERTY( double minValue READ minValue WRITE setMinValue ) + Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue ) + Q_PROPERTY( QString specialText READ specialText WRITE setSpecialText ) + Q_PROPERTY( QString suffix READ suffix WRITE setSuffix ) + Q_PROPERTY( int precision READ precision WRITE setPrecision ) + + double min, max, _off; + QString _specialText; // text to show if value outside min,max + QString _suffix; + int _precision; + + double calcIncrement() const; + + virtual bool setSValue(const QString&); + virtual bool setString(double val); + virtual void incValue(double); + virtual void decValue(double); + + public: + DoubleLabel(QWidget* parent = 0, const char* name = 0); + DoubleLabel(double val, double min, double max, QWidget* parent = 0); + virtual QSize sizeHint() const; + virtual QSize minimumSizeHint () const; + double minValue() const { return min; } + double maxValue() const { return max; } + double off() const { return _off; } + void setMinValue(double v) { min = v; } + void setMaxValue(double v) { max = v; } + void setRange(double a, double b) { _off = a - (min - _off); min = a; max = b; } + void setOff(double v); + int precision() const { return _precision; } + void setPrecision(int val); + QString specialText() const { return _specialText; } + void setSpecialText(const QString& s) { + _specialText = s; + update(); + } + QString suffix() const { return _suffix; } + void setSuffix(const QString& s) { _suffix = s; } + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/drange.cpp b/attic/muse2-oom/muse2/muse/widgets/drange.cpp new file mode 100644 index 00000000..e144dfea --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/drange.cpp @@ -0,0 +1,265 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: drange.cpp,v 1.2.2.1 2009/03/09 02:05:18 terminator356 Exp $ +// +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include <cmath> + +#include <QtGlobal> + +#include "mmath.h" +#include "drange.h" + +const double DoubleRange::MinRelStep = 1.0e-10; +const double DoubleRange::DefaultRelStep = 1.0e-2; +const double DoubleRange::MinEps = 1.0e-10; + +//----------------------------------------------------------- +// This class is useful as a base class or a member for sliders. +// It represents an interval of type double within which a value can +// be moved. The value can be either an arbitrary point inside +// the interval (see @DoubleRange::setValue@), or it can be fitted +// into a step raster (see @DoubleRange::fitValue@ and +// @DoubleRange::incValue@). +// +// As a special case, a DoubleRange can be periodic, which means that +// a value outside the interval will be mapped to a value inside the +// interval when @DoubleRange::setValue@, @DoubleRange::fitValue@, +// @DoubleRange::incValue@ or @DoubleRange::incPages@ are called. +//------------------------------------------------------------ + +//--------------------------------------------------------- +// doubleRange +//--------------------------------------------------------- + +DoubleRange::DoubleRange() + { + d_minValue = 0; + d_maxValue = 100.0; + d_prevValue = 0.0; + d_exactPrevValue = 0.0; + d_exactValue = 0.0; + d_value = 0.0; + d_step = 0.1; + d_periodic = FALSE; + } + +//--------------------------------------------------------- +// setNewValue +//--------------------------------------------------------- + +void DoubleRange::setNewValue(double x, bool align) + { + d_prevValue = d_value; + + double vmin = qwtMin(d_minValue, d_maxValue); + double vmax = qwtMax(d_minValue, d_maxValue); + + // Range check + + if (x < vmin) { + if ((d_periodic) && (vmin != vmax)) + d_value = x + ceil((vmin - x) / (vmax - vmin)) + * (vmax - vmin); + else + d_value = vmin; + } + else if (x > vmax) { + if ((d_periodic) && (vmin != vmax)) + d_value = x - ceil( ( x - vmax) / (vmax - vmin )) + * (vmax - vmin); + else + d_value = vmax; + } + else + d_value = x; + + d_exactPrevValue = d_exactValue; + d_exactValue = d_value; + + // align to grid + if (align) { + if (d_step != 0.0) + d_value = d_minValue + rint((d_value - d_minValue) / d_step ) * d_step; + else + d_value = d_minValue; + + // correct rounding error at the border + if (fabs(d_value - d_maxValue) < MinEps * qwtAbs(d_step)) + d_value = d_maxValue; + + // correct rounding error if value = 0 + if (fabs(d_value) < MinEps * qwtAbs(d_step)) + d_value = 0.0; + } + if (d_prevValue != d_value) + valueChange(); + } + +//--------------------------------------------------------- +// fitValue +// Adjust the value to the closest point in the step +// raster. +// The value is clipped when it lies outside the range. +// When the range is @DoubleRange::periodic@, it will +// be mapped to a point in the interval such that +//--------------------------------------------------------- + +void DoubleRange::fitValue(double x) + { + setNewValue(x, true); + } + +//--------------------------------------------------------- +// setValue +// Set a new value without adjusting to the step raster +// The value is clipped when it lies outside the range. +// When the range is @DoubleRange::periodic@, it will +// be mapped to a point in the interval such that +// +// new value := x + n * (max. value - min. value) +// +// with an integer number n. +//--------------------------------------------------------- + +void DoubleRange::setValue(double x) + { + setNewValue(x, false); + } + +//--------------------------------------------------------- +// setRange +// Specify range and step size +// - A change of the range changes the value if it lies outside the +// new range. The current value +// will *not* be adjusted to the new step raster. +// - vmax < vmin is allowed. +// - If the step size is left out or set to zero, it will be +// set to 1/100 of the interval length. +// - If the step size has an absurd value, it will be corrected +// to a better one. +//--------------------------------------------------------- + +void DoubleRange::setRange(double vmin, double vmax, double vstep, int pageSize) + { + bool rchg = ((d_maxValue != vmax) || (d_minValue != vmin)); + + if (rchg) { + d_minValue = vmin; + d_maxValue = vmax; + } + + // + // look if the step width has an acceptable + // value or otherwise change it. + // + setStep(vstep); + + // + // limit page size + // + d_pageSize = qwtLim(pageSize,0, int(qwtAbs((d_maxValue - d_minValue) / d_step))); + + // + // If the value lies out of the range, it + // will be changed. Note that it will not be adjusted to + // the new step width. + setNewValue(d_value, false); + + // call notifier after the step width has been + // adjusted. + if (rchg) + rangeChange(); + } + +//--------------------------------------------------------- +// setStep +// Change the step raster +// +// The value will *not* be adjusted to the new step raster. +//--------------------------------------------------------- + +void DoubleRange::setStep(double vstep) + { + double newStep,intv; + + intv = d_maxValue - d_minValue; + + if (vstep == 0.0) + newStep = intv * DefaultRelStep; + else { + if (((intv > 0) && (vstep < 0)) || ((intv < 0) && (vstep > 0))) + newStep = -vstep; + else + newStep = vstep; + + if ( fabs(newStep) < fabs(MinRelStep * intv) ) + newStep = MinRelStep * intv; + } + + if (newStep != d_step) { + d_step = newStep; + stepChange(); + } + } + +//--------------------------------------------------------- +// setPeriodic +// Make the range periodic +// +// When the range is periodic, the value will be set to a point +// inside the interval such that +// +// point = value + n * width +// +// if the user tries to set a new value which is outside the range. +// If the range is nonperiodic (the default), values outside the +// range will be clipped. +//--------------------------------------------------------- + +void DoubleRange::setPeriodic(bool tf) + { + d_periodic = tf; + } + +//------------------------------------------------------------ +// incValue +// Increment the value by a specified number of steps +// +// As a result of this operation, the new value will always be +// adjusted to the step raster. +//------------------------------------------------------------ + +void DoubleRange::incValue(int nSteps) + { + setNewValue(d_value + double(nSteps) * d_step, true); + } + +//--------------------------------------------------------- +// incPages +// Increment the value by a specified number of pages +//--------------------------------------------------------- + +void DoubleRange::incPages(int nPages) + { + setNewValue(d_value + double(nPages) * double(d_pageSize) + * d_step, true); + } + +//--------------------------------------------------------- +// step +//--------------------------------------------------------- + +double DoubleRange::step() const + { + return qwtAbs(d_step); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/drange.h b/attic/muse2-oom/muse2/muse/widgets/drange.h new file mode 100644 index 00000000..d0931e86 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/drange.h @@ -0,0 +1,69 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: drange.h,v 1.1.1.1.2.1 2007/01/27 14:52:43 spamatica Exp $ +// +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __DOUBLE_RANGE_H__ +#define __DOUBLE_RANGE_H__ + +//--------------------------------------------------------- +// DoubleRange +//--------------------------------------------------------- + +class DoubleRange + { + static const double MinRelStep; + static const double DefaultRelStep; + static const double MinEps; + + double d_minValue; + double d_maxValue; + double d_step; + int d_pageSize; + double d_value; + double d_exactValue; + double d_exactPrevValue; + double d_prevValue; + bool d_periodic; + + void setNewValue(double x, bool align = false); + + protected: + double exactValue() const { return d_exactValue; } + double exactPrevValue() const { return d_exactPrevValue; } + double prevValue() const { return d_prevValue; } + virtual void valueChange() {} + virtual void stepChange() {} + virtual void rangeChange() {} + + public: + DoubleRange(); + virtual ~DoubleRange(){}; + + double value() const { return d_value; } + virtual void setValue(double); + + virtual void fitValue(double); + virtual void incValue(int); + virtual void incPages(int); + void setPeriodic(bool tf); + void setRange(double vmin, double vmax, double vstep = 0.0, + int pagesize = 1); + void setStep(double); + + double maxValue() const { return d_maxValue; } + double minValue() const { return d_minValue; } + bool periodic() const { return d_periodic; } + int pageSize() const { return d_pageSize; } + double step() const; + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/editnotedialogbase.ui b/attic/muse2-oom/muse2/muse/widgets/editnotedialogbase.ui new file mode 100644 index 00000000..b19efc49 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/editnotedialogbase.ui @@ -0,0 +1,223 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>EditNoteDialogBase</class> + <widget class="QDialog" name="EditNoteDialogBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>231</width> + <height>182</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Enter Note</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="5" column="0" colspan="2"> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <spacer name="Horizontal Spacing2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonOk"> + <property name="text"> + <string>OK</string> + </property> + <property name="shortcut"> + <number>0</number> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonCancel"> + <property name="text"> + <string>Cancel</string> + </property> + <property name="shortcut"> + <number>0</number> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>Length:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> + <string>Time Position:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="TextLabel3"> + <property name="text"> + <string>Pitch:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="TextLabel4"> + <property name="text"> + <string>Velocity On:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="TextLabel5"> + <property name="text"> + <string>Velocity Off:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="Awl::PosEdit" name="epos"/> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="il1"> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>1000000</number> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QSpinBox" name="il2"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QSpinBox" name="il3"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="PitchEdit" name="pl" native="true"/> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <customwidgets> + <customwidget> + <class>Awl::PosEdit</class> + <extends>QWidget</extends> + <header>awl/posedit.h</header> + <container>0</container> + </customwidget> + <customwidget> + <class>PitchEdit</class> + <extends>QWidget</extends> + <header>pitchedit.h</header> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>il1</tabstop> + <tabstop>pl</tabstop> + <tabstop>il2</tabstop> + <tabstop>il3</tabstop> + <tabstop>buttonOk</tabstop> + <tabstop>buttonCancel</tabstop> + </tabstops> + <includes> + <include location="local">pitchedit.h</include> + </includes> + <resources/> + <connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>EditNoteDialogBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>EditNoteDialogBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/editsysexdialogbase.ui b/attic/muse2-oom/muse2/muse/widgets/editsysexdialogbase.ui new file mode 100644 index 00000000..adf5b186 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/editsysexdialogbase.ui @@ -0,0 +1,196 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>EditSysexDialogBase</class> + <widget class="QDialog" name="EditSysexDialogBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>433</width> + <height>330</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Enter SysEx</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> + <string>TimePosition:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="Awl::PosEdit" name="epos"/> + </item> + <item> + <spacer name="Spacer2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="saveButton"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="loadButton"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QTextEdit" name="edit"/> + </item> + <item> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>Comment:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QTextEdit" name="comment"/> + </item> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <spacer name="Horizontal Spacing2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonOk"> + <property name="text"> + <string>OK</string> + </property> + <property name="shortcut"> + <number>0</number> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonCancel"> + <property name="text"> + <string>Cancel</string> + </property> + <property name="shortcut"> + <number>0</number> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <customwidgets> + <customwidget> + <class>Awl::PosEdit</class> + <extends>QWidget</extends> + <header>awl/posedit.h</header> + <container>0</container> + </customwidget> + </customwidgets> + <resources/> + <connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>EditSysexDialogBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>EditSysexDialogBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/fdialogbuttons.ui b/attic/muse2-oom/muse2/muse/widgets/fdialogbuttons.ui new file mode 100644 index 00000000..24f58e1f --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/fdialogbuttons.ui @@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>FileDialogButtons</class> + <widget class="QWidget" name="FileDialogButtons"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>145</width> + <height>438</height> + </rect> + </property> + <property name="windowTitle"> + <string>fdialogbuttons</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QFrame" name="pathGroup"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <property name="lineWidth"> + <number>0</number> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QToolButton" name="globalButton"> + <property name="minimumSize"> + <size> + <width>80</width> + <height>80</height> + </size> + </property> + <property name="text"> + <string>Global</string> + </property> + <property name="iconSize"> + <size> + <width>48</width> + <height>48</height> + </size> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextUnderIcon</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="userButton"> + <property name="minimumSize"> + <size> + <width>80</width> + <height>80</height> + </size> + </property> + <property name="text"> + <string>User</string> + </property> + <property name="iconSize"> + <size> + <width>48</width> + <height>48</height> + </size> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextUnderIcon</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="projectButton"> + <property name="minimumSize"> + <size> + <width>80</width> + <height>80</height> + </size> + </property> + <property name="text"> + <string>Project</string> + </property> + <property name="iconSize"> + <size> + <width>48</width> + <height>48</height> + </size> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextUnderIcon</enum> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="Spacer1"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>245</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QFrame" name="loadAllGroup"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QRadioButton" name="loadAllButton"> + <property name="text"> + <string>Songdata + +Configuration</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="loadSongButton"> + <property name="text"> + <string>only +Songdata</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections/> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/filedialog.cpp b/attic/muse2-oom/muse2/muse/widgets/filedialog.cpp new file mode 100644 index 00000000..d2b189b6 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/filedialog.cpp @@ -0,0 +1,546 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filedialog.cpp,v 1.3.2.3 2005/06/19 06:32:07 lunar_shuttle Exp $ +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include <errno.h> + +#include <QIcon> +#include <QMessageBox> +#include <QPixmap> +#include <QSplitter> +#include <QStringList> + +#include "icons.h" +#include "filedialog.h" +#include "../globals.h" +#include "gconfig.h" + +MFileDialog::ViewType MFileDialog::lastViewUsed = GLOBAL_VIEW; +QString MFileDialog::lastUserDir = ""; +QString MFileDialog::lastGlobalDir = ""; + +//--------------------------------------------------------- +// createDir +// return true if dir could not created +//--------------------------------------------------------- + +static bool createDir(const QString& s) + { + QString sl("/"); + QStringList l = s.split(sl, QString::SkipEmptyParts); + QString path(sl); + QDir dir; + for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + dir.setPath(path); + if (!QDir(path + sl + *it).exists()) { + if (!dir.mkdir(*it)) { + printf("mkdir failed: %s %s\n", + path.toLatin1().constData(), (*it).toLatin1().constData()); + return true; + } + } + path += sl; + path += *it; + } + return false; + } + +//--------------------------------------------------------- +// testDirCreate +// return true if dir does not exist +//--------------------------------------------------------- + +static bool testDirCreate(QWidget* parent, const QString& path) +{ + QDir dir(path); + if (!dir.exists()) + { + if(QMessageBox::information(parent, + QWidget::tr("MusE: get file name"), + QWidget::tr("The directory\n") + path + + QWidget::tr("\ndoes not exist.\nCreate it?"), + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok) != QMessageBox::Ok) + return true; + + if (createDir(path)) + { + QMessageBox::critical(parent, + QWidget::tr("MusE: create directory"), + QWidget::tr("creating dir failed")); + return true; + } + } + return false; +} + +//--------------------------------------------------------- +// globalToggled +//--------------------------------------------------------- + +void MFileDialog::globalToggled(bool flag) + { + if (flag) { + buttons.userButton->setChecked(!flag); + buttons.projectButton->setChecked(!flag); + if (lastGlobalDir.isEmpty()) + lastGlobalDir = museGlobalShare + QString("/") + baseDir; // Initialize if first time + QString dir = lastGlobalDir; + setDirectory(dir); + lastViewUsed = GLOBAL_VIEW; + } + } + +//--------------------------------------------------------- +// userToggled +//--------------------------------------------------------- + +void MFileDialog::userToggled(bool flag) + { + if (flag) { + buttons.globalButton->setChecked(!flag); + buttons.projectButton->setChecked(!flag); + + + if (lastUserDir.isEmpty()) { + lastUserDir = museUser + QString("/") + baseDir; // Initialize if first time + } + + if (testDirCreate(this, lastUserDir)) + setDirectory(museUser); + else + setDirectory(lastUserDir); + + lastViewUsed = USER_VIEW; + } + } + +//--------------------------------------------------------- +// projectToggled +//--------------------------------------------------------- + +void MFileDialog::projectToggled(bool flag) + { + if (flag) { + buttons.globalButton->setChecked(!flag); + buttons.userButton->setChecked(!flag); + + QString s; + if (museProject == museProjectInitPath ) { + // if project path is uninitialized, meaning it is still set to museProjectInitPath. + // then project path is set to current pwd instead. + //s = QString(getcwd(0,0)) + QString("/"); + s = config.projectBaseFolder; + } + else + s = museProject + QString("/"); // + baseDir; + + if (testDirCreate(this, s)) + setDirectory(museProject); + else + setDirectory(s); + lastViewUsed = PROJECT_VIEW; + } + } + + +//--------------------------------------------------------- +// MFileDialog +//--------------------------------------------------------- + +MFileDialog::MFileDialog(const QString& dir, + const QString& filter, QWidget* parent, bool writeFlag) + : QFileDialog(parent, QString(), QString("."), filter) + { + showButtons = false; + if (dir.length() > 0 && dir[0] == QChar('/')) { + setDirectory(dir); + } + else { + // We replace the original sidebar widget with our 3-button widget + QLayout* mainlayout = this->layout(); + QSplitter* spl = (QSplitter*)mainlayout->itemAt(2)->widget(); + QWidget* original_sidebarwidget = spl->widget(0); + original_sidebarwidget->setVisible(false); + + baseDir = dir; + showButtons = true; + + spl->insertWidget(0,&buttons); + + // Qt >= 4.6 allows us to select icons from the theme +#if QT_VERSION >= 0x040600 + buttons.globalButton->setIcon(*globalIcon); + buttons.userButton->setIcon(*userIcon); + buttons.projectButton->setIcon(*projectIcon); +#else + buttons.globalButton->setIcon(style()->standardIcon(QStyle::SP_DirIcon)); + buttons.userButton->setIcon(style()->standardIcon(QStyle::SP_DirHomeIcon)); + buttons.projectButton->setIcon(style()->standardIcon(QStyle::SP_DirOpenIcon)); +#endif + + connect(buttons.globalButton, SIGNAL(toggled(bool)), this, SLOT(globalToggled(bool))); + connect(buttons.userButton, SIGNAL(toggled(bool)), this, SLOT(userToggled(bool))); + connect(buttons.projectButton, SIGNAL(toggled(bool)), this, SLOT(projectToggled(bool))); + connect(this, SIGNAL(directoryEntered(const QString&)), SLOT(directoryChanged(const QString&))); + + if (writeFlag) { + setAcceptMode(QFileDialog::AcceptSave); + buttons.globalButton->setEnabled(false); + switch (lastViewUsed) { + case GLOBAL_VIEW: + case PROJECT_VIEW: + buttons.projectButton->setChecked(true); + break; + + case USER_VIEW: + buttons.userButton->setChecked(true); + break; + } + } + else { + switch (lastViewUsed) { + case GLOBAL_VIEW: + buttons.globalButton->setChecked(true); + break; + + case PROJECT_VIEW: + buttons.projectButton->setChecked(true); + break; + + case USER_VIEW: + buttons.userButton->setChecked(true); + break; + } + + } + buttons.loadAllGroup->setVisible(false); + } + } + +//--------------------------------------------------------- +// MFileDialog::directoryChanged +//--------------------------------------------------------- +void MFileDialog::directoryChanged(const QString&) + { + ViewType currentView = GLOBAL_VIEW; + QDir ndir = directory(); + ///QString newdir = ndir.absolutePath().toLatin1(); + QString newdir = ndir.absolutePath(); + if (buttons.projectButton->isChecked()) + currentView = PROJECT_VIEW; + else if (buttons.userButton->isChecked()) + currentView = USER_VIEW; + + switch (currentView) { + case GLOBAL_VIEW: + lastGlobalDir = newdir; + break; + + case USER_VIEW: + lastUserDir = newdir; + break; + + case PROJECT_VIEW: // Do nothing + default: + break; + } + } + + +//--------------------------------------------------------- +// getFilterExtension +//--------------------------------------------------------- + +QString getFilterExtension(const QString &filter) +{ + // + // Return the first extension found. Must contain at least one * character. + // + + int pos = filter.indexOf('*'); + if(pos == -1) + return QString(); + + QString filt; + int len = filter.length(); + ++pos; + for( ; pos < len; ++pos) + { + QChar c = filter[pos]; + if((c == ')') || (c == ';') || (c == ',') || (c == ' ')) + break; + filt += filter[pos]; + } + return filt; +} + +//--------------------------------------------------------- +// getOpenFileName +//--------------------------------------------------------- +QString getOpenFileName(const QString &startWith, + const QStringList& filters, QWidget* parent, const QString& name, bool* all, MFileDialog::ViewType viewType) + { + QString initialSelection; // FIXME Tim. + MFileDialog *dlg = new MFileDialog(startWith, QString::null, parent, false); + dlg->setNameFilters(filters); + dlg->setWindowTitle(name); + if (viewType == MFileDialog::GLOBAL_VIEW) + dlg->globalToggled(true); + else if (viewType == MFileDialog::PROJECT_VIEW) + dlg->projectToggled(true); + else if (viewType == MFileDialog::USER_VIEW) + dlg->userToggled(true); + if (all) { + dlg->buttons.loadAllGroup->setVisible(true); + //dlg->buttons.globalButton->setVisible(false); + } + if (!initialSelection.isEmpty()) + dlg->selectFile(initialSelection); + dlg->setFileMode(QFileDialog::ExistingFile); + QStringList files; + QString result; + if (dlg->exec() == QDialog::Accepted) { + files = dlg->selectedFiles(); + if (!files.isEmpty()) + result = files[0]; + if (all) { + *all = dlg->buttons.loadAllButton->isChecked(); + } + } + delete dlg; + return result; + } + +//--------------------------------------------------------- +// getSaveFileName +//--------------------------------------------------------- + +QString getSaveFileName(const QString &startWith, + //const char** filters, QWidget* parent, const QString& name) + const QStringList& filters, QWidget* parent, const QString& name) + { + MFileDialog *dlg = new MFileDialog(startWith, QString::null, parent, true); + dlg->setNameFilters(filters); + dlg->setWindowTitle(name); + dlg->setFileMode(QFileDialog::AnyFile); + QStringList files; + QString result; + if (dlg->exec() == QDialog::Accepted) { + files = dlg->selectedFiles(); + if (!files.isEmpty()) + result = files[0]; + } + + // Added by T356. + if(!result.isEmpty()) + { + QString filt = dlg->selectedNameFilter(); + filt = getFilterExtension(filt); + // Do we have a valid extension? + if(!filt.isEmpty()) + { + // If the rightmost characters of the filename do not already contain + // the extension, add the extension to the filename. + //if(result.right(filt.length()) != filt) + if(!result.endsWith(filt)) + result += filt; + } + else + { + // No valid extension, or just * was given. Although it would be nice to allow no extension + // or any desired extension by commenting this section out, it's probably not a good idea to do so. + // + // NOTE: Most calls to this routine getSaveFileName() are followed by fileOpen(), + // which can tack on its own extension, but only if the *complete* extension is blank. + // So there is some overlap going on. Enabling this actually stops that action, + // but only if there are no errors in the list of filters. fileOpen() will act as a 'catchall'. + // + // Force the filter list to the first one (the preferred one), and then get the filter. + dlg->selectNameFilter(dlg->nameFilters().at(0)); + filt = dlg->selectedNameFilter(); + filt = getFilterExtension(filt); + + // Do we have a valid extension? + if(!filt.isEmpty()) + { + // If the rightmost characters of the filename do not already contain + // the extension, add the extension to the filename. + //if(result.right(filt.length()) != filt) + if(!result.endsWith(filt)) + result += filt; + } + } + } + + delete dlg; + return result; + } + +//--------------------------------------------------------- +// getImageFileName +//--------------------------------------------------------- + +QString getImageFileName(const QString& startWith, + //const char** filters, QWidget* parent, const QString& name) + const QStringList& filters, QWidget* parent, const QString& name) + { + QString initialSelection; + QString* workingDirectory = new QString(QDir::currentPath()); + if (!startWith.isEmpty() ) { + QFileInfo fi(startWith); + if (fi.exists() && fi.isDir()) { + *workingDirectory = startWith; + } + else if (fi.exists() && fi.isFile()) { + *workingDirectory = fi.absolutePath(); + initialSelection = fi.absoluteFilePath(); + } + } + MFileDialog *dlg = new MFileDialog(*workingDirectory, QString::null, + parent); + + /* ORCAN - disable preview for now. It is not available in qt4. We will + need to implement it ourselves. + dlg->setContentsPreviewEnabled(true); + ContentsPreview* preview = new ContentsPreview(dlg); + dlg->setContentsPreview(preview, preview); + dlg->setPreviewMode(QFileDialog::Contents); + */ + dlg->setWindowTitle(name); + dlg->setNameFilters(filters); + dlg->setFileMode(QFileDialog::ExistingFile); + QStringList files; + QString result; + if (!initialSelection.isEmpty()) + dlg->selectFile( initialSelection); + if (dlg->exec() == QDialog::Accepted) { + files = dlg->selectedFiles(); + if (!files.isEmpty()) + result = files[0]; + } + delete dlg; + return result; + } + +//--------------------------------------------------------- +// fileOpen +// opens file "name" with extension "ext" in mode "mode" +// handles "name.ext.bz2" and "name.ext.gz" +// +// mode = "r" or "w" +// popenFlag set to true on return if file was opened +// with popen() (and therefore must be closed +// with pclose()) +// noError show no error if file was not found in "r" +// mode. Has no effect in "w" mode +// overwriteWarning +// warn in "w" mode, if file exists +//--------------------------------------------------------- + +FILE* fileOpen(QWidget* parent, QString name, const QString& ext, + const char* mode, bool& popenFlag, bool noError, + bool overwriteWarning) + { + QFileInfo info(name); + QString zip; + + popenFlag = false; + if (info.completeSuffix() == "") { + name += ext; + info.setFile(name); + } + else if (info.suffix() == "gz") { + popenFlag = true; + zip = QString("gzip"); + } + else if (info.suffix() == "bz2") { + popenFlag = true; + zip = QString("bzip2"); + } + + if (strcmp(mode,"w") == 0 && overwriteWarning && info.exists()) { + QString s(QWidget::tr("File\n") + name + QWidget::tr("\nexists. Overwrite?")); + /* + int rv = QMessageBox::warning(parent, + QWidget::tr("MusE: write"), + s, + QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save); + switch(rv) { + case 0: // overwrite + break; + case 1: // quit + return 0; + } + */ + if(QMessageBox::warning(parent, + QWidget::tr("MusE: write"), s, + QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save) + != QMessageBox::Save) + return 0; + + } + FILE* fp = 0; + if (popenFlag) { + if (strcmp(mode, "r") == 0) + zip += QString(" -d < "); + else + zip += QString(" > "); + zip += name; + fp = popen(zip.toAscii().data(), mode); + } + else { + fp = fopen(name.toAscii().data(), mode); + } + if (fp == 0 && !noError) { + QString s(QWidget::tr("Open File\n") + name + QWidget::tr("\nfailed: ") + + QString(strerror(errno))); + QMessageBox::critical(parent, QWidget::tr("MusE: Open File"), s); + return 0; + } + return fp; + } + +//--------------------------------------------------------- +// MFile +//--------------------------------------------------------- + +MFile::MFile(const QString& _path, const QString& _ext) + : path(_path), ext(_ext) + { + f = 0; + isPopen = false; + } + +MFile::~MFile() + { + if (f) { + if (isPopen) + pclose(f); + else + fclose(f); + } + } + +//--------------------------------------------------------- +// open +//--------------------------------------------------------- + +//FILE* MFile::open(const char* mode, const char** pattern, +FILE* MFile::open(const char* mode, const QStringList& pattern, + QWidget* parent, bool noError, bool warnIfOverwrite, const QString& caption) + { + QString name; + if (strcmp(mode, "r") == 0) + name = getOpenFileName(path, pattern, parent, caption, 0); + else + name = getSaveFileName(path, pattern, parent, caption); + if (name.isEmpty()) + return 0; + f = fileOpen(parent, name, ext, mode, isPopen, noError, + warnIfOverwrite); + return f; + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/filedialog.h b/attic/muse2-oom/muse2/muse/widgets/filedialog.h new file mode 100644 index 00000000..0d3dfc8c --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/filedialog.h @@ -0,0 +1,110 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filedialog.h,v 1.2.2.2 2008/01/19 13:33:46 wschweer Exp $ +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QFileDialog> + +#include "ui_fdialogbuttons.h" + +class QStringList; + +//--------------------------------------------------------- +// FileDialogButtonsWidget +// Wrapper around Ui::FileDialogButtons +//--------------------------------------------------------- + +class FileDialogButtonsWidget : public QWidget, public Ui::FileDialogButtons +{ + Q_OBJECT + + public: + FileDialogButtonsWidget(QWidget *parent = 0) + : QWidget(parent) + { setupUi(this); } +}; + +//--------------------------------------------------------- +// MFileDialog +//--------------------------------------------------------- + +class MFileDialog : public QFileDialog { + Q_OBJECT + + static QString lastUserDir, lastGlobalDir; + bool showButtons; + QString baseDir; + + private slots: + void directoryChanged(const QString& directory); + public slots: + void globalToggled(bool); + void userToggled(bool); + void projectToggled(bool); + + public: + enum ViewType { GLOBAL_VIEW, PROJECT_VIEW, USER_VIEW }; //!< The three different viewtypes + static ViewType lastViewUsed; + FileDialogButtonsWidget buttons; + MFileDialog(const QString& dir, const QString& filter = QString::null, + QWidget* parent = 0, bool writeFlag = false); + }; + +/* ORCAN - Disable previeww for now. It is not available in qt4. We will + need to implement it ourselves. +//--------------------------------------------------------- +// ContentsPreview +//--------------------------------------------------------- + +class ContentsPreview : public QWidget, public Q3FilePreview { + Q_OBJECT + + virtual void previewUrl(const Q3Url &url); + QString path; + QPixmap* bg; + + public: + ContentsPreview(QWidget* parent, const char* name=0) + : QWidget(parent, name) { + bg = 0; + } + ~ContentsPreview(); + }; +*/ + +//QString getSaveFileName(const QString& startWidth, const char** filter, +QString getSaveFileName(const QString& startWidth, const QStringList& filters, + QWidget* parent, const QString& name); +//QString getOpenFileName(const QString& startWidth, const char** filter, +QString getOpenFileName(const QString& startWidth, const QStringList& filters, + QWidget* parent, const QString& name, bool* openAll, MFileDialog::ViewType viewType = MFileDialog::PROJECT_VIEW); +//QString getImageFileName(const QString& startWith, const char** filters, +QString getImageFileName(const QString& startWith, const QStringList& filters, + QWidget* parent, const QString& name); + +FILE* fileOpen(QWidget*, QString, const QString&, + const char*, bool&, bool = false, bool = false); + + +//--------------------------------------------------------- +// MFile +// "Muse" File +//--------------------------------------------------------- + +class MFile { + bool isPopen; + FILE* f; + QString path; + QString ext; + + public: + MFile(const QString& path, const QString& ext); + ~MFile(); + //FILE* open(const char* mode, const char** pattern, + FILE* open(const char* mode, const QStringList& pattern, + QWidget* parent, bool noError, + bool warnIfOverwrite, const QString& caption); + }; + diff --git a/attic/muse2-oom/muse2/muse/widgets/gatetime.cpp b/attic/muse2-oom/muse2/muse/widgets/gatetime.cpp new file mode 100644 index 00000000..f1804c35 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/gatetime.cpp @@ -0,0 +1,51 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: gatetime.cpp,v 1.1.1.1 2003/10/27 18:54:37 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QButtonGroup> +#include <QDialog> + +#include "gatetime.h" + +#include "song.h" + +//--------------------------------------------------------- +// GateTime +//--------------------------------------------------------- + +GateTime::GateTime(QWidget* parent) + : QDialog(parent) + { + setupUi(this); + rangeGroup = new QButtonGroup(rangeBox); + rangeGroup->addButton(allButton, 0); + rangeGroup->addButton(selButton, 1); + rangeGroup->addButton(loopButton, 2); + rangeGroup->addButton(sloopButton, 3); + rangeGroup->setExclusive(true); + } + +//--------------------------------------------------------- +// accept +//--------------------------------------------------------- + +void GateTime::accept() + { + _range = rangeGroup->checkedId(); + _rateVal = rate->value(); + _offsetVal = offset->value(); + QDialog::accept(); + } + +//--------------------------------------------------------- +// setRange +//--------------------------------------------------------- + +void GateTime::setRange(int id) + { + rangeGroup->button(id)->setChecked(true); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/gatetime.h b/attic/muse2-oom/muse2/muse/widgets/gatetime.h new file mode 100644 index 00000000..dcb1827c --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/gatetime.h @@ -0,0 +1,40 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: gatetime.h,v 1.1.1.1.2.1 2008/01/19 13:33:47 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __GATETIME_H__ +#define __GATETIME_H__ + +#include "ui_gatetimebase.h" + +class QButtonGroup; +class QDialog; + +//--------------------------------------------------------- +// GateTime +//--------------------------------------------------------- + +class GateTime : public QDialog, public Ui::GateTimeBase { + Q_OBJECT + + int _range; + int _rateVal; + int _offsetVal; + QButtonGroup *rangeGroup; + + protected slots: + void accept(); + + public: + GateTime(QWidget* parent=0); + void setRange(int id); + int range() const { return _range; } + int rateVal() const { return _rateVal; } + int offsetVal() const { return _offsetVal; } + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/gatetimebase.ui b/attic/muse2-oom/muse2/muse/widgets/gatetimebase.ui new file mode 100644 index 00000000..babf5f02 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/gatetimebase.ui @@ -0,0 +1,213 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>GateTimeBase</class> + <widget class="QDialog" name="GateTimeBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>275</width> + <height>316</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Modify Gate Time</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QGroupBox" name="rangeBox"> + <property name="title"> + <string>Range</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QRadioButton" name="allButton"> + <property name="text"> + <string>All Events</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="selButton"> + <property name="text"> + <string>Selected Events</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="loopButton"> + <property name="text"> + <string>Looped Events</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="sloopButton"> + <property name="text"> + <string>Selected & Looped</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="GroupBox3"> + <property name="title"> + <string>Values</string> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel3"> + <property name="text"> + <string>Rate:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="TextLabel4"> + <property name="text"> + <string>Offset:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QSpinBox" name="rate"> + <property name="suffix"> + <string>%</string> + </property> + <property name="maximum"> + <number>200</number> + </property> + <property name="value"> + <number>100</number> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="offset"> + <property name="minimum"> + <number>-999</number> + </property> + <property name="maximum"> + <number>999</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <spacer name="spacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="okButton"> + <property name="text"> + <string>OK</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton"> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>okButton</sender> + <signal>clicked()</signal> + <receiver>GateTimeBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>cancelButton</sender> + <signal>clicked()</signal> + <receiver>GateTimeBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/genset.cpp b/attic/muse2-oom/muse2/muse/widgets/genset.cpp new file mode 100644 index 00000000..0d81d846 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/genset.cpp @@ -0,0 +1,464 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: genset.cpp,v 1.7.2.8 2009/12/01 03:52:40 terminator356 Exp $ +// +// (C) Copyright 2001-2004 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> + +#include <QFileDialog> +#include <QRect> +#include <QShowEvent> + +#include "genset.h" +#include "app.h" +#include "gconfig.h" +#include "midiseq.h" +#include "globals.h" +#include "icons.h" + +static int rtcResolutions[] = { + 1024, 2048, 4096, 8192, 16384, 32768 + }; +static int divisions[] = { + 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288 + }; +static int dummyAudioBufSizes[] = { + 16, 32, 64, 128, 256, 512, 1024, 2048 + }; + +//--------------------------------------------------------- +// GlobalSettingsConfig +//--------------------------------------------------------- + +GlobalSettingsConfig::GlobalSettingsConfig(QWidget* parent) + : QDialog(parent) + { + setupUi(this); + startSongGroup = new QButtonGroup(this); + startSongGroup->addButton(startLastButton, 0); + startSongGroup->addButton(startEmptyButton, 1); + startSongGroup->addButton(startSongButton, 2); + for (unsigned i = 0; i < sizeof(rtcResolutions)/sizeof(*rtcResolutions); ++i) { + if (rtcResolutions[i] == config.rtcTicks) { + rtcResolutionSelect->setCurrentIndex(i); + break; + } + } + for (unsigned i = 0; i < sizeof(divisions)/sizeof(*divisions); ++i) { + if (divisions[i] == config.division) { + midiDivisionSelect->setCurrentIndex(i); + break; + } + } + for (unsigned i = 0; i < sizeof(divisions)/sizeof(*divisions); ++i) { + if (divisions[i] == config.guiDivision) { + guiDivisionSelect->setCurrentIndex(i); + break; + } + } + for (unsigned i = 0; i < sizeof(dummyAudioBufSizes)/sizeof(*dummyAudioBufSizes); ++i) { + if (dummyAudioBufSizes[i] == config.dummyAudioBufSize) { + dummyAudioSize->setCurrentIndex(i); + break; + } + } + + userInstrumentsPath->setText(config.userInstrumentsDir); + selectInstrumentsDirButton->setIcon(*openIcon); + defaultInstrumentsDirButton->setIcon(*undoIcon); + connect(selectInstrumentsDirButton, SIGNAL(clicked()), SLOT(selectInstrumentsPath())); + connect(defaultInstrumentsDirButton, SIGNAL(clicked()), SLOT(defaultInstrumentsPath())); + + guiRefreshSelect->setValue(config.guiRefresh); + minSliderSelect->setValue(int(config.minSlider)); + minMeterSelect->setValue(config.minMeter); + freewheelCheckBox->setChecked(config.freewheelMode); + denormalCheckBox->setChecked(config.useDenormalBias); + outputLimiterCheckBox->setChecked(config.useOutputLimiter); + vstInPlaceCheckBox->setChecked(config.vstInPlace); + dummyAudioRate->setValue(config.dummyAudioSampleRate); + + //DummyAudioDevice* dad = dynamic_cast<DummyAudioDevice*>(audioDevice); + //dummyAudioRealRate->setText(dad ? QString().setNum(sampleRate) : "---"); + dummyAudioRealRate->setText(QString().setNum(sampleRate)); + + startSongEntry->setText(config.startSong); + startSongGroup->button(config.startMode)->setChecked(true); + + showTransport->setChecked(config.transportVisible); + showBigtime->setChecked(config.bigTimeVisible); + //showMixer->setChecked(config.mixerVisible); + showMixer->setChecked(config.mixer1Visible); + showMixer2->setChecked(config.mixer2Visible); + + arrangerX->setValue(config.geometryMain.x()); + arrangerY->setValue(config.geometryMain.y()); + arrangerW->setValue(config.geometryMain.width()); + arrangerH->setValue(config.geometryMain.height()); + + transportX->setValue(config.geometryTransport.x()); + transportY->setValue(config.geometryTransport.y()); + + bigtimeX->setValue(config.geometryBigTime.x()); + bigtimeY->setValue(config.geometryBigTime.y()); + bigtimeW->setValue(config.geometryBigTime.width()); + bigtimeH->setValue(config.geometryBigTime.height()); + + //mixerX->setValue(config.geometryMixer.x()); + //mixerY->setValue(config.geometryMixer.y()); + //mixerW->setValue(config.geometryMixer.width()); + //mixerH->setValue(config.geometryMixer.height()); + mixerX->setValue(config.mixer1.geometry.x()); + mixerY->setValue(config.mixer1.geometry.y()); + mixerW->setValue(config.mixer1.geometry.width()); + mixerH->setValue(config.mixer1.geometry.height()); + mixer2X->setValue(config.mixer2.geometry.x()); + mixer2Y->setValue(config.mixer2.geometry.y()); + mixer2W->setValue(config.mixer2.geometry.width()); + mixer2H->setValue(config.mixer2.geometry.height()); + + //setMixerCurrent->setEnabled(muse->mixerWindow()); + setMixerCurrent->setEnabled(muse->mixer1Window()); + setMixer2Current->setEnabled(muse->mixer2Window()); + + setBigtimeCurrent->setEnabled(muse->bigtimeWindow()); + setTransportCurrent->setEnabled(muse->transportWindow()); + + showSplash->setChecked(config.showSplashScreen); + showDidYouKnow->setChecked(config.showDidYouKnow); + externalWavEditorSelect->setText(config.externalWavEditor); + oldStyleStopCheckBox->setChecked(config.useOldStyleStopShortCut); + moveArmedCheckBox->setChecked(config.moveArmedCheckBox); + + //updateSettings(); // TESTING + + connect(applyButton, SIGNAL(clicked()), SLOT(apply())); + connect(okButton, SIGNAL(clicked()), SLOT(ok())); + connect(cancelButton, SIGNAL(clicked()), SLOT(cancel())); + connect(setMixerCurrent, SIGNAL(clicked()), SLOT(mixerCurrent())); + connect(setMixer2Current, SIGNAL(clicked()), SLOT(mixer2Current())); + connect(setBigtimeCurrent, SIGNAL(clicked()), SLOT(bigtimeCurrent())); + connect(setArrangerCurrent, SIGNAL(clicked()), SLOT(arrangerCurrent())); + connect(setTransportCurrent, SIGNAL(clicked()), SLOT(transportCurrent())); + } + +//--------------------------------------------------------- +// updateSettings +//--------------------------------------------------------- + +void GlobalSettingsConfig::updateSettings() +{ + for (unsigned i = 0; i < sizeof(rtcResolutions)/sizeof(*rtcResolutions); ++i) { + if (rtcResolutions[i] == config.rtcTicks) { + rtcResolutionSelect->setCurrentIndex(i); + break; + } + } + for (unsigned i = 0; i < sizeof(divisions)/sizeof(*divisions); ++i) { + if (divisions[i] == config.division) { + midiDivisionSelect->setCurrentIndex(i); + break; + } + } + for (unsigned i = 0; i < sizeof(divisions)/sizeof(*divisions); ++i) { + if (divisions[i] == config.guiDivision) { + guiDivisionSelect->setCurrentIndex(i); + break; + } + } + for (unsigned i = 0; i < sizeof(dummyAudioBufSizes)/sizeof(*dummyAudioBufSizes); ++i) { + if (dummyAudioBufSizes[i] == config.dummyAudioBufSize) { + dummyAudioSize->setCurrentIndex(i); + break; + } + } + + guiRefreshSelect->setValue(config.guiRefresh); + minSliderSelect->setValue(int(config.minSlider)); + minMeterSelect->setValue(config.minMeter); + freewheelCheckBox->setChecked(config.freewheelMode); + denormalCheckBox->setChecked(config.useDenormalBias); + outputLimiterCheckBox->setChecked(config.useOutputLimiter); + vstInPlaceCheckBox->setChecked(config.vstInPlace); + dummyAudioRate->setValue(config.dummyAudioSampleRate); + + //DummyAudioDevice* dad = dynamic_cast<DummyAudioDevice*>(audioDevice); + //dummyAudioRealRate->setText(dad ? QString().setNum(sampleRate) : "---"); + dummyAudioRealRate->setText(QString().setNum(sampleRate)); + + startSongEntry->setText(config.startSong); + startSongGroup->button(config.startMode)->setChecked(true); + + showTransport->setChecked(config.transportVisible); + showBigtime->setChecked(config.bigTimeVisible); + //showMixer->setChecked(config.mixerVisible); + showMixer->setChecked(config.mixer1Visible); + showMixer2->setChecked(config.mixer2Visible); + + arrangerX->setValue(config.geometryMain.x()); + arrangerY->setValue(config.geometryMain.y()); + arrangerW->setValue(config.geometryMain.width()); + arrangerH->setValue(config.geometryMain.height()); + + transportX->setValue(config.geometryTransport.x()); + transportY->setValue(config.geometryTransport.y()); + + bigtimeX->setValue(config.geometryBigTime.x()); + bigtimeY->setValue(config.geometryBigTime.y()); + bigtimeW->setValue(config.geometryBigTime.width()); + bigtimeH->setValue(config.geometryBigTime.height()); + + //mixerX->setValue(config.geometryMixer.x()); + //mixerY->setValue(config.geometryMixer.y()); + //mixerW->setValue(config.geometryMixer.width()); + //mixerH->setValue(config.geometryMixer.height()); + mixerX->setValue(config.mixer1.geometry.x()); + mixerY->setValue(config.mixer1.geometry.y()); + mixerW->setValue(config.mixer1.geometry.width()); + mixerH->setValue(config.mixer1.geometry.height()); + mixer2X->setValue(config.mixer2.geometry.x()); + mixer2Y->setValue(config.mixer2.geometry.y()); + mixer2W->setValue(config.mixer2.geometry.width()); + mixer2H->setValue(config.mixer2.geometry.height()); + + //setMixerCurrent->setEnabled(muse->mixerWindow()); + setMixerCurrent->setEnabled(muse->mixer1Window()); + setMixer2Current->setEnabled(muse->mixer2Window()); + + setBigtimeCurrent->setEnabled(muse->bigtimeWindow()); + setTransportCurrent->setEnabled(muse->transportWindow()); + + showSplash->setChecked(config.showSplashScreen); + showDidYouKnow->setChecked(config.showDidYouKnow); + externalWavEditorSelect->setText(config.externalWavEditor); + oldStyleStopCheckBox->setChecked(config.useOldStyleStopShortCut); + moveArmedCheckBox->setChecked(config.moveArmedCheckBox); +} + +//--------------------------------------------------------- +// showEvent +//--------------------------------------------------------- + +void GlobalSettingsConfig::showEvent(QShowEvent* e) +{ + QDialog::showEvent(e); + //updateSettings(); // TESTING +} + +//--------------------------------------------------------- +// apply +//--------------------------------------------------------- + +void GlobalSettingsConfig::apply() + { + int rtcticks = rtcResolutionSelect->currentIndex(); + config.guiRefresh = guiRefreshSelect->value(); + config.minSlider = minSliderSelect->value(); + config.minMeter = minMeterSelect->value(); + config.freewheelMode = freewheelCheckBox->isChecked(); + config.useDenormalBias = denormalCheckBox->isChecked(); + config.useOutputLimiter = outputLimiterCheckBox->isChecked(); + config.vstInPlace = vstInPlaceCheckBox->isChecked(); + config.rtcTicks = rtcResolutions[rtcticks]; + config.userInstrumentsDir = userInstrumentsPath->text(); + config.startSong = startSongEntry->text(); + config.startMode = startSongGroup->checkedId(); + int das = dummyAudioSize->currentIndex(); + config.dummyAudioBufSize = dummyAudioBufSizes[das]; + config.dummyAudioSampleRate = dummyAudioRate->value(); + + int div = midiDivisionSelect->currentIndex(); + config.division = divisions[div]; + div = guiDivisionSelect->currentIndex(); + config.guiDivision = divisions[div]; + + config.transportVisible = showTransport->isChecked(); + config.bigTimeVisible = showBigtime->isChecked(); + //config.mixerVisible = showMixer->isChecked(); + config.mixer1Visible = showMixer->isChecked(); + config.mixer2Visible = showMixer2->isChecked(); + + config.geometryMain.setX(arrangerX->value()); + config.geometryMain.setY(arrangerY->value()); + config.geometryMain.setWidth(arrangerW->value()); + config.geometryMain.setHeight(arrangerH->value()); + + config.geometryTransport.setX(transportX->value()); + config.geometryTransport.setY(transportY->value()); + config.geometryTransport.setWidth(0); + config.geometryTransport.setHeight(0); + + config.geometryBigTime.setX(bigtimeX->value()); + config.geometryBigTime.setY(bigtimeY->value()); + config.geometryBigTime.setWidth(bigtimeW->value()); + config.geometryBigTime.setHeight(bigtimeH->value()); + + //config.geometryMixer.setX(mixerX->value()); + //config.geometryMixer.setY(mixerY->value()); + //config.geometryMixer.setWidth(mixerW->value()); + //config.geometryMixer.setHeight(mixerH->value()); + config.mixer1.geometry.setX(mixerX->value()); + config.mixer1.geometry.setY(mixerY->value()); + config.mixer1.geometry.setWidth(mixerW->value()); + config.mixer1.geometry.setHeight(mixerH->value()); + config.mixer2.geometry.setX(mixer2X->value()); + config.mixer2.geometry.setY(mixer2Y->value()); + config.mixer2.geometry.setWidth(mixer2W->value()); + config.mixer2.geometry.setHeight(mixer2H->value()); + + config.showSplashScreen = showSplash->isChecked(); + config.showDidYouKnow = showDidYouKnow->isChecked(); + config.externalWavEditor = externalWavEditorSelect->text(); + config.useOldStyleStopShortCut = oldStyleStopCheckBox->isChecked(); + config.moveArmedCheckBox = moveArmedCheckBox->isChecked(); + //muse->showMixer(config.mixerVisible); + muse->showMixer1(config.mixer1Visible); + muse->showMixer2(config.mixer2Visible); + + muse->showBigtime(config.bigTimeVisible); + muse->showTransport(config.transportVisible); + QWidget* w = muse->transportWindow(); + if (w) { + w->resize(config.geometryTransport.size()); + w->move(config.geometryTransport.topLeft()); + } + //w = muse->mixerWindow(); + //if (w) { + // w->resize(config.geometryMixer.size()); + // w->move(config.geometryMixer.topLeft()); + // } + w = muse->mixer1Window(); + if (w) { + w->resize(config.mixer1.geometry.size()); + w->move(config.mixer1.geometry.topLeft()); + } + w = muse->mixer2Window(); + if (w) { + w->resize(config.mixer2.geometry.size()); + w->move(config.mixer2.geometry.topLeft()); + } + w = muse->bigtimeWindow(); + if (w) { + w->resize(config.geometryBigTime.size()); + w->move(config.geometryBigTime.topLeft()); + } + muse->resize(config.geometryMain.size()); + muse->move(config.geometryMain.topLeft()); + + museUserInstruments = config.userInstrumentsDir; + + muse->setHeartBeat(); // set guiRefresh + midiSeq->msgSetRtc(); // set midi tick rate + muse->changeConfig(true); // save settings + } + +//--------------------------------------------------------- +// ok +//--------------------------------------------------------- + +void GlobalSettingsConfig::ok() + { + apply(); + close(); + } + +//--------------------------------------------------------- +// cancel +//--------------------------------------------------------- + +void GlobalSettingsConfig::cancel() + { + close(); + } + +//--------------------------------------------------------- +// mixerCurrent +//--------------------------------------------------------- + +void GlobalSettingsConfig::mixerCurrent() + { + QWidget* w = muse->mixer1Window(); + if (!w) + return; + QRect r(w->frameGeometry()); + mixerX->setValue(r.x()); + mixerY->setValue(r.y()); + mixerW->setValue(r.width()); + mixerH->setValue(r.height()); + } + +//--------------------------------------------------------- +// mixer2Current +//--------------------------------------------------------- + +void GlobalSettingsConfig::mixer2Current() + { + QWidget* w = muse->mixer2Window(); + if (!w) + return; + QRect r(w->frameGeometry()); + mixer2X->setValue(r.x()); + mixer2Y->setValue(r.y()); + mixer2W->setValue(r.width()); + mixer2H->setValue(r.height()); + } + +//--------------------------------------------------------- +// bigtimeCurrent +//--------------------------------------------------------- + +void GlobalSettingsConfig::bigtimeCurrent() + { + QWidget* w = muse->bigtimeWindow(); + if (!w) + return; + QRect r(w->frameGeometry()); + bigtimeX->setValue(r.x()); + bigtimeY->setValue(r.y()); + bigtimeW->setValue(r.width()); + bigtimeH->setValue(r.height()); + } + +//--------------------------------------------------------- +// arrangerCurrent +//--------------------------------------------------------- + +void GlobalSettingsConfig::arrangerCurrent() + { + QRect r(muse->frameGeometry()); + arrangerX->setValue(r.x()); + arrangerY->setValue(r.y()); + arrangerW->setValue(r.width()); + arrangerH->setValue(r.height()); + } + +//--------------------------------------------------------- +// transportCurrent +//--------------------------------------------------------- + +void GlobalSettingsConfig::transportCurrent() + { + QWidget* w = muse->transportWindow(); + if (!w) + return; + QRect r(w->frameGeometry()); + transportX->setValue(r.x()); + transportY->setValue(r.y()); + } + +void GlobalSettingsConfig::selectInstrumentsPath() + { + QString dir = QFileDialog::getExistingDirectory(this, + tr("Selects instruments directory"), + config.userInstrumentsDir); + userInstrumentsPath->setText(dir); + } + +void GlobalSettingsConfig::defaultInstrumentsPath() + { + QString dir = configPath + "/instruments"; + userInstrumentsPath->setText(dir); + } diff --git a/attic/muse2-oom/muse2/muse/widgets/genset.h b/attic/muse2-oom/muse2/muse/widgets/genset.h new file mode 100644 index 00000000..ea094296 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/genset.h @@ -0,0 +1,44 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: genset.h,v 1.3 2004/01/25 09:55:17 wschweer Exp $ +// +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __GENSET_H__ +#define __GENSET_H__ + +#include "ui_gensetbase.h" + +#include <QShowEvent> + +//--------------------------------------------------------- +// GlobalSettingsConfig +//--------------------------------------------------------- + +class GlobalSettingsConfig : public QDialog, public Ui::GlobalSettingsDialogBase { + Q_OBJECT + + private slots: + void updateSettings(); + void apply(); + void ok(); + void cancel(); + void mixerCurrent(); + void mixer2Current(); + void bigtimeCurrent(); + void arrangerCurrent(); + void transportCurrent(); + void selectInstrumentsPath(); + void defaultInstrumentsPath(); + + protected: + void showEvent(QShowEvent*); + QButtonGroup *startSongGroup; + + public: + GlobalSettingsConfig(QWidget* parent=0); + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/gensetbase.ui b/attic/muse2-oom/muse2/muse/widgets/gensetbase.ui new file mode 100644 index 00000000..44261c87 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/gensetbase.ui @@ -0,0 +1,1268 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>GlobalSettingsDialogBase</class> + <widget class="QDialog" name="GlobalSettingsDialogBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>522</width> + <height>518</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Global Settings</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QTabWidget" name="TabWidget2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="TabPage"> + <attribute name="title"> + <string>Application</string> + </attribute> + <layout class="QGridLayout"> + <item row="1" column="0"> + <widget class="QGroupBox" name="groupBox4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Views</string> + </property> + <layout class="QGridLayout"> + <item row="1" column="3"> + <widget class="QSpinBox" name="transportY"> + <property name="toolTip"> + <string>y-pos</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="showTransport"> + <property name="text"> + <string>show</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QSpinBox" name="transportX"> + <property name="toolTip"> + <string>x-pos</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="0" column="5"> + <widget class="QSpinBox" name="arrangerH"> + <property name="toolTip"> + <string>height</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="QSpinBox" name="arrangerW"> + <property name="toolTip"> + <string>width</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QSpinBox" name="arrangerY"> + <property name="toolTip"> + <string>y-pos</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QSpinBox" name="arrangerX"> + <property name="toolTip"> + <string>x-pos</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="showBigtime"> + <property name="text"> + <string>show</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QSpinBox" name="bigtimeX"> + <property name="toolTip"> + <string>x-pos</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QSpinBox" name="bigtimeY"> + <property name="toolTip"> + <string>y-pos</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="2" column="4"> + <widget class="QSpinBox" name="bigtimeW"> + <property name="toolTip"> + <string>width</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="2" column="5"> + <widget class="QSpinBox" name="bigtimeH"> + <property name="toolTip"> + <string>height</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QCheckBox" name="showMixer"> + <property name="text"> + <string>show</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QCheckBox" name="showMixer2"> + <property name="text"> + <string>show</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="textLabel4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Mixer A</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="textLabel4_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Mixer B</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="textLabel3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Big Time</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="textLabel1_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Arranger</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="textLabel2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Transport</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="5"> + <widget class="QSpinBox" name="mixerH"> + <property name="toolTip"> + <string>height</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="3" column="4"> + <widget class="QSpinBox" name="mixerW"> + <property name="toolTip"> + <string>width</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QSpinBox" name="mixerY"> + <property name="toolTip"> + <string>y-pos</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QSpinBox" name="mixerX"> + <property name="toolTip"> + <string>x-pos</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="3" column="6"> + <widget class="QPushButton" name="setMixerCurrent"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>set current values</string> + </property> + <property name="text"> + <string>Cur</string> + </property> + </widget> + </item> + <item row="4" column="5"> + <widget class="QSpinBox" name="mixer2H"> + <property name="toolTip"> + <string>height</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="4" column="4"> + <widget class="QSpinBox" name="mixer2W"> + <property name="toolTip"> + <string>width</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="4" column="3"> + <widget class="QSpinBox" name="mixer2Y"> + <property name="toolTip"> + <string>y-pos</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QSpinBox" name="mixer2X"> + <property name="toolTip"> + <string>x-pos</string> + </property> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="4" column="6"> + <widget class="QPushButton" name="setMixer2Current"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>set current values</string> + </property> + <property name="text"> + <string>Cur</string> + </property> + </widget> + </item> + <item row="2" column="6"> + <widget class="QPushButton" name="setBigtimeCurrent"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>set current values</string> + </property> + <property name="text"> + <string>Cur</string> + </property> + </widget> + </item> + <item row="0" column="6"> + <widget class="QPushButton" name="setArrangerCurrent"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>set current values</string> + </property> + <property name="text"> + <string>Cur</string> + </property> + </widget> + </item> + <item row="1" column="6"> + <widget class="QPushButton" name="setTransportCurrent"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>set current values</string> + </property> + <property name="text"> + <string>Cur</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox3"> + <property name="title"> + <string>Start Muse</string> + </property> + <layout class="QGridLayout"> + <item row="0" column="0"> + <layout class="QGridLayout"> + <item row="1" column="0"> + <spacer name="spacer7_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>51</height> + </size> + </property> + </spacer> + </item> + <item row="2" column="0" colspan="2"> + <layout class="QHBoxLayout"> + <item> + <widget class="QLabel" name="textLabel1_2"> + <property name="text"> + <string>start song:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="startSongEntry"/> + </item> + </layout> + </item> + <item row="0" column="0"> + <widget class="QGroupBox" name="startSongBox"> + <property name="title"> + <string>Start song</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QRadioButton" name="startLastButton"> + <property name="text"> + <string>start with last song</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="startEmptyButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>start with template: default.med</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="startSongButton"> + <property name="text"> + <string>start with song</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="1"> + <widget class="QGroupBox" name="startUpBox"> + <property name="title"> + <string>On Launch</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QCheckBox" name="showSplash"> + <property name="text"> + <string>show splash screen</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="showDidYouKnow"> + <property name="text"> + <string>show "Did you know?" dialog</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="1"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Audio</string> + </attribute> + <layout class="QGridLayout"> + <item row="0" column="0"> + <widget class="QGroupBox" name="GroupBox4"> + <property name="title"> + <string>Mixer</string> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="1"> + <widget class="QSpinBox" name="minSliderSelect"> + <property name="suffix"> + <string>dB</string> + </property> + <property name="minimum"> + <number>-100</number> + </property> + <property name="maximum"> + <number>0</number> + </property> + <property name="singleStep"> + <number>10</number> + </property> + <property name="value"> + <number>-60</number> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="TextLabel3_2"> + <property name="text"> + <string>min. Meter Value</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel2_2"> + <property name="text"> + <string>min. Slider Val</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="minMeterSelect"> + <property name="suffix"> + <string>dB</string> + </property> + <property name="minimum"> + <number>-100</number> + </property> + <property name="maximum"> + <number>0</number> + </property> + <property name="singleStep"> + <number>10</number> + </property> + <property name="value"> + <number>-60</number> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="freewheelLabel"> + <property name="text"> + <string>Use Jack freewheel mode if possible. +(Speeds up bounce operations).</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QCheckBox" name="denormalCheckBox"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="freewheelCheckBox"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="textLabel1_5"> + <property name="text"> + <string>Enable denormal protection</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="textLabel1_5_2"> + <property name="text"> + <string>Enable output limiter</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QCheckBox" name="outputLimiterCheckBox"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="vstInPlaceTextLabel"> + <property name="text"> + <string>Enable in-place processing for VST plugins. +(Requires restart.)</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QCheckBox" name="vstInPlaceCheckBox"> + <property name="whatsThis"> + <string>Turn this off if VST Ladspa effect rack plugins do not work or feedback loudly, even if they are supposed to be in-place capable.</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="groupBox13"> + <property name="title"> + <string>External Waveditor</string> + </property> + <layout class="QGridLayout"> + <item row="0" column="0"> + <layout class="QGridLayout"> + <item row="0" column="0"> + <layout class="QHBoxLayout"> + <item> + <widget class="QLabel" name="textLabel2_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>External Waveditor command</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <spacer name="spacer13"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>60</width> + <height>23</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLineEdit" name="externalWavEditorSelect"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="textLabel1_6"> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <property name="text"> + <string>Note: External editor opened from the internal editor.</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item row="2" column="0"> + <widget class="QGroupBox" name="dummyAudioGroupBox"> + <property name="title"> + <string>Dummy Audio Driver (settings require restart)</string> + </property> + <layout class="QGridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="dummyAudioRateLabel"> + <property name="text"> + <string>Preferred sample rate</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QSpinBox" name="dummyAudioRate"> + <property name="whatsThis"> + <string>Actual rate used depends on limitations of + timer used. If a high rate timer is available, + short periods can be used with high sample rates. +Period affects midi playback resolution. +Shorter periods are desirable.</string> + </property> + <property name="suffix"> + <string>Hz</string> + </property> + <property name="minimum"> + <number>3000</number> + </property> + <property name="maximum"> + <number>200000</number> + </property> + <property name="singleStep"> + <number>10</number> + </property> + <property name="value"> + <number>44100</number> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="dummyAudioRealRateLabel"> + <property name="text"> + <string>Actual rate used now (dummy or not):</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="dummyAudioRealRate"> + <property name="text"> + <string>---</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="dummyAudioSizeLabel"> + <property name="text"> + <string>Period size (Frames per period):</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="dummyAudioSize"> + <item> + <property name="text"> + <string>16</string> + </property> + </item> + <item> + <property name="text"> + <string>32</string> + </property> + </item> + <item> + <property name="text"> + <string>64</string> + </property> + </item> + <item> + <property name="text"> + <string>128</string> + </property> + </item> + <item> + <property name="text"> + <string>256</string> + </property> + </item> + <item> + <property name="text"> + <string>512</string> + </property> + </item> + <item> + <property name="text"> + <string>1024</string> + </property> + </item> + <item> + <property name="text"> + <string>2048</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab2"> + <attribute name="title"> + <string>Midi</string> + </attribute> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QGroupBox" name="GroupBox2"> + <property name="title"> + <string>Ticks</string> + </property> + <layout class="QGridLayout" name="gridLayout9"> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel3"> + <property name="text"> + <string>RTC Resolution +(Ticks/Sec)</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="rtcResolutionSelect"> + <item> + <property name="text"> + <string>1024</string> + </property> + </item> + <item> + <property name="text"> + <string>2048</string> + </property> + </item> + <item> + <property name="text"> + <string>4096</string> + </property> + </item> + <item> + <property name="text"> + <string>8192</string> + </property> + </item> + <item> + <property name="text"> + <string>16384</string> + </property> + </item> + <item> + <property name="text"> + <string>32768</string> + </property> + </item> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="midiResLabel"> + <property name="text"> + <string>Midi Resolution +(Ticks/Quarternote)</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="midiDivisionSelect"> + <property name="currentIndex"> + <number>3</number> + </property> + <item> + <property name="text"> + <string>48</string> + </property> + </item> + <item> + <property name="text"> + <string>96</string> + </property> + </item> + <item> + <property name="text"> + <string>192</string> + </property> + </item> + <item> + <property name="text"> + <string>384</string> + </property> + </item> + <item> + <property name="text"> + <string>768</string> + </property> + </item> + <item> + <property name="text"> + <string>1536</string> + </property> + </item> + <item> + <property name="text"> + <string>3072</string> + </property> + </item> + <item> + <property name="text"> + <string>6144</string> + </property> + </item> + <item> + <property name="text"> + <string>12288</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="TextLabel4"> + <property name="text"> + <string>Displayed Resolution +(Ticks/Quarternote)</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="guiDivisionSelect"> + <property name="currentIndex"> + <number>3</number> + </property> + <item> + <property name="text"> + <string>48</string> + </property> + </item> + <item> + <property name="text"> + <string>96</string> + </property> + </item> + <item> + <property name="text"> + <string>192</string> + </property> + </item> + <item> + <property name="text"> + <string>384</string> + </property> + </item> + <item> + <property name="text"> + <string>768</string> + </property> + </item> + <item> + <property name="text"> + <string>1536</string> + </property> + </item> + <item> + <property name="text"> + <string>3072</string> + </property> + </item> + <item> + <property name="text"> + <string>6144</string> + </property> + </item> + <item> + <property name="text"> + <string>12288</string> + </property> + </item> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="TextLabel3_4"> + <property name="text"> + <string>Instruments Directory</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="userInstrumentsPath"/> + </item> + <item row="3" column="2"> + <widget class="QPushButton" name="selectInstrumentsDirButton"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QPushButton" name="defaultInstrumentsDirButton"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab3"> + <attribute name="title"> + <string>GUI</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Behavior</string> + </property> + <layout class="QGridLayout" name="gridLayout_2" columnminimumwidth="280,0,0"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> + <string>GUI Refresh Rate</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1" colspan="2"> + <widget class="QSpinBox" name="guiRefreshSelect"> + <property name="suffix"> + <string>/sec</string> + </property> + <property name="minimum"> + <number>2</number> + </property> + <property name="maximum"> + <number>100</number> + </property> + <property name="value"> + <number>20</number> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="textLabel1_4"> + <property name="text"> + <string>Use old-style stop shortcut:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="textLabel1_4_2"> + <property name="text"> + <string>Move single armed track with selection</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="moveArmedCheckBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="oldStyleStopCheckBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <spacer name="Spacer1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="applyButton"> + <property name="text"> + <string>&Apply</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="okButton"> + <property name="text"> + <string>&Ok</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton"> + <property name="text"> + <string>&Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections/> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/header.cpp b/attic/muse2-oom/muse2/muse/widgets/header.cpp new file mode 100644 index 00000000..16cc374b --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/header.cpp @@ -0,0 +1,111 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: header.cpp,v 1.1.1.1 2003/10/27 18:55:05 wschweer Exp $ +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include "header.h" +#include "xml.h" + +#include <QStringList> +#include <QStandardItemModel> + +//--------------------------------------------------------- +// readStatus +//--------------------------------------------------------- + +void Header::readStatus(Xml& xml) + { + for (;;) { + Xml::Token token = xml.parse(); + const QString& tag = xml.s1(); + switch (token) { + case Xml::Error: + case Xml::End: + return; + case Xml::Text: + { + //QStringList l = QStringList::split(QString(" "), tag); + QStringList l = tag.split(QString(" "), QString::SkipEmptyParts); + int index = count() -1; + for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + int section = visualIndex((*it).toInt()); + moveSection(section, index); + --index; + } + } + break; + case Xml::TagStart: + xml.unknown("Header"); + break; + case Xml::TagEnd: + if (tag ==objectName()) + return; + default: + break; + } + } + } + +//--------------------------------------------------------- +// writeStatus +//--------------------------------------------------------- + +void Header::writeStatus(int level, Xml& xml) const + { + //xml.nput(level, "<%s> ", name()); + xml.nput(level, "<%s> ", Xml::xmlString(objectName()).toLatin1().constData()); + int n = count() - 1; + for (int i = n; i >= 0; --i) + xml.nput("%d ", logicalIndex(i)); + //xml.put("</%s>", name()); + xml.put("</%s>", Xml::xmlString(objectName()).toLatin1().constData()); + } + +//--------------------------------------------------------- +// Header +//--------------------------------------------------------- + +Header::Header(QWidget* parent, const char* name) + : QHeaderView(Qt::Horizontal, parent) + { + setObjectName(name); + itemModel = new QStandardItemModel; + setModel(itemModel); + //setResizeMode(QHeaderView::ResizeToContents); + setDefaultSectionSize(30); + } + +//--------------------------------------------------------- +// setColumnLabel +//--------------------------------------------------------- + +void Header::setColumnLabel(const QString & text, int col, int width ) + { + QStandardItem *sitem = new QStandardItem(text ); + itemModel->setHorizontalHeaderItem(col, sitem); + if (width > -1) + resizeSection(col, width); + } + +//--------------------------------------------------------- +// setToolTip +//--------------------------------------------------------- + +void Header::setToolTip(int col, const QString &text) + { + QStandardItem *item = itemModel->horizontalHeaderItem(col); + item->setToolTip(text); + } + +//--------------------------------------------------------- +// setWhatsThis +//--------------------------------------------------------- + +void Header::setWhatsThis(int col, const QString &text) + { + QStandardItem *item = itemModel->horizontalHeaderItem(col); + item->setWhatsThis(text); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/header.h b/attic/muse2-oom/muse2/muse/widgets/header.h new file mode 100644 index 00000000..83680f8a --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/header.h @@ -0,0 +1,32 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: header.h,v 1.1.1.1 2003/10/27 18:55:03 wschweer Exp $ +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __HEADER_H__ +#define __HEADER_H__ + +#include <QHeaderView> + +class QStandardItemModel; + +class Xml; + +class Header : public QHeaderView { + Q_OBJECT + + QStandardItemModel *itemModel; + + public: + Header(QWidget* parent=0, const char* name=0); + void writeStatus(int level, Xml&) const; + void readStatus(Xml&); + void setColumnLabel( const QString & s, int col, int width = -1 ); + void setToolTip(int col, const QString &text); + void setWhatsThis(int col, const QString &text); +}; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/hitscale.cpp b/attic/muse2-oom/muse2/muse/widgets/hitscale.cpp new file mode 100644 index 00000000..feba5920 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/hitscale.cpp @@ -0,0 +1,133 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: hitscale.cpp,v 1.3.2.1 2007/01/27 14:52:43 spamatica Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include "hitscale.h" +#include "midieditor.h" + +#include <QMouseEvent> +#include <QPainter> + +#include "song.h" + +//--------------------------------------------------------- +// HitScale +//--------------------------------------------------------- + +HitScale::HitScale(int* r, QWidget* parent, int xs) + : View(parent, xs, 1) + { + raster = r; + pos[0] = song->cpos(); + pos[1] = song->lpos(); + pos[2] = song->rpos(); + button = Qt::NoButton; + setMouseTracking(true); + connect(song, SIGNAL(posChanged(int, unsigned, bool)), this, SLOT(setPos(int, unsigned, bool))); + setFixedHeight(18); + } + +//--------------------------------------------------------- +// setPos +//--------------------------------------------------------- + +void HitScale::setPos(int idx, unsigned val, bool) + { + if (val == pos[idx]) + return; + unsigned int opos = mapx(pos[idx]); // in order preventing comparison of sigend & unsigned int ??is this OK? + pos[idx] = val; + if (!isVisible()) + return; + val = mapx(val); + int x = -9; + int w = 18; + if (opos > val) { //here would be the comparison signed/unsigned + w += opos - val; + x += val; + } + else { + w += val - opos; + x += opos; + } + paint(QRect(x, 0, w, height())); + } + +void HitScale::viewMousePressEvent(QMouseEvent* event) + { + button = event->button(); + viewMouseMoveEvent(event); + } + +void HitScale::viewMouseReleaseEvent(QMouseEvent*) + { + button = Qt::NoButton; + } + +void HitScale::viewMouseMoveEvent(QMouseEvent* event) + { + int x = AL::sigmap.raster(event->x(), *raster); + emit timeChanged(x); + int i; + switch (button) { + case Qt::LeftButton: + i = 0; + break; + case Qt::MidButton: + i = 1; + break; + case Qt::RightButton: + i = 2; + break; + default: + return; + } + Pos p(x, true); + song->setPos(i, p); + } + +//--------------------------------------------------------- +// leaveEvent +//--------------------------------------------------------- + +void HitScale::leaveEvent(QEvent*) + { + emit timeChanged(-1); + } + +//--------------------------------------------------------- +// draw +//--------------------------------------------------------- + +void HitScale::pdraw(QPainter& p, const QRect& r) + { + int x = r.x(); + int w = r.width(); + +// x -= 10; +// w += 20; + + if (x < 0) + x = 0; + + //--------------------------------------------------- + // draw location marker + //--------------------------------------------------- + + p.setPen(Qt::red); + int xp = mapx(pos[0]); + if (xp >= x && xp < x+w) + p.drawLine(xp, 0, xp, height()); + p.setPen(Qt::blue); + xp = mapx(pos[1]); + if (xp >= x && xp < x+w) + p.drawLine(xp, 0, xp, height()); + xp = mapx(pos[2]); + if (xp >= x && xp < x+w) + p.drawLine(xp, 0, xp, height()); + } + + diff --git a/attic/muse2-oom/muse2/muse/widgets/hitscale.h b/attic/muse2-oom/muse2/muse/widgets/hitscale.h new file mode 100644 index 00000000..0eaae399 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/hitscale.h @@ -0,0 +1,46 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: hitscale.h,v 1.2 2004/01/11 18:55:37 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __HITSCALE_H__ +#define __HITSCALE_H__ + +#include "view.h" + +class MidiEditor; + +//--------------------------------------------------------- +// HitScale +// scale for midi track +//--------------------------------------------------------- + +class HitScale : public View { + Q_OBJECT + int* raster; + unsigned pos[3]; + int button; + + signals: +// void posChanged(int, int); + + protected: + virtual void pdraw(QPainter&, const QRect&); + virtual void viewMousePressEvent(QMouseEvent* event); + virtual void viewMouseMoveEvent(QMouseEvent* event); + virtual void viewMouseReleaseEvent(QMouseEvent* event); + virtual void leaveEvent(QEvent*e); + + signals: + void timeChanged(int); + + public slots: + void setPos(int, unsigned, bool); + + public: + HitScale(int* raster, QWidget* parent, int xscale); + }; +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/intlabel.cpp b/attic/muse2-oom/muse2/muse/widgets/intlabel.cpp new file mode 100644 index 00000000..355f4510 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/intlabel.cpp @@ -0,0 +1,140 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: intlabel.cpp,v 1.1.1.1.2.1 2008/08/18 00:15:26 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> + +#include "intlabel.h" +#include "utils.h" + +//--------------------------------------------------------- +// IntLabel +//--------------------------------------------------------- + +IntLabel::IntLabel(int _val, int _min, int _max, QWidget* parent, + int _off, const QString& str, int lPos) + : Nentry(parent, str, lPos) + { + specialValue = "off"; + min = _min; + max = _max; + val = _val+1; // dont optimize away + off = _off; + setValue(_val); + int len = num2cols(min, max); + setSize(len); + } + +void IntLabel::setSpecialValueText(const QString& s) + { + specialValue = s; + setString(val); + } + +//--------------------------------------------------------- +// setRange +//--------------------------------------------------------- + +void IntLabel::setRange(int mn, int mx) +{ + min = mn; + max = mx; + setSize(num2cols(min, max)); + int v = val; + if(val < mn) + v = mn; + else + if(val > mx) + v = mx; + setValue(v); +} + +//--------------------------------------------------------- +// setString +//--------------------------------------------------------- + +bool IntLabel::setString(int v, bool editable) + { + if (v < min || v > max) { + setText(QString("---")); + return true; + } + else if (v == off) { + if (editable) + setText(QString("")); + else + setText(specialValue); + } + else { + QString s; + s.setNum(v); + if (!editable) + s += suffix; + setText(s); + } + return false; + } + +//--------------------------------------------------------- +// setSValue +//--------------------------------------------------------- + +bool IntLabel::setSValue(const QString& s) + { + int v; + if (s == specialValue) + v = off; + else { + bool ok; + v = s.toInt(&ok); + if (!ok) + return true; + if (v < min) + v = min; + if (v > max) + v = max; + } + if (v != val) { + setValue(v); + emit valueChanged(val); + } + return false; + } + +//--------------------------------------------------------- +// incValue +//--------------------------------------------------------- + +void IntLabel::incValue(int) + { + if (val < max) { + setValue(val+1); + emit valueChanged(val); + } + } + +//--------------------------------------------------------- +// decValue +//--------------------------------------------------------- + +void IntLabel::decValue(int) + { + if (val > min) { + setValue(val-1); + emit valueChanged(val); + } + } + +//--------------------------------------------------------- +// setOff +//--------------------------------------------------------- + +void IntLabel::setOff(int v) + { + off = v; + setString(val); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/intlabel.h b/attic/muse2-oom/muse2/muse/widgets/intlabel.h new file mode 100644 index 00000000..df452891 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/intlabel.h @@ -0,0 +1,46 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: intlabel.h,v 1.1.1.1.2.2 2008/08/18 00:15:26 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __INTLABEL_H__ +#define __INTLABEL_H__ + +#include <values.h> +#include "nentry.h" + +class QString; + +//--------------------------------------------------------- +// IntLabel +//--------------------------------------------------------- + +class IntLabel : public Nentry { + Q_OBJECT + + int min, max, off; + QString suffix; + QString specialValue; + + void init(); + + virtual bool setSValue(const QString&); + virtual bool setString(int val, bool editable = false); + virtual void incValue(int); + virtual void decValue(int); + + signals: + void valueChanged(int); + + public: + IntLabel(int, int, int, QWidget*, int _off = MAXINT, + const QString& = QString(""), int lpos = 0); + void setOff(int v); + void setSuffix(const QString& s) { suffix = s; } + void setSpecialValueText(const QString& s); + void setRange(int, int); + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/itransformbase.ui b/attic/muse2-oom/muse2/muse/widgets/itransformbase.ui new file mode 100644 index 00000000..51280e56 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/itransformbase.ui @@ -0,0 +1,1170 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MidiInputTransformDialogBase</class> + <widget class="QDialog" name="MidiInputTransformDialogBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>832</width> + <height>587</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Midi Input Transformator</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="1" colspan="3"> + <widget class="QGroupBox" name="GroupBox3"> + <property name="title"> + <string>Filter</string> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="1" column="0"> + <widget class="QComboBox" name="selEventOp"> + <item> + <property name="text"> + <string>All</string> + </property> + </item> + <item> + <property name="text"> + <string>Equal</string> + </property> + </item> + <item> + <property name="text"> + <string>Unequal</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0"> + <widget class="QComboBox" name="selType"> + <property name="enabled"> + <bool>false</bool> + </property> + <item> + <property name="text"> + <string>Note</string> + </property> + </item> + <item> + <property name="text"> + <string>Poly Pressure</string> + </property> + </item> + <item> + <property name="text"> + <string>Control Change</string> + </property> + </item> + <item> + <property name="text"> + <string>Aftertouch</string> + </property> + </item> + <item> + <property name="text"> + <string>Pitch Bend</string> + </property> + </item> + <item> + <property name="text"> + <string>NRPN</string> + </property> + </item> + <item> + <property name="text"> + <string>RPN</string> + </property> + </item> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="TextLabel3"> + <property name="text"> + <string>Value 2</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>Value 1</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> + <string>Event Type</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="selVal1Op"> + <item> + <property name="text"> + <string>Ignore</string> + </property> + </item> + <item> + <property name="text"> + <string>Equal</string> + </property> + </item> + <item> + <property name="text"> + <string>Unequal</string> + </property> + </item> + <item> + <property name="text"> + <string>Higher</string> + </property> + </item> + <item> + <property name="text"> + <string>Lower</string> + </property> + </item> + <item> + <property name="text"> + <string>Inside</string> + </property> + </item> + <item> + <property name="text"> + <string>Outside</string> + </property> + </item> + </widget> + </item> + <item row="3" column="1"> + <widget class="QSpinBox" name="selVal1b"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QSpinBox" name="selVal2b"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QSpinBox" name="selVal1a"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QComboBox" name="selVal2Op"> + <item> + <property name="text"> + <string>Ignore</string> + </property> + </item> + <item> + <property name="text"> + <string>Equal</string> + </property> + </item> + <item> + <property name="text"> + <string>Unequal</string> + </property> + </item> + <item> + <property name="text"> + <string>Higher</string> + </property> + </item> + <item> + <property name="text"> + <string>Lower</string> + </property> + </item> + <item> + <property name="text"> + <string>Inside</string> + </property> + </item> + <item> + <property name="text"> + <string>Outside</string> + </property> + </item> + </widget> + </item> + <item row="1" column="3"> + <widget class="QComboBox" name="selPortOp"> + <item> + <property name="text"> + <string>Ignore</string> + </property> + </item> + <item> + <property name="text"> + <string>Equal</string> + </property> + </item> + <item> + <property name="text"> + <string>Unequal</string> + </property> + </item> + <item> + <property name="text"> + <string>Higher</string> + </property> + </item> + <item> + <property name="text"> + <string>Lower</string> + </property> + </item> + <item> + <property name="text"> + <string>Inside</string> + </property> + </item> + <item> + <property name="text"> + <string>Outside</string> + </property> + </item> + </widget> + </item> + <item row="1" column="4"> + <widget class="QComboBox" name="selChannelOp"> + <item> + <property name="text"> + <string>Ignore</string> + </property> + </item> + <item> + <property name="text"> + <string>Equal</string> + </property> + </item> + <item> + <property name="text"> + <string>Unequal</string> + </property> + </item> + <item> + <property name="text"> + <string>Higher</string> + </property> + </item> + <item> + <property name="text"> + <string>Lower</string> + </property> + </item> + <item> + <property name="text"> + <string>Inside</string> + </property> + </item> + <item> + <property name="text"> + <string>Outside</string> + </property> + </item> + </widget> + </item> + <item row="0" column="4"> + <widget class="QLabel" name="TextLabel2_2"> + <property name="text"> + <string>Channel</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QLabel" name="TextLabel1_3"> + <property name="text"> + <string>Port</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QSpinBox" name="selVal2a"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="2" column="4"> + <widget class="QSpinBox" name="selChannelVala"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QSpinBox" name="selPortVala"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="3" column="4"> + <widget class="QSpinBox" name="selChannelValb"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QSpinBox" name="selPortValb"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="1" colspan="3"> + <widget class="QGroupBox" name="GroupBox5"> + <property name="title"> + <string>Processing</string> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel5"> + <property name="text"> + <string>Event Type</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QComboBox" name="procEventOp"> + <item> + <property name="text"> + <string>Keep</string> + </property> + </item> + <item> + <property name="text"> + <string>Fix</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0"> + <widget class="QComboBox" name="procType"> + <property name="enabled"> + <bool>false</bool> + </property> + <item> + <property name="text"> + <string>Poly Pressure</string> + </property> + </item> + <item> + <property name="text"> + <string>Control Change</string> + </property> + </item> + <item> + <property name="text"> + <string>Aftertouch</string> + </property> + </item> + <item> + <property name="text"> + <string>Pitch Bend</string> + </property> + </item> + <item> + <property name="text"> + <string>NRPN</string> + </property> + </item> + <item> + <property name="text"> + <string>RPN</string> + </property> + </item> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="procVal1Op"> + <item> + <property name="text"> + <string>Keep</string> + </property> + </item> + <item> + <property name="text"> + <string>Plus</string> + </property> + </item> + <item> + <property name="text"> + <string>Minus</string> + </property> + </item> + <item> + <property name="text"> + <string>Multiply</string> + </property> + </item> + <item> + <property name="text"> + <string>Divide</string> + </property> + </item> + <item> + <property name="text"> + <string>Fix</string> + </property> + </item> + <item> + <property name="text"> + <string>Value 2</string> + </property> + </item> + <item> + <property name="text"> + <string>Invert</string> + </property> + </item> + <item> + <property name="text"> + <string>ScaleMap</string> + </property> + </item> + <item> + <property name="text"> + <string>Flip</string> + </property> + </item> + <item> + <property name="text"> + <string>Dyn</string> + </property> + </item> + <item> + <property name="text"> + <string>Random</string> + </property> + </item> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="TextLabel6"> + <property name="text"> + <string>Value 1</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="TextLabel7"> + <property name="text"> + <string>Value 2</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QSpinBox" name="procVal1b"> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QSpinBox" name="procVal2b"> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="SpinBoxFP" name="procVal1a"> + <property name="maximum" stdset="0"> + <number>99999999</number> + </property> + </widget> + </item> + <item row="3" column="4"> + <widget class="QSpinBox" name="procChannelValb"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QSpinBox" name="procPortValb"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QLabel" name="TextLabel1_3_2"> + <property name="text"> + <string>Port</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QComboBox" name="procVal2Op"> + <item> + <property name="text"> + <string>Keep</string> + </property> + </item> + <item> + <property name="text"> + <string>Plus</string> + </property> + </item> + <item> + <property name="text"> + <string>Minus</string> + </property> + </item> + <item> + <property name="text"> + <string>Multiply</string> + </property> + </item> + <item> + <property name="text"> + <string>Divide</string> + </property> + </item> + <item> + <property name="text"> + <string>Fix</string> + </property> + </item> + <item> + <property name="text"> + <string>Value 1</string> + </property> + </item> + <item> + <property name="text"> + <string>Invert</string> + </property> + </item> + <item> + <property name="text"> + <string>Dyn</string> + </property> + </item> + <item> + <property name="text"> + <string>Random</string> + </property> + </item> + </widget> + </item> + <item row="1" column="4"> + <widget class="QComboBox" name="procChannelOp"> + <item> + <property name="text"> + <string>Keep</string> + </property> + </item> + <item> + <property name="text"> + <string>Plus</string> + </property> + </item> + <item> + <property name="text"> + <string>Minus</string> + </property> + </item> + <item> + <property name="text"> + <string>Multiply</string> + </property> + </item> + <item> + <property name="text"> + <string>Divide</string> + </property> + </item> + <item> + <property name="text"> + <string>Fix</string> + </property> + </item> + <item> + <property name="text"> + <string>Value 1</string> + </property> + </item> + <item> + <property name="text"> + <string>Invert</string> + </property> + </item> + <item> + <property name="text"> + <string>Dyn</string> + </property> + </item> + <item> + <property name="text"> + <string>Random</string> + </property> + </item> + </widget> + </item> + <item row="1" column="3"> + <widget class="QComboBox" name="procPortOp"> + <item> + <property name="text"> + <string>Keep</string> + </property> + </item> + <item> + <property name="text"> + <string>Plus</string> + </property> + </item> + <item> + <property name="text"> + <string>Minus</string> + </property> + </item> + <item> + <property name="text"> + <string>Multiply</string> + </property> + </item> + <item> + <property name="text"> + <string>Divide</string> + </property> + </item> + <item> + <property name="text"> + <string>Fix</string> + </property> + </item> + <item> + <property name="text"> + <string>Value 1</string> + </property> + </item> + <item> + <property name="text"> + <string>Invert</string> + </property> + </item> + <item> + <property name="text"> + <string>Dyn</string> + </property> + </item> + <item> + <property name="text"> + <string>Random</string> + </property> + </item> + </widget> + </item> + <item row="0" column="4"> + <widget class="QLabel" name="TextLabel2_2_2"> + <property name="text"> + <string>Channel</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="SpinBoxFP" name="procVal2a"> + <property name="maximum" stdset="0"> + <number>99999999</number> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="SpinBoxFP" name="procPortVala"> + <property name="maximum" stdset="0"> + <number>99999999</number> + </property> + </widget> + </item> + <item row="2" column="4"> + <widget class="SpinBoxFP" name="procChannelVala"> + <property name="maximum" stdset="0"> + <number>99999999</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="2"> + <widget class="QGroupBox" name="GroupBox5_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Modules</string> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="0" rowspan="4"> + <widget class="QGroupBox" name="modulBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string/> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <property name="lineWidth" stdset="0"> + <number>0</number> + </property> + <property name="exclusive" stdset="0"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout"> + <item> + <widget class="QToolButton" name="modul1select"> + <property name="text"> + <string>1</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="modul2select"> + <property name="text"> + <string>2</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="modul3select"> + <property name="text"> + <string>3</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="modul4select"> + <property name="text"> + <string>4</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="1"> + <widget class="QCheckBox" name="modul1enable"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>enable modul 1</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="modul2enable"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>enable modul 2</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="modul3enable"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>enable modul 3</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QCheckBox" name="modul4enable"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>enable modul 4</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="1"> + <widget class="QGroupBox" name="GroupBox6_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Preset</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="TextLabel13_2"> + <property name="text"> + <string>Name:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="nameEntry"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="TextLabel14_2"> + <property name="text"> + <string>Comment:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QTextEdit" name="commentEntry"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="3"> + <widget class="QGroupBox" name="GroupBox7_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Function</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QComboBox" name="funcOp"/> + </item> + </layout> + </widget> + </item> + <item row="3" column="0" colspan="4"> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QPushButton" name="buttonNew"> + <property name="toolTip"> + <string>create new preset</string> + </property> + <property name="text"> + <string>&New</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonDelete"> + <property name="toolTip"> + <string>delete preset</string> + </property> + <property name="text"> + <string>&Delete</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="Horizontal Spacing2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonOk"> + <property name="text"> + <string>&Dismiss</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="0" rowspan="3"> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="TextLabel1_2"> + <property name="text"> + <string>PresetList</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QListWidget" name="presetList"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <customwidgets> + <customwidget> + <class>SpinBoxFP</class> + <extends>QDoubleSpinBox</extends> + <header>spinboxFP.h</header> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>selEventOp</tabstop> + <tabstop>selType</tabstop> + <tabstop>selVal1Op</tabstop> + <tabstop>selVal1a</tabstop> + <tabstop>selVal1b</tabstop> + <tabstop>selVal2Op</tabstop> + <tabstop>selVal2a</tabstop> + <tabstop>selVal2b</tabstop> + <tabstop>selPortOp</tabstop> + <tabstop>selPortVala</tabstop> + <tabstop>selPortValb</tabstop> + <tabstop>selChannelOp</tabstop> + <tabstop>selChannelVala</tabstop> + <tabstop>selChannelValb</tabstop> + <tabstop>procEventOp</tabstop> + <tabstop>procType</tabstop> + <tabstop>procVal1Op</tabstop> + <tabstop>procVal1b</tabstop> + <tabstop>procVal2Op</tabstop> + <tabstop>procVal2b</tabstop> + <tabstop>procPortOp</tabstop> + <tabstop>procPortValb</tabstop> + <tabstop>procChannelOp</tabstop> + <tabstop>procChannelValb</tabstop> + <tabstop>modul1enable</tabstop> + <tabstop>modul2enable</tabstop> + <tabstop>modul3enable</tabstop> + <tabstop>modul4enable</tabstop> + <tabstop>funcOp</tabstop> + <tabstop>nameEntry</tabstop> + <tabstop>commentEntry</tabstop> + <tabstop>presetList</tabstop> + <tabstop>buttonNew</tabstop> + <tabstop>buttonDelete</tabstop> + <tabstop>buttonOk</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>MidiInputTransformDialogBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/knob.cpp b/attic/muse2-oom/muse2/muse/widgets/knob.cpp new file mode 100644 index 00000000..950888a3 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/knob.cpp @@ -0,0 +1,540 @@ +//====================================================================== +// MusE +// Linux Music Editor +// $Id: knob.cpp,v 1.3.2.3 2009/03/09 02:05:18 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +// +// Adapted from Qwt Lib: +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// This program 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 this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//========================================================= + +#include <stdio.h> +#include "knob.h" +#include <cmath> +#include "mmath.h" + +#include <QPainter> +#include <QPalette> +#include <QPaintEvent> +#include <QResizeEvent> + +//--------------------------------------------------------- +// The QwtKnob widget imitates look and behaviour of a volume knob on a radio. +// It contains +// a scale around the knob which is set up automatically or can +// be configured manually (see @^QwtScaleIf@). +// Automatic scrolling is enabled when the user presses a mouse +// button on the scale. For a description of signals, slots and other +// members, see QwtSliderBase@. +//--------------------------------------------------------- + + +//--------------------------------------------------------- +// Knob +//--------------------------------------------------------- + +Knob::Knob(QWidget* parent, const char* name) + : SliderBase(parent, name) + { + hasScale = false; + + d_borderWidth = 2; + d_borderDist = 4; + d_totalAngle = 270.0; + d_scaleDist = 1; + d_symbol = Line; + d_maxScaleTicks = 11; + d_knobWidth = 30; + _faceColSel = FALSE; + d_faceColor = palette().color(QPalette::Window); + d_curFaceColor = d_faceColor; + d_altFaceColor = d_faceColor; + d_markerColor = palette().color(QPalette::WindowText); + d_dotWidth = 8; + + setMinimumSize(30,30); + setUpdateTime(50); + } + +//------------------------------------------------------------ +// QwtKnob::setTotalAngle +// Set the total angle by which the knob can be turned +// +// Syntax +// void QwtKnob::setTotalAngle(double angle) +// +// Parameters +// double angle -- angle in degrees. +// +// Description +// The default angle is 270 degrees. It is possible to specify +// an angle of more than 360 degrees so that the knob can be +// turned several times around its axis. +//------------------------------------------------------------ + +void Knob::setTotalAngle (double angle) + { + if (angle < 10.0) + d_totalAngle = 10.0; + else + d_totalAngle = angle; + d_scale.setAngleRange( -0.5 * d_totalAngle, 0.5 * d_totalAngle); + } + +//------------------------------------------------------------ +// QwtKnob::drawKnob +// const QRect &r -- borders of the knob +//------------------------------------------------------------ + +void Knob::drawKnob(QPainter* p, const QRect& r) + { + QRect aRect; + + const QPalette& pal = palette(); + QPen pn; + int bw2 = d_borderWidth / 2; + + aRect.setRect(r.x() + bw2, + r.y() + bw2, + r.width() - 2*bw2, + r.height() - 2*bw2); + + // + // draw button face + // + // p->setPen(Qt::NoPen); + // p->setBrush(d_curFaceColor); + // p->drawEllipse(aRect); + + // + // draw button shades + // + // pn.setWidth(d_borderWidth); + + + // pn.setColor(pal.color(QPalette::Light)); + // p->setPen(pn); + // p->drawArc(aRect, 45*16,180*16); + + // pn.setColor(pal.color(QPalette::Dark)); + // p->setPen(pn); + // p->drawArc(aRect, 225*16,180*16); + QPixmap dial; + bool loaded; + if(!knobImage.isEmpty()) + { + loaded = dial.load(knobImage); + } + else + { + loaded = dial.load(":images/knob.png"); + } + if(loaded) + p->drawPixmap(aRect, dial); + + //printf("\n\n\nButton size is X:%d : Y:%d : W:%d : H:%d \n\n\n\n",aRect.x(), aRect.y(), aRect.width(), aRect.height()); + + // + // draw marker + // + //drawMarker(p, d_angle, isEnabled() ? d_markerColor : Qt::gray); + drawMarker(p, d_angle, pal.currentColorGroup() == QPalette::Disabled ? + pal.color(QPalette::Disabled, QPalette::WindowText) : d_markerColor); + } + +//------------------------------------------------------------ +//.F QwtSliderBase::valueChange +// Notify change of value +// +//.u Parameters +// double x -- new value +// +//.u Description +// Sets the slider's value to the nearest multiple +// of the step size. +//------------------------------------------------------------ + +void Knob::valueChange() + { + recalcAngle(); + d_newVal++; + repaint(kRect); + SliderBase::valueChange(); + } + +//------------------------------------------------------------ +//.F QwtKnob::getValue +// Determine the value corresponding to a specified position +// +//.u Parameters: +// const QPoint &p -- point +// +//.u Description: +// Called by QwtSliderBase +//------------------------------------------------------------ + +double Knob::getValue(const QPoint &p) + { + double newValue; + double oneTurn; + double eqValue; + double arc; + + const QRect& r = rect(); + + double dx = double((r.x() + r.width() / 2) - p.x() ); + double dy = double((r.y() + r.height() / 2) - p.y() ); + + arc = atan2(-dx,dy) * 180.0 / M_PI; + + newValue = 0.5 * (minValue() + maxValue()) + + (arc + d_nTurns * 360.0) * (maxValue() - minValue()) + / d_totalAngle; + + oneTurn = fabs(maxValue() - minValue()) * 360.0 / d_totalAngle; + eqValue = value() + d_mouseOffset; + + if (fabs(newValue - eqValue) > 0.5 * oneTurn) + { + if (newValue < eqValue) + newValue += oneTurn; + else + newValue -= oneTurn; + } + + return newValue; + +} + + + +//------------------------------------------------------------ +//.- +//.F QwtKnob::setScrollMode +// Determine the scrolling mode and direction +// corresponding to a specified position +// +//.u Parameters +// const QPoint &p -- point in question +// +//.u Description +// Called by QwtSliderBase +//------------------------------------------------------------ +void Knob::getScrollMode( QPoint &p, const Qt::MouseButton &/*button*/, int &scrollMode, int &direction)// prevent compiler warning : unsused parameter +{ + int dx, dy, r; + double arc; + + /*Qt::ButtonState but= button ;*/ // prevent compiler warning : unsused variable + r = kRect.width() / 2; + + dx = kRect.x() + r - p.x(); + dy = kRect.y() + r - p.y(); + + if ( (dx * dx) + (dy * dy) <= (r * r)) // point is inside the knob + { + scrollMode = ScrMouse; + direction = 0; + } + else // point lies outside + { + scrollMode = ScrTimer; + arc = atan2(double(-dx),double(dy)) * 180.0 / M_PI; + if ( arc < d_angle) + direction = -1; + else if (arc > d_angle) + direction = 1; + else + direction = 0; + } + return; +} + + + +//------------------------------------------------------------ +//.F QwtKnob::rangeChange +// Notify a change of the range +// +//.u Description +// Called by QwtSliderBase +//------------------------------------------------------------ + +void Knob::rangeChange() +{ + if (!hasUserScale()) + { + d_scale.setScale(minValue(), maxValue(), + d_maxMajor, d_maxMinor); + } + recalcAngle(); + resize(size()); + repaint(); +} + +//--------------------------------------------------------- +// resizeEvent +//--------------------------------------------------------- + +void Knob::resizeEvent(QResizeEvent *) + { + int width, width_2; + + const QRect& r = rect(); + +// printf("resize %d %d %d\n", r.height(), r.width(), d_knobWidth); + +// width = qwtMin(qwtMin(r.height(), r.width()), d_knobWidth); + width = qwtMin(r.height(), r.width()); + width_2 = width / 2; + + int x = r.x() + r.width() / 2 - width_2; + int y = r.y() + r.height() / 2 - width_2; + + kRect.setRect(x, y, width, width); + + x = kRect.x() - d_scaleDist; + y = kRect.y() - d_scaleDist; + int w = width + 2 * d_scaleDist; + + d_scale.setGeometry(x, y, w, ScaleDraw::Round); + } + +//------------------------------------------------------------ +// paintEvent +//------------------------------------------------------------ + +void Knob::paintEvent(QPaintEvent*) + { +/* QPainter p(this); + const QRect &r = e->rect(); + + if ((r == kRect) && d_newVal ) { // event from valueChange() + if (d_newVal > 1) // lost paintEvents()? + drawKnob(&p, kRect); + else { + drawMarker(&p, d_oldAngle, d_curFaceColor); + drawMarker(&p, d_angle, d_markerColor); + } + } + else { + p.eraseRect(rect()); + if (hasScale) + d_scale.draw(&p); + drawKnob(&p, kRect); + } + d_newVal = 0; +*/ + + QPainter p(this); + p.setRenderHint(QPainter::Antialiasing, true); + if(hasScale) + d_scale.draw(&p); + drawKnob(&p, kRect); + //drawMarker(&p, d_oldAngle, d_curFaceColor); + //drawMarker(&p, d_angle, d_markerColor); + + d_newVal = 0; + } + +//------------------------------------------------------------ +//.- +//.F QwtKnob::drawMarker +// Draw the marker at the knob's front +// +//.u Parameters +//.p QPainter *p -- painter +// double arc -- angle of the marker +// const QColor &c -- marker color +// +//.u Syntax +// void QwtKnob::drawMarker(QPainter *p) +// +//------------------------------------------------------------ +void Knob::drawMarker(QPainter *p, double arc, const QColor &c) +{ + + QPen pn; + int radius; + double rb,re; + double rarc; + + rarc = arc * M_PI / 180.0; + double ca = cos(rarc); + double sa = - sin(rarc); + radius = kRect.width() / 2 - d_borderWidth; + if (radius < 3) radius = 3; + int ym = kRect.y() + radius + d_borderWidth; + int xm = kRect.x() + radius + d_borderWidth; + + switch (d_symbol) + { + case Dot: + + p->setBrush(c); + p->setPen(Qt::NoPen); + rb = double(qwtMax(radius - 4 - d_dotWidth / 2, 0)); + p->drawEllipse(xm - int(rint(sa * rb)) - d_dotWidth / 2, + ym - int(rint(ca * rb)) - d_dotWidth / 2, + d_dotWidth, d_dotWidth); + + break; + + case Line: + + pn.setColor(c); + pn.setWidth(2); + p->setPen(pn); + + rb = qwtMax(double((radius - 4) / 3.0), 0.0); + re = qwtMax(double(radius - 4), 0.0); + + p->drawLine( xm - int(rint(sa * rb)), + ym - int(rint(ca * rb)), + xm - int(rint(sa * re)), + ym - int(rint(ca * re))); + + break; + } + + +} + +//------------------------------------------------------------ +// +//.F QwtKnob::setKnobWidth +// Change the knob's width. +// +//.u Syntax +//.f void QwtKnob::setKnobWidth(int w) +// +//.u Parameters +//.p int w -- new width +// +//.u Description +// The specified width must be >= 5, or it will be clipped. +// +//------------------------------------------------------------ +void Knob::setKnobWidth(int w) +{ + d_knobWidth = qwtMax(w,5); + resize(size()); + repaint(); +} + +//------------------------------------------------------------ +// +//.F QwtKnob::setBorderWidth +// Set the knob's border width +// +//.u Syntax +//.f void QwtKnob::setBorderWidth(int bw) +// +//.u Parameters +//.p int bw -- new border width +// +//------------------------------------------------------------ +void Knob::setBorderWidth(int bw) +{ + d_borderWidth = qwtMax(bw, 0); + resize(size()); + repaint(); +} + +//------------------------------------------------------------ +//.- +//.F QwtKnob::recalcAngle +// Recalculate the marker angle corresponding to the +// current value +// +//.u Syntax +//.f void QwtKnob::recalcAngle() +// +//------------------------------------------------------------ +void Knob::recalcAngle() +{ + d_oldAngle = d_angle; + + // + // calculate the angle corresponding to the value + // + if (maxValue() == minValue()) + { + d_angle = 0; + d_nTurns = 0; + } + else + { + d_angle = (value() - 0.5 * (minValue() + maxValue())) + / (maxValue() - minValue()) * d_totalAngle; + d_nTurns = floor((d_angle + 180.0) / 360.0); + d_angle = d_angle - d_nTurns * 360.0; + + } + +} + +//------------------------------------------------------------ +// setFaceColor +//------------------------------------------------------------ +void Knob::setFaceColor(const QColor c) +{ + d_faceColor = c; + if(!_faceColSel) + //update(FALSE); + repaint(); +} + +//------------------------------------------------------------ +// setAltFaceColor +//------------------------------------------------------------ +void Knob::setAltFaceColor(const QColor c) +{ + d_altFaceColor = c; + if(_faceColSel) + //update(FALSE); + repaint(); +} + +//------------------------------------------------------------ +// selectFaceColor +//------------------------------------------------------------ +void Knob::selectFaceColor(bool alt) +{ + _faceColSel = alt; + if(alt) + d_curFaceColor = d_altFaceColor; + else + d_curFaceColor = d_faceColor; + //update(FALSE); + repaint(); +} + +//------------------------------------------------------------ +// setKnobImage +//------------------------------------------------------------ +void Knob::setKnobImage(const QString img) +{ + knobImage = img; +} + +//------------------------------------------------------------ +// setMarkerColor +//------------------------------------------------------------ +void Knob::setMarkerColor(const QColor c) +{ + d_markerColor = c; + //update(FALSE); + repaint(); +} + diff --git a/attic/muse2-oom/muse2/muse/widgets/knob.h b/attic/muse2-oom/muse2/muse/widgets/knob.h new file mode 100644 index 00000000..ce43f2ad --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/knob.h @@ -0,0 +1,79 @@ +#ifndef QWT_KNOB_H +#define QWT_KNOB_H + +#include "sliderbase.h" +#include "sclif.h" +#include <QColor> +#include <QResizeEvent> +#include <QPaintEvent> + + +//--------------------------------------------------------- +// Knob +//--------------------------------------------------------- + +class Knob : public SliderBase, public ScaleIf + { + Q_OBJECT + + public: + enum Symbol { Line, Dot }; + + private: + bool hasScale; + + int d_borderWidth; + int d_borderDist; + int d_scaleDist; + int d_maxScaleTicks; + int d_newVal; + int d_knobWidth; + int d_dotWidth; + + Symbol d_symbol; + double d_angle; + double d_oldAngle; + double d_totalAngle; + double d_nTurns; + + QRect kRect; + bool _faceColSel; + QColor d_faceColor; + QColor d_curFaceColor; + QColor d_altFaceColor; + QColor d_markerColor; + QString knobImage; + + void recalcAngle(); + void valueChange(); + void rangeChange(); + void drawKnob(QPainter *p, const QRect &r); + void drawMarker(QPainter *p, double arc, const QColor &c); + + void paintEvent(QPaintEvent *); + void resizeEvent(QResizeEvent *e); + double getValue(const QPoint &p); + void getScrollMode( QPoint &p, const Qt::MouseButton &button, int &scrollMode, int &direction ); + void scaleChange() { repaint(); } + void fontChange(const QFont &) { repaint(); } + + public: + Knob(QWidget* parent = 0, const char *name = 0); + ~Knob() {} + + void setKnobWidth(int w); + void setTotalAngle (double angle); + void setBorderWidth(int bw); + void selectFaceColor(bool alt); + bool selectedFaceColor() { return _faceColSel; } + QColor faceColor() { return d_faceColor; } + void setFaceColor(const QColor c); + QColor altFaceColor() { return d_altFaceColor; } + void setAltFaceColor(const QColor c); + QColor markerColor() { return d_markerColor; } + void setMarkerColor(const QColor c); + void setKnobImage(const QString img); + }; + + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/lcombo.cpp b/attic/muse2-oom/muse2/muse/widgets/lcombo.cpp new file mode 100644 index 00000000..e4bdf00c --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/lcombo.cpp @@ -0,0 +1,51 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: lcombo.cpp,v 1.1.1.1.2.3 2009/07/01 22:14:56 spamatica Exp $ +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include "lcombo.h" + +#include <QHBoxLayout> +#include <QLabel> + + +//--------------------------------------------------------- +// LabelCombo +//--------------------------------------------------------- + +LabelCombo::LabelCombo(const QString& txt, QWidget* parent, + const char* name) : QWidget(parent) + { + setObjectName(name); +// setFixedHeight(20); + QHBoxLayout* layout = new QHBoxLayout(this); + QLabel* label = new QLabel(txt, this); + //box = new QComboBox(false, this); + box = new QComboBox(this); + box->setEditable(false); + ///layout->addStretch(); + layout->addSpacing(5); + layout->addWidget(label); + layout->addSpacing(5); + layout->addWidget(box); + layout->addSpacing(5); + ///layout->addStretch(); + connect(box, SIGNAL(activated(int)), SIGNAL(activated(int))); + } + +void LabelCombo::setCurrentIndex(int i) +{ + int rc = box->model()->rowCount(); + if(rc == 0) + return; + int r = i % rc; + int c = i / rc; + if(c >= box->model()->columnCount()) + return; + if(box->modelColumn() != c) + box->setModelColumn(c); + if(box->currentIndex() != r) + box->setCurrentIndex(r); +} diff --git a/attic/muse2-oom/muse2/muse/widgets/lcombo.h b/attic/muse2-oom/muse2/muse/widgets/lcombo.h new file mode 100644 index 00000000..b125fce5 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/lcombo.h @@ -0,0 +1,43 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: lcombo.h,v 1.1.1.1.2.3 2009/07/01 22:14:56 spamatica Exp $ +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __LCOMBO_H__ +#define __LCOMBO_H__ + +#include <QAbstractItemView> +#include <QComboBox> +#include <QVariant> + +class QString; + + +//--------------------------------------------------------- +// LabelCombo +//--------------------------------------------------------- + +class LabelCombo : public QWidget { + QComboBox* box; + Q_OBJECT + + signals: + void activated(int); + + public slots: + void clearFocus() { box->clearFocus(); } + void setCurrentIndex(int i); + + public: + LabelCombo(const QString& label, QWidget* parent, + const char* name=0); + void addItem(const QString& txt, const QVariant & userData = QVariant()) { box->addItem(txt, userData); } + void insertItem(int index, const QString& txt, const QVariant & userData = QVariant()) { box->insertItem(index, txt, userData); } + //void setListBox(Q3ListBox* lb) { box->setListBox(lb); } // ddskrjo + void setView(QAbstractItemView* v) { box->setModel(v->model()); box->setView(v); } // p4.0.3 + void setFocusPolicy ( Qt::FocusPolicy fp ) { box->setFocusPolicy(fp); } + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/menutitleitem.h b/attic/muse2-oom/muse2/muse/widgets/menutitleitem.h new file mode 100644 index 00000000..016d4663 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/menutitleitem.h @@ -0,0 +1,25 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: menutitleitem.h,v 1.1.2.1 2009/06/10 00:34:59 terminator356 Exp $ +// (C) Copyright 1999-2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __MENU_TITLE_ITEM_H__ +#define __MENU_TITLE_ITEM_H__ + +#include <QWidgetAction> + +//--------------------------------------------------------- +// MenuTitleItem +//--------------------------------------------------------- + +class MenuTitleItem : public QWidgetAction { + QString s; + + public: + MenuTitleItem(const QString&, QWidget* /*parent*/); + QWidget* createWidget(QWidget* /*parent*/); + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/metronome.cpp b/attic/muse2-oom/muse2/muse/widgets/metronome.cpp new file mode 100644 index 00000000..08c8abac --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/metronome.cpp @@ -0,0 +1,183 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: metronome.cpp,v 1.2.2.1 2009/12/20 05:00:35 terminator356 Exp $ +// +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> +#include "metronome.h" + +#include <QMenu> +#include "globals.h" +#include "song.h" +#include "track.h" +#include "audio.h" + +//--------------------------------------------------------- +// MetronomeConfig +//--------------------------------------------------------- + +MetronomeConfig::MetronomeConfig(QDialog* parent) + : QDialog(parent) + { + setupUi(this); + connect(buttonApply, SIGNAL(clicked()), SLOT(apply())); + connect(midiClick, SIGNAL(toggled(bool)), SLOT(midiClickChanged(bool))); + connect(precountEnable, SIGNAL(toggled(bool)), SLOT(precountEnableChanged(bool))); + connect(precountFromMastertrack, SIGNAL(toggled(bool)), + SLOT(precountFromMastertrackChanged(bool))); + connect(audioBeepRoutesButton, SIGNAL(clicked()), SLOT(audioBeepRoutesClicked())); + connect(volumeSlider, SIGNAL(valueChanged(int)), SLOT(beepVolumeChanged(int))); + + measureNote->setValue(measureClickNote); + measureVelocity->setValue(measureClickVelo); + beatNote->setValue(beatClickNote); + beatVelocity->setValue(beatClickVelo); + midiChannel->setValue(clickChan+1); + midiPort->setValue(clickPort+1); + + /* + precountBars->setValue(preMeasures); + precountEnable->setChecked(precountEnableFlag); + precountFromMastertrack->setChecked(precountFromMastertrackFlag); + precountSigZ->setValue(::precountSigZ); + precountSigN->setValue(::precountSigN); + precountPrerecord->setChecked(::precountPrerecord); + precountPreroll->setChecked(::precountPreroll); + */ + + midiClick->setChecked(midiClickFlag); + audioBeep->setChecked(audioClickFlag); + } + +//--------------------------------------------------------- +// audioBeepRoutesClicked +//--------------------------------------------------------- + +void MetronomeConfig::audioBeepRoutesClicked() +{ + if(song->outputs()->size() == 0) + return; + + QMenu* pup = new QMenu; + + OutputList* ol = song->outputs(); + + int nn = 0; + for(iAudioOutput iao = ol->begin(); iao != ol->end(); ++iao) + { + QAction* action = pup->addAction(QT_TRANSLATE_NOOP("@default", (*iao)->name())); + action->setCheckable(true); + action->setData(nn); + if((*iao)->sendMetronome()) + action->setChecked(true); + ++nn; + } + + QAction* clickaction = pup->exec(QCursor::pos()); + if (clickaction) + { + //QString s(pup->text(n)); + nn = 0; + for(iAudioOutput iao = ol->begin(); iao != ol->end(); ++iao) + { + //if(((*iao)->name() == s) && (n == nn)) + if (nn == clickaction->data()) + { + //(*iao)->setSendMetronome(); + audio->msgSetSendMetronome(*iao, clickaction->isChecked()); + //song->update(SC_ROUTE); + break; + } + ++nn; + } + } + + delete pup; + audioBeepRoutesButton->setDown(false); // pup->exec() catches mouse release event +} + +//--------------------------------------------------------- +// accept +//--------------------------------------------------------- + +void MetronomeConfig::accept() + { + apply(); + QDialog::accept(); + } + +//--------------------------------------------------------- +// apply +//--------------------------------------------------------- + +void MetronomeConfig::apply() + { + measureClickNote = measureNote->value(); + measureClickVelo = measureVelocity->value(); + beatClickNote = beatNote->value(); + beatClickVelo = beatVelocity->value(); + clickChan = midiChannel->value() - 1; + clickPort = midiPort->value() - 1; + preMeasures = precountBars->value(); + /* + precountEnableFlag = precountEnable->isChecked(); + precountFromMastertrackFlag = precountFromMastertrack->isChecked(); + ::precountSigZ = precountSigZ->value(); + ::precountSigN = precountSigN->value(); + ::precountPrerecord = precountPrerecord->isChecked(); + ::precountPreroll = precountPreroll->isChecked(); + */ + midiClickFlag = midiClick->isChecked(); + audioClickFlag = audioBeep->isChecked(); + //audioVolumeChanged = volumeSlider->value(); + } + +//--------------------------------------------------------- +// reject +//--------------------------------------------------------- + +void MetronomeConfig::reject() + { + QDialog::reject(); + } + +//--------------------------------------------------------- +// midiClickChanged +//--------------------------------------------------------- + +void MetronomeConfig::midiClickChanged(bool flag) + { + measureNote->setEnabled(flag); + measureVelocity->setEnabled(flag); + beatNote->setEnabled(flag); + beatVelocity->setEnabled(flag); + midiChannel->setEnabled(flag); + midiPort->setEnabled(flag); + } + +void MetronomeConfig::precountEnableChanged(bool /*flag*/) + { + /* + precountBars->setEnabled(flag); + precountFromMastertrack->setEnabled(flag); + precountSigZ->setEnabled(flag && !precountFromMastertrack->isChecked()); + precountSigN->setEnabled(flag && !precountFromMastertrack->isChecked()); + */ + } + +void MetronomeConfig::precountFromMastertrackChanged(bool /*flag*/) + { + /* + precountSigZ->setEnabled(!flag); + precountSigN->setEnabled(!flag); + */ + } + +void MetronomeConfig::beepVolumeChanged(int volume) + { + // this value is directly applied, not using th Apply button, it just seems more usable this way. + audioClickVolume=volume/100.0; + } diff --git a/attic/muse2-oom/muse2/muse/widgets/metronome.h b/attic/muse2-oom/muse2/muse/widgets/metronome.h new file mode 100644 index 00000000..976dfcd0 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/metronome.h @@ -0,0 +1,36 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: metronome.h,v 1.1.1.1.2.1 2009/12/20 05:00:35 terminator356 Exp $ +// +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __METRONOME_H__ +#define __METRONOME_H__ + +#include "ui_metronomebase.h" + +class QDialog; + +//--------------------------------------------------------- +// MetronomeConfig +//--------------------------------------------------------- + +class MetronomeConfig : public QDialog, public Ui::MetronomeConfigBase { + Q_OBJECT + + private slots: + virtual void accept(); + void apply(); + virtual void reject(); + virtual void audioBeepRoutesClicked(); + void midiClickChanged(bool); + void precountEnableChanged(bool); + void precountFromMastertrackChanged(bool); + void beepVolumeChanged(int); + + public: + MetronomeConfig(QDialog* parent=0); + }; +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/metronomebase.ui b/attic/muse2-oom/muse2/muse/widgets/metronomebase.ui new file mode 100644 index 00000000..18a2d2f6 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/metronomebase.ui @@ -0,0 +1,568 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MetronomeConfigBase</class> + <widget class="QDialog" name="MetronomeConfigBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>557</width> + <height>363</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Metronome Config</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="0"> + <layout class="QGridLayout"> + <item row="0" column="0"> + <widget class="QGroupBox" name="GroupBox1"> + <property name="title"> + <string>Metronome</string> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="0"> + <layout class="QVBoxLayout"> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QCheckBox" name="audioBeep"> + <property name="text"> + <string>Audio Beep</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="audioBeepRoutesButton"> + <property name="text"> + <string>Choose outputs...</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QSlider" name="volumeSlider"> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>100</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + <property name="pageStep"> + <number>10</number> + </property> + <property name="value"> + <number>50</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="volumeLabel"> + <property name="text"> + <string>50</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="textLabel1"> + <property name="text"> + <string>% Audio volume</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QCheckBox" name="midiClick"> + <property name="text"> + <string>MIDI Click</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <layout class="QGridLayout"> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="4" column="1"> + <widget class="QLabel" name="TextLabel5"> + <property name="text"> + <string>Midi Channel</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> + <string>Measure Note</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QSpinBox" name="midiChannel"> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>16</number> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>Measure Velocity</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="TextLabel4"> + <property name="text"> + <string>Beat Velocity</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QSpinBox" name="midiPort"> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>16</number> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="TextLabel3"> + <property name="text"> + <string>Beat Note</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QSpinBox" name="beatNote"/> + </item> + <item row="1" column="0"> + <widget class="QSpinBox" name="measureVelocity"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QSpinBox" name="measureNote"/> + </item> + <item row="5" column="1"> + <widget class="QLabel" name="TextLabel6"> + <property name="text"> + <string>Midi Port</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QSpinBox" name="beatVelocity"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="Spacer10"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item row="0" column="1"> + <widget class="QGroupBox" name="GroupBox2"> + <property name="title"> + <string>Precount</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QCheckBox" name="precountEnable"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>enable</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="precountBars"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>10</number> + </property> + <property name="value"> + <number>2</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel7"> + <property name="text"> + <string>Bars</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QCheckBox" name="precountFromMastertrack"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>From Mastertrack</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="precountSigZ"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>32</number> + </property> + <property name="value"> + <number>4</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel8"> + <property name="text"> + <string>/</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="precountSigN"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="minimum"> + <number>2</number> + </property> + <property name="maximum"> + <number>64</number> + </property> + <property name="value"> + <number>4</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel9"> + <property name="text"> + <string>Signature</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QCheckBox" name="precountPrerecord"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Prerecord</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="precountPreroll"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Preroll</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <layout class="QHBoxLayout"> + <item> + <widget class="QLabel" name="textLabel3"> + <property name="text"> + <string>Hint: Enable metronome in Transportpanel</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <spacer name="Horizontal Spacing2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>8</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonApply"> + <property name="text"> + <string>&Apply</string> + </property> + <property name="shortcut"> + <string>Alt+A</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonOk"> + <property name="text"> + <string>&OK</string> + </property> + <property name="shortcut"> + <string>Alt+O</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonCancel"> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="shortcut"> + <string>Alt+C</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <tabstops> + <tabstop>audioBeep</tabstop> + <tabstop>audioBeepRoutesButton</tabstop> + <tabstop>midiClick</tabstop> + <tabstop>measureNote</tabstop> + <tabstop>measureVelocity</tabstop> + <tabstop>beatNote</tabstop> + <tabstop>beatVelocity</tabstop> + <tabstop>midiChannel</tabstop> + <tabstop>midiPort</tabstop> + <tabstop>precountEnable</tabstop> + <tabstop>precountBars</tabstop> + <tabstop>precountFromMastertrack</tabstop> + <tabstop>precountSigZ</tabstop> + <tabstop>precountPrerecord</tabstop> + <tabstop>precountPreroll</tabstop> + <tabstop>precountSigN</tabstop> + <tabstop>buttonApply</tabstop> + <tabstop>buttonOk</tabstop> + <tabstop>buttonCancel</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>MetronomeConfigBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>MetronomeConfigBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>volumeSlider</sender> + <signal>valueChanged(int)</signal> + <receiver>volumeLabel</receiver> + <slot>setNum(int)</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/midisync.ui b/attic/muse2-oom/muse2/muse/widgets/midisync.ui new file mode 100644 index 00000000..8fc6248a --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/midisync.ui @@ -0,0 +1,409 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <author>werner schweer</author> + <comment>midi sync +configuration dialog</comment> + <class>MidiSyncConfigBase</class> + <widget class="QDialog" name="MidiSyncConfigBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>655</width> + <height>419</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Midi Sync</string> + </property> + <layout class="QGridLayout"> + <item row="2" column="0"> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <spacer name="Spacer1_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="applyButton"> + <property name="text"> + <string>Apply</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="okButton"> + <property name="text"> + <string>Ok</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton"> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="GroupBox13"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="title"> + <string>MTC</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QLabel" name="textLabel2"> + <property name="text"> + <string>Type:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="mtcSyncType"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <item> + <property name="text"> + <string>24</string> + </property> + </item> + <item> + <property name="text"> + <string>25</string> + </property> + </item> + <item> + <property name="text"> + <string>30D</string> + </property> + </item> + <item> + <property name="text"> + <string>30N</string> + </property> + </item> + </widget> + </item> + <item> + <spacer name="spacer4"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QLabel" name="textLabel1"> + <property name="text"> + <string>Offset:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="mtcOffH"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>hour</string> + </property> + <property name="maximum"> + <number>23</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>h</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="mtcOffM"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>minute</string> + </property> + <property name="maximum"> + <number>59</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel3"> + <property name="text"> + <string>m</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="mtcOffS"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>second</string> + </property> + <property name="maximum"> + <number>59</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel4"> + <property name="text"> + <string>s</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="mtcOffF"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>frame</string> + </property> + <property name="maximum"> + <number>30</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel5"> + <property name="text"> + <string>f</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="mtcOffSf"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>subframe</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item row="0" column="0"> + <widget class="QGroupBox" name="syncGen"> + <property name="title"> + <string>Sync receiving and sending</string> + </property> + <layout class="QGridLayout"> + <item row="0" column="0" colspan="2"> + <widget class="QCheckBox" name="useJackTransportCheckbox"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="toolTip"> + <string>Send and receive Jack transport</string> + </property> + <property name="whatsThis"> + <string>Send and receive Jack transport information, + including stop, start and position.</string> + </property> + <property name="text"> + <string>Use Jack transport</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QCheckBox" name="jackTransportMasterCheckbox"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="toolTip"> + <string>Make MusE the Jack transport Timebase Master</string> + </property> + <property name="whatsThis"> + <string>Make MusE the Jack transport Timebase Master. +Allows Jack to show time as + MusE Bars, Beats, and Ticks. +MusE will try to become master, but other + Jack clients can also take over later. +You can always click here again for Master.</string> + </property> + <property name="text"> + <string>Jack transport Timebase Master</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QCheckBox" name="extSyncCheckbox"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="toolTip"> + <string>Control MusE timing by external midi clock or MTC sync</string> + </property> + <property name="whatsThis"> + <string>When in slave mode, tempo is + controlled externally. +MusE can sync to midi clock, or MTC quarter frame sync. +Enabled inputs in the list will + be in effect (RMC, RMMC, RMTC).</string> + </property> + <property name="text"> + <string>Slave to external sync</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="0"> + <layout class="QHBoxLayout"> + <item> + <widget class="QSpinBox" name="syncDelaySpinBox"> + <property name="toolTip"> + <string>Send start to first clock delay</string> + </property> + <property name="whatsThis"> + <string>Allows 'slow sync' devices time + to synchronize to MusE. This value is the + delay from sending start to sending + the first clock.</string> + </property> + <property name="suffix"> + <string>ms</string> + </property> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>60000</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + <property name="value"> + <number>1</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="syncDelayLabel"> + <property name="text"> + <string>Send sync delay</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="4" column="0"> + <widget class="QTreeWidget" name="devicesListView"> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <tabstops> + <tabstop>mtcOffH</tabstop> + <tabstop>mtcOffM</tabstop> + <tabstop>mtcOffS</tabstop> + <tabstop>mtcOffF</tabstop> + <tabstop>mtcOffSf</tabstop> + <tabstop>applyButton</tabstop> + <tabstop>okButton</tabstop> + <tabstop>cancelButton</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.cpp b/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.cpp new file mode 100644 index 00000000..75d21ac0 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.cpp @@ -0,0 +1,1252 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: midisyncimpl.cpp,v 1.1.1.1.2.4 2009/05/03 04:14:01 terminator356 Exp $ +// +// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QCloseEvent> +#include <QInputDialog> +#include <QMessageBox> +#include <QStringList> +#include <QTimer> +#include <QTreeWidgetItem> + +#include "app.h" +#include "song.h" +#include "midiport.h" +#include "midiseq.h" +#include "mididev.h" +#include "icons.h" +#include "sync.h" +#include "globals.h" +#include "midisyncimpl.h" +#include "driver/audiodev.h" +#include "audio.h" + +enum { DEVCOL_NO = 0, DEVCOL_NAME, DEVCOL_IN, DEVCOL_TICKIN, DEVCOL_MRTIN, DEVCOL_MMCIN, DEVCOL_MTCIN, DEVCOL_MTCTYPE, + DEVCOL_RID, DEVCOL_RCLK, DEVCOL_RMRT, DEVCOL_RMMC, DEVCOL_RMTC, DEVCOL_RREWSTART, + DEVCOL_TID, DEVCOL_TCLK, DEVCOL_TMRT, DEVCOL_TMMC, DEVCOL_TMTC, /* DEVCOL_TREWSTART, */ }; + +//MidiSyncInfo tmpMidiSyncPorts[MIDI_PORTS]; + +//--------------------------------------------------------- +// MidiSyncConfig::setToolTips +//--------------------------------------------------------- + +void MidiSyncConfig::setToolTips(QTreeWidgetItem *item) +{ + item->setToolTip(DEVCOL_NO, tr("Port Number")); + item->setToolTip(DEVCOL_NAME, tr("Name of the midi device associated with" + " this port number")); + item->setToolTip(DEVCOL_IN, tr("Midi clock input detected")); + item->setToolTip(DEVCOL_TICKIN, tr("Midi tick input detected")); + item->setToolTip(DEVCOL_MRTIN, tr("Midi real time input detected")); + item->setToolTip(DEVCOL_MMCIN, tr("MMC input detected")); + item->setToolTip(DEVCOL_MTCIN, tr("MTC input detected")); + item->setToolTip(DEVCOL_MTCTYPE, tr("Detected SMPTE format")); + item->setToolTip(DEVCOL_RID, tr("Receive id number. 127 = Global. Double click to edit.")); + item->setToolTip(DEVCOL_RCLK, tr("Accept midi clock input")); + item->setToolTip(DEVCOL_RMRT, tr("Accept midi real time input")); + item->setToolTip(DEVCOL_RMMC, tr("Accept MMC input")); + item->setToolTip(DEVCOL_RMTC, tr("Accept MTC input")); + item->setToolTip(DEVCOL_RREWSTART, tr("Receive start rewinds before playing")); + item->setToolTip(DEVCOL_TID, tr("Transmit id number. 127 = Global. Double click to edit.")); + item->setToolTip(DEVCOL_TCLK, tr("Send midi clock output")); + item->setToolTip(DEVCOL_TMRT, tr("Send midi realtime output")); + item->setToolTip(DEVCOL_TMMC, tr("Send MMC output")); + item->setToolTip(DEVCOL_TMTC, tr("Send MTC output")); + //item->setToolTip(DEVCOL_TREWSTART, tr("Send continue instead of start")); +} + +//--------------------------------------------------------- +// MidiSyncConfig::setWhatsThis +//--------------------------------------------------------- + +void MidiSyncConfig::setWhatsThis(QTreeWidgetItem *item) +{ + item->setWhatsThis(DEVCOL_NO, tr("Port Number")); + item->setWhatsThis(DEVCOL_NAME, tr("Name of the midi device associated with this port number")); + item->setWhatsThis(DEVCOL_IN, tr("Midi clock input detected.\n" + "Current port actually used is red.\nClick to force a port to be used.")); + item->setWhatsThis(DEVCOL_TICKIN, tr("Midi tick input detected")); + item->setWhatsThis(DEVCOL_MRTIN, tr("Midi realtime input detected, including\n start/stop/continue, and song position.")); + item->setWhatsThis(DEVCOL_MMCIN, tr("MMC input detected, including stop/play/deferred play, and locate.")); + //"Current port actually used is red. Click to force a port to be current.")); + item->setWhatsThis(DEVCOL_MTCIN, tr("MTC input detected, including forward quarter-frame sync and full-frame locate.\n" + "Current port actually used is red. Click to force a port to be current.")); + item->setWhatsThis(DEVCOL_MTCTYPE, tr("Detected SMPTE format: 24fps, 25fps, 30fps drop frame, or 30fps non-drop\n" + "Detects format of MTC quarter and full frame, and MMC locate.")); + item->setWhatsThis(DEVCOL_RID, tr("Receive id number. 127 = global receive all, even if not global.")); + item->setWhatsThis(DEVCOL_RCLK, tr("Accept midi clock input. Only one input is used for clock.\n" + "Auto-acquire: If two or more port realtime inputs are enabled,\n" + " the first clock detected is used, until clock is lost,\n" + " then another can take over. Best if each turns off its clock\n" + " at stop, so MusE can re-acquire the clock from another port.\n" + "Click on detect indicator to force another.")); + item->setWhatsThis(DEVCOL_RMRT, tr("Accept midi realtime input, including\n start/stop/continue, and song position.\n" + "Non-clock events (start,stop etc) are\n accepted by ALL enabled ports.\n" + "This means you may have several master\n devices connected, and muse will accept\n" + " input from them.")); + item->setWhatsThis(DEVCOL_RMMC, tr("Accept MMC input, including stop/play/deferred play, and locate.")); + item->setWhatsThis(DEVCOL_RMTC, tr("Accept MTC input, including forward quarter-frame sync and full-frame locate.\n" + "See 'rc' column for more help.")); + item->setWhatsThis(DEVCOL_RREWSTART, tr("When start is received, rewind before playing.\n" + "Note: It may be impossible to rewind fast\n" + " enough to synchronize with the external device.")); + item->setWhatsThis(DEVCOL_TID, tr("Transmit id number. 127 = global transmit to all.")); + item->setWhatsThis(DEVCOL_TCLK, tr("Send midi clock output. If 'Slave to External Sync' is chosen,\n" + " muse can re-transmit clock to any other chosen ports.")); + item->setWhatsThis(DEVCOL_TMRT, tr("Send midi realtime output, including start/stop/continue,\n" + " and song position. If 'Slave to external sync' is chosen,\n" + " muse can re-transmit midi realtime input messages to any\n" + " other chosen ports. This means you may have several slave\n" + " devices connected, and muse can re-send realtime messages\n" + " to any or all of them.")); + item->setWhatsThis(DEVCOL_TMMC, tr("Send MMC output")); + item->setWhatsThis(DEVCOL_TMTC, tr("Send MTC output")); + // item->setWhatsThis(DEVCOL_TREWSTART, tr("When transport is starting, send continue instead of start.\n")); +} + +//--------------------------------------------------------- +// MidiSyncConfig::addDevice +//--------------------------------------------------------- + +void MidiSyncConfig::addDevice(QTreeWidgetItem *item, QTreeWidget *tree) +{ + setWhatsThis(item); + tree->addTopLevelItem(item); +} + +/* +//--------------------------------------------------------- +// MidiSyncLViewItem +// setDevice +//--------------------------------------------------------- + +void MidiSyncLViewItem::setDevice(MidiDevice* d) +{ + _device = d; + if(_device) + _syncInfo.copyParams(_device->syncInfo()); +} +*/ + +//--------------------------------------------------------- +// MidiSyncLViewItem +// setPort +//--------------------------------------------------------- + +void MidiSyncLViewItem::setPort(int port) +{ + _port = port; + if(_port < 0 || port > MIDI_PORTS) + return; + + //_syncInfo.copyParams(midiPorts[port].syncInfo()); + copyFromSyncInfo(midiPorts[port].syncInfo()); +} + +//--------------------------------------------------------- +// MidiSyncLViewItem +// copyFromSyncInfo +//--------------------------------------------------------- + +void MidiSyncLViewItem::copyFromSyncInfo(const MidiSyncInfo &sp) +{ + _idOut = sp.idOut(); + _idIn = sp.idIn(); + _sendMC = sp.MCOut(); + _sendMRT = sp.MRTOut(); + _sendMMC = sp.MMCOut(); + _sendMTC = sp.MTCOut(); + _recMC = sp.MCIn(); + _recMRT = sp.MRTIn(); + _recMMC = sp.MMCIn(); + _recMTC = sp.MTCIn(); + _recRewOnStart = sp.recRewOnStart(); + //_sendContNotStart = sp.sendContNotStart(); +} + +//--------------------------------------------------------- +// MidiSyncLViewItem +// copyToSyncInfo +//--------------------------------------------------------- + +void MidiSyncLViewItem::copyToSyncInfo(MidiSyncInfo &sp) +{ + sp.setIdOut(_idOut); + sp.setIdIn(_idIn); + sp.setMCOut(_sendMC); + sp.setMRTOut(_sendMRT); + sp.setMMCOut(_sendMMC); + sp.setMTCOut(_sendMTC); + sp.setMCIn(_recMC); + sp.setMRTIn(_recMRT); + sp.setMMCIn(_recMMC); + sp.setMTCIn(_recMTC); + sp.setRecRewOnStart(_recRewOnStart); + //sp.setSendContNotStart(_sendContNotStart); +} + +//--------------------------------------------------------- +// MidiSyncConfig +// Midi Sync Config +//--------------------------------------------------------- + +MidiSyncConfig::MidiSyncConfig(QWidget* parent) + : QDialog(parent) +{ + setupUi(this); + + _dirty = false; + applyButton->setEnabled(false); + + //inHeartBeat = true; + + //for(int i = 0; i < MIDI_PORTS; ++i) + // tmpMidiSyncPorts[i] = midiSyncPorts[i]; + + //bool ext = extSyncFlag.value(); + //syncMode->setButton(int(ext)); + //syncChanged(ext); +// extSyncCheckbox->setChecked(extSyncFlag.value()); + +// dstDevId->setValue(txDeviceId); +// srcDevId->setValue(rxDeviceId); +// srcSyncPort->setValue(rxSyncPort + 1); +// dstSyncPort->setValue(txSyncPort + 1); + +// mtcSync->setChecked(genMTCSync); +// mcSync->setChecked(genMCSync); +// midiMachineControl->setChecked(genMMC); + +// acceptMTCCheckbox->setChecked(acceptMTC); + //acceptMTCCheckbox->setChecked(false); +// acceptMCCheckbox->setChecked(acceptMC); +// acceptMMCCheckbox->setChecked(acceptMMC); + +// mtcSyncType->setCurrentItem(mtcType); + +// mtcOffH->setValue(mtcOffset.h()); +// mtcOffM->setValue(mtcOffset.m()); +// mtcOffS->setValue(mtcOffset.s()); +// mtcOffF->setValue(mtcOffset.f()); +// mtcOffSf->setValue(mtcOffset.sf()); + + + + + devicesListView->setAllColumnsShowFocus(true); + QStringList columnnames; + columnnames << tr("Port") + << tr("Device Name") + << tr("c") + << tr("k") + << tr("r") + << tr("m") + << tr("t") + << tr("type") + << tr("rid") // Receive + << tr("rc") // Receive + << tr("rr") // Receive + << tr("rm") // Receive + << tr("rt") // Receive + << tr("rw") // Receive + << tr("tid") // Transmit + << tr("tc") // Transmit + << tr("tr") // Transmit + << tr("tm") // Transmit + << tr("tt"); // Transmit + + devicesListView->setColumnCount(columnnames.size()); + devicesListView->setHeaderLabels(columnnames); + setWhatsThis(devicesListView->headerItem()); + setToolTips(devicesListView->headerItem()); + devicesListView->setFocusPolicy(Qt::NoFocus); + + //MSyncHeaderTip::add(devicesListView->header(), QString("Midi sync ports")); + +// updateSyncInfoLV(); + + songChanged(-1); + + //connect(devicesListView, SIGNAL(pressed(QListViewItem*,const QPoint&,int)), + // this, SLOT(dlvClicked(QListViewItem*,const QPoint&,int))); + connect(devicesListView, SIGNAL(itemClicked(QTreeWidgetItem*, int)), + this, SLOT(dlvClicked(QTreeWidgetItem*, int))); + connect(devicesListView, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), + this, SLOT(dlvDoubleClicked(QTreeWidgetItem*, int))); + //connect(devicesListView, SIGNAL(itemRenamed(QListViewItem*, int, const QString&)), + // this, SLOT(renameOk(QListViewItem*, int, const QString&))); + + connect(okButton, SIGNAL(clicked()), SLOT(ok())); + connect(applyButton, SIGNAL(clicked()), SLOT(apply())); + connect(cancelButton, SIGNAL(clicked()), SLOT(cancel())); + + //connect(syncMode, SIGNAL(clicked(int)), SLOT(syncChanged(int))); + connect(extSyncCheckbox, SIGNAL(clicked()), SLOT(syncChanged())); + connect(mtcSyncType, SIGNAL(activated(int)), SLOT(syncChanged())); + connect(useJackTransportCheckbox, SIGNAL(clicked()), SLOT(syncChanged())); + connect(jackTransportMasterCheckbox, SIGNAL(clicked()), SLOT(syncChanged())); + connect(&extSyncFlag, SIGNAL(valueChanged(bool)), SLOT(extSyncChanged(bool))); + connect(syncDelaySpinBox, SIGNAL(valueChanged(int)), SLOT(syncChanged())); + + // Done in show(). + //connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + //connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat())); + + //inHeartBeat = false; +} + +MidiSyncConfig::~MidiSyncConfig() +{ +} + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void MidiSyncConfig::songChanged(int flags) +{ + // Is it simply a midi controller value adjustment? Forget it. Otherwise, it's mainly midi port/device changes we want. + if(flags == SC_MIDI_CONTROLLER || + !(flags & (SC_CONFIG | SC_MASTER | SC_TEMPO | SC_SIG | SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED | + SC_PART_INSERTED | SC_PART_REMOVED | SC_PART_MODIFIED | SC_EVENT_INSERTED | SC_EVENT_REMOVED | SC_EVENT_MODIFIED | + SC_MIDI_CONTROLLER_ADD))) + return; + + // Reset dirty flag, since we're loading new values. + _dirty = false; + if(applyButton->isEnabled()) + applyButton->setEnabled(false); + + //for(int i = 0; i < MIDI_PORTS; ++i) + // tmpMidiSyncPorts[i] = midiSyncPorts[i]; + + extSyncCheckbox->blockSignals(true); + useJackTransportCheckbox->blockSignals(true); + jackTransportMasterCheckbox->blockSignals(true); + syncDelaySpinBox->blockSignals(true); + extSyncCheckbox->setChecked(extSyncFlag.value()); + useJackTransportCheckbox->setChecked(useJackTransport.value()); + jackTransportMasterCheckbox->setChecked(jackTransportMaster); + //jackTransportMasterCheckbox->setEnabled(useJackTransport); + syncDelaySpinBox->setValue(syncSendFirstClockDelay); + syncDelaySpinBox->blockSignals(false); + jackTransportMasterCheckbox->blockSignals(false); + useJackTransportCheckbox->blockSignals(false); + extSyncCheckbox->blockSignals(false); + + mtcSyncType->setCurrentIndex(mtcType); + + mtcOffH->blockSignals(true); + mtcOffM->blockSignals(true); + mtcOffS->blockSignals(true); + mtcOffF->blockSignals(true); + mtcOffSf->blockSignals(true); + mtcOffH->setValue(mtcOffset.h()); + mtcOffM->setValue(mtcOffset.m()); + mtcOffS->setValue(mtcOffset.s()); + mtcOffF->setValue(mtcOffset.f()); + mtcOffSf->setValue(mtcOffset.sf()); + mtcOffH->blockSignals(false); + mtcOffM->blockSignals(false); + mtcOffS->blockSignals(false); + mtcOffF->blockSignals(false); + mtcOffSf->blockSignals(false); + + updateSyncInfoLV(); + + //selectionChanged(); +} + +//--------------------------------------------------------- +// heartBeat +//--------------------------------------------------------- + +void MidiSyncConfig::heartBeat() +{ + //inHeartBeat = true; + for (int i = MIDI_PORTS-1; i >= 0; --i) + { + MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)devicesListView->topLevelItem(i); + int port = lvi->port(); + if(port >= 0 && port < MIDI_PORTS) + { + bool sdet = midiPorts[port].syncInfo().MCSyncDetect(); + if(sdet) + { + if(port == curMidiSyncInPort) + { + if(!lvi->_curDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting current red icon\n"); + + lvi->_curDet = true; + lvi->_inDet = false; + lvi->setIcon(DEVCOL_IN, QIcon( *record1_Icon)); + } + } + else + if(!lvi->_inDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting non-current green icon\n"); + + lvi->_inDet = true; + lvi->_curDet = false; + lvi->setIcon(DEVCOL_IN, QIcon( *dotIcon)); + } + } + else + { + if(lvi->_curDet || lvi->_inDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting off icon\n"); + + lvi->_curDet = false; + lvi->_inDet = false; + lvi->setIcon(DEVCOL_IN, QIcon( *dothIcon)); + } + } + + sdet = midiPorts[port].syncInfo().tickDetect(); + if(sdet) + { + if(!lvi->_tickDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting tick on icon\n"); + + lvi->_tickDet = true; + lvi->setIcon(DEVCOL_TICKIN, QIcon( *dotIcon)); + } + } + else + { + if(lvi->_tickDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting tick off icon\n"); + + lvi->_tickDet = false; + lvi->setIcon(DEVCOL_TICKIN, QIcon( *dothIcon)); + } + } + + sdet = midiPorts[port].syncInfo().MRTDetect(); + if(sdet) + { + if(!lvi->_MRTDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting MRT on icon\n"); + + lvi->_MRTDet = true; + lvi->setIcon(DEVCOL_MRTIN, QIcon( *dotIcon)); + } + } + else + { + if(lvi->_MRTDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting MRT off icon\n"); + + lvi->_MRTDet = false; + lvi->setIcon(DEVCOL_MRTIN, QIcon( *dothIcon)); + } + } + + int type = midiPorts[port].syncInfo().recMTCtype(); + sdet = midiPorts[port].syncInfo().MMCDetect(); + bool mtcdet = midiPorts[port].syncInfo().MTCDetect(); + if(sdet) + { + if(!lvi->_MMCDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting MMC on icon\n"); + + lvi->_MMCDet = true; + lvi->setIcon(DEVCOL_MMCIN, QIcon( *dotIcon)); + } + // MMC locate command can contain SMPTE format type. Update now. + if(!mtcdet && lvi->_recMTCtype != type) + { + lvi->_recMTCtype = type; + switch(type) + { + case 0: + lvi->setText(DEVCOL_MTCTYPE, "24"); + break; + case 1: + lvi->setText(DEVCOL_MTCTYPE, "25"); + break; + case 2: + lvi->setText(DEVCOL_MTCTYPE, "30D"); + break; + case 3: + lvi->setText(DEVCOL_MTCTYPE, "30N"); + break; + default: + lvi->setText(DEVCOL_MTCTYPE, "??"); + break; + } + } + } + else + { + if(lvi->_MMCDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting MMC off icon\n"); + + lvi->_MMCDet = false; + lvi->setIcon(DEVCOL_MMCIN, QIcon( *dothIcon)); + } + } + + if(mtcdet) + { + if(port == curMidiSyncInPort) + { + if(!lvi->_curMTCDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting current red icon\n"); + + lvi->_curMTCDet = true; + lvi->_MTCDet = false; + lvi->setIcon(DEVCOL_MTCIN, QIcon( *record1_Icon)); + } + } + else + if(!lvi->_MTCDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting MTC on icon\n"); + + lvi->_MTCDet = true; + lvi->_curMTCDet = false; + lvi->setIcon(DEVCOL_MTCIN, QIcon( *dotIcon)); + } + + if(lvi->_recMTCtype != type) + { + lvi->_recMTCtype = type; + switch(type) + { + case 0: + lvi->setText(DEVCOL_MTCTYPE, "24"); + break; + case 1: + lvi->setText(DEVCOL_MTCTYPE, "25"); + break; + case 2: + lvi->setText(DEVCOL_MTCTYPE, "30D"); + break; + case 3: + lvi->setText(DEVCOL_MTCTYPE, "30N"); + break; + default: + lvi->setText(DEVCOL_MTCTYPE, "??"); + break; + } + } + } + else + { + if(lvi->_curMTCDet || lvi->_MTCDet) + { + // Added by Tim. p3.3.6 + //printf("MidiSyncConfig::heartBeat setting MTC off icon\n"); + + lvi->_MTCDet = false; + lvi->_curMTCDet = false; + lvi->setIcon(DEVCOL_MTCIN, QIcon( *dothIcon)); + } + } + } + + //MidiDevice* dev = lvi->device(); + //bool sdet = dev->syncInfo().MCSyncDetect(); + //if(lvi->pixmap(DEVCOL_IN) != (sdet ? *dotIcon : *dothIcon)) + // lvi->setIcon(DEVCOL_IN, QIcon( sdet ? *dotIcon : *dothIcon)); + + } + + //inHeartBeat = false; +} + +//--------------------------------------------------------- +// syncChanged +// val = 1 - Master Mode +// 0 - Slave Mode +//--------------------------------------------------------- + +void MidiSyncConfig::syncChanged() + { + setDirty(); + + //jackTransportMasterCheckbox->setEnabled(useJackTransport); + + //acceptMTCCheckbox->setEnabled(val); +// acceptMTCCheckbox->setEnabled(false); +// acceptMCCheckbox->setEnabled(val); +// acceptMMCCheckbox->setEnabled(val); + } + +//--------------------------------------------------------- +// extSyncChanged +//--------------------------------------------------------- + +void MidiSyncConfig::extSyncChanged(bool v) + { + extSyncCheckbox->blockSignals(true); + extSyncCheckbox->setChecked(v); +// if(v) +// song->setMasterFlag(false); + extSyncCheckbox->blockSignals(false); + } + +//--------------------------------------------------------- +// ok Pressed +//--------------------------------------------------------- + +void MidiSyncConfig::ok() + { + apply(); + cancel(); + } + +//--------------------------------------------------------- +// cancel Pressed +//--------------------------------------------------------- + +void MidiSyncConfig::cancel() + { + _dirty = false; + if(applyButton->isEnabled()) + applyButton->setEnabled(false); + + close(); + } + +//--------------------------------------------------------- +// show +//--------------------------------------------------------- + +void MidiSyncConfig::show() +{ + songChanged(-1); + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat())); + QDialog::show(); +} + +//--------------------------------------------------------- +// closeEvent +//--------------------------------------------------------- + +void MidiSyncConfig::closeEvent(QCloseEvent* e) + { + if(_dirty) + { + int n = QMessageBox::warning(this, tr("MusE"), + tr("Settings have changed\n" + "Apply sync settings?"), + tr("&Apply"), tr("&No"), tr("&Abort"), 0, 2); + + if(n == 2) + { + e->ignore(); + return; + } + + if(n == 0) + apply(); + } + + //emit deleted((unsigned long)this); + + disconnect(heartBeatTimer, SIGNAL(timeout()), this, SLOT(heartBeat())); + disconnect(song, SIGNAL(songChanged(int)), this, SLOT(songChanged(int))); + + e->accept(); + } + +//--------------------------------------------------------- +// apply Pressed +//--------------------------------------------------------- + +void MidiSyncConfig::apply() +{ +// txDeviceId = dstDevId->value(); +// rxDeviceId = srcDevId->value(); +// rxSyncPort = srcSyncPort->value() - 1; +// txSyncPort = dstSyncPort->value() - 1; + +// genMTCSync = mtcSync->isChecked(); +// genMCSync = mcSync->isChecked(); +// genMMC = midiMachineControl->isChecked(); + + syncSendFirstClockDelay = syncDelaySpinBox->value(); + + mtcType = mtcSyncType->currentIndex(); + //extSyncFlag.setValue(syncMode->id(syncMode->selected())); + //extSyncFlag.blockSignals(true); + extSyncFlag.setValue(extSyncCheckbox->isChecked()); +// if(extSyncFlag.value()) +// song->setMasterFlag(false); + //extSyncFlag.blockSignals(false); + useJackTransport.setValue(useJackTransportCheckbox->isChecked()); +// if(useJackTransport) + jackTransportMaster = jackTransportMasterCheckbox->isChecked(); +// else +// jackTransportMaster = false; +// jackTransportMasterCheckbox->setEnabled(useJackTransport); + if(audioDevice) + audioDevice->setMaster(jackTransportMaster); + + mtcOffset.setH(mtcOffH->value()); + mtcOffset.setM(mtcOffM->value()); + mtcOffset.setS(mtcOffS->value()); + mtcOffset.setF(mtcOffF->value()); + mtcOffset.setSf(mtcOffSf->value()); + +// acceptMC = acceptMCCheckbox->isChecked(); +// acceptMMC = acceptMMCCheckbox->isChecked(); +// acceptMTC = acceptMTCCheckbox->isChecked(); + + + //MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)devicesListView->firstChild(); + //while(lvi) + for (int i = MIDI_PORTS-1; i >= 0; --i) + { + MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)devicesListView->topLevelItem(i); + //MidiDevice* dev = lvi->device(); + // Does the device really exist? + //if(midiDevices.find(dev) != midiDevices.end()) + // dev->syncInfo().copyParams(lvi->syncInfo()); + int port = lvi->port(); + if(port >= 0 && port < MIDI_PORTS) + //midiPorts[port].syncInfo().copyParams(lvi->syncInfo()); + lvi->copyToSyncInfo(midiPorts[port].syncInfo()); + + } + + //muse->changeConfig(true); // save settings + + _dirty = false; + if(applyButton->isEnabled()) + applyButton->setEnabled(false); + + // Do not call this. Causes freeze sometimes. Only will be needed if extra pollfds are used by midi seq thread. + //midiSeq->msgUpdatePollFd(); +} + +//--------------------------------------------------------- +// updateSyncInfoLV +//--------------------------------------------------------- + +void MidiSyncConfig::updateSyncInfoLV() + { + devicesListView->clear(); + for(int i = 0; i < MIDI_PORTS; ++i) + { + MidiPort* port = &midiPorts[i]; + MidiDevice* dev = port->device(); + // p3.3.31 + // Don't show if it is a synthesizer device. + // Hmm, some synths might support transport commands or even sync? + // If anything, the DSSI or VST synths just might... + // TODO: Must test to see if it screws any of them up, especially clock out. + // Also, if we do this, we must prevent such messages from reaching + // those ports at several other places in the code. + //if(dev && dev->isSynti()) + // continue; + + QString s; + s.setNum(i+1); + MidiSyncLViewItem* lvi = new MidiSyncLViewItem(devicesListView); + lvi->setPort(i); // setPort will copy parameters. + //MidiSyncInfo& si = lvi->syncInfo(); + //si.copyParams(port->syncInfo()); + //lvi.copyFromSyncInfo(port->syncInfo()); + MidiSyncInfo& portsi = port->syncInfo(); + + lvi->setText(DEVCOL_NO, s); + + if (dev) + lvi->setText(DEVCOL_NAME, dev->name()); + else + lvi->setText(DEVCOL_NAME, tr("<none>")); + + if(portsi.MCSyncDetect()) + { + if(i == curMidiSyncInPort) + { + lvi->_curDet = true; + lvi->_inDet = false; + lvi->setIcon(DEVCOL_IN, QIcon( *record1_Icon)); + } + else + { + lvi->_curDet = false; + lvi->_inDet = true; + lvi->setIcon(DEVCOL_IN, QIcon( *dotIcon)); + } + } + else + { + lvi->_curDet = false; + lvi->_inDet = false; + lvi->setIcon(DEVCOL_IN, QIcon( *dothIcon)); + } + + if(portsi.tickDetect()) + { + lvi->_tickDet = true; + lvi->setIcon(DEVCOL_TICKIN, QIcon( *dotIcon)); + } + else + { + lvi->_tickDet = false; + lvi->setIcon(DEVCOL_TICKIN, QIcon( *dothIcon)); + } + + if(portsi.MRTDetect()) + { + lvi->_MRTDet = true; + lvi->setIcon(DEVCOL_MRTIN, QIcon( *dotIcon)); + } + else + { + lvi->_MRTDet = false; + lvi->setIcon(DEVCOL_MRTIN, QIcon( *dothIcon)); + } + + if(portsi.MMCDetect()) + { + lvi->_MMCDet = true; + lvi->setIcon(DEVCOL_MMCIN, QIcon( *dotIcon)); + // MMC locate command can have SMPTE format bits... + if(lvi->_recMTCtype != portsi.recMTCtype()) + { + switch(portsi.recMTCtype()) + { + case 0: + lvi->setText(DEVCOL_MTCTYPE, "24"); + break; + case 1: + lvi->setText(DEVCOL_MTCTYPE, "25"); + break; + case 2: + lvi->setText(DEVCOL_MTCTYPE, "30D"); + break; + case 3: + lvi->setText(DEVCOL_MTCTYPE, "30N"); + break; + default: + lvi->setText(DEVCOL_MTCTYPE, "??"); + break; + } + } + } + else + { + lvi->_MMCDet = false; + lvi->setIcon(DEVCOL_MMCIN, QIcon( *dothIcon)); + } + + if(portsi.MTCDetect()) + { + if(i == curMidiSyncInPort) + { + lvi->_curMTCDet = true; + lvi->_MTCDet = false; + lvi->setIcon(DEVCOL_MTCIN, QIcon( *record1_Icon)); + } + else + { + lvi->_curMTCDet = false; + lvi->_MTCDet = true; + lvi->setIcon(DEVCOL_MTCIN, QIcon( *dotIcon)); + } + + if(lvi->_recMTCtype != portsi.recMTCtype()) + { + switch(portsi.recMTCtype()) + { + case 0: + lvi->setText(DEVCOL_MTCTYPE, "24"); + break; + case 1: + lvi->setText(DEVCOL_MTCTYPE, "25"); + break; + case 2: + lvi->setText(DEVCOL_MTCTYPE, "30D"); + break; + case 3: + lvi->setText(DEVCOL_MTCTYPE, "30N"); + break; + default: + lvi->setText(DEVCOL_MTCTYPE, "??"); + break; + } + } + } + else + { + lvi->_curMTCDet = false; + lvi->_MTCDet = false; + lvi->setIcon(DEVCOL_MTCIN, QIcon( *dothIcon)); + //lvi->setText(DEVCOL_MTCTYPE, "--"); + } + + //lvi->setText(DEVCOL_RID, QString().setNum(si.idIn()) ); + //lvi->setRenameEnabled(DEVCOL_RID, true); + //lvi->setIcon(DEVCOL_RCLK, QIcon( si.MCIn() ? *dotIcon : *dothIcon)); + //lvi->setIcon(DEVCOL_RMMC, QIcon( si.MMCIn() ? *dotIcon : *dothIcon)); + //lvi->setIcon(DEVCOL_RMTC, QIcon( si.MTCIn() ? *dotIcon : *dothIcon)); + lvi->setText(DEVCOL_RID, QString().setNum(lvi->_idIn) ); + lvi->setIcon(DEVCOL_RCLK, QIcon( lvi->_recMC ? *dotIcon : *dothIcon)); + lvi->setIcon(DEVCOL_RMRT, QIcon( lvi->_recMRT ? *dotIcon : *dothIcon)); + lvi->setIcon(DEVCOL_RMMC, QIcon( lvi->_recMMC ? *dotIcon : *dothIcon)); + lvi->setIcon(DEVCOL_RMTC, QIcon( lvi->_recMTC ? *dotIcon : *dothIcon)); + lvi->setIcon(DEVCOL_RREWSTART, QIcon( lvi->_recRewOnStart ? *dotIcon : *dothIcon)); + + //lvi->setText(DEVCOL_TID, QString().setNum(si.idOut()) ); + //lvi->setRenameEnabled(DEVCOL_TID, true); + //lvi->setIcon(DEVCOL_TCLK, QIcon( si.MCOut() ? *dotIcon : *dothIcon)); + //lvi->setIcon(DEVCOL_TMMC, QIcon( si.MMCOut() ? *dotIcon : *dothIcon)); + //lvi->setIcon(DEVCOL_TMTC, QIcon( si.MTCOut() ? *dotIcon : *dothIcon)); + lvi->setText(DEVCOL_TID, QString().setNum(lvi->_idOut) ); + lvi->setIcon(DEVCOL_TCLK, QIcon(lvi->_sendMC ? *dotIcon : *dothIcon)); + lvi->setIcon(DEVCOL_TMRT, QIcon(lvi->_sendMRT ? *dotIcon : *dothIcon)); + lvi->setIcon(DEVCOL_TMMC, QIcon(lvi->_sendMMC ? *dotIcon : *dothIcon)); + lvi->setIcon(DEVCOL_TMTC, QIcon(lvi->_sendMTC ? *dotIcon : *dothIcon)); + //lvi->setIcon(DEVCOL_TREWSTART, QIcon( lvi->_sendContNotStart ? *dotIcon : *dothIcon)); + + addDevice(lvi, devicesListView); + } + devicesListView->resizeColumnToContents(DEVCOL_NO); + //devicesListView->resizeColumnToContents(DEVCOL_NAME); + devicesListView->header()->resizeSection(DEVCOL_NAME, 120); + devicesListView->resizeColumnToContents(DEVCOL_IN); + devicesListView->resizeColumnToContents(DEVCOL_TICKIN); + devicesListView->resizeColumnToContents(DEVCOL_MRTIN); + devicesListView->resizeColumnToContents(DEVCOL_MMCIN); + devicesListView->resizeColumnToContents(DEVCOL_MTCIN); + devicesListView->resizeColumnToContents(DEVCOL_MTCTYPE); + devicesListView->resizeColumnToContents(DEVCOL_RID); + devicesListView->resizeColumnToContents(DEVCOL_RCLK); + devicesListView->resizeColumnToContents(DEVCOL_RMRT); + devicesListView->resizeColumnToContents(DEVCOL_RMMC); + devicesListView->resizeColumnToContents(DEVCOL_RMTC); + devicesListView->resizeColumnToContents(DEVCOL_RREWSTART); + devicesListView->resizeColumnToContents(DEVCOL_TID); + devicesListView->resizeColumnToContents(DEVCOL_TCLK); + devicesListView->resizeColumnToContents(DEVCOL_TMRT); + devicesListView->resizeColumnToContents(DEVCOL_TMMC); + devicesListView->resizeColumnToContents(DEVCOL_TMTC); + + devicesListView->header()->setResizeMode(DEVCOL_NO, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_IN, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_TICKIN, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_MRTIN, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_MMCIN, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_MTCIN, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_RCLK, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_RMRT, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_RMMC, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_RMTC, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_RMTC, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_RREWSTART, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_TCLK, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_TMRT, QHeaderView::Fixed); + devicesListView->header()->setResizeMode(DEVCOL_TMMC, QHeaderView::Fixed); + + + /* + for(iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id) + { + MidiDevice* dev = *id; + + //MidiPort* port = &midiPorts[i]; + //MidiDevice* dev = port->device(); + MidiSyncLViewItem* lvi = new MidiSyncLViewItem(devicesListView); + //lvi->setPort(i); + // setDevice will copy parameters. + lvi->setDevice(dev); + MidiSyncInfo& si = lvi->syncInfo(); + //si.copyParams(dev->syncInfo()); + + lvi->setText(DEVCOL_NAME, dev->name()); + + lvi->setIcon(DEVCOL_IN, QIcon( si.MCSyncDetect() ? *dotIcon : *dothIcon)); + + lvi->setText(DEVCOL_RID, QString().setNum(si.idIn()) ); + lvi->setIcon(DEVCOL_RCLK, QIcon( si.MCIn() ? *dotIcon : *dothIcon)); + lvi->setIcon(DEVCOL_RMMC, QIcon( si.MMCIn() ? *dotIcon : *dothIcon)); + lvi->setIcon(DEVCOL_RMTC, QIcon( si.MTCIn() ? *dotIcon : *dothIcon)); + + lvi->setText(DEVCOL_TID, QString().setNum(si.idOut()) ); + lvi->setIcon(DEVCOL_TCLK, QIcon( si.MCOut() ? *dotIcon : *dothIcon)); + lvi->setIcon(DEVCOL_TMMC, QIcon( si.MMCOut() ? *dotIcon : *dothIcon)); + lvi->setIcon(DEVCOL_TMTC, QIcon( si.MTCOut() ? *dotIcon : *dothIcon)); + + devicesListView->insertItem(lvi); + } + */ + } + + +//--------------------------------------------------------- +// dlvClicked +//--------------------------------------------------------- + +//void MidiSyncConfig::dlvClicked(QListViewItem* item, const QPoint&, int col) +void MidiSyncConfig::dlvClicked(QTreeWidgetItem* item, int col) +{ + if (item == 0) + return; + + MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)item; + int no = lvi->port(); + if (no < 0 || no >= MIDI_PORTS) + return; + //MidiDevice* dev = lvi->device(); + // Does the device really exist? + //if(midiDevices.find(dev) == midiDevices.end()) + // return; + + //int n; + //MidiPort* port = &midiPorts[no]; + //MidiDevice* dev = port->device(); + //int rwFlags = dev ? dev->rwFlags() : 0; + //int openFlags = dev ? dev->openFlags() : 0; + //MidiSyncInfo& si = lvi->syncInfo(); + //MidiSyncInfo& portsi = midiPorts[no].syncInfo(); + + switch (col) + { + case DEVCOL_NO: + break; + case DEVCOL_NAME: + break; + case DEVCOL_IN: + // If this is not the current midi sync in port, and sync in from this port is enabled, + // and sync is in fact detected on this port, allow the user to force this port to now be the + // current sync in port. + //if(no != curMidiSyncInPort && si.MCIn() && midiPorts[no].syncInfo().MCSyncDetect()) + //if(no != curMidiSyncInPort && lvi->_recMC && midiPorts[no].syncInfo().MCSyncDetect()) + if(no != curMidiSyncInPort) + { + if(lvi->_recMC && midiPorts[no].syncInfo().MCSyncDetect()) + { + curMidiSyncInPort = no; + lvi->setIcon(DEVCOL_IN, QIcon( *record1_Icon)); + } + if(lvi->_recMTC && midiPorts[no].syncInfo().MTCDetect()) + { + curMidiSyncInPort = no; + lvi->setIcon(DEVCOL_MTCIN, QIcon( *record1_Icon)); + } + } + break; + case DEVCOL_TICKIN: + break; + case DEVCOL_MMCIN: + break; + case DEVCOL_MTCIN: + // If this is not the current midi sync in port, and sync in from this port is enabled, + // and sync is in fact detected on this port, allow the user to force this port to now be the + // current sync in port. + //if(no != curMidiSyncInPort && si.MTCIn() && midiPorts[no].syncInfo().MTCDetect()) + //if(no != curMidiSyncInPort && lvi->_recMTC && midiPorts[no].syncInfo().MTCDetect()) + if(no != curMidiSyncInPort) + { + if(lvi->_recMTC && midiPorts[no].syncInfo().MTCDetect()) + { + curMidiSyncInPort = no; + lvi->setIcon(DEVCOL_MTCIN, QIcon( *record1_Icon)); + } + if(lvi->_recMC && midiPorts[no].syncInfo().MCSyncDetect()) + { + curMidiSyncInPort = no; + lvi->setIcon(DEVCOL_IN, QIcon( *record1_Icon)); + } + } + break; + case DEVCOL_MTCTYPE: + break; + case DEVCOL_RID: + break; + case DEVCOL_RCLK: + //si.setMCIn(si.MCIn() ? false : true); + //lvi->setIcon(DEVCOL_RCLK, QIcon( si.MCIn() ? *dotIcon : *dothIcon)); + lvi->_recMC = (lvi->_recMC ? false : true); + lvi->setIcon(DEVCOL_RCLK, QIcon( lvi->_recMC ? *dotIcon : *dothIcon)); + setDirty(); + break; + case DEVCOL_RMRT: + lvi->_recMRT = (lvi->_recMRT ? false : true); + lvi->setIcon(DEVCOL_RMRT, QIcon( lvi->_recMRT ? *dotIcon : *dothIcon)); + setDirty(); + break; + case DEVCOL_RMMC: + //si.setMMCIn(si.MMCIn() ? false : true); + //lvi->setIcon(DEVCOL_RMMC, QIcon( si.MMCIn() ? *dotIcon : *dothIcon)); + lvi->_recMMC = (lvi->_recMMC ? false : true); + lvi->setIcon(DEVCOL_RMMC, QIcon( lvi->_recMMC ? *dotIcon : *dothIcon)); + setDirty(); + break; + case DEVCOL_RMTC: + //si.setMTCIn(si.MTCIn() ? false : true); + //lvi->setIcon(DEVCOL_RMTC, QIcon( si.MTCIn() ? *dotIcon : *dothIcon)); + lvi->_recMTC = (lvi->_recMTC ? false : true); + lvi->setIcon(DEVCOL_RMTC, QIcon( lvi->_recMTC ? *dotIcon : *dothIcon)); + setDirty(); + break; + case DEVCOL_RREWSTART: + lvi->_recRewOnStart = (lvi->_recRewOnStart ? false : true); + lvi->setIcon(DEVCOL_RREWSTART, QIcon( lvi->_recRewOnStart ? *dotIcon : *dothIcon)); + setDirty(); + break; + case DEVCOL_TID: + break; + case DEVCOL_TCLK: + //si.setMCOut(si.MCOut() ? false : true); + //lvi->setIcon(DEVCOL_TCLK, QIcon( si.MCOut() ? *dotIcon : *dothIcon)); + lvi->_sendMC = (lvi->_sendMC ? false : true); + lvi->setIcon(DEVCOL_TCLK, QIcon( lvi->_sendMC ? *dotIcon : *dothIcon)); + setDirty(); + break; + case DEVCOL_TMRT: + lvi->_sendMRT = (lvi->_sendMRT ? false : true); + lvi->setIcon(DEVCOL_TMRT, QIcon( lvi->_sendMRT ? *dotIcon : *dothIcon)); + setDirty(); + break; + case DEVCOL_TMMC: + //si.setMMCOut(si.MMCOut() ? false : true); + //lvi->setIcon(DEVCOL_TMMC, QIcon( si.MMCOut() ? *dotIcon : *dothIcon)); + lvi->_sendMMC = (lvi->_sendMMC ? false : true); + lvi->setIcon(DEVCOL_TMMC, QIcon( lvi->_sendMMC ? *dotIcon : *dothIcon)); + setDirty(); + break; + case DEVCOL_TMTC: + //si.setMTCOut(si.MTCOut() ? false : true); + //lvi->setIcon(DEVCOL_TMTC, QIcon( si.MTCOut() ? *dotIcon : *dothIcon)); + lvi->_sendMTC = (lvi->_sendMTC ? false : true); + lvi->setIcon(DEVCOL_TMTC, QIcon( lvi->_sendMTC ? *dotIcon : *dothIcon)); + setDirty(); + break; + //case DEVCOL_TREWSTART: + // lvi->_sendContNotStart = (lvi->_sendContNotStart ? false : true); + // lvi->setIcon(DEVCOL_TREWSTART, QIcon( lvi->_sendContNotStart ? *dotIcon : *dothIcon)); + // setDirty(); + // break; + } + //songChanged(-1); +} + +//--------------------------------------------------------- +// dlvDoubleClicked +//--------------------------------------------------------- + +void MidiSyncConfig::dlvDoubleClicked(QTreeWidgetItem* item, int col) +{ + if(!item) + return; + + MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)item; + + //if(col == DEVCOL_RID) + // lvi->startRename(DEVCOL_RID); + //else + //if(col == DEVCOL_TID) + // lvi->startRename(DEVCOL_TID); + + bool ok = false; + if(col == DEVCOL_RID) + { + //int val = lvi->syncInfo().idIn(); + int val = lvi->_idIn; + int newval = QInputDialog::getInteger(this, "Muse: Sync info" , "Enter new id number (127 = all):", val, 0, 127, 1, &ok); + if(ok) + { + //lvi->syncInfo().setIdIn(newval); + lvi->_idIn = newval; + lvi->setText(DEVCOL_RID, QString().setNum(newval)); + } + } + else + if(col == DEVCOL_TID) + { + //int val = lvi->syncInfo().idOut(); + int val = lvi->_idOut; + int newval = QInputDialog::getInteger(this, "Muse: Sync info" , "Enter new id number (127 = global):", val, 0, 127, 1, &ok); + if(ok) + { + //lvi->syncInfo().setIdOut(newval); + lvi->_idOut = newval; + lvi->setText(DEVCOL_TID, QString().setNum(newval)); + } + } + + if(ok) + setDirty(); +} + +/* +//--------------------------------------------------------- +// renameOk +//--------------------------------------------------------- +//void MidiSyncConfig::renameOk(QListViewItem* item, int col) +void MidiSyncConfig::renameOk(QListViewItem* item, int col, const QString & text) +{ + if(!item) + return; + + MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)item; + QString t = text; + bool ok; + int id = text.toInt(&ok); + if(!ok) + { + lvi->setText(t); + return; + } + if(col == DEVCOL_RID) + { + //lvi->syncInfo().setIdIn(id); + lvi->_idIn = id; + setDirty(); + } + else + if(col == DEVCOL_TID) + { + //lvi->syncInfo().setIdOut(id); + lvi->_idOut = id; + setDirty(); + } +} +*/ + +//--------------------------------------------------------- +// MidiSyncConfig::setDirty +//--------------------------------------------------------- + +void MidiSyncConfig::setDirty() +{ + _dirty = true; + if(!applyButton->isEnabled()) + applyButton->setEnabled(true); +} + diff --git a/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.h b/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.h new file mode 100644 index 00000000..3eb33451 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.h @@ -0,0 +1,119 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: midisyncimpl.h,v 1.1.1.1.2.3 2009/05/03 04:14:01 terminator356 Exp $ +// +// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __MIDISYNCIMPL_H__ +#define __MIDISYNCIMPL_H__ + +#include "ui_midisync.h" +#include "sync.h" + +class QCloseEvent; +class QDialog; +class QTreeWidgetItem; + +//---------------------------------------------------------- +// MidiSyncLViewItem +//---------------------------------------------------------- + +class MidiSyncLViewItem : public QTreeWidgetItem +{ + //MidiSyncInfo _syncInfo; + //MidiDevice* _device; + int _port; + + //protected: + //int _port; + + public: + MidiSyncLViewItem(QTreeWidget* parent) + : QTreeWidgetItem(parent) { _port = -1; _inDet = _curDet = _tickDet = false; } + //: QListViewItem(parent) { _device = 0; } + + //MidiSyncLViewItem(QListView* parent, QListViewItem* after) + // : QListViewItem(parent, after) { _port = -1; } + + //virtual QString text(int column) const; + //virtual unsigned tick() = 0; + + //int _port; + bool _inDet; + bool _curDet; + bool _curMTCDet; + bool _tickDet; + bool _MRTDet; + bool _MMCDet; + bool _MTCDet; + int _recMTCtype; + + int _idOut; + int _idIn; + + bool _sendMC; + bool _sendMRT; + bool _sendMMC; + bool _sendMTC; + bool _recMC; + bool _recMRT; + bool _recMMC; + bool _recMTC; + + bool _recRewOnStart; + //bool _sendContNotStart; + + int port() const { return _port; } + void setPort(int port); + //MidiDevice* device() const { return _device; } + //void setDevice(MidiDevice* d); + + //MidiSyncInfo& syncInfo() { return _syncInfo; } + void copyFromSyncInfo(const MidiSyncInfo &sp); + void copyToSyncInfo(MidiSyncInfo &sp); +}; + +//--------------------------------------------------------- +// MSConfig +//--------------------------------------------------------- + +class MidiSyncConfig : public QDialog, public Ui::MidiSyncConfigBase { + Q_OBJECT + + bool inHeartBeat; + bool _dirty; + + void updateSyncInfoLV(); + void closeEvent(QCloseEvent*); + void setToolTips(QTreeWidgetItem *item); + void setWhatsThis(QTreeWidgetItem *item); + void addDevice(QTreeWidgetItem *item, QTreeWidget *tree); + + private slots: + void heartBeat(); + void syncChanged(); + void extSyncChanged(bool v); + void ok(); + void cancel(); + void apply(); + //void dlvClicked(QListViewItem*, const QPoint&, int); + void dlvClicked(QTreeWidgetItem*, int); + void dlvDoubleClicked(QTreeWidgetItem*, int); + //void renameOk(QListViewItem*, int, const QString&); + void songChanged(int); + + //signals: + // void deleted(unsigned long); + + public: + MidiSyncConfig(QWidget* parent=0); + //MidiSyncConfig(); + ~MidiSyncConfig(); + void show(); + void setDirty(); + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/mittransposebase.ui b/attic/muse2-oom/muse2/muse/widgets/mittransposebase.ui new file mode 100644 index 00000000..b29e34ed --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mittransposebase.ui @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MITTransposeBase</class> + <widget class="QWidget" name="MITTransposeBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>423</width> + <height>50</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Midi Input Plugin: Transpose</string> + </property> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QCheckBox" name="onCheckBox"> + <property name="text"> + <string>On</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> + <string>TriggerKey</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="indent"> + <number>5</number> + </property> + </widget> + </item> + <item> + <widget class="PitchEdit" name="triggerKeySpinBox" native="true"/> + </item> + <item> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>Transpose:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="indent"> + <number>5</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="transposeLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::Panel</enum> + </property> + <property name="lineWidth"> + <number>2</number> + </property> + <property name="midLineWidth"> + <number>2</number> + </property> + <property name="text"> + <string>+0</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="margin"> + <number>2</number> + </property> + <property name="indent"> + <number>5</number> + </property> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <customwidgets> + <customwidget> + <class>PitchEdit</class> + <extends>QWidget</extends> + <header>pitchedit.h</header> + </customwidget> + </customwidgets> + <includes> + <include location="local">pitchedit.h</include> + </includes> + <resources/> + <connections/> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.cpp b/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.cpp new file mode 100644 index 00000000..8ab26859 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.cpp @@ -0,0 +1,105 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mixdowndialog.cpp,v 1.1.1.1 2003/10/27 18:55:02 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QFileDialog> + +#include "globals.h" +#include "mixdowndialog.h" +#include "wave.h" + +//--------------------------------------------------------- +// sndFileOpen +// sf - old soundfile, used to preset file parameters +//--------------------------------------------------------- + +SndFile* getSndFile(const SndFile* sf, QWidget* parent) + { + MixdownFileDialog* dialog = new MixdownFileDialog(sf, parent); + dialog->exec(); + SndFile* sndFile = dialog->sndFile(); + delete dialog; + return sndFile; + } + +//--------------------------------------------------------- +// MixdownFileDialog +//--------------------------------------------------------- + +MixdownFileDialog::MixdownFileDialog(const SndFile* _sf, + QWidget* parent, Qt::WFlags fl) + : QDialog(parent, fl) + { + setupUi(this); + sf = 0; + connect(buttonPath, SIGNAL(clicked()), SLOT(fdialog())); + if (_sf) { + int channels = _sf->channels(); + int format = _sf->format(); + switch(channels) { + case 1: channels = 1; break; + case 2: channels = 0; break; + case 6: channels = 2; break; + } + editPath->setText(_sf->path()); + comboChannel->setCurrentIndex(channels); + comboFormat->setCurrentIndex(format); + } + } + +//--------------------------------------------------------- +// accept +//--------------------------------------------------------- + +void MixdownFileDialog::accept() + { + QString oldpath; + unsigned channel = comboChannel->currentIndex(); + unsigned format = comboFormat->currentIndex(); + switch (channel) { + case 0: channel = 2; break; + case 1: channel = 1; break; + case 2: channel = 6; break; // not implemented! + } + switch (format) { + case 0: // 16 bit wave + format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; + break; + case 1: // 24 bit wave + format = SF_FORMAT_WAV | SF_FORMAT_PCM_24; + break; + case 2: // 32 bit float wave + format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; + break; + } + QString path = editPath->text(); + if (path.isEmpty()) { + sf = 0; + reject(); + return; + } + if (path.right(4) != ".wav") + path += ".wav"; + sf = new SndFile(path); + sf->setFormat(format, channel, sampleRate); + done(1); + } + +//--------------------------------------------------------- +// fdialog +//--------------------------------------------------------- + +void MixdownFileDialog::fdialog() + { + QString oldpath; + if (sf) + oldpath = sf->path(); + QString path = QFileDialog::getSaveFileName( + this, 0, oldpath, tr("Wave Files (*.wav);;All Files (*)")); + if (!path.isEmpty()) + editPath->setText(path); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.h b/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.h new file mode 100644 index 00000000..750acd28 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.h @@ -0,0 +1,38 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mixdowndialog.h,v 1.1.1.1 2003/10/27 18:54:28 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __MIXDOWNDIALOG_H__ +#define __MIXDOWNDIALOG_H__ + +#include "ui_mixdowndialogbase.h" + +class QWidget; + +class SndFile; + +extern SndFile* getSndFile(const SndFile* sf, QWidget* parent); + +//--------------------------------------------------------- +// MixdownFileDialog +//--------------------------------------------------------- + +class MixdownFileDialog : public QDialog, public Ui::MixdownFileDialogBase { + Q_OBJECT + SndFile* sf; + + private slots: + void fdialog(); + virtual void accept(); + + public: + MixdownFileDialog(const SndFile* f, QWidget* parent = 0, + Qt::WFlags fl = 0); + SndFile* sndFile() { return sf; } + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/mixdowndialogbase.ui b/attic/muse2-oom/muse2/muse/widgets/mixdowndialogbase.ui new file mode 100644 index 00000000..486518fb --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mixdowndialogbase.ui @@ -0,0 +1,217 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MixdownFileDialogBase</class> + <widget class="QDialog" name="MixdownFileDialogBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>381</width> + <height>116</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Set Mixdown Wavefile</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="2" column="0" colspan="5"> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <spacer name="Horizontal Spacing2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonOk"> + <property name="text"> + <string>&OK</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonCancel"> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> + <string>File Path</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>Channel</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1" colspan="4"> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QLineEdit" name="editPath"/> + </item> + <item> + <widget class="QToolButton" name="buttonPath"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="comboChannel"> + <item> + <property name="text"> + <string>Stereo</string> + </property> + </item> + <item> + <property name="text"> + <string>Mono</string> + </property> + </item> + <item> + <property name="text"> + <string>5.1</string> + </property> + </item> + </widget> + </item> + <item row="1" column="4"> + <widget class="QComboBox" name="comboFormat"> + <item> + <property name="text"> + <string>wav,16 Bit</string> + </property> + </item> + <item> + <property name="text"> + <string>wav, 24 Bit</string> + </property> + </item> + <item> + <property name="text"> + <string>wav, 32 Bit (float)</string> + </property> + </item> + </widget> + </item> + <item row="1" column="3"> + <widget class="QLabel" name="TextLabel3"> + <property name="text"> + <string>Format</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="2"> + <spacer name="Spacer1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>MixdownFileDialogBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>MixdownFileDialogBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/mktest b/attic/muse2-oom/muse2/muse/widgets/mktest new file mode 100644 index 00000000..08738898 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mktest @@ -0,0 +1,5 @@ +CPPFLAGS = -I/usr/qt/include -I.. + +mops: mops.o musewidgetsplug.o + g++ -o mops mops.o musewidgetsplug.o -L . -l musewidgetsplugin -L /usr/qt/lib -l qt-mt + diff --git a/attic/muse2-oom/muse2/muse/widgets/mlabel.cpp b/attic/muse2-oom/muse2/muse/widgets/mlabel.cpp new file mode 100644 index 00000000..2b9526d4 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mlabel.cpp @@ -0,0 +1,15 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mlabel.cpp,v 1.1.1.1 2003/10/27 18:55:03 wschweer Exp $ +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include "mlabel.h" + + +void MLabel::mousePressEvent(QMouseEvent*) + { + emit mousePressed(); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/mlabel.h b/attic/muse2-oom/muse2/muse/widgets/mlabel.h new file mode 100644 index 00000000..01bfa788 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mlabel.h @@ -0,0 +1,37 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mlabel.h,v 1.1.1.1 2003/10/27 18:55:03 wschweer Exp $ +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __MLABEL_H__ +#define __MLABEL_H__ + +#include <QLabel> + +//--------------------------------------------------------- +// MLabel +// label widged which sends signal mousePressed +// on mousePressEvent +//--------------------------------------------------------- + +class MLabel : public QLabel { + + Q_OBJECT + + protected: + virtual void mousePressEvent(QMouseEvent*); + + signals: + void mousePressed(); + + public: + MLabel(const QString& txt, QWidget* parent, const char* name = 0) + : QLabel(txt, parent) {setObjectName(name);}; + + MLabel(QWidget* parent, const char* name = 0) + : QLabel(parent) {setObjectName(name);}; + }; +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/mmath.cpp b/attic/muse2-oom/muse2/muse/widgets/mmath.cpp new file mode 100644 index 00000000..acc8e25a --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mmath.cpp @@ -0,0 +1,300 @@ +#include <cmath> +#include "mmath.h" + +// QwtMath - a set of mathematical routines +// +// qwtGetMin -- Find the smallest value in an array +// qwtGetMax -- Find the largest value in an array +// qwtTwistArray -- invert the order of an array +// qwtFloor125 -- Find the largest value fitting in a 1-2-5 pattern +// qwtCeil125 -- Find the smallest value fitting in a 1-2-5 pattern +// qwtChkMono -- Check for monotony +// qwtLinSpace -- construct an array of equally spaced values +// qwtLogSpace -- construct an array of logarithmically equally spaced values +// qwtMax -- Return the largest of two values +// qwtMin -- Return the smallest of two values +// qwtAbs -- return the absolute value +// qwtSign -- Return the sign of a number +// qwtSqr -- Return the square of a number +// qwtCopyArray -- Copy an array into another +// qwtShiftArray -- Shift an array +// qwtSwap -- Swap two values +// qwtSort (1) -- Sort two values +// qwtSort (2) -- Sort two values +// qwtInt -- Return nearest integer +// qwtLim -- Limit a values + + +//------------------------------------------------------------ +//.F qwtGetMin +// Find the smallest value in an array +// +//.u Syntax +//.f double qwtGetMin(double *array, int size) +// +//.u Parameters +//.p double *array, int size +// +//------------------------------------------------------------ + +double qwtGetMin(double *array, int size) +{ + double rv; + int i; + + if (size > 0) + { + rv = array[0]; + for (i=1; i< size; i++) + rv = qwtMin(rv, array[i]); + return rv; + } + else + return 0.0; + +} + + +//------------------------------------------------------------ +// +//.F qwtGetMax +// Find the largest value in an array +// +//.u Syntax +//.f double qwtGetMax(double *array, int size) +// +//.u Parameters +//.p double *array, int size +// +//------------------------------------------------------------ +double qwtGetMax(double *array, int size) +{ + double rv; + int i; + + if (size > 0) + { + rv = array[0]; + for (i=1; i< size; i++) + rv = qwtMax(rv, array[i]); + return rv; + } + else + return 0.0; + +} + + +//------------------------------------------------------------ +// +//.F qwtCeil125 +// Find the smallest value out of {1,2,5}*10^n with an integer number n +// which is greater than or equal to x +// +//.u Syntax +//.f double qwtCeil125(double x) +// +//.u Parameters +//.p double x +// +//------------------------------------------------------------ +double qwtCeil125( double x) +{ + double lx, rv; + double p10, fr; + double sign = ( x > 0) ? 1.0 : -1.0; + + if (x == 0.0) return 0.0; + + lx = log10(fabs(x)); + p10 = floor(lx); + fr = pow(10.0,lx - p10); + if (fr <=1.0) + fr = 1.0; + else if (fr <= 2.0) + fr = 2.0; + else if (fr <= 5.0) + fr = 5.0; + else + fr = 10.0; + rv = fr * pow(10.0,p10); + return sign * rv; +} + + +//------------------------------------------------------------ +// +//.F qwtFloor125 +// Find the largest value out of {1,2,5}*10^n with an integer number n +// which is smaller than or equal to x +// +//.u Syntax +//.f double qwtFloor125(double x) +// +//.u Parameters +//.p double x +// +//------------------------------------------------------------ +double qwtFloor125( double x) +{ + double lx, rv; + double p10, fr; + double sign = ( x > 0) ? 1.0 : -1.0; + + if (x == 0.0) return 0.0; + + lx = log10(fabs(x)); + p10 = floor(lx); + fr = pow(10.0,lx - p10); + if (fr >= 10.0) + fr = 10.0; + else if (fr >= 5.0) + fr = 5.0; + else if (fr >= 2.0) + fr = 2.0; + else + fr = 1.0; + rv = fr * pow(10.0,p10); + return sign * rv; +} + + +//------------------------------------------------------------ +// +//.F qwtChkMono +// Checks if an array is a strictly monotonic sequence +// +//.u Syntax +//.f int qwtChkMono(double *array, int size) +// +//.u Parameters +//.p double *array -- pointer to a double array +// int size -- size of the array +// +//.u Return Value +//.t 0 -- sequence is not strictly monotonic +// 1 -- sequence is strictly monotonically increasing +// -1 -- sequence is strictly monotonically decreasing +// +//------------------------------------------------------------ +int qwtChkMono(double *array, int size) +{ + int rv, i; + + if (size < 2) return 0; + + rv = qwtSign(array[1] - array[0]); + for (i=1;i<size-1;i++) + { + if ( qwtSign(array[i+1] - array[i]) != rv ) + { + rv = 0; + break; + } + } + return rv; + +} + +//------------------------------------------------------------ +// +//.F qwtTwistArray +// Invert the order of array elements +// +//.u Syntax +//.f void qwtTwistArray(double *array, int size) +// +//.u Parameters +//.p double *array, int size +// +//------------------------------------------------------------ +void qwtTwistArray(double *array, int size) +{ + int itmp; + int i, s2; + double dtmp; + + s2 = size / 2; + + for (i=0; i < s2; i++) + { + itmp = size - 1 - i; + dtmp = array[i]; + array[i] = array[itmp]; + array[itmp] = dtmp; + } + +} + + +//------------------------------------------------------------ +// +//.F qwtLinSpace +// Create an array of equally spaced values +// +//.u Syntax +//.f void qwtLinSpace(double *array, int size, double xmin, double xmax) +// +//.u Parameters +//.p double *array -- where to put the values +// int size -- size of the array +// double xmin -- value associated with index 0 +// double xmax -- value associated with index (size-1) +// +//------------------------------------------------------------ +void qwtLinSpace(double *array, int size, double xmin, double xmax) +{ + int i, imax; + imax = size -1; + double step; + + if (size > 0) + { + array[0] = xmin; + array[imax] = xmax; + step = (xmax - xmin) / double(imax); + + for (i=1;i<imax;i++) + array[i] = xmin + double(i) * step; + } + +} + + +//------------------------------------------------------------ +// +//.F qwtLogSpace +// Create an array of logarithmically equally spaced values +// +//.u Syntax +//.f void qwtLogSpace(double *array, int size, double xmin, double xmax) +// +//.u Parameters +//.p double *array -- where to put the values +// int size -- size of the array +// double xmin -- value associated with index 0 +// double xmax -- value associated with index (size-1) +//------------------------------------------------------------ +void qwtLogSpace(double *array, int size, double xmin, double xmax) +{ + int i, imax; + + double lxmin,lxmax; + double lstep; + + imax = size -1; + + if ((xmin <= 0.0) || (xmax <= 0.0) || (size <= 0)) + return; + + array[0] = xmin; + array[imax] = xmax; + lxmin = log(xmin); + lxmax = log(xmax); + + lstep = (lxmax - lxmin) / double(imax); + + for (i=1; i<imax;i++) + array[i] = exp(lxmin + double(i) * lstep); + +} diff --git a/attic/muse2-oom/muse2/muse/widgets/mmath.h b/attic/muse2-oom/muse2/muse/widgets/mmath.h new file mode 100644 index 00000000..51381047 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mmath.h @@ -0,0 +1,77 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mmath.h,v 1.1.1.1 2003/10/27 18:54:47 wschweer Exp $ +// +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __MATH_H__ +#define __MATH_H__ + +#define LOG_MIN 1.0e-100 +#define LOG_MAX 1.0e100 + +double qwtCeil125(double x); +double qwtFloor125(double x); +void qwtTwistArray(double *array, int size); +int qwtChkMono(double *array, int size); +void qwtLinSpace(double *array, int size, double xmin, double xmax); +void qwtLogSpace(double *array, int size, double xmin, double xmax); + +template <class T> +inline int qwtSign(const T& x) +{ + if (x > T(0)) + return 1; + else if (x < T(0)) + return (-1); + else + return 0; +} + +inline int qwtInt(double x) +{ + return int(rint(x)); +} + +template <class T> +inline T qwtAbs (const T& x) +{ + return( x > T(0) ? x : -x ); +} + +template <class T> +inline const T& qwtMax (const T& x, const T& y) +{ + return ( x > y ? x : y ); +} + +template <class T> +inline const T& qwtMin ( const T& x, const T& y) +{ + return ( x < y ? x : y ); +} + + +template <class T> +T qwtLim(const T& x, const T& x1, const T& x2) +{ + T rv; + T xmin, xmax; + + xmin = qwtMin(x1, x2); + xmax = qwtMax(x1, x2); + + if ( x < xmin ) + rv = xmin; + else if ( x > xmax ) + rv = xmax; + else + rv = x; + + return rv; +} + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/moc_ttoolbar.cpp b/attic/muse2-oom/muse2/muse/widgets/moc_ttoolbar.cpp new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/moc_ttoolbar.cpp diff --git a/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.cpp b/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.cpp new file mode 100644 index 00000000..38d02735 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.cpp @@ -0,0 +1,1831 @@ +//========================================================= +// MusE +// Linux Music Editor +// (C) Copyright 2010 Werner Schweer and others (ws@seh.de) +//========================================================= + +#include <QTimer> +#include <QMessageBox> +#include <QStandardItemModel> +#include <QStandardItem> + +#include <math.h> +#include <string.h> + +#include "mtrackinfo.h" +#include "song.h" +#include "globals.h" +#include "config.h" +#include "gconfig.h" +#include "midiport.h" +#include "minstrument.h" +#include "mididev.h" +#include "utils.h" +#include "audio.h" +#include "midi.h" +#include "midictrl.h" +#include "icons.h" +#include "app.h" +#include "route.h" +#include "popupmenu.h" +#include "pctable.h" + +//--------------------------------------------------------- +// setTrack +//--------------------------------------------------------- + +void MidiTrackInfo::setTrack(Track* t) +{ + if(!t) + { + selected = 0; + return; + } + + if(!t->isMidiTrack()) + return; + selected = t; + + QPalette pal; + if(selected->type() == Track::DRUM) + pal.setColor(trackNameLabel->backgroundRole(), config.drumTrackLabelBg); + else + pal.setColor(trackNameLabel->backgroundRole(), config.midiTrackLabelBg); + trackNameLabel->setPalette(pal); + + updateTrackInfo(-1); +} + +//--------------------------------------------------------- +// midiTrackInfo +//--------------------------------------------------------- + +MidiTrackInfo::MidiTrackInfo(QWidget* parent, Track* sel_track) : QFrame(parent)//QWidget(parent) +{ + setupUi(this); + _midiDetect = false; + _progRowNum = 0; + editing = false; + _matrix = new QList<int>; + _tableModel = new ProgramChangeTableModel(this); + tableView = new ProgramChangeTable(this); + tableView->setMinimumHeight(150); + tableView->horizontalHeader()->setStretchLastSection(true);//setResizeMode(1,QHeaderView::Stretch); + tableBox->addWidget(tableView); + selected = sel_track; + + // Since program covers 3 controls at once, it is in 'midi controller' units rather than 'gui control' units. + //program = -1; + program = CTRL_VAL_UNKNOWN; + pan = -65; + volume = -1; + + setFont(config.fonts[2]); + + //iChanDetectLabel->setPixmap(*darkgreendotIcon); + iChanDetectLabel->setPixmap(*darkRedLedIcon); + + QIcon recEchoIconSet; + recEchoIconSet.addPixmap(*midiThruOnIcon, QIcon::Normal, QIcon::On); + recEchoIconSet.addPixmap(*midiThruOffIcon, QIcon::Normal, QIcon::Off); + recEchoButton->setIcon(recEchoIconSet); + recEchoButton->setIconSize(midiThruOnIcon->size()); + + // MusE-2: AlignCenter and WordBreak are set in the ui(3) file, but not supported by QLabel. Turn them on here. + trackNameLabel->setAlignment(Qt::AlignCenter); + //Qt::TextWordWrap is not available for alignment in Qt4 - Orcan + // MusE-2 Tested: TextWrapAnywhere actually works, but in fact it takes precedence + // over word wrap, so I found it is not really desirable. Maybe with a user setting... + //trackNameLabel->setAlignment(Qt::AlignCenter | Qt::TextWordWrap | Qt::TextWrapAnywhere); + //trackNameLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum)); + + if(selected) + { + trackNameLabel->setObjectName(selected->cname()); + QPalette pal; + //pal.setColor(trackNameLabel->backgroundRole(), QColor(0, 160, 255)); // Med blue + if(selected->type() == Track::DRUM) + pal.setColor(trackNameLabel->backgroundRole(), config.drumTrackLabelBg); + else + pal.setColor(trackNameLabel->backgroundRole(), config.midiTrackLabelBg); + trackNameLabel->setPalette(pal); + } + //else + //{ + // pal.setColor(trackNameLabel->backgroundRole(), config.midiTrackLabelBg); + // trackNameLabel->setPalette(pal); + //} + + //trackNameLabel->setStyleSheet(QString("background-color: ") + QColor(0, 160, 255).name()); // Med blue + trackNameLabel->setWordWrap(true); + trackNameLabel->setAutoFillBackground(true); + trackNameLabel->setTextFormat(Qt::PlainText); + trackNameLabel->setLineWidth(2); + trackNameLabel->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel); + trackNameLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum)); + + setLabelText(); + setLabelFont(); + + QStandardItem* hid = new QStandardItem(tr("I")); + QStandardItem* hstat = new QStandardItem(true); + hstat->setCheckable(true); + hstat->setCheckState(Qt::Unchecked); + QStandardItem* hpatch = new QStandardItem(tr("Patch")); + _tableModel->setHorizontalHeaderItem(0, hid); + _tableModel->setHorizontalHeaderItem(1, hstat); + _tableModel->setHorizontalHeaderItem(2, hpatch); + + tableView->setModel(_tableModel); + tableView->setColumnWidth(1, 20); + tableView->setColumnHidden(0, true); + + btnUp->setIcon(*upPCIcon); + btnDown->setIcon(*downPCIcon); + btnDelete->setIcon(*garbagePCIcon); + btnUp->setIconSize(upPCIcon->size()); + btnDown->setIconSize(downPCIcon->size()); + btnDelete->setIconSize(garbagePCIcon->size()); + + connect(tableView, SIGNAL(rowOrderChanged()), SLOT(rebuildMatrix())); + connect(_tableModel, SIGNAL(itemChanged(QStandardItem*)), SLOT(matrixItemChanged(QStandardItem*))); + connect(chkAdvanced, SIGNAL(stateChanged(int)), SLOT(toggleAdvanced(int))); + connect(btnDelete, SIGNAL(clicked(bool)), SLOT(deleteSelectedPatches(bool))); + connect(btnUp, SIGNAL(clicked(bool)), SLOT(movePatchUp(bool))); + connect(btnDown, SIGNAL(clicked(bool)), SLOT(movePatchDown(bool))); + + //setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding)); + + connect(iPatch, SIGNAL(released()), SLOT(instrPopup())); + + ///pop = new QMenu(iPatch); + //pop->setCheckable(false); // not needed in Qt4 + + // Removed by Tim. p3.3.9 + //connect(iName, SIGNAL(returnPressed()), SLOT(iNameChanged())); + + connect(iOutputChannel, SIGNAL(valueChanged(int)), SLOT(iOutputChannelChanged(int))); + ///connect(iInputChannel, SIGNAL(textChanged(const QString&)), SLOT(iInputChannelChanged(const QString&))); + connect(iHBank, SIGNAL(valueChanged(int)), SLOT(iProgHBankChanged())); + connect(iLBank, SIGNAL(valueChanged(int)), SLOT(iProgLBankChanged())); + connect(iProgram, SIGNAL(valueChanged(int)), SLOT(iProgramChanged())); + connect(iHBank, SIGNAL(doubleClicked()), SLOT(iProgramDoubleClicked())); + connect(iLBank, SIGNAL(doubleClicked()), SLOT(iProgramDoubleClicked())); + connect(iProgram, SIGNAL(doubleClicked()), SLOT(iProgramDoubleClicked())); + connect(iLautst, SIGNAL(valueChanged(int)), SLOT(iLautstChanged(int))); + connect(iLautst, SIGNAL(doubleClicked()), SLOT(iLautstDoubleClicked())); + connect(iTransp, SIGNAL(valueChanged(int)), SLOT(iTranspChanged(int))); + connect(iAnschl, SIGNAL(valueChanged(int)), SLOT(iAnschlChanged(int))); + connect(iVerz, SIGNAL(valueChanged(int)), SLOT(iVerzChanged(int))); + connect(iLen, SIGNAL(valueChanged(int)), SLOT(iLenChanged(int))); + connect(iKompr, SIGNAL(valueChanged(int)), SLOT(iKomprChanged(int))); + connect(iPan, SIGNAL(valueChanged(int)), SLOT(iPanChanged(int))); + connect(iPan, SIGNAL(doubleClicked()), SLOT(iPanDoubleClicked())); + connect(iOutput, SIGNAL(activated(int)), SLOT(iOutputPortChanged(int))); + ///connect(iInput, SIGNAL(textChanged(const QString&)), SLOT(iInputPortChanged(const QString&))); + connect(recordButton, SIGNAL(clicked()), SLOT(recordClicked())); + connect(progRecButton, SIGNAL(clicked()), SLOT(progRecClicked())); + connect(volRecButton, SIGNAL(clicked()), SLOT(volRecClicked())); + connect(panRecButton, SIGNAL(clicked()), SLOT(panRecClicked())); + connect(recEchoButton, SIGNAL(toggled(bool)), SLOT(recEchoToggled(bool))); + connect(iRButton, SIGNAL(pressed()), SLOT(inRoutesPressed())); + + // TODO: Works OK, but disabled for now, until we figure out what to do about multiple out routes and display values... + //oRButton->setEnabled(false); + //oRButton->setVisible(false); + //connect(oRButton, SIGNAL(pressed()), SLOT(outRoutesPressed())); + + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + connect(muse, SIGNAL(configChanged()), SLOT(configChanged())); + + connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat())); +} + +//--------------------------------------------------------- +// heartBeat +//--------------------------------------------------------- + +void MidiTrackInfo::heartBeat() +{ + ///if(!showTrackinfoFlag || !selected) + if(!isVisible() || !isEnabled() || !selected) + return; + switch(selected->type()) + { + case Track::MIDI: + case Track::DRUM: + { + MidiTrack* track = (MidiTrack*)selected; + + int outChannel = track->outChannel(); + int outPort = track->outPort(); + ///int ichMask = track->inChannelMask(); + //int iptMask = track->inPortMask(); + ///unsigned int iptMask = track->inPortMask(); + + MidiPort* mp = &midiPorts[outPort]; + + // Set record echo. + //if(recEchoButton->isChecked() != track->recEcho()) + //{ + // recEchoButton->blockSignals(true); + // recEchoButton->setChecked(track->recEcho()); + // recEchoButton->blockSignals(false); + //} + + // Check for detection of midi general activity on chosen channels... + int mpt = 0; + //int mch = 0; + RouteList* rl = track->inRoutes(); + + ciRoute r = rl->begin(); + //for( ; mpt < MIDI_PORTS; ++mpt) + for( ; r != rl->end(); ++r) + { + //if(!r->isValid() || ((r->type != Route::ALSA_MIDI_ROUTE) && (r->type != Route::JACK_MIDI_ROUTE))) + //if(!r->isValid() || (r->type != Route::MIDI_DEVICE_ROUTE)) + if(!r->isValid() || (r->type != Route::MIDI_PORT_ROUTE)) // p3.3.49 + continue; + + // NOTE: TODO: Code for channelless events like sysex, ** IF we end up using the 'special channel 17' method. + //if(r->channel == -1) + if(r->channel == -1 || r->channel == 0) // p3.3.50 + continue; + + // No port assigned to the device? + //mpt = r->device->midiPort(); + mpt = r->midiPort; // p3.3.49 + if(mpt < 0 || mpt >= MIDI_PORTS) + continue; + + //for(; mch < MIDI_CHANNELS; ++mch) + //{ + //if(midiPorts[mpt].syncInfo().actDetect(mch) && (iptMask & (1 << mpt)) && (ichMask & (1 << mch)) ) + //if((iptMask & bitShiftLU[mpt]) && (midiPorts[mpt].syncInfo().actDetectBits() & ichMask) ) + //if(midiPorts[mpt].syncInfo().actDetectBits() & bitShiftLU[r->channel]) + if(midiPorts[mpt].syncInfo().actDetectBits() & r->channel) // p3.3.50 Use new channel mask. + { + //if(iChanTextLabel->paletteBackgroundColor() != green) + // iChanTextLabel->setPaletteBackgroundColor(green); + //if(iChanDetectLabel->pixmap() != greendotIcon) + if(!_midiDetect) + { + //printf("Arranger::midiTrackInfoHeartBeat setting green icon\n"); + + _midiDetect = true; + //iChanDetectLabel->setPixmap(*greendotIcon); + iChanDetectLabel->setPixmap(*redLedIcon); + } + break; + } + //} + } + // No activity detected? + //if(mch == MIDI_CHANNELS) + //if(mpt == MIDI_PORTS) + if(r == rl->end()) + { + //if(iChanTextLabel->paletteBackgroundColor() != darkGreen) + // iChanTextLabel->setPaletteBackgroundColor(darkGreen); + //if(iChanDetectLabel->pixmap() != darkgreendotIcon) + if(_midiDetect) + { + //printf("Arranger::midiTrackInfoHeartBeat setting darkgreen icon\n"); + + _midiDetect = false; + //iChanDetectLabel->setPixmap(*darkgreendotIcon); + iChanDetectLabel->setPixmap(*darkRedLedIcon); + } + } + + int nprogram = mp->hwCtrlState(outChannel, CTRL_PROGRAM); + if(nprogram == CTRL_VAL_UNKNOWN) + { + if(program != CTRL_VAL_UNKNOWN) + { + //printf("Arranger::midiTrackInfoHeartBeat setting program to unknown\n"); + + program = CTRL_VAL_UNKNOWN; + if(iHBank->value() != 0) + { + iHBank->blockSignals(true); + iHBank->setValue(0); + iHBank->blockSignals(false); + } + if(iLBank->value() != 0) + { + iLBank->blockSignals(true); + iLBank->setValue(0); + iLBank->blockSignals(false); + } + if(iProgram->value() != 0) + { + iProgram->blockSignals(true); + iProgram->setValue(0); + iProgram->blockSignals(false); + } + } + + nprogram = mp->lastValidHWCtrlState(outChannel, CTRL_PROGRAM); + if(nprogram == CTRL_VAL_UNKNOWN) + { + //const char* n = "<unknown>"; + const QString n(tr("Select Patch")); + //if(strcmp(iPatch->text().toLatin1().constData(), n) != 0) + if(iPatch->text() != n) + { + //printf("Arranger::midiTrackInfoHeartBeat setting patch <unknown>\n"); + + iPatch->setText(n); + } + } + else + { + MidiInstrument* instr = mp->instrument(); + QString name = instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM); + if(name.isEmpty()) + { + const QString n("???"); + if(iPatch->text() != n) + iPatch->setText(n); + } + else + if(iPatch->text() != name) + { + //printf("Arranger::midiTrackInfoHeartBeat setting patch name\n"); + + iPatch->setText(name); + } + } + } + else + if(program != nprogram) + { + program = nprogram; + + //int hb, lb, pr; + //if (program == CTRL_VAL_UNKNOWN) { + // hb = lb = pr = 0; + // iPatch->setText("---"); + // } + //else + //{ + MidiInstrument* instr = mp->instrument(); + QString name = instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM); + if(iPatch->text() != name) + iPatch->setText(name); + + int hb = ((program >> 16) & 0xff) + 1; + if (hb == 0x100) + hb = 0; + int lb = ((program >> 8) & 0xff) + 1; + if (lb == 0x100) + lb = 0; + int pr = (program & 0xff) + 1; + if (pr == 0x100) + pr = 0; + //} + + //printf("Arranger::midiTrackInfoHeartBeat setting program\n"); + + if(iHBank->value() != hb) + { + iHBank->blockSignals(true); + iHBank->setValue(hb); + iHBank->blockSignals(false); + } + if(iLBank->value() != lb) + { + iLBank->blockSignals(true); + iLBank->setValue(lb); + iLBank->blockSignals(false); + } + if(iProgram->value() != pr) + { + iProgram->blockSignals(true); + iProgram->setValue(pr); + iProgram->blockSignals(false); + } + + } + + MidiController* mc = mp->midiController(CTRL_VOLUME); + int mn = mc->minVal(); + int v = mp->hwCtrlState(outChannel, CTRL_VOLUME); + if(v == CTRL_VAL_UNKNOWN) + //{ + //v = mc->initVal(); + //if(v == CTRL_VAL_UNKNOWN) + // v = 0; + v = mn - 1; + //} + else + // Auto bias... + v -= mc->bias(); + if(volume != v) + { + volume = v; + if(iLautst->value() != v) + { + //printf("Arranger::midiTrackInfoHeartBeat setting volume\n"); + + iLautst->blockSignals(true); + //iLautst->setRange(mn - 1, mc->maxVal()); + iLautst->setValue(v); + iLautst->blockSignals(false); + } + } + + mc = mp->midiController(CTRL_PANPOT); + mn = mc->minVal(); + v = mp->hwCtrlState(outChannel, CTRL_PANPOT); + if(v == CTRL_VAL_UNKNOWN) + //{ + //v = mc->initVal(); + //if(v == CTRL_VAL_UNKNOWN) + // v = 0; + v = mn - 1; + //} + else + // Auto bias... + v -= mc->bias(); + if(pan != v) + { + pan = v; + if(iPan->value() != v) + { + //printf("Arranger::midiTrackInfoHeartBeat setting pan\n"); + + iPan->blockSignals(true); + //iPan->setRange(mn - 1, mc->maxVal()); + iPan->setValue(v); + iPan->blockSignals(false); + } + } + + // Does it include a midi controller value adjustment? Then handle it... + //if(flags & SC_MIDI_CONTROLLER) + // seek(); + + /* + if(iTransp->value() != track->transposition) + iTransp->setValue(track->transposition); + if(iAnschl->value() != track->velocity) + iAnschl->setValue(track->velocity); + if(iVerz->value() != track->delay) + iVerz->setValue(track->delay); + if(iLen->value() != track->len) + iLen->setValue(track->len); + if(iKompr->value() != track->compression) + iKompr->setValue(track->compression); + */ + } + break; + + case Track::WAVE: + case Track::AUDIO_OUTPUT: + case Track::AUDIO_INPUT: + case Track::AUDIO_GROUP: + case Track::AUDIO_AUX: + case Track::AUDIO_SOFTSYNTH: + break; + } +} + +//--------------------------------------------------------- +// configChanged +//--------------------------------------------------------- + +void MidiTrackInfo::configChanged() + { + //printf("MidiTrackInfo::configChanged\n"); + + //if (config.canvasBgPixmap.isEmpty()) { + // canvas->setBg(config.partCanvasBg); + // canvas->setBg(QPixmap()); + //} + //else { + // canvas->setBg(QPixmap(config.canvasBgPixmap)); + //} + + setFont(config.fonts[2]); + //updateTrackInfo(type); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void MidiTrackInfo::songChanged(int type) +{ + // Is it simply a midi controller value adjustment? Forget it. + if(type == SC_MIDI_CONTROLLER) + return; + if(type == SC_SELECTION) + return; + if(!isVisible()) + return; + updateTrackInfo(type); +} + +//--------------------------------------------------------- +// setLabelText +//--------------------------------------------------------- + +void MidiTrackInfo::setLabelText() +{ + MidiTrack* track = (MidiTrack*)selected; + if(track) + trackNameLabel->setText(track->name()); + else + trackNameLabel->setText(QString()); +} + +//--------------------------------------------------------- +// setLabelFont +//--------------------------------------------------------- + +void MidiTrackInfo::setLabelFont() +{ + //if(!selected) + // return; + //MidiTrack* track = (MidiTrack*)selected; + + // Use the new font #6 I created just for these labels (so far). + // Set the label's font. + trackNameLabel->setFont(config.fonts[6]); + // Dealing with a horizontally constrained label. Ignore vertical. Use a minimum readable point size. + autoAdjustFontSize(trackNameLabel, trackNameLabel->text(), false, true, config.fonts[6].pointSize(), 5); +} + +//--------------------------------------------------------- +// iOutputChannelChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iOutputChannelChanged(int channel) + { + --channel; + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + if (channel != track->outChannel()) { + // Changed by T356. + //track->setOutChannel(channel); + audio->msgIdle(true); + //audio->msgSetTrackOutChannel(track, channel); + track->setOutChanAndUpdate(channel); + audio->msgIdle(false); + + // may result in adding/removing mixer strip: + //song->update(-1); + song->update(SC_MIDI_TRACK_PROP); + } + } + +//--------------------------------------------------------- +// iOutputPortChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iOutputPortChanged(int index) + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + if (index == track->outPort()) + return; + // Changed by T356. + //track->setOutPort(index); + audio->msgIdle(true); + //audio->msgSetTrackOutPort(track, index); + track->setOutPortAndUpdate(index); + _tableModel->clear(); + rebuildMatrix(); + audio->msgIdle(false); + + song->update(SC_MIDI_TRACK_PROP); + } + +//--------------------------------------------------------- +// routingPopupMenuActivated +//--------------------------------------------------------- + +//void MidiTrackInfo::routingPopupMenuActivated(int n) +void MidiTrackInfo::routingPopupMenuActivated(QAction* act) +{ + ///if(!midiTrackInfo || gRoutingPopupMenuMaster != midiTrackInfo || !selected || !selected->isMidiTrack()) + if((gRoutingPopupMenuMaster != this) || !selected || !selected->isMidiTrack()) + return; + muse->routingPopupMenuActivated(selected, act->data().toInt()); +} + +#if 0 +//--------------------------------------------------------- +// routingPopupViewActivated +//--------------------------------------------------------- + +void MidiTrackInfo::routingPopupViewActivated(const QModelIndex& mdi) +{ + ///if(!midiTrackInfo || gRoutingPopupMenuMaster != midiTrackInfo || !selected || !selected->isMidiTrack()) + if(gRoutingPopupMenuMaster != this || !selected || !selected->isMidiTrack()) + return; + muse->routingPopupMenuActivated(selected, mdi.data().toInt()); +} +#endif + +//--------------------------------------------------------- +// inRoutesPressed +//--------------------------------------------------------- + +void MidiTrackInfo::inRoutesPressed() +{ + if(!selected) + return; + if(!selected->isMidiTrack()) + return; + + PopupMenu* pup = muse->prepareRoutingPopupMenu(selected, false); + //PopupView* pup = muse->prepareRoutingPopupView(selected, false); + + if(!pup) { + int ret = QMessageBox::warning(this, tr("No inputs"), + tr("There are no midi inputs.\n" + "Do you want to open the midi configuration dialog?"), + QMessageBox::Ok | QMessageBox::Cancel, + QMessageBox::Ok); + if (ret == QMessageBox::Ok) { + // printf("open config midi ports\n"); + muse->configMidiPorts(); + } + return; + } + + ///gRoutingPopupMenuMaster = midiTrackInfo; + gRoutingPopupMenuMaster = this; + connect(pup, SIGNAL(triggered(QAction*)), SLOT(routingPopupMenuActivated(QAction*))); + //connect(pup, SIGNAL(activated(const QModelIndex&)), SLOT(routingPopupViewActivated(const QModelIndex&))); + connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide())); + //connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupViewAboutToHide())); + pup->popup(QCursor::pos()); + //pup->setVisible(true); + iRButton->setDown(false); + return; +} + +//--------------------------------------------------------- +// outRoutesPressed +//--------------------------------------------------------- + +void MidiTrackInfo::outRoutesPressed() +{ + if(!selected) + return; + if(!selected->isMidiTrack()) + return; + + PopupMenu* pup = muse->prepareRoutingPopupMenu(selected, true); + if(!pup) + return; + + ///gRoutingPopupMenuMaster = midiTrackInfo; + gRoutingPopupMenuMaster = this; + connect(pup, SIGNAL(triggered(QAction*)), SLOT(routingPopupMenuActivated(QAction*))); + connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide())); + pup->popup(QCursor::pos()); + ///oRButton->setDown(false); + return; +} + +//--------------------------------------------------------- +// iProgHBankChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iProgHBankChanged() + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int channel = track->outChannel(); + int port = track->outPort(); + int hbank = iHBank->value(); + int lbank = iLBank->value(); + int prog = iProgram->value(); + + if (hbank > 0 && hbank < 129) + hbank -= 1; + else + hbank = 0xff; + if (lbank > 0 && lbank < 129) + lbank -= 1; + else + lbank = 0xff; + if (prog > 0 && prog < 129) + prog -= 1; + else + prog = 0xff; + + MidiPort* mp = &midiPorts[port]; + if(prog == 0xff && hbank == 0xff && lbank == 0xff) + { + program = CTRL_VAL_UNKNOWN; + if(mp->hwCtrlState(channel, CTRL_PROGRAM) != CTRL_VAL_UNKNOWN) + audio->msgSetHwCtrlState(mp, channel, CTRL_PROGRAM, CTRL_VAL_UNKNOWN); + return; + } + + int np = mp->hwCtrlState(channel, CTRL_PROGRAM); + if(np == CTRL_VAL_UNKNOWN) + { + np = mp->lastValidHWCtrlState(channel, CTRL_PROGRAM); + if(np != CTRL_VAL_UNKNOWN) + { + lbank = (np & 0xff00) >> 8; + prog = np & 0xff; + if(prog == 0xff) + prog = 0; + int ilbnk = lbank; + int iprog = prog; + if(ilbnk == 0xff) + ilbnk = -1; + ++ilbnk; + ++iprog; + iLBank->blockSignals(true); + iProgram->blockSignals(true); + iLBank->setValue(ilbnk); + iProgram->setValue(iprog); + iLBank->blockSignals(false); + iProgram->blockSignals(false); + } + } + + if(prog == 0xff && (hbank != 0xff || lbank != 0xff)) + { + prog = 0; + iProgram->blockSignals(true); + iProgram->setValue(1); + iProgram->blockSignals(false); + } + program = (hbank << 16) + (lbank << 8) + prog; + MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, program); + audio->msgPlayMidiEvent(&ev); + + MidiInstrument* instr = mp->instrument(); + iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM)); +// updateTrackInfo(); + } + +//--------------------------------------------------------- +// iProgLBankChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iProgLBankChanged() + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int channel = track->outChannel(); + int port = track->outPort(); + int hbank = iHBank->value(); + int lbank = iLBank->value(); + int prog = iProgram->value(); + + if (hbank > 0 && hbank < 129) + hbank -= 1; + else + hbank = 0xff; + if (lbank > 0 && lbank < 129) + lbank -= 1; + else + lbank = 0xff; + if (prog > 0 && prog < 129) + prog -= 1; + else + prog = 0xff; + + MidiPort* mp = &midiPorts[port]; + if(prog == 0xff && hbank == 0xff && lbank == 0xff) + { + program = CTRL_VAL_UNKNOWN; + if(mp->hwCtrlState(channel, CTRL_PROGRAM) != CTRL_VAL_UNKNOWN) + audio->msgSetHwCtrlState(mp, channel, CTRL_PROGRAM, CTRL_VAL_UNKNOWN); + return; + } + + int np = mp->hwCtrlState(channel, CTRL_PROGRAM); + if(np == CTRL_VAL_UNKNOWN) + { + np = mp->lastValidHWCtrlState(channel, CTRL_PROGRAM); + if(np != CTRL_VAL_UNKNOWN) + { + hbank = (np & 0xff0000) >> 16; + prog = np & 0xff; + if(prog == 0xff) + prog = 0; + int ihbnk = hbank; + int iprog = prog; + if(ihbnk == 0xff) + ihbnk = -1; + ++ihbnk; + ++iprog; + iHBank->blockSignals(true); + iProgram->blockSignals(true); + iHBank->setValue(ihbnk); + iProgram->setValue(iprog); + iHBank->blockSignals(false); + iProgram->blockSignals(false); + } + } + + if(prog == 0xff && (hbank != 0xff || lbank != 0xff)) + { + prog = 0; + iProgram->blockSignals(true); + iProgram->setValue(1); + iProgram->blockSignals(false); + } + program = (hbank << 16) + (lbank << 8) + prog; + MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, program); + audio->msgPlayMidiEvent(&ev); + + MidiInstrument* instr = mp->instrument(); + iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM)); +// updateTrackInfo(); + } + +//--------------------------------------------------------- +// iProgramChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iProgramChanged() + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int channel = track->outChannel(); + int port = track->outPort(); + int hbank = iHBank->value(); + int lbank = iLBank->value(); + int prog = iProgram->value(); + + if (hbank > 0 && hbank < 129) + hbank -= 1; + else + hbank = 0xff; + if (lbank > 0 && lbank < 129) + lbank -= 1; + else + lbank = 0xff; + if (prog > 0 && prog < 129) + prog -= 1; + else + prog = 0xff; + + MidiPort *mp = &midiPorts[port]; + if(prog == 0xff) + { + program = CTRL_VAL_UNKNOWN; + iHBank->blockSignals(true); + iLBank->blockSignals(true); + iHBank->setValue(0); + iLBank->setValue(0); + iHBank->blockSignals(false); + iLBank->blockSignals(false); + + if(mp->hwCtrlState(channel, CTRL_PROGRAM) != CTRL_VAL_UNKNOWN) + audio->msgSetHwCtrlState(mp, channel, CTRL_PROGRAM, CTRL_VAL_UNKNOWN); + return; + } + else + { + int np = mp->hwCtrlState(channel, CTRL_PROGRAM); + if(np == CTRL_VAL_UNKNOWN) + { + np = mp->lastValidHWCtrlState(channel, CTRL_PROGRAM); + if(np != CTRL_VAL_UNKNOWN) + { + hbank = (np & 0xff0000) >> 16; + lbank = (np & 0xff00) >> 8; + int ihbnk = hbank; + int ilbnk = lbank; + if(ihbnk == 0xff) + ihbnk = -1; + if(ilbnk == 0xff) + ilbnk = -1; + ++ihbnk; + ++ilbnk; + iHBank->blockSignals(true); + iLBank->blockSignals(true); + iHBank->setValue(ihbnk); + iLBank->setValue(ilbnk); + iHBank->blockSignals(false); + iLBank->blockSignals(false); + } + } + program = (hbank << 16) + (lbank << 8) + prog; + MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, program); + audio->msgPlayMidiEvent(&ev); + + MidiInstrument* instr = mp->instrument(); + iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM)); + } + +// updateTrackInfo(); + } + +//--------------------------------------------------------- +// iLautstChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iLautstChanged(int val) + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int outPort = track->outPort(); + int chan = track->outChannel(); + MidiPort* mp = &midiPorts[outPort]; + MidiController* mctl = mp->midiController(CTRL_VOLUME); + if((val < mctl->minVal()) || (val > mctl->maxVal())) + { + if(mp->hwCtrlState(chan, CTRL_VOLUME) != CTRL_VAL_UNKNOWN) + audio->msgSetHwCtrlState(mp, chan, CTRL_VOLUME, CTRL_VAL_UNKNOWN); + } + else + { + val += mctl->bias(); + + MidiPlayEvent ev(0, outPort, chan, + ME_CONTROLLER, CTRL_VOLUME, val); + audio->msgPlayMidiEvent(&ev); + } + song->update(SC_MIDI_CONTROLLER); + } + +//--------------------------------------------------------- +// iTranspChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iTranspChanged(int val) + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + track->transposition = val; + song->update(SC_MIDI_TRACK_PROP); + } + +//--------------------------------------------------------- +// iAnschlChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iAnschlChanged(int val) + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + track->velocity = val; + song->update(SC_MIDI_TRACK_PROP); + } + +//--------------------------------------------------------- +// iVerzChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iVerzChanged(int val) + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + track->delay = val; + song->update(SC_MIDI_TRACK_PROP); + } + +//--------------------------------------------------------- +// iLenChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iLenChanged(int val) + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + track->len = val; + song->update(SC_MIDI_TRACK_PROP); + } + +//--------------------------------------------------------- +// iKomprChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iKomprChanged(int val) + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + track->compression = val; + song->update(SC_MIDI_TRACK_PROP); + } + +//--------------------------------------------------------- +// iPanChanged +//--------------------------------------------------------- + +void MidiTrackInfo::iPanChanged(int val) + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int port = track->outPort(); + int chan = track->outChannel(); + MidiPort* mp = &midiPorts[port]; + MidiController* mctl = mp->midiController(CTRL_PANPOT); + if((val < mctl->minVal()) || (val > mctl->maxVal())) + { + if(mp->hwCtrlState(chan, CTRL_PANPOT) != CTRL_VAL_UNKNOWN) + audio->msgSetHwCtrlState(mp, chan, CTRL_PANPOT, CTRL_VAL_UNKNOWN); + } + else + { + val += mctl->bias(); + + // Realtime Change: + MidiPlayEvent ev(0, port, chan, + ME_CONTROLLER, CTRL_PANPOT, val); + audio->msgPlayMidiEvent(&ev); + } + song->update(SC_MIDI_CONTROLLER); + } + +//--------------------------------------------------------- +// instrPopup +//--------------------------------------------------------- + +void MidiTrackInfo::instrPopup() +{ + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int channel = track->outChannel(); + int port = track->outPort(); + MidiInstrument* instr = midiPorts[port].instrument(); + QMenu* pup = new QMenu; + ///instr->populatePatchPopup(pop, channel, song->mtype(), track->type() == Track::DRUM); + instr->populatePatchPopup(pup, channel, song->mtype(), track->type() == Track::DRUM); + + ///if(pop->actions().count() == 0) + /// return; + if(pup->actions().count() == 0) + { + delete pup; + return; + } + + ///QAction *act = pop->exec(iPatch->mapToGlobal(QPoint(10,5))); + QAction *act = pup->exec(iPatch->mapToGlobal(QPoint(10,5))); + if (act) { + //int rv = act->data().toInt(); + QVariant _data = act->data(); + QStringList lst = _data.toStringList(); + if(!lst.isEmpty()) + { + QString str = lst.at(0); + QString pg = "";//lst.at(1); + int rv = str.toInt(); + + MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, rv); + audio->msgPlayMidiEvent(&ev); + updateTrackInfo(-1); + + //At this point we add the event to the list. + if(lst.size() > 1) + { + pg = lst.at(1); + } + //QLabel label; + //label.setText(pg); + QString label = " " + pg + (pg.isEmpty() ? "" : ":\n ") + act->text(); + //QList<QStandardItem*> found = _tableModel->findItems(label, Qt::MatchExactly, 1); + //if(found.size() == 0) + //{ + QList<QStandardItem*> rowData; + QStandardItem* chk = new QStandardItem(true); + chk->setCheckable(true); + chk->setCheckState(Qt::Checked); + chk->setToolTip(tr("Add to patch sequence")); + //_tableModel->setItem(row, 0, chk); + QStandardItem* patch = new QStandardItem(label); + patch->setToolTip(label); + patch->setEditable(false); + rowData.append(new QStandardItem(str)); + rowData.append(chk); + rowData.append(patch); + //_tableModel->setItem(row, 1, patch); + //_tableModel->setItem(row, 2, new QStandardItem(str)); + for(int i=0; i < _tableModel->rowCount(); ++i) + { + QStandardItem* item = _tableModel->item(i, 1); + item->setCheckState(Qt::Unchecked); + } + _tableModel->insertRow(0, rowData); + tableView->resizeRowToContents(0); + tableView->selectRow(0); + _matrix->append(0); + tableView->setColumnWidth(1, 20); + tableView->setColumnWidth(0, 1); + /* tableView->setColumnHidden(0, true); + if(_tableModel->rowCount() == 1) + { + QStringList headers; + headers.append(tr("I")); + headers.append(tr("M")); + headers.append(tr("Patch")); + _tableModel->setHorizontalHeaderLabels(headers); + }*/ + /*} + else + { + for(int i=0; i < _tableModel->rowCount(); ++i) + { + QStandardItem* item = _tableModel->item(i, 0); + item->setCheckState(Qt::Unchecked); + } + //Select the patch that was a duplicate only + QStandardItem* dup = found.at(0); + QStandardItem* dchk = _tableModel->item(dup->row(), 0); + dchk->setCheckState(Qt::Checked); + }*/ + } + } + + delete pup; +} + +//--------------------------------------------------------- +// recEchoToggled +//--------------------------------------------------------- + +void MidiTrackInfo::recEchoToggled(bool v) +{ + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + track->setRecEcho(v); + song->update(SC_MIDI_TRACK_PROP); +} + +//--------------------------------------------------------- +// iProgramDoubleClicked +//--------------------------------------------------------- + +void MidiTrackInfo::iProgramDoubleClicked() +{ + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int port = track->outPort(); + int chan = track->outChannel(); + MidiPort* mp = &midiPorts[port]; + MidiController* mctl = mp->midiController(CTRL_PROGRAM); + + if(!track || !mctl) + return; + + int lastv = mp->lastValidHWCtrlState(chan, CTRL_PROGRAM); + int curv = mp->hwCtrlState(chan, CTRL_PROGRAM); + + if(curv == CTRL_VAL_UNKNOWN) + { + // If no value has ever been set yet, use the current knob value + // (or the controller's initial value?) to 'turn on' the controller. + if(lastv == CTRL_VAL_UNKNOWN) + { + int kiv = mctl->initVal(); + //int kiv = lrint(_knob->value()); + if(kiv == CTRL_VAL_UNKNOWN) + kiv = 0; + //else + //{ + //if(kiv < mctrl->minVal()) + // kiv = mctrl->minVal(); + //if(kiv > mctrl->maxVal()) + // kiv = mctrl->maxVal(); + //kiv += mctrl->bias(); + //} + + //MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, num, kiv); + MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_PROGRAM, kiv); + audio->msgPlayMidiEvent(&ev); + } + else + { + MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_PROGRAM, lastv); + audio->msgPlayMidiEvent(&ev); + } + } + else + { + if(mp->hwCtrlState(chan, CTRL_PROGRAM) != CTRL_VAL_UNKNOWN) + audio->msgSetHwCtrlState(mp, chan, CTRL_PROGRAM, CTRL_VAL_UNKNOWN); + } + + song->update(SC_MIDI_CONTROLLER); +} + +//--------------------------------------------------------- +// iLautstDoubleClicked +//--------------------------------------------------------- + +void MidiTrackInfo::iLautstDoubleClicked() +{ + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int port = track->outPort(); + int chan = track->outChannel(); + MidiPort* mp = &midiPorts[port]; + MidiController* mctl = mp->midiController(CTRL_VOLUME); + + if(!track || !mctl) + return; + + int lastv = mp->lastValidHWCtrlState(chan, CTRL_VOLUME); + int curv = mp->hwCtrlState(chan, CTRL_VOLUME); + + if(curv == CTRL_VAL_UNKNOWN) + { + // If no value has ever been set yet, use the current knob value + // (or the controller's initial value?) to 'turn on' the controller. + if(lastv == CTRL_VAL_UNKNOWN) + { + int kiv = mctl->initVal(); + //int kiv = lrint(_knob->value()); + if(kiv == CTRL_VAL_UNKNOWN) + // Set volume to 78% of range, so that if range is 0 - 127, then value is 100. + kiv = lround(double(mctl->maxVal() - mctl->minVal()) * 0.7874); + else + { + if(kiv < mctl->minVal()) + kiv = mctl->minVal(); + if(kiv > mctl->maxVal()) + kiv = mctl->maxVal(); + kiv += mctl->bias(); + } + + MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_VOLUME, kiv); + audio->msgPlayMidiEvent(&ev); + } + else + { + MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_VOLUME, lastv); + audio->msgPlayMidiEvent(&ev); + } + } + else + { + if(mp->hwCtrlState(chan, CTRL_VOLUME) != CTRL_VAL_UNKNOWN) + audio->msgSetHwCtrlState(mp, chan, CTRL_VOLUME, CTRL_VAL_UNKNOWN); + } + + song->update(SC_MIDI_CONTROLLER); +} + +//--------------------------------------------------------- +// iPanDoubleClicked +//--------------------------------------------------------- + +void MidiTrackInfo::iPanDoubleClicked() +{ + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int port = track->outPort(); + int chan = track->outChannel(); + MidiPort* mp = &midiPorts[port]; + MidiController* mctl = mp->midiController(CTRL_PANPOT); + + if(!track || !mctl) + return; + + int lastv = mp->lastValidHWCtrlState(chan, CTRL_PANPOT); + int curv = mp->hwCtrlState(chan, CTRL_PANPOT); + + if(curv == CTRL_VAL_UNKNOWN) + { + // If no value has ever been set yet, use the current knob value + // (or the controller's initial value?) to 'turn on' the controller. + if(lastv == CTRL_VAL_UNKNOWN) + { + int kiv = mctl->initVal(); + //int kiv = lrint(_knob->value()); + if(kiv == CTRL_VAL_UNKNOWN) + // Set volume to 50% of range, so that if range is 0 - 127, then value is 64. + kiv = lround(double(mctl->maxVal() - mctl->minVal()) * 0.5); + else + { + if(kiv < mctl->minVal()) + kiv = mctl->minVal(); + if(kiv > mctl->maxVal()) + kiv = mctl->maxVal(); + kiv += mctl->bias(); + } + + MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_PANPOT, kiv); + audio->msgPlayMidiEvent(&ev); + } + else + { + MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_PANPOT, lastv); + audio->msgPlayMidiEvent(&ev); + } + } + else + { + if(mp->hwCtrlState(chan, CTRL_PANPOT) != CTRL_VAL_UNKNOWN) + audio->msgSetHwCtrlState(mp, chan, CTRL_PANPOT, CTRL_VAL_UNKNOWN); + } + + song->update(SC_MIDI_CONTROLLER); +} + + +//--------------------------------------------------------- +// updateTrackInfo +//--------------------------------------------------------- + +void MidiTrackInfo::updateTrackInfo(int flags) +{ + // Is it simply a midi controller value adjustment? Forget it. + if(flags == SC_MIDI_CONTROLLER) + return; + if(flags == SC_SELECTION) + return; + + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + + // p3.3.47 Update the routing popup menu if anything relevant changes. + //if(gRoutingPopupMenuMaster == midiTrackInfo && selected && (flags & (SC_ROUTE | SC_CHANNELS | SC_CONFIG))) + if(flags & (SC_ROUTE | SC_CHANNELS | SC_CONFIG)) // p3.3.50 + // Use this handy shared routine. + //muse->updateRouteMenus(selected); + ///muse->updateRouteMenus(selected, midiTrackInfo); // p3.3.50 + muse->updateRouteMenus(selected, this); + + // Added by Tim. p3.3.9 + setLabelText(); + setLabelFont(); + + if(flags & (SC_MIDI_TRACK_PROP)) + { + iTransp->blockSignals(true); + iAnschl->blockSignals(true); + iVerz->blockSignals(true); + iLen->blockSignals(true); + iKompr->blockSignals(true); + iTransp->setValue(track->transposition); + iAnschl->setValue(track->velocity); + iVerz->setValue(track->delay); + iLen->setValue(track->len); + iKompr->setValue(track->compression); + iTransp->blockSignals(false); + iAnschl->blockSignals(false); + iVerz->blockSignals(false); + iLen->blockSignals(false); + iKompr->blockSignals(false); + + int outChannel = track->outChannel(); + ///int inChannel = track->inChannelMask(); + int outPort = track->outPort(); + //int inPort = track->inPortMask(); + ///unsigned int inPort = track->inPortMask(); + + iOutput->blockSignals(true); + //iInput->clear(); + iOutput->clear(); + + for (int i = 0; i < MIDI_PORTS; ++i) { + QString name; + name.sprintf("%d:%s", i+1, midiPorts[i].portname().toLatin1().constData()); + iOutput->insertItem(i, name); + if (i == outPort) + iOutput->setCurrentIndex(i); + } + iOutput->blockSignals(false); + + //iInput->setText(bitmap2String(inPort)); + ///iInput->setText(u32bitmap2String(inPort)); + + //iInputChannel->setText(bitmap2String(inChannel)); + + // Removed by Tim. p3.3.9 + //if (iName->text() != selected->name()) { + // iName->setText(selected->name()); + // iName->home(false); + // } + + iOutputChannel->blockSignals(true); + iOutputChannel->setValue(outChannel+1); + iOutputChannel->blockSignals(false); + ///iInputChannel->setText(bitmap2String(inChannel)); + + // Set record echo. + if(recEchoButton->isChecked() != track->recEcho()) + { + recEchoButton->blockSignals(true); + recEchoButton->setChecked(track->recEcho()); + recEchoButton->blockSignals(false); + } + } + + int outChannel = track->outChannel(); + int outPort = track->outPort(); + MidiPort* mp = &midiPorts[outPort]; + int nprogram = mp->hwCtrlState(outChannel, CTRL_PROGRAM); + if(nprogram == CTRL_VAL_UNKNOWN) + { + iHBank->blockSignals(true); + iLBank->blockSignals(true); + iProgram->blockSignals(true); + iHBank->setValue(0); + iLBank->setValue(0); + iProgram->setValue(0); + iHBank->blockSignals(false); + iLBank->blockSignals(false); + iProgram->blockSignals(false); + + program = CTRL_VAL_UNKNOWN; + nprogram = mp->lastValidHWCtrlState(outChannel, CTRL_PROGRAM); + if(nprogram == CTRL_VAL_UNKNOWN) + //iPatch->setText(QString("<unknown>")); + iPatch->setText(tr("Select Patch")); + else + { + MidiInstrument* instr = mp->instrument(); + iPatch->setText(instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM)); + } + } + else + //if (program != nprogram) + { + program = nprogram; + + //int hb, lb, pr; + //if (program == CTRL_VAL_UNKNOWN) { + // hb = lb = pr = 0; + // iPatch->setText("---"); + // } + //else + //{ + MidiInstrument* instr = mp->instrument(); + iPatch->setText(instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM)); + + int hb = ((program >> 16) & 0xff) + 1; + if (hb == 0x100) + hb = 0; + int lb = ((program >> 8) & 0xff) + 1; + if (lb == 0x100) + lb = 0; + int pr = (program & 0xff) + 1; + if (pr == 0x100) + pr = 0; + //} + iHBank->blockSignals(true); + iLBank->blockSignals(true); + iProgram->blockSignals(true); + + iHBank->setValue(hb); + iLBank->setValue(lb); + iProgram->setValue(pr); + + iHBank->blockSignals(false); + iLBank->blockSignals(false); + iProgram->blockSignals(false); + } + + MidiController* mc = mp->midiController(CTRL_VOLUME); + int mn = mc->minVal(); + int v = mp->hwCtrlState(outChannel, CTRL_VOLUME); + volume = v; + if(v == CTRL_VAL_UNKNOWN) + //{ + //v = mc->initVal(); + //if(v == CTRL_VAL_UNKNOWN) + // v = 0; + v = mn - 1; + //} + else + // Auto bias... + v -= mc->bias(); + iLautst->blockSignals(true); + iLautst->setRange(mn - 1, mc->maxVal()); + iLautst->setValue(v); + iLautst->blockSignals(false); + + mc = mp->midiController(CTRL_PANPOT); + mn = mc->minVal(); + v = mp->hwCtrlState(outChannel, CTRL_PANPOT); + pan = v; + if(v == CTRL_VAL_UNKNOWN) + //{ + //v = mc->initVal(); + //if(v == CTRL_VAL_UNKNOWN) + // v = 0; + v = mn - 1; + //} + else + // Auto bias... + v -= mc->bias(); + iPan->blockSignals(true); + iPan->setRange(mn - 1, mc->maxVal()); + iPan->setValue(v); + iPan->blockSignals(false); + //} + +} + +//--------------------------------------------------------- +// progRecClicked +//--------------------------------------------------------- + +void MidiTrackInfo::progRecClicked() + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int portno = track->outPort(); + int channel = track->outChannel(); + MidiPort* port = &midiPorts[portno]; + int program = port->hwCtrlState(channel, CTRL_PROGRAM); + if(program == CTRL_VAL_UNKNOWN || program == 0xffffff) + return; + + unsigned tick = song->cpos(); + Event a(Controller); + a.setTick(tick); + a.setA(CTRL_PROGRAM); + a.setB(program); + + song->recordEvent(track, a); + } + +//--------------------------------------------------------- +// volRecClicked +//--------------------------------------------------------- + +void MidiTrackInfo::volRecClicked() + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int portno = track->outPort(); + int channel = track->outChannel(); + MidiPort* port = &midiPorts[portno]; + int volume = port->hwCtrlState(channel, CTRL_VOLUME); + if(volume == CTRL_VAL_UNKNOWN) + return; + + unsigned tick = song->cpos(); + Event a(Controller); + a.setTick(tick); + a.setA(CTRL_VOLUME); + a.setB(volume); + + song->recordEvent(track, a); + } + +//--------------------------------------------------------- +// panRecClicked +//--------------------------------------------------------- + +void MidiTrackInfo::panRecClicked() + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int portno = track->outPort(); + int channel = track->outChannel(); + MidiPort* port = &midiPorts[portno]; + int pan = port->hwCtrlState(channel, CTRL_PANPOT); + if(pan == CTRL_VAL_UNKNOWN) + return; + + unsigned tick = song->cpos(); + Event a(Controller); + a.setTick(tick); + a.setA(CTRL_PANPOT); + a.setB(pan); + + song->recordEvent(track, a); + } + +//--------------------------------------------------------- +// recordClicked +//--------------------------------------------------------- + +void MidiTrackInfo::recordClicked() + { + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int portno = track->outPort(); + int channel = track->outChannel(); + MidiPort* port = &midiPorts[portno]; + unsigned tick = song->cpos(); + + int program = port->hwCtrlState(channel, CTRL_PROGRAM); + if(program != CTRL_VAL_UNKNOWN && program != 0xffffff) + { + Event a(Controller); + a.setTick(tick); + a.setA(CTRL_PROGRAM); + a.setB(program); + song->recordEvent(track, a); + } + int volume = port->hwCtrlState(channel, CTRL_VOLUME); + if(volume != CTRL_VAL_UNKNOWN) + { + Event a(Controller); + a.setTick(tick); + a.setA(CTRL_VOLUME); + a.setB(volume); + song->recordEvent(track, a); + } + int pan = port->hwCtrlState(channel, CTRL_PANPOT); + if(pan != CTRL_VAL_UNKNOWN) + { + Event a(Controller); + a.setTick(tick); + a.setA(CTRL_PANPOT); + a.setB(pan); + song->recordEvent(track, a); + } + } + +void MidiTrackInfo::toggleAdvanced(int checked) +{ + if(checked == Qt::Checked) + { + frame->show(); + } + else + { + frame->hide(); + } +} + + +void MidiTrackInfo::rebuildMatrix() +{ + //Clear the matrix + _matrix->erase(_matrix->begin(), _matrix->end()); + //Rebuild from order of selected table items + for(int i=0; i < _tableModel->rowCount(); ++i) + { + QStandardItem* item = _tableModel->item(i, 1); + if(item->checkState() == Qt::Checked) + _matrix->append(item->row()); + } + tableView->resizeRowsToContents(); +} + +void MidiTrackInfo::matrixItemChanged(QStandardItem* item) +{ + rebuildMatrix(); + //if(item->column() != -1 && item->column() == 0 && item->isCheckable()) + //{ + // if(item->checkState() == Qt::Checked) + // { + // printf("Adding item to matrix %d\n", item->row()); + // _matrix->append(item->row()); + // } + // else + // { + // int ind = _matrix->indexOf(item->row()); + // if(ind != -1) + // { + // printf("Removing item from matrix %d\n",ind); + // _matrix->removeAt(ind); + // } + // } + //} +} + +void MidiTrackInfo::insertMatrixEvent() +{ + if(!selected) + return; + MidiTrack* track = (MidiTrack*)selected; + int channel = track->outChannel(); + int port = track->outPort(); + if(_matrix->size() == 1) + { + //Get the QStandardItem in the hidden third column + //This column contains the ID of the Patch + int row = _matrix->at(0); + QStandardItem* item = _tableModel->item(row, 0); + int id = item->text().toInt(); + MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, id); + audio->msgPlayMidiEvent(&ev); + updateTrackInfo(-1); + tableView->selectRow(item->row()); + progRecClicked(); + } + else if(_matrix->size() > 1) + { + int row = _matrix->takeFirst(); + tableView->selectRow(_matrix->at(0)); + //printf("Adding Program Change for row: %d\n", row); + if(row != -1 && row < _tableModel->rowCount()) + { + QStandardItem* item = _tableModel->item(row, 0); + int id = item->text().toInt(); + MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, id); + audio->msgPlayMidiEvent(&ev); + updateTrackInfo(-1); + progRecClicked(); + } + _matrix->push_back(row); + } +} + +void MidiTrackInfo::deleteSelectedPatches(bool b) +{ + QList<int> rows = tableView->getSelectedRows(); + if(!rows.isEmpty()) + { + int id = rows.at(0); + if(!_matrix->isEmpty()) + { + int mid = _matrix->indexOf(0); + if(mid != -1) + _matrix->takeAt(mid); + } + _tableModel->removeRow(id); + _tableModel->emit_layoutChanged(); + tableView->resizeRowsToContents(); + int c = _tableModel->rowCount(); + //printf("Row Count: %d - Deleted Row:%d\n",c ,id); + if(c > id) + tableView->selectRow(id); + else + { + tableView->selectRow(0); + } + } +/* for(int i =0; i < rows.size(); ++i) + { + if(!_matrix->isEmpty()) + { + int mid = _matrix->indexOf(i); + if(mid != -1) + _matrix->takeAt(mid); + } + _tableModel->removeRow(i); + } + */ +} + +void MidiTrackInfo::movePatchDown(bool b) +{ + QList<int> rows = tableView->getSelectedRows(); + if(!rows.isEmpty()) + { + int id = rows.at(0); + if((id + 1) >= _tableModel->rowCount()) + return; + int row = (id + 1); + QList<QStandardItem*> item = _tableModel->takeRow(id); + QStandardItem* txt = item.at(2); + txt->setEditable(false); + _tableModel->insertRow(row, item); + tableView->resizeRowsToContents(); + tableView->setColumnWidth(1, 20); + tableView->setColumnWidth(0, 1); + tableView->selectRow(row); + } +} + +void MidiTrackInfo::movePatchUp(bool clicked) +{ + QList<int> rows = tableView->getSelectedRows(); + if(!rows.isEmpty()) + { + int id = rows.at(0); + if((id - 1) < 0) + return; + int row = (id - 1); + QList<QStandardItem*> item = _tableModel->takeRow(id); + QStandardItem* txt = item.at(2); + txt->setEditable(false); + _tableModel->insertRow(row, item); + tableView->resizeRowsToContents(); + tableView->setColumnWidth(1, 20); + tableView->setColumnWidth(0, 1); + tableView->selectRow(row); + } +} + +void MidiTrackInfo::updateSize() +{ + tableView->resizeRowsToContents(); +} diff --git a/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.h b/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.h new file mode 100644 index 00000000..a1303786 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.h @@ -0,0 +1,91 @@ +//========================================================= +// MusE +// Linux Music Editor +// (C) Copyright 2010 Werner Schweer and others (ws@seh.de) +//========================================================= + +#ifndef __MTRACKINFO_H__ +#define __MTRACKINFO_H__ + +#include "ui_mtrackinfobase.h" +#include "pctablemodel.h" +#include "pctable.h" + +class Track; +class QTableView; +class QStandardItem; + +//--------------------------------------------------------- +// MidiTrackInfo +//--------------------------------------------------------- + +class MidiTrackInfo : public QFrame/*QWidget*/, public Ui::MidiTrackInfoBase +{ + Q_OBJECT + Track* selected; + bool _midiDetect; + int program, pan, volume; + int _progRowNum; + ProgramChangeTable* tableView; + QList<int>* _matrix; + ProgramChangeTableModel* _tableModel; + bool editing; + + private slots: + void iOutputChannelChanged(int); + void iOutputPortChanged(int); + void iProgHBankChanged(); + void iProgLBankChanged(); + void iProgramChanged(); + void iProgramDoubleClicked(); + void iLautstChanged(int); + void iLautstDoubleClicked(); + void iTranspChanged(int); + void iAnschlChanged(int); + void iVerzChanged(int); + void iLenChanged(int); + void iKomprChanged(int); + void iPanChanged(int); + void iPanDoubleClicked(); + void recordClicked(); + void volRecClicked(); + void panRecClicked(); + void recEchoToggled(bool); + void inRoutesPressed(); + void outRoutesPressed(); + void routingPopupMenuActivated(QAction*); + //void routingPopupViewActivated(const QModelIndex&); + void toggleAdvanced(int); + void matrixItemChanged(QStandardItem*); + void rebuildMatrix(); + void deleteSelectedPatches(bool); + void movePatchUp(bool); + void movePatchDown(bool); + + protected slots: + virtual void heartBeat(); + + public slots: + void setTrack(Track*); + void configChanged(); + void instrPopup(); + void progRecClicked(); + void songChanged(int); + void insertMatrixEvent(); + void updateSize(); + + signals: + void outputPortChanged(int); + + public: + MidiTrackInfo(QWidget*, Track* = 0); + Track* track() const { return selected; } + void setLabelText(); + void setLabelFont(); + void updateTrackInfo(int); +}; + + + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/mtrackinfobase.ui b/attic/muse2-oom/muse2/muse/widgets/mtrackinfobase.ui new file mode 100644 index 00000000..2ffa432c --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mtrackinfobase.ui @@ -0,0 +1,1077 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MidiTrackInfoBase</class> + <widget class="QFrame" name="MidiTrackInfoBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>150</width> + <height>580</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>3</horstretch> + <verstretch>3</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="windowTitle"> + <string>MusE: TrackInfo</string> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="trackNameLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Track 1</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="sizeConstraint"> + <enum>QLayout::SetMinAndMaxSize</enum> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QPushButton" name="iPatch"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>50</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>Select instrument patch</string> + </property> + <property name="text"> + <string>Select Patch</string> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="tableBox"> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="matrixActions"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QPushButton" name="btnUp"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="btnDown"> + <property name="minimumSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::MinimumExpanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="btnDelete"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QCheckBox" name="chkAdvanced"> + <property name="cursor"> + <cursorShape>PointingHandCursor</cursorShape> + </property> + <property name="text"> + <string>Advanced</string> + </property> + <property name="iconSize"> + <size> + <width>16</width> + <height>16</height> + </size> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <widget class="QFrame" name="frame"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <layout class="QGridLayout" name="advGrid" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"> + <property name="sizeConstraint"> + <enum>QLayout::SetMinimumSize</enum> + </property> + <property name="verticalSpacing"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <item row="12" column="1"> + <widget class="SpinBox" name="iTransp" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="specialValueText" stdset="0"> + <string>off</string> + </property> + <property name="maximum" stdset="0"> + <number>127</number> + </property> + <property name="minimum" stdset="0"> + <number>-127</number> + </property> + <property name="value" stdset="0"> + <number>1</number> + </property> + </widget> + </item> + <item row="12" column="2"> + <widget class="QLabel" name="TextLabel9"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>Transp.</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="indent"> + <number>2</number> + </property> + </widget> + </item> + <item row="13" column="1"> + <widget class="SpinBox" name="iVerz" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="specialValueText" stdset="0"> + <string>off</string> + </property> + <property name="maximum" stdset="0"> + <number>1000</number> + </property> + <property name="minimum" stdset="0"> + <number>-1000</number> + </property> + </widget> + </item> + <item row="13" column="2"> + <widget class="QLabel" name="TextLabel10"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>Delay</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="indent"> + <number>2</number> + </property> + </widget> + </item> + <item row="14" column="1"> + <widget class="SpinBox" name="iLen" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="suffix" stdset="0"> + <string>%</string> + </property> + <property name="maximum" stdset="0"> + <number>200</number> + </property> + <property name="minimum" stdset="0"> + <number>25</number> + </property> + <property name="value" stdset="0"> + <number>100</number> + </property> + </widget> + </item> + <item row="14" column="2"> + <widget class="QLabel" name="TextLabel11"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>Length</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="indent"> + <number>2</number> + </property> + </widget> + </item> + <item row="15" column="1"> + <widget class="SpinBox" name="iKompr" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="prefix" stdset="0"> + <string/> + </property> + <property name="suffix" stdset="0"> + <string>%</string> + </property> + <property name="maximum" stdset="0"> + <number>200</number> + </property> + <property name="minimum" stdset="0"> + <number>25</number> + </property> + <property name="value" stdset="0"> + <number>100</number> + </property> + </widget> + </item> + <item row="15" column="2"> + <widget class="QLabel" name="TextLabel13"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>50</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Compr.</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="indent"> + <number>2</number> + </property> + </widget> + </item> + <item row="16" column="1"> + <widget class="SpinBox" name="iAnschl" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="maximum" stdset="0"> + <number>127</number> + </property> + <property name="minimum" stdset="0"> + <number>-127</number> + </property> + <property name="value" stdset="0"> + <number>0</number> + </property> + </widget> + </item> + <item row="16" column="2"> + <widget class="QLabel" name="TextLabel12"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>Velocity</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="indent"> + <number>0</number> + </property> + </widget> + </item> + <item row="10" column="1"> + <widget class="SpinBox" name="iPan" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>Change stereo position. Double-click on/off.</string> + </property> + <property name="whatsThis"> + <string>Change stereo position. Double-click on/off.</string> + </property> + <property name="specialValueText" stdset="0"> + <string>off</string> + </property> + <property name="maximum" stdset="0"> + <number>63</number> + </property> + <property name="minimum" stdset="0"> + <number>-65</number> + </property> + <property name="value" stdset="0"> + <number>-65</number> + </property> + </widget> + </item> + <item row="10" column="2"> + <widget class="QToolButton" name="panRecButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>50</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>Add pan setting to song</string> + </property> + <property name="text"> + <string>Pan</string> + </property> + </widget> + </item> + <item row="9" column="1"> + <widget class="SpinBox" name="iLautst" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>Volume. Double-click on/off.</string> + </property> + <property name="specialValueText" stdset="0"> + <string>off</string> + </property> + <property name="maximum" stdset="0"> + <number>127</number> + </property> + <property name="minimum" stdset="0"> + <number>-1</number> + </property> + <property name="value" stdset="0"> + <number>-1</number> + </property> + </widget> + </item> + <item row="9" column="2"> + <widget class="QToolButton" name="volRecButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>50</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>Add vol setting to song</string> + </property> + <property name="text"> + <string>Vol</string> + </property> + </widget> + </item> + <item row="8" column="1"> + <widget class="SpinBox" name="iProgram" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>Program. Double-click on/off.</string> + </property> + <property name="specialValueText" stdset="0"> + <string>off</string> + </property> + <property name="maximum" stdset="0"> + <number>128</number> + </property> + <property name="minimum" stdset="0"> + <number>0</number> + </property> + <property name="value" stdset="0"> + <number>0</number> + </property> + </widget> + </item> + <item row="8" column="2"> + <widget class="QToolButton" name="progRecButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>50</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>Add bank + prog settings to song</string> + </property> + <property name="text"> + <string>Prog</string> + </property> + </widget> + </item> + <item row="0" column="1" colspan="2"> + <widget class="QComboBox" name="iOutput"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>output port</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="SpinBox" name="iOutputChannel" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>output channel</string> + </property> + <property name="whatsThis"> + <string>all midi events are sent to this output channel</string> + </property> + <property name="maximum" stdset="0"> + <number>16</number> + </property> + <property name="minimum" stdset="0"> + <number>1</number> + </property> + </widget> + </item> + <item row="5" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="textLabel1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>Record:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="5" column="2"> + <widget class="QToolButton" name="recordButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>50</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>Add all settings to song</string> + </property> + <property name="text"> + <string>All</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="SpinBox" name="iHBank" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>Bank Select MSB. Double-click on/off.</string> + </property> + <property name="specialValueText" stdset="0"> + <string>off</string> + </property> + <property name="maximum" stdset="0"> + <number>128</number> + </property> + <property name="minimum" stdset="0"> + <number>0</number> + </property> + <property name="value" stdset="0"> + <number>0</number> + </property> + </widget> + </item> + <item row="6" column="2"> + <widget class="QLabel" name="TextLabel4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>50</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="lineWidth"> + <number>1</number> + </property> + <property name="text"> + <string>H-Bank</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="indent"> + <number>2</number> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="SpinBox" name="iLBank" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>Bank Select LSB. Double-click on/off.</string> + </property> + <property name="specialValueText" stdset="0"> + <string>off</string> + </property> + <property name="maximum" stdset="0"> + <number>128</number> + </property> + <property name="minimum" stdset="0"> + <number>0</number> + </property> + <property name="value" stdset="0"> + <number>0</number> + </property> + </widget> + </item> + <item row="7" column="2"> + <widget class="QLabel" name="TextLabel5"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>50</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="lineWidth"> + <number>1</number> + </property> + <property name="text"> + <string>L-Bank</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="indent"> + <number>2</number> + </property> + </widget> + </item> + <item row="2" column="2"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="sizeConstraint"> + <enum>QLayout::SetFixedSize</enum> + </property> + <item> + <widget class="QLabel" name="iChanDetectLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>input detect</string> + </property> + <property name="whatsThis"> + <string>Input detect indicator. Detects all note on-off, controller, aftertouch, + program change, and pitchbend (but not sysex or realtime) events + on the selected channels, on the selected midi ports.</string> + </property> + <property name="text"> + <string>W</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="recEchoButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>Midi thru</string> + </property> + <property name="whatsThis"> + <string>Pass input events through ('thru') to output.</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <property name="sizeConstraint"> + <enum>QLayout::SetMinimumSize</enum> + </property> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="iRButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="toolTip"> + <string>input routing</string> + </property> + <property name="text"> + <string>In</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="2"> + <widget class="QLabel" name="TextLabel2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>Out ch</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="indent"> + <number>1</number> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>SpinBox</class> + <extends>QWidget</extends> + <header location="global">spinbox.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/mtscale.cpp b/attic/muse2-oom/muse2/muse/widgets/mtscale.cpp new file mode 100644 index 00000000..8f27329f --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mtscale.cpp @@ -0,0 +1,424 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mtscale.cpp,v 1.8.2.7 2009/05/03 04:14:01 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <values.h> + +#include <QMouseEvent> +#include <QPainter> + +#include "mtscale.h" +#include "song.h" +#include "icons.h" +#include "gconfig.h" + +//--------------------------------------------------------- +// MTScale +// Midi Time Scale +//--------------------------------------------------------- + +MTScale::MTScale(int* r, QWidget* parent, int xs, bool _mode) + : View(parent, xs, 1) + { + waveMode = _mode; + setToolTip(tr("bar scale")); + barLocator = false; + raster = r; + if (waveMode) { + pos[0] = tempomap.tick2frame(song->cpos()); + pos[1] = tempomap.tick2frame(song->lpos()); + pos[2] = tempomap.tick2frame(song->rpos()); + } + else { + pos[0] = song->cpos(); + pos[1] = song->lpos(); + pos[2] = song->rpos(); + } + pos[3] = MAXINT; // do not show + button = Qt::NoButton; + setMouseTracking(true); + connect(song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool))); + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + connect(song, SIGNAL(markerChanged(int)), SLOT(redraw())); + + setFixedHeight(28); + //setBg(QColor(53, 51, 56)); + setBg(QColor(150, 176, 187)); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void MTScale::songChanged(int type) + { + if (type & (SC_SIG|SC_TEMPO)) { + if ((type & SC_TEMPO) && waveMode) { + pos[0] = tempomap.tick2frame(song->cpos()); + pos[1] = tempomap.tick2frame(song->lpos()); + pos[2] = tempomap.tick2frame(song->rpos()); + } + redraw(); + } + } + +//--------------------------------------------------------- +// setPos +//--------------------------------------------------------- + +void MTScale::setPos(int idx, unsigned val, bool) + { + if (val == MAXINT) { + if (idx == 3) { + pos[3] = MAXINT; + redraw(QRect(0, 0, width(), height())); + } + return; + } + if (waveMode) + val = tempomap.tick2frame(val); + if (val == pos[idx]) + return; + //unsigned opos = mapx(pos[idx] == MAXINT ? val : pos[idx]); + int opos = mapx(pos[idx] == MAXINT ? val : pos[idx]); + pos[idx] = val; + if (!isVisible()) + return; + + int tval = mapx(val); + int x = -9; + int w = 18; + + if (tval < 0) { // tval<0 occurs whenever the window is scrolled left, so I switched to signed int (ml) + //printf("MTScale::setPos - idx:%d val:%d tval:%d opos:%d w:%d h:%d\n", idx, val, tval, opos, width(), height()); + + redraw(QRect(0,0,width(),height())); + return; + } + //if (opos > (unsigned int) tval) { //prevent compiler warning: comparison signed/unsigned + if (opos > tval) { + w += opos - tval; + x += tval; + } + else { + w += tval - opos; + x += opos; + } + //printf("MTScale::setPos idx:%d val:%d tval:%d opos:%d x:%d w:%d h:%d\n", idx, val, tval, opos, x, w, height()); + + redraw(QRect(x, 0, w, height())); + } + +//--------------------------------------------------------- +// viewMousePressEvent +//--------------------------------------------------------- + +void MTScale::viewMousePressEvent(QMouseEvent* event) + { + button = event->button(); + viewMouseMoveEvent(event); + } + +//--------------------------------------------------------- +// viewMouseReleaseEvent +//--------------------------------------------------------- + +void MTScale::viewMouseReleaseEvent(QMouseEvent*) + { + button = Qt::NoButton; + } + +//--------------------------------------------------------- +// viewMouseMoveEvent +//--------------------------------------------------------- + +void MTScale::viewMouseMoveEvent(QMouseEvent* event) + { + if (event->modifiers() & Qt::ShiftModifier ) + setCursor(QCursor(Qt::PointingHandCursor)); + else + setCursor(QCursor(Qt::ArrowCursor)); + + int x = event->x(); + if (waveMode) + x = tempomap.frame2tick(x); + x = AL::sigmap.raster(x, *raster); + if (x < 0) + x = 0; + //printf("MTScale::viewMouseMoveEvent\n"); + emit timeChanged(x); + int i; + switch (button) { + case Qt::LeftButton: + i = 0; + break; + case Qt::MidButton: + i = 1; + break; + case Qt::RightButton: + i = 2; + break; + default: + return; // if no button is pressed the function returns here + } + Pos p(x, true); + + if(i== 0 && (event->modifiers() & Qt::ShiftModifier )) { // If shift +LMB we add a marker + Marker *alreadyExists = song->getMarkerAt(x); + if (!alreadyExists) { + song->addMarker(QString(""), x, false); + // Removed p3.3.43 + // Song::addMarker() already emits a 'markerChanged'. + //emit addMarker(x); + } + } + else if (i== 2 && (event->modifiers() & Qt::ShiftModifier )) { // If shift +RMB we remove a marker + Marker *toRemove = song->getMarkerAt(x); + if (toRemove) + song->removeMarker(toRemove); + else + printf("No marker to remove\n"); + } + else + song->setPos(i, p); // all other cases: relocating one of the locators + } + +//--------------------------------------------------------- +// leaveEvent +//--------------------------------------------------------- + +void MTScale::leaveEvent(QEvent*) + { + emit timeChanged(MAXINT); + } + +//--------------------------------------------------------- +// draw +//--------------------------------------------------------- + +void MTScale::pdraw(QPainter& p, const QRect& r) + { + QColor colTimeLine = QColor(0,0,0); + int x = r.x(); + int w = r.width(); + + // Added by Tim. p3.3.6 + //printf("MTScale::pdraw x:%d w:%d\n", x, w); + + x -= 20; + w += 40; // wg. Text + + //--------------------------------------------------- + // draw Marker + //--------------------------------------------------- + + int y = 12; + //p.setPen(QColor(255,255,255)); + p.setPen(colTimeLine); + p.setFont(config.fonts[4]); + p.drawLine(r.x(), y+1, r.x() + r.width(), y+1); + QRect tr(r); + tr.setHeight(12); + MarkerList* marker = song->marker(); + for (iMarker m = marker->begin(); m != marker->end(); ++m) { + + int xp; + if(waveMode) + xp = mapx(m->second.frame()); + else + xp = mapx(m->second.tick()); + if (xp > x+w) + break; + int xe = r.x() + r.width(); + iMarker mm = m; + ++mm; + if (mm != marker->end()) { + + if(waveMode) + xe = mapx(tempomap.tick2frame(mm->first)); + else + xe = mapx(mm->first); + } + + QRect tr(xp, 0, xe-xp, 13); + //if (m->second.current()) + // p.fillRect(tr, white); + + QRect wr = r.intersect(tr); + //if (r.intersects(tr)) + if(!wr.isEmpty()) + { + if (m->second.current()) + { + //p.fillRect(tr, white); + p.fillRect(wr, QColor(89,89,102)); + } + + int x2; + //iMarker mm = m; + //++mm; + if (mm != marker->end()) + { + if(waveMode) + x2 = mapx(tempomap.tick2frame(mm->first)); + else + x2 = mapx(mm->first); + } + else + x2 = xp+200; + + //printf("MTScale::pdraw marker %s xp:%d y:%d h:%d r.x:%d r.w:%d\n", m->second.name().toLatin1(), xp, height(), y, r.x(), r.width()); + + // Must be reasonable about very low negative x values! With long songs > 15min + // and with high horizontal magnification, 'ghost' drawings appeared, + // apparently the result of truncation later (xp = -65006 caused ghosting + // at bar 245 with magnification at max.), even with correct clipping region + // applied to painter in View::paint(). Tim. Apr 5 2009 + // Quote: "Warning: Note that QPainter does not attempt to work around + // coordinate limitations in the underlying window system. Some platforms may + // behave incorrectly with coordinates as small as +/-4000." + if(xp >= -32) + p.drawPixmap(xp, 0, *flagIconS); + + if(xp >= -1023) + { + QRect r = QRect(xp+10, 0, x2-xp, 12); + //p.setPen(QColor(220,222,223)); + //p.setPen(QColor(255,255,255)); + p.setPen(colTimeLine); + p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter, m->second.name()); + } + + if(xp >= 0) + { + p.setPen(QColor(243,191,124)); + p.drawLine(xp, y, xp, height()); + } + } + } + + //--------------------------------------------------- + // draw location marker + //--------------------------------------------------- + + int h = height()-12; + + if (barLocator) { + p.setPen(Qt::red); + int xp = mapx(pos[0]); + if (xp >= x && xp < x+w) + p.drawLine(xp, y, xp, h); + p.setPen(Qt::blue); + xp = mapx(pos[1]); + if (xp >= x && xp < x+w) + p.drawLine(xp, y, xp, h); + xp = mapx(pos[2]); + if (xp >= x && xp < x+w) + p.drawLine(xp, y, xp, h); + } + else { + for (int i = 0; i < 3; ++i) { + int xp = mapx(pos[i]); + if (xp >= x && xp < x+w) { + QPixmap* pm = markIcon[i]; + p.drawPixmap(xp - pm->width()/2, y-1, *pm); + } + } + } + //p.setPen(QColor(220,222,223)); + p.setPen(colTimeLine); + if (pos[3] != MAXINT) { + int xp = mapx(pos[3]); + if (xp >= x && xp < x+w) + p.drawLine(xp, 0, xp, height()); + } + + unsigned ctick; + int bar1, bar2, beat; + unsigned tick; + + if (waveMode) { + ctick = tempomap.frame2tick(mapxDev(x)); + AL::sigmap.tickValues(ctick, &bar1, &beat, &tick); + AL::sigmap.tickValues(tempomap.frame2tick(mapxDev(x+w)), + &bar2, &beat, &tick); + } + else { + ctick = mapxDev(x); + AL::sigmap.tickValues(ctick, &bar1, &beat, &tick); + AL::sigmap.tickValues(mapxDev(x+w), &bar2, &beat, &tick); + } + +//printf("bar %d %d-%d=%d\n", bar, ntick, stick, ntick-stick); + + int stick = AL::sigmap.bar2tick(bar1, 0, 0); + int ntick; + for (int bar = bar1; bar <= bar2; bar++, stick = ntick) { + ntick = AL::sigmap.bar2tick(bar+1, 0, 0); + int tpix, a, b=0; + if (waveMode) { + a = tempomap.tick2frame(ntick); + b = tempomap.tick2frame(stick); + tpix = rmapx(a - b); + } + else { + tpix = rmapx(ntick - stick); + } + if (tpix < 64) { + // donÃŊÂŋÂ―t show beats if measure is this small + int n = 1; + if (tpix < 32) + n = 2; + if (tpix <= 16) + n = 4; + if (tpix < 8) + n = 8; + if (tpix <= 4) + n = 16; + if (tpix <= 2) + n = 32; + if (bar % n) + continue; + p.setFont(config.fonts[3]); + int x = mapx(waveMode ? b : stick); + QString s; + s.setNum(bar + 1); + p.drawLine(x, y+1, x, y+1+h); +// QRect r = QRect(x+2, y, 0, h); + QRect r = QRect(x+2, y, 1000, h); + p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter|Qt::TextDontClip, s); + } + else { + int z, n; + AL::sigmap.timesig(stick, z, n); + for (int beat = 0; beat < z; beat++) { + int xx = AL::sigmap.bar2tick(bar, beat, 0); + if (waveMode) + xx = tempomap.tick2frame(xx); + int xp = mapx(xx); + QString s; + QRect r(xp+2, y, 1000, h); + int y1; + int num; + if (beat == 0) { + num = bar + 1; + y1 = y + 1; + p.setFont(config.fonts[3]); + } + else { + num = beat + 1; + y1 = y + 7; + p.setFont(config.fonts[1]); + r.setY(y+3); + } + s.setNum(num); + p.drawLine(xp, y1, xp, y+1+h); + p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter|Qt::TextDontClip, s); + } + } + } + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/mtscale.h b/attic/muse2-oom/muse2/muse/widgets/mtscale.h new file mode 100644 index 00000000..7c53d4ff --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/mtscale.h @@ -0,0 +1,49 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mtscale.h,v 1.3 2004/04/27 22:27:06 spamatica Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __MTSCALE_H__ +#define __MTSCALE_H__ + +#include "view.h" + + +//--------------------------------------------------------- +// MTScale +// scale for midi track +//--------------------------------------------------------- + +class MTScale : public View { + Q_OBJECT + int* raster; + unsigned pos[4]; + int button; + bool barLocator; + bool waveMode; + + private slots: + void songChanged(int); + + protected: + virtual void pdraw(QPainter&, const QRect&); + virtual void viewMousePressEvent(QMouseEvent* event); + virtual void viewMouseMoveEvent(QMouseEvent* event); + virtual void viewMouseReleaseEvent(QMouseEvent* event); + virtual void leaveEvent(QEvent*e); + + signals: + void timeChanged(unsigned); + //void addMarker(int); + + public slots: + void setPos(int, unsigned, bool); + + public: + MTScale(int* raster, QWidget* parent, int xscale, bool f = false); + void setBarLocator(bool f) { barLocator = f; } + }; +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/musewidgetsplug.cpp b/attic/muse2-oom/muse2/muse/widgets/musewidgetsplug.cpp new file mode 100644 index 00000000..4b61cf2a --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/musewidgetsplug.cpp @@ -0,0 +1,572 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: musewidgetsplug.cpp,v 1.9.2.9 2009/12/01 03:52:40 terminator356 Exp $ +// (C) Copyright 2001-2003 Werner Schweer (ws@seh.de) +//========================================================= + +// this file makes some of the MusE widgets available +// to QT-Designer + +// #include <qwidgetplugin.h> +#include <QtCore/QtPlugin> // p4.0.2 +#include <QtDesigner/QDesignerCustomWidgetInterface> // +#include <QPixmap> + +#include "poslabel.h" +#include "pitchedit.h" +#include "pitchlabel.h" +#include "sig.h" +#include "tempo.h" +#include "tempolabel.h" +#include "sigedit.h" +#include "slider.h" +#include "doublelabel.h" +#include "checkbox.h" +#include "combobox.h" +#include "gconfig.h" + +int sampleRate = 44100; // some dummy values to get things compiled/linked +int division = 384; +int mtcType = 0; +bool hIsB = false; + +static const char* vall[] = { + "c","c#","d","d#","e","f","f#","g","g#","a","a#","h" + }; +static const char* valu[] = { + "C","C#","D","D#","E","F","F#","G","G#","A","A#","H" + }; + +GlobalConfigValues config = { + 190, // globalAlphaBlend + { + QColor(0xff, 0xff, 0xff), // palette + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff), + QColor(0xff, 0xff, 0xff) + }, + { + QColor(255, 232, 140), // part colors + QColor(0xff, 0x00, 0x00), + QColor(0x00, 0xff, 0x00), + QColor(0x00, 0x00, 0xff), + QColor(0xff, 0xff, 0x00), + QColor(0x00, 0xff, 0xff), + QColor(0xff, 0x00, 0xff), + QColor(0x9f, 0xc7, 0xef), + QColor(0x00, 0xff, 0x7f), + QColor(0x7f, 0x00, 0x00), + QColor(0x00, 0x7f, 0x00), + QColor(0x00, 0x00, 0x7f), + QColor(0x7f, 0x7f, 0x3f), + QColor(0x00, 0x7f, 0x7f), + QColor(0x7f, 0x00, 0x7f), + QColor(0x00, 0x7f, 0xff), + QColor(0x00, 0x3f, 0x3f) + }, + { + QString("Default"), // Default part color names + QString("Refrain"), + QString("Bridge"), + QString("Intro"), + QString("Coda"), + QString("Chorus"), + QString("Solo"), + QString("Brass"), + QString("Percussion"), + QString("Drums"), + QString("Guitar"), + QString("Bass"), + QString("Flute"), + QString("Strings"), + QString("Keyboard"), + QString("Piano"), + QString("Saxophone") + }, + QColor(0, 0, 255), // transportHandleColor; + QColor(255, 0, 0), // bigTimeForegroundColor; + QColor(0, 0, 0), // bigTimeBackgroundColor; + QColor(200, 200, 200), // waveEditBackgroundColor; + { + QFont(QString("arial"), 10, QFont::Normal), + QFont(QString("arial"), 8, QFont::Normal), + QFont(QString("arial"), 10, QFont::Normal), + QFont(QString("arial"), 10, QFont::Bold), + QFont(QString("arial"), 8, QFont::Bold), // timescale numbers + QFont(QString("Lucidatypewriter"), 14, QFont::Bold), + QFont(QString("arial"), 8, QFont::Bold, true) // Mixer strip labels. Looks and fits better with bold + italic than bold alone, + // at the price of only few more pixels than Normal mode. + }, + QColor(0xff, 0xff, 0xff), // trackBg; + QColor(0x80, 0xff, 0x80), // selected track Bg; + QColor(0x00, 0x00, 0x00), // selected track Fg; + + QColor(0, 160, 255), // midiTrackLabelBg; // Med blue + QColor(0, 160, 255), // drumTrackLabelBg; // Med blue + Qt::magenta, // waveTrackLabelBg; + Qt::green, // outputTrackLabelBg; + Qt::red, // inputTrackLabelBg; + Qt::yellow, // groupTrackLabelBg; + QColor(120, 255, 255), // auxTrackLabelBg; // Light blue + QColor(255, 130, 0), // synthTrackLabelBg; // Med orange + + QColor(220, 220, 220), // midiTrackBg; + QColor(220, 220, 220), // drumTrackBg; + QColor(220, 220, 220), // waveTrackBg; + QColor(189, 220, 193), // outputTrackBg; + QColor(189, 220, 193), // inputTrackBg; + QColor(220, 220, 220), // groupTrackBg; + QColor(220, 220, 220), // auxTrackBg; + QColor(220, 220, 220), // synthTrackBg; + + QColor(98, 124, 168), // part canvas bg + QColor(255, 170, 0), // ctrlGraphFg; Medium orange + QColor(98, 124, 168), // mixerBg; + + 384, // division; + 1024, // rtcTicks + -60, // int minMeter; + -60.0, // double minSlider; + false, // use Jack freewheel + 20, // int guiRefresh; + QString(""), // helpBrowser + true, // extendedMidi + 384, // division for smf export + QString(""), // copyright string for smf export + 1, // smf export file format + false, // midi export file 2 byte timesigs instead of 4 + true, // optimize midi export file note offs + true, // Split imported tracks into multiple parts. + 1, // startMode + QString(""), // start song path + 384, // gui division + QRect(0, 0, 400, 300), // GeometryMain; + QRect(0, 0, 200, 100), // GeometryTransport; + QRect(0, 0, 600, 200), // GeometryBigTime; + QRect(0, 0, 400, 300), // GeometryPianoroll; + QRect(0, 0, 400, 300), // GeometryDrumedit; + //QRect(0, 0, 300, 500), // GeometryMixer; // Obsolete + { + QString("Mixer A"), + QRect(0, 0, 300, 500), // Mixer1 + true, true, true, true, + true, true, true, true + }, + { + QString("Mixer B"), + QRect(200, 200, 300, 500), // Mixer2 + true, true, true, true, + true, true, true, true + }, + true, // TransportVisible; + false, // BigTimeVisible; + false, // mixer1Visible; + false, // mixer2Visible; + + false, // markerVisible; // This line was missing 2007-01-08 (willyfoobar) + true, // showSplashScreen + 1, // canvasShowPartType 1 - names, 2 events + 5, // canvasShowPartEvent + false, // canvasShowGrid; + QString(""), // canvasBgPixmap; + QString(""), // styleSheetFile + QString(""), // style + QString(""), // externalWavEditor //this line was missing 2007-01-08 (willyfoobar) + false, // useOldStyleStopShortCut + true, // moveArmedCheckBox + true, // useDenormalBias + false, // useOutputLimiter + true, // showDidYouKnow + false, // vstInPlace Enable VST in-place processing + 44100, // Dummy audio preferred sample rate + 512 // Dummy audio buffer size + }; + +//--------------------------------------------------------- +// pitch2string +//--------------------------------------------------------- + +QString pitch2string(int v) + { + if (v < 0 || v > 127) + return QString("----"); + int octave = (v / 12) - 2; + QString o; + o.sprintf("%d", octave); + int i = v % 12; + QString s(octave < 0 ? valu[i] : vall[i]); + if (hIsB) { + if (s == "h") + s = "b"; + else if (s == "H") + s = "B"; + } + return s + o; + } + + +/* XPM */ +static const char* slider_pixmap[]={ +"22 22 50 1", +". c None", +"f c #004005", +"g c #004007", +"h c #004107", +"m c #004108", +"j c #00430a", +"E c #00501f", +"s c #005021", +"e c #014006", +"l c #024006", +"F c #095e34", +"D c #0b572a", +"k c #0b582b", +"n c #0f5328", +"u c #12562d", +"o c #155a35", +"p c #165c38", +"q c #165c39", +"i c #17501a", +"I c #175522", +"r c #18603f", +"N c #18795e", +"t c #187a60", +"R c #1e5a29", +"y c #22633d", +"O c #307755", +"B c #408262", +"v c #439191", +"G c #468667", +"d c #4c7a51", +"H c #4d8a6c", +"J c #569174", +"C c #599276", +"P c #5e967a", +"A c #63b1c2", +"V c #659477", +"Q c #659b80", +"S c #6da087", +"w c #70b2bc", +"x c #72b5c0", +"z c #74b7c3", +"K c #79a891", +"a c #7ea48a", +"T c #8cb4a0", +"L c #a3c3b3", +"M c #b7d8d1", +"U c #bedcd5", +"c c #c3d2c3", +"b c #f1f5f1", +"# c #ffffff", +"......................", +"......................", +"......................", +"......................", +"......................", +"......###a............", +"......#bcad...........", +"......#bcad...........", +"......#bcad...........", +"..efgh#bcaihhhhhhhjk..", +".lmnop#bcaippppppqrst.", +".huvwx#bcayxxxxxxzABC.", +".DEFGH#bcaIHHHHHHJKLM.", +"..NOPQ#bcaRQQQQQQSTU..", +"......#bcad...........", +"......#bcad...........", +"......#bcad...........", +"......VVVVd...........", +".......dddd...........", +"......................", +"......................", +"......................"}; +static const char *posedit_pixmap[] = { + "22 22 8 1", + " c Gray100", + ". c Gray97", + "X c #4f504f", + "o c #00007f", + "O c Gray0", + "+ c none", + "@ c Gray0", + "# c Gray0", + "++++++++++++++++++++++", + "++++++++++++++++++++++", + "++++++++++++++++++++++", + "++++++++++++++++++++++", + "+OOOOOOOOOOOOOOOOOOOO+", + "OOXXXXXXXXXXXXXXXXXXOO", + "OXX. OO OO O", + "OX. oo O O", + "OX. oo O .O", + "OX ooo oooo O O", + "OX oo oo oo O O", + "OX oooo oo oo O O", + "OX oo oo oo oo O O", + "OX oo oo oo oo O O", + "OX oooo oooo O O", + "OX OO OO O", + "OO..................OO", + "+OOOOOOOOOOOOOOOOOOOO+", + "++++++++++++++++++++++", + "++++++++++++++++++++++", + "++++++++++++++++++++++", + "++++++++++++++++++++++" + }; + +static const char *pitchedit_pixmap[] = { + "22 22 8 1", + " c Gray100", + ". c Gray97", + "X c #4f504f", + "o c #00007f", + "O c Gray0", + "+ c none", + "@ c Gray0", + "# c Gray0", + "++++++++++++++++++++++", + "++++++++++++++++++++++", + "++++++++++++++++++++++", + "++++++++++++++++++++++", + "+OOOOOOOOOOOOOOOOOOOO+", + "OOXXXXXXXXXXXXXXXXXXOO", + "OXX. OO OO O", + "OX. o O O", + "OX. oo O .O", + "OX o o O O", + "OX o O O", + "OX o o O O", + "OX oooo O O", + "OX o O O", + "OX O O", + "OX OO OO O", + "OO..................OO", + "+OOOOOOOOOOOOOOOOOOOO+", + "++++++++++++++++++++++", + "++++++++++++++++++++++", + "++++++++++++++++++++++", + "++++++++++++++++++++++" + }; + +//--------------------------------------------------------- +// MusEPlugin +//--------------------------------------------------------- + +class MusEPlugin : public QWidgetPlugin { + public: + MusEPlugin() {} + ~MusEPlugin() {} + QStringList keys() const; + QWidget* create(const QString& key, QWidget* parent=0, + const char* name = 0); + QString group(const QString& key) const; + QIcon iconSet(const QString& key) const; + QString includeFile(const QString& key) const; + QString toolTip(const QString& key) const; + QString whatsThis(const QString& key) const; + bool isContainer(const QString& key) const; + }; + +//--------------------------------------------------------- +// keys +//--------------------------------------------------------- + +QStringList MusEPlugin::keys() const + { + QStringList list; + list << QString("PosEdit") + << QString("PitchEdit") + << QString("PosLabel") + << QString("PitchLabel") + << QString("TempoLabel") + << QString("TempoEdit") + << QString("SigEdit") + << QString("Slider") + << QString("DoubleLabel") + << QString("CheckBox") + << QString("ComboBox") + ; + return list; + } + +//--------------------------------------------------------- +// create +//--------------------------------------------------------- + +QWidget* MusEPlugin::create(const QString& key, QWidget* parent, + const char* name) + { + if (key == QString("PosEdit")) + return new PosEdit(parent, name); + else if (key == QString("PitchEdit")) + return new PitchEdit(parent, name); + else if (key == QString("PitchLabel")) + return new PitchLabel(parent, name); + else if (key == QString("PosLabel")) + return new PosLabel(parent, name); + else if (key == QString("TempoLabel")) + return new TempoLabel(parent, name); + else if (key == QString("TempoEdit")) + return new TempoEdit(parent, name); + else if (key == QString("SigEdit")) + return new SigEdit(parent, name); + else if (key == QString("Slider")) + return new Slider(parent, name); + else if (key == QString("DoubleLabel")) + return new DoubleLabel(parent, name); + else if (key == QString("CheckBox")) + return new CheckBox(parent, -1, name); + else if (key == QString("ComboBox")) + return new ComboBox(parent, name); + return 0; + } + +//--------------------------------------------------------- +// group +//--------------------------------------------------------- + +QString MusEPlugin::group(const QString& /*key*/) const + { + return QString("MusE"); + } + +//--------------------------------------------------------- +// iconSet +//--------------------------------------------------------- + +QIcon MusEPlugin::iconSet(const QString& key) const + { + if (key == "PosEdit" || key == "PosLabel") + return QIcon(QPixmap(posedit_pixmap)); + else if (key == "PitchEdit" || key == "PitchLabel") + return QIcon(QPixmap(pitchedit_pixmap)); + else if (key == "TempoEdit" || key == "TempoLabel") + return QIcon(QPixmap(pitchedit_pixmap)); + else if (key == "SigEdit") + return QIcon(QPixmap(pitchedit_pixmap)); + else if (key == QString("Slider")) + return QIcon(QPixmap(slider_pixmap)); +// else if (key == QString("CheckBox")) +// return QIconSet(QPixmap(slider_pixmap)); +// else if (key == QString("ComboBox")) +// return QIconSet(QPixmap(slider_pixmap)); + return QIcon(); + } + +//--------------------------------------------------------- +// includeFile +//--------------------------------------------------------- + +QString MusEPlugin::includeFile(const QString& key) const + { + if (key == QString("PosEdit")) + return QString("posedit.h"); + else if (key == QString("PitchEdit")) + return QString("pitchedit.h"); + else if (key == QString("PitchLabel")) + return QString("pitchlabel.h"); + else if (key == QString("PosLabel")) + return QString("poslabel.h"); + else if (key == QString("TempoLabel")) + return QString("tempolabel.h"); + else if (key == QString("TempoEdit")) + return QString("tempolabel.h"); + else if (key == QString("SigEdit")) + return QString("sigedit.h"); + else if (key == QString("Slider")) + return QString("slider.h"); + else if (key == QString("DoubleLabel")) + return QString("dentry.h"); + else if (key == QString("CheckBox")) + return QString("checkbox.h"); + else if (key == QString("ComboBox")) + return QString("combobox.h"); + return QString::null; + } + +//--------------------------------------------------------- +// toolTip +//--------------------------------------------------------- + +QString MusEPlugin::toolTip (const QString& key) const + { + if (key == QString("PosEdit")) + return QString("midi time position editor"); + else if (key == QString("PitchEdit")) + return QString("midi pitch spinbox"); + else if (key == QString("PitchLabel")) + return QString("midi pitch label"); + else if (key == QString("PosLabel")) + return QString("midi time position label"); + else if (key == QString("TempoLabel")) + return QString("midi tempo label"); + else if (key == QString("TempoEdit")) + return QString("midi tempo spinbox"); + else if (key == QString("SigEdit")) + return QString("midi signature spinbox"); + else if (key == QString("Slider")) + return QString("slider for double values"); + else if (key == QString("DoubleLabel")) + return QString("entry/label for double values"); + else if (key == QString("CheckBox")) + return QString("checkbox with id"); + else if (key == QString("ComboBox")) + return QString("combobox with id"); + return QString::null; + } + +//--------------------------------------------------------- +// whatsThis +//--------------------------------------------------------- + +QString MusEPlugin::whatsThis (const QString& key) const + { + if (key == QString("PosEdit")) + return QString("midi time position editor"); + else if (key == QString("PitchEdit")) + return QString("midi pitch spinbox"); + else if (key == QString("PitchLabel")) + return QString("midi pitch label"); + else if (key == QString("PosLabel")) + return QString("midi time position label"); + else if (key == QString("TempoLabel")) + return QString("midi tempo label"); + else if (key == QString("TempoEdit")) + return QString("midi tempo spinbox"); + else if (key == QString("SigEdit")) + return QString("midi signature spinbox"); + else if (key == QString("Slider")) + return QString("slider for double values"); + else if (key == QString("DoubleLabel")) + return QString("entry/label for double values"); + else if (key == QString("CheckBox")) + return QString("checkbox with id"); + else if (key == QString("ComboBox")) + return QString("combobox with id"); + return QString::null; + } + +//--------------------------------------------------------- +// isContainer +//--------------------------------------------------------- + +bool MusEPlugin::isContainer (const QString& /*key*/) const + { + return false; + } + +Q_EXPORT_PLUGIN(MusEPlugin) + diff --git a/attic/muse2-oom/muse2/muse/widgets/nentry.cpp b/attic/muse2-oom/muse2/muse/widgets/nentry.cpp new file mode 100644 index 00000000..77710e5a --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/nentry.cpp @@ -0,0 +1,401 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: nentry.cpp,v 1.1.1.1.2.1 2008/05/21 00:28:54 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QApplication> +#include <QHBoxLayout> +#include <QLabel> +#include <QLineEdit> +#include <QMouseEvent> +#include <QTimer> + +#include "nentry.h" + +#define TIMER1 400 +#define TIMER2 200 +#define TIMEC 7 +#define TIMER3 100 +#define TIMEC2 20 +#define TIMER4 50 + +NentryFilter::NentryFilter(QObject* parent) + : QObject(parent) + { + } + +void Nentry::setText(const QString& s) + { + edit->setText(s); + } + +//--------------------------------------------------------- +// eventFilter +//--------------------------------------------------------- + +bool NentryFilter::eventFilter(QObject*, QEvent* event) + { + Nentry* e = (Nentry*)parent(); + if (event->type() == QEvent::MouseButtonPress) { + e->mousePress((QMouseEvent*)event); + return true; + } + if (event->type() == QEvent::MouseMove) { + e->mouseMove((QMouseEvent*)event); + return true; + } + if (event->type() == QEvent::MouseButtonDblClick) { + e->mouseDoubleClick((QMouseEvent*)event); + return true; + } + if (event->type() == QEvent::MouseButtonRelease) { + e->mouseRelease((QMouseEvent*)event); + return true; + } + if (event->type() == QEvent::Wheel) { + e->wheel((QWheelEvent*)event); + return true; + } + if (event->type() == QEvent::KeyPress) { + return e->keyPress((QKeyEvent*)event); + } + if (event->type() == QEvent::ContextMenu) { + return e->contextMenu((QContextMenuEvent*)event); + } + return false; + } + +//--------------------------------------------------------- +// Nentry +// lineedit int values +//--------------------------------------------------------- + +Nentry::Nentry(QWidget* parent, const QString& txt, + int _lPos, bool dark) : QFrame(parent) + { + focusW = 0; + lPos = _lPos; + edit = new QLineEdit(this); + timer = new QTimer(this); + filter = new NentryFilter(this); + drawFrame = false; + edit->installEventFilter(filter); + edit->setFrame(drawFrame); + + connect(timer, SIGNAL(timeout()), SLOT(repeat())); + connect(edit, SIGNAL(returnPressed()), SLOT(endEdit())); + edit->setCursor(QCursor(Qt::ArrowCursor)); +// edit->setFont(font3); + val = 0; + layout = new QHBoxLayout(this); + if (txt == "") { + layout->addWidget(edit, 1, Qt::AlignHCenter); + } + else { + label = new QLabel(txt, this); + if (lPos == 0) { + layout->addStretch(5); + layout->addSpacing(5); + layout->addWidget(label); + layout->addSpacing(5); + layout->addWidget(edit); + layout->addSpacing(5); + layout->addStretch(5); + } + else { + label->setAlignment(Qt::AlignLeft); + layout->addWidget(edit, 0, Qt::AlignRight); + layout->addSpacing(5); + layout->addWidget(label, 100, Qt::AlignRight|Qt::AlignVCenter); + } + } + if (dark) { + setDark(); + } + edit->setFocusPolicy(Qt::NoFocus); + } + +void Nentry::setFocusPolicy(Qt::FocusPolicy policy) + { + edit->setFocusPolicy(policy); + } + +void Nentry::setDark() + { + const QPalette& oldpalette = edit->palette(); + + const QColor& newcolor = oldpalette.color(QPalette::Window); + QPalette newpalette(oldpalette); + newpalette.setColor(QPalette::Base, newcolor); + + edit->setPalette(newpalette); + } + +//--------------------------------------------------------- +// setSize +//--------------------------------------------------------- + +void Nentry::setSize(int n) + { + QString s("0000000000000000"); + QFontMetrics fm = edit->fontMetrics(); + int w; + if (n <= 16) + w = fm.width(s, n); + else + w = fm.width('0') * n; + + edit->setFixedWidth(w + 14); + } + +//--------------------------------------------------------- +// setFrame +//--------------------------------------------------------- + +void Nentry::setFrame(bool flag) + { + drawFrame = flag; + edit->setFrame(drawFrame); + } + +//--------------------------------------------------------- +// endEdit +//--------------------------------------------------------- + +void Nentry::endEdit() + { + if (edit->isModified()) { + if (setSValue(edit->text())) { + setString(val, false); + return; + } + edit->setModified(false); + } + if (focusW) + focusW->setFocus(); + focusW = 0; + edit->clearFocus(); + if (!drawFrame) + edit->setFrame(false); + setString(val, false); + } + +//--------------------------------------------------------- +// contextMenuEvent +//--------------------------------------------------------- + +bool Nentry::contextMenu(QContextMenuEvent *e) +{ + e->accept(); + return true; +} +//--------------------------------------------------------- +// mousePress +//--------------------------------------------------------- + +void Nentry::mousePress(QMouseEvent* event) + { + button = event->button(); + starty = event->y(); + evx = event->x(); + if (event->button() == Qt::LeftButton) { + focusW = qApp->focusWidget(); + edit->setFocus(); + edit->setFrame(true); + setString(val, true); + } + else { + timecount = 0; + repeat(); + timer->start(TIMER1); + } + } + +//--------------------------------------------------------- +// repeat +//--------------------------------------------------------- + +void Nentry::repeat() + { + if (timecount == 1) { + ++timecount; + timer->stop(); + timer->start(TIMER2); + return; + } + ++timecount; + if (timecount == TIMEC) { + timer->stop(); + timer->start(TIMER3); + } + if (timecount == TIMEC2) { + timer->stop(); + timer->start(TIMER4); + } + + switch (button) { + case Qt::LeftButton: + return; + case Qt::MidButton: + decValue(evx); + break; + case Qt::RightButton: + incValue(evx); + break; + default: + break; + } + if (focusW) + focusW->setFocus(); + edit->clearFocus(); + } + +//--------------------------------------------------------- +// mouseRelease +//--------------------------------------------------------- + +void Nentry::mouseRelease(QMouseEvent* event) + { + button = Qt::NoButton; + timer->stop(); + if (event->button() != Qt::LeftButton) { + if (focusW) + focusW->setFocus(); + edit->clearFocus(); + } + } + +//--------------------------------------------------------- +// mouseMove +//--------------------------------------------------------- + +void Nentry::mouseMove(QMouseEvent*) + { + switch (button) { + case Qt::LeftButton: + break; + case Qt::MidButton: + break; + case Qt::RightButton: + break; + default: + break; + } + } + +//--------------------------------------------------------- +// mouseDoubleClick +//--------------------------------------------------------- + +void Nentry::mouseDoubleClick(QMouseEvent* event) + { + if (event->button() != Qt::LeftButton) { + mousePress(event); + return; + } + } + +//--------------------------------------------------------- +// wheel +//--------------------------------------------------------- + +void Nentry::wheel(QWheelEvent* event) + { + int n = event->delta(); + if (n > 0) + incValue(n); + else + decValue(-n); + event->accept(); + } + +//--------------------------------------------------------- +// setValue +//--------------------------------------------------------- + +void Nentry::setValue(int v) + { + if (v == val) + return; + if (setString(v)) { + if (!drawFrame) + edit->setFrame(false); + edit->setEnabled(false); + } + else { + edit->setEnabled(true); + } + val = v; + } + +//--------------------------------------------------------- +// keyPress +//--------------------------------------------------------- + +bool Nentry::keyPress(QKeyEvent* event) + { + bool shift = event->modifiers() & Qt::ShiftModifier; + bool ctrl = event->modifiers() & Qt::ControlModifier; + int key = event->key(); + + if (shift) { + switch(key) { + case Qt::Key_Left: + case Qt::Key_Right: + return false; + default: + return true; + } + return true; + } + if (ctrl) { + switch(key) { + case Qt::Key_A: + case Qt::Key_B: + case Qt::Key_C: + case Qt::Key_D: + case Qt::Key_E: + case Qt::Key_F: + case Qt::Key_H: + case Qt::Key_V: + case Qt::Key_X: + case Qt::Key_Z: + case Qt::Key_Y: + return false; + default: + return true; + } + return true; + } + if (event->modifiers()) + return true; + switch (key) { + case Qt::Key_Up: incValue(0); return true; + case Qt::Key_Down: decValue(0); return true; + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case Qt::Key_Minus: + case Qt::Key_Left: + case Qt::Key_Right: + case Qt::Key_Backspace: + case Qt::Key_Home: + case Qt::Key_End: + case Qt::Key_Delete: + case Qt::Key_Return: + return false; + default: + break; + } + return true; + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/nentry.h b/attic/muse2-oom/muse2/muse/widgets/nentry.h new file mode 100644 index 00000000..48343b4a --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/nentry.h @@ -0,0 +1,84 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: nentry.h,v 1.1.1.1.2.2 2008/05/21 00:28:54 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __NENTRY_H__ +#define __NENTRY_H__ + +#include <QFrame> + +class QHBoxLayout; +class QLabel; +class QLineEdit; +class QTimer; + +class NentryFilter : public QObject { + Q_OBJECT + + protected: + bool eventFilter(QObject* object, QEvent* event); + public: + NentryFilter(QObject* parent); + }; + +//--------------------------------------------------------- +// Nentry +// numerical entry widget with optional label +//--------------------------------------------------------- + +class Nentry : public QFrame { + Q_OBJECT + + int button; + int starty; + bool drawFrame; + QTimer* timer; + int evx; + int timecount; + QHBoxLayout* layout; + QObject* filter; + QLabel* label; + int lPos; // label Position 0 - left, 1 - right + QWidget* focusW; + + protected: + QLineEdit* edit; + int val; + virtual void incValue(int x) = 0; + virtual void decValue(int x) = 0; + virtual bool setString(int, bool editable = false) = 0; + virtual bool setSValue(const QString&) = 0; + + private slots: + void repeat(); + + protected slots: + void endEdit(); + + public slots: + virtual void setValue(int); + + public: + Nentry(QWidget* parent, const QString& txt = QString(""), + int lPos = 0, bool dark=false); + + int value() const { return val; } + void setFrame(bool); + //void setAlignment(int flag) { edit->setAlignment(flag); } + void setText(const QString& s); + void setSize(int n); + void setDark(); + + void mousePress(QMouseEvent*); + void mouseMove(QMouseEvent*); + void mouseDoubleClick(QMouseEvent*); + void mouseRelease(QMouseEvent*); + void wheel(QWheelEvent*); + bool keyPress(QKeyEvent*); + void setFocusPolicy(Qt::FocusPolicy); + bool contextMenu(QContextMenuEvent*); + }; +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/noteinfo.cpp b/attic/muse2-oom/muse2/muse/widgets/noteinfo.cpp new file mode 100644 index 00000000..4f0e0c8c --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/noteinfo.cpp @@ -0,0 +1,210 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: noteinfo.cpp,v 1.4.2.1 2008/08/18 00:15:26 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QLabel> + +#include "config.h" +#include "noteinfo.h" +#include "awl/posedit.h" +//#include "awl/pitchedit.h" +#include "song.h" +#include "globals.h" +///#include "posedit.h" +#include "pitchedit.h" + +//--------------------------------------------------- +// NoteInfo +// ToolBar +// Start, LÃŊÂŋÂ―nge, Note, Velo an, Velo aus, Kanal +//--------------------------------------------------- + +//NoteInfo::NoteInfo(QMainWindow* parent) +NoteInfo::NoteInfo(QWidget* parent) + : QToolBar(tr("Note Info"), parent) + { + deltaMode = false; + + //QLabel* label = new QLabel(tr("Start"), this, "Start"); + QLabel* label = new QLabel(tr("Start")); + label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + label->setIndent(3); + addWidget(label); + + //selTime = new PosEdit(this, "Start"); + ///selTime = new PosEdit(0, "Start"); + selTime = new Awl::PosEdit; + selTime->setObjectName("Start"); + + addWidget(selTime); + + //label = new QLabel(tr("Len"), this, "Len"); + label = new QLabel(tr("Len")); + label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + label->setIndent(3); + addWidget(label); + //selLen = new QSpinBox(0, 100000, 1, this); + selLen = new QSpinBox(); + selLen->setRange(0, 100000); + selLen->setSingleStep(1); + addWidget(selLen); + + //label = new QLabel(tr("Pitch"), this, "Pitch"); + label = new QLabel(tr("Pitch")); + label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + label->setIndent(3); + addWidget(label); + //selPitch = new PitchEdit(this, "selPitch"); + selPitch = new PitchEdit; + addWidget(selPitch); + + //label = new QLabel(tr("Velo On"), this, "Velocity On"); + label = new QLabel(tr("Velo On")); + label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + label->setIndent(3); + addWidget(label); + //selVelOn = new QSpinBox(0, 127, 1, this); + selVelOn = new QSpinBox(); + selVelOn->setRange(0, 127); + selVelOn->setSingleStep(1); + addWidget(selVelOn); + + //label = new QLabel(tr("Velo Off"), this, "Velocity Off"); + label = new QLabel(tr("Velo Off")); + label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + label->setIndent(3); + addWidget(label); + //selVelOff = new QSpinBox(0, 127, 1, this); + selVelOff = new QSpinBox(); + selVelOff->setRange(0, 127); + selVelOff->setSingleStep(1); + addWidget(selVelOff); + + connect(selLen, SIGNAL(valueChanged(int)), SLOT(lenChanged(int))); + connect(selPitch, SIGNAL(valueChanged(int)), SLOT(pitchChanged(int))); + connect(selVelOn, SIGNAL(valueChanged(int)), SLOT(velOnChanged(int))); + connect(selVelOff, SIGNAL(valueChanged(int)), SLOT(velOffChanged(int))); + connect(selTime, SIGNAL(valueChanged(const Pos&)), SLOT(timeChanged(const Pos&))); + } + +//--------------------------------------------------------- +// setDeltaMode +//--------------------------------------------------------- + +void NoteInfo::setDeltaMode(bool val) + { + deltaMode = val; + selPitch->setDeltaMode(val); + if (val) { + selLen->setRange(-100000, 100000); + selVelOn->setRange(-127, 127); + selVelOff->setRange(-127, 127); + } + else { + selLen->setRange(0, 100000); + selVelOn->setRange(0, 127); + selVelOff->setRange(0, 127); + } + } + +//--------------------------------------------------------- +// lenChanged +//--------------------------------------------------------- + +void NoteInfo::lenChanged(int val) + { + if (!signalsBlocked()) + emit valueChanged(VAL_LEN, val); + } + +//--------------------------------------------------------- +// velOnChanged +//--------------------------------------------------------- + +void NoteInfo::velOnChanged(int val) + { + if (!signalsBlocked()) + emit valueChanged(VAL_VELON, val); + } + +//--------------------------------------------------------- +// velOffChanged +//--------------------------------------------------------- + +void NoteInfo::velOffChanged(int val) + { + if (!signalsBlocked()) + emit valueChanged(VAL_VELOFF, val); + } + +//--------------------------------------------------------- +// pitchChanged +//--------------------------------------------------------- + +void NoteInfo::pitchChanged(int val) + { + if (!signalsBlocked()) + emit valueChanged(VAL_PITCH, val); + } + +//--------------------------------------------------------- +// setValue +//--------------------------------------------------------- + +void NoteInfo::setValue(ValType type, int val) + { + blockSignals(true); + switch(type) { + case VAL_TIME: + selTime->setValue(val); + break; + case VAL_LEN: + selLen->setValue(val); + break; + case VAL_VELON: + selVelOn->setValue(val); + break; + case VAL_VELOFF: + selVelOff->setValue(val); + break; + case VAL_PITCH: + selPitch->setValue(val); + break; + } + blockSignals(false); + } + +//--------------------------------------------------------- +// setValue +//--------------------------------------------------------- + +void NoteInfo::setValues(unsigned tick, int val2, int val3, int val4, + int val5) + { + blockSignals(true); + if (selTime->pos().tick() != tick) + selTime->setValue(tick); + if (selLen->value() != val2) + selLen->setValue(val2); + if (selPitch->value() != val3) + selPitch->setValue(val3); + if (selVelOn->value() != val4) + selVelOn->setValue(val4); + if (selVelOff->value() != val5) + selVelOff->setValue(val5); + blockSignals(false); + } + +//--------------------------------------------------------- +// timeChanged +//--------------------------------------------------------- + +void NoteInfo::timeChanged(const Pos& pos) + { + if (!signalsBlocked()) + emit valueChanged(VAL_TIME, pos.tick()); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/noteinfo.h b/attic/muse2-oom/muse2/muse/widgets/noteinfo.h new file mode 100644 index 00000000..cc8fe16d --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/noteinfo.h @@ -0,0 +1,59 @@ +// MusE +// Linux Music Editor +// $Id: noteinfo.h,v 1.3 2004/01/09 17:12:54 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __NOTE_INFO_H__ +#define __NOTE_INFO_H__ + +#include <QToolBar> + +namespace Awl { + class PosEdit; + //class PitchEdit; + }; + +class QSpinBox; + +///class PosEdit; +class PitchEdit; +class Pos; + +//--------------------------------------------------------- +// NoteInfo +//--------------------------------------------------------- + +class NoteInfo : public QToolBar { + ///PosEdit* selTime; + Awl::PosEdit* selTime; + QSpinBox* selLen; + PitchEdit* selPitch; + QSpinBox* selVelOn; + QSpinBox* selVelOff; + bool deltaMode; + + Q_OBJECT + + public: + enum ValType {VAL_TIME, VAL_LEN, VAL_VELON, VAL_VELOFF, VAL_PITCH }; + //NoteInfo(QMainWindow* parent); + NoteInfo(QWidget* parent = 0); + void setValues(unsigned, int, int, int, int); + void setDeltaMode(bool); + + private slots: + void lenChanged(int); + void velOnChanged(int); + void velOffChanged(int); + void pitchChanged(int); + void timeChanged(const Pos&); + + public slots: + void setValue(ValType, int); + + signals: + void valueChanged(NoteInfo::ValType, int); + }; +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/pcscale.cpp b/attic/muse2-oom/muse2/muse/widgets/pcscale.cpp new file mode 100644 index 00000000..10392876 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/pcscale.cpp @@ -0,0 +1,337 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mtscale.cpp,v 1.8.2.7 2009/05/03 04:14:01 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <values.h> + +#include <QMouseEvent> +#include <QPainter> + +#include "pcscale.h" +#include "song.h" +#include "icons.h" +#include "gconfig.h" +#include "prcanvas.h" + +//--------------------------------------------------------- +// PCScale +// Midi Time Scale +//--------------------------------------------------------- + +PCScale::PCScale(int* r, QWidget* parent, PianoRoll* editor, int xs, bool _mode) + : View(parent, xs, 1) + { + audio = 0; + currentEditor = editor; + waveMode = _mode; + setToolTip(tr("bar pcscale")); + barLocator = false; + raster = r; + if (waveMode) { + pos[0] = tempomap.tick2frame(song->cpos()); + pos[1] = tempomap.tick2frame(song->lpos()); + pos[2] = tempomap.tick2frame(song->rpos()); + } + else { + pos[0] = song->cpos(); + pos[1] = song->lpos(); + pos[2] = song->rpos(); + } + pos[3] = MAXINT; // do not show + button = Qt::NoButton; + setMouseTracking(true); + connect(song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool))); + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + //connect(song, SIGNAL(markerChanged(int)), SLOT(redraw())); + + setFixedHeight(14); + setBg(QColor(110, 141, 152)); +} + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void PCScale::songChanged(int type) +{ + if (type & (SC_SIG|SC_TEMPO)) { + if ((type & SC_TEMPO) && waveMode) { + pos[0] = tempomap.tick2frame(song->cpos()); + pos[1] = tempomap.tick2frame(song->lpos()); + pos[2] = tempomap.tick2frame(song->rpos()); + } + redraw(); + } + redraw(); +} + +//--------------------------------------------------------- +// setPos +//--------------------------------------------------------- + +void PCScale::setPos(int idx, unsigned val, bool) +{ + if (val == MAXINT) { + if (idx == 3) { + pos[3] = MAXINT; + redraw(QRect(0, 0, width(), height())); + } + return; + } + if (waveMode) + val = tempomap.tick2frame(val); + if (val == pos[idx]) + return; + //unsigned opos = mapx(pos[idx] == MAXINT ? val : pos[idx]); + int opos = mapx(pos[idx] == MAXINT ? val : pos[idx]); + pos[idx] = val; + if (!isVisible()) + return; + + int tval = mapx(val); + int x = -9; + int w = 18; + + if (tval < 0) { // tval<0 occurs whenever the window is scrolled left, so I switched to signed int (ml) + //printf("PCScale::setPos - idx:%d val:%d tval:%d opos:%d w:%d h:%d\n", idx, val, tval, opos, width(), height()); + + redraw(QRect(0,0,width(),height())); + return; + } + //if (opos > (unsigned int) tval) { //prevent compiler warning: comparison signed/unsigned + if (opos > tval) { + w += opos - tval; + x += tval; + } + else { + w += tval - opos; + x += opos; + } + //printf("PCScale::setPos idx:%d val:%d tval:%d opos:%d x:%d w:%d h:%d\n", idx, val, tval, opos, x, w, height()); + + redraw(QRect(x, 0, w, height())); +} + +//--------------------------------------------------------- +// viewMousePressEvent +//--------------------------------------------------------- + +void PCScale::viewMousePressEvent(QMouseEvent* event) +{ + button = event->button(); + viewMouseMoveEvent(event); +} + +//--------------------------------------------------------- +// viewMouseReleaseEvent +//--------------------------------------------------------- + +void PCScale::viewMouseReleaseEvent(QMouseEvent*) +{ + button = Qt::NoButton; +} + +//--------------------------------------------------------- +// viewMouseMoveEvent +//--------------------------------------------------------- + +void PCScale::viewMouseMoveEvent(QMouseEvent* event) +{ + if (event->modifiers() & Qt::ShiftModifier ) + setCursor(QCursor(Qt::PointingHandCursor)); + else + setCursor(QCursor(Qt::ArrowCursor)); + + int x = event->x(); + x = AL::sigmap.raster(x, *raster); + if (x < 0) + x = 0; + //printf("PCScale::viewMouseMoveEvent\n"); + int i; + switch (button) { + case Qt::LeftButton: + i = 0; + break; + case Qt::MidButton: + i = 1; + break; + case Qt::RightButton: + i = 2; + break; + default: + return; // if no button is pressed the function returns here + } + Pos p(x, true); + if (waveMode) + { + song->setPos(i, p); + return; + } + + if(i== 0 && (event->modifiers() & Qt::ShiftModifier )) { // If shift +LMB we add a marker + //Add program change here + song->setPos(i, p); // all other cases: relocating one of the locators + emit selectInstrument(); + emit addProgramChange(); + } + else if (i== 2 && (event->modifiers() & Qt::ShiftModifier )) { // If shift +RMB we remove a marker + //Delete Program change here + Track* track = song->findTrack(currentEditor->curCanvasPart()); + PartList* parts = track->parts(); + for (iPart p = parts->begin(); p != parts->end(); ++p) + { + Part* mprt = p->second; + EventList* eventList = mprt->events(); + for(iEvent evt = eventList->begin(); evt != eventList->end(); ++evt) + { + //Get event type. + Event pcevt = evt->second; + if(!pcevt.isNote()) + { + if(pcevt.type() == Controller && pcevt.dataA() == CTRL_PROGRAM) + { + int xp = pcevt.tick()+mprt->tick(); + if(xp >= x && xp <= (x+50)) + { + //currentEditor->deleteSelectedProgramChange(evt->second, p->second); + if(audio) + { + song->startUndo(); + audio->msgDeleteEvent(evt->second, p->second, true, true, true); + song->endUndo(SC_EVENT_MODIFIED); + } + } + } + } + } + } + } + else + song->setPos(i, p); // all other cases: relocating one of the locators +} + +//--------------------------------------------------------- +// leaveEvent +//--------------------------------------------------------- + +void PCScale::leaveEvent(QEvent*) +{ + //emit timeChanged(MAXINT); +} + +void PCScale::setEditor(PianoRoll* editor) +{ + currentEditor = editor; +} + +void PCScale::updateProgram() +{ + redraw(); +} + +void PCScale::setAudio(Audio* a) +{ + if(!a) + return; + audio = a; +} + + +//--------------------------------------------------------- +// draw +//--------------------------------------------------------- + +void PCScale::pdraw(QPainter& p, const QRect& r) +{ + if(waveMode) + return; + int x = r.x(); + int w = r.width(); + + x -= 20; + w += 40; // wg. Text + + //--------------------------------------------------- + // draw Flag + //--------------------------------------------------- + + int y = 12; + p.setPen(Qt::black); + p.setFont(config.fonts[4]); + p.drawLine(r.x(), y+1, r.x() + r.width(), y+1); + QRect tr(r); + tr.setHeight(12); + Track* track = song->findTrack(currentEditor->curCanvasPart()); + PartList* parts = track->parts(); + for (iPart m = parts->begin(); m != parts->end(); ++m) + { + Part* mprt = m->second; + EventList* eventList = mprt->events(); + for(iEvent evt = eventList->begin(); evt != eventList->end(); ++evt) + { + //Get event type. + Event pcevt = evt->second; + if(!pcevt.isNote()) + { + if(pcevt.type() == Controller && pcevt.dataA() == CTRL_PROGRAM) + { + int xp = mapx(pcevt.tick()+mprt->tick()); + if (xp > x+w) + { + //printf("Its dying from greater than bar size\n"); + break; + } + int xe = r.x() + r.width(); + iEvent mm = evt; + ++mm; + + QRect tr(xp, 0, xe-xp, 13); + + QRect wr = r.intersect(tr); + if(!wr.isEmpty()) + { + int x2; + if (mm != eventList->end()) + { + x2 = mapx(pcevt.tick() + mprt->tick()); + } + else + x2 = xp+200; + + //printf("PCScale::pdraw marker %s xp:%d y:%d h:%d r.x:%d r.w:%d\n", "Test Debug", xp, height(), y, r.x(), r.width()); + + // Must be reasonable about very low negative x values! With long songs > 15min + // and with high horizontal magnification, 'ghost' drawings appeared, + // apparently the result of truncation later (xp = -65006 caused ghosting + // at bar 245 with magnification at max.), even with correct clipping region + // applied to painter in View::paint(). Tim. Apr 5 2009 + // Quote: "Warning: Note that QPainter does not attempt to work around + // coordinate limitations in the underlying window system. Some platforms may + // behave incorrectly with coordinates as small as +/-4000." + if(xp >= -32) + p.drawPixmap(xp, 0, *flagIconSP); + + // if(xp >= -1023) + // { + // QRect r = QRect(xp+10, 0, x2-xp, 12); + // p.setPen(Qt::black); + // //Use the program change info as name + // p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter, "Test"/*pcevt.name()*/); + // } + + //Andrew Commenting this line to test the new flag + //if(xp >= 0) + //{ + // p.setPen(Qt::red); + // p.drawLine(xp, y, xp, height()); + //} + }//END if(wr.isEmpty) + }//END if(CTRL_PROGRAM) + }//END if(!isNote) + } + } +} + diff --git a/attic/muse2-oom/muse2/muse/widgets/pcscale.h b/attic/muse2-oom/muse2/muse/widgets/pcscale.h new file mode 100644 index 00000000..6f1de1aa --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/pcscale.h @@ -0,0 +1,58 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mtscale.h,v 1.3 2004/04/27 22:27:06 spamatica Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __PCSCALE_H__ +#define __PCSCALE_H__ + +#include "view.h" +#include "pianoroll.h" +#include "midictrl.h" +#include "audio.h" + +//--------------------------------------------------------- +// PCScale +// program change scale for midi track +//--------------------------------------------------------- + +class PCScale : public View { + Q_OBJECT + PianoRoll* currentEditor; + int* raster; + unsigned pos[4]; + int button; + bool barLocator; + bool waveMode; + Audio* audio; + + + private slots: + void songChanged(int); + + protected: + virtual void pdraw(QPainter&, const QRect&); + virtual void viewMousePressEvent(QMouseEvent* event); + virtual void viewMouseMoveEvent(QMouseEvent* event); + virtual void viewMouseReleaseEvent(QMouseEvent* event); + virtual void leaveEvent(QEvent*e); + + signals: + void selectInstrument(); + void addProgramChange(); + + public slots: + void setPos(int, unsigned, bool); + void updateProgram(); + void setAudio(Audio*); + + public: + PCScale(int* raster, QWidget* parent, PianoRoll* editor, int xscale, bool f = false); + void setBarLocator(bool f) { barLocator = f; } + void setEditor(PianoRoll*); + PianoRoll* getEditor() { return currentEditor; } + }; +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/pctable.cpp b/attic/muse2-oom/muse2/muse/widgets/pctable.cpp new file mode 100644 index 00000000..afb6f6e9 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/pctable.cpp @@ -0,0 +1,124 @@ +#include "pctable.h" +#include "pctablemodel.h" +#include <QTableView> +#include <QHeaderView> +#include <QModelIndex> +#include <QDrag> +#include <QPainter> +#include <QPoint> +#include <QBrush> +#include <QPen> + +ProgramChangeTable::ProgramChangeTable(QWidget *parent) : QTableView(parent) +{ + setDragEnabled(true); + setAcceptDrops(true); + setCornerButtonEnabled(false); + verticalHeader()->hide(); + //horizontalHeader()->hide(); + setAutoFillBackground(true); + setTextElideMode(Qt::ElideNone); + setSelectionBehavior(QAbstractItemView::SelectRows); + setAlternatingRowColors(true); + setWordWrap(false); +} + +void ProgramChangeTable::dropEvent(QDropEvent *evt) +{ + if (evt->mimeData()->hasText()) { + evt->setDropAction(Qt::MoveAction); + ProgramChangeTableModel* m = (ProgramChangeTableModel*)model(); + QRect r = frameRect(); + QModelIndex index = indexAt ( evt->pos() ); + QString t = evt->mimeData()->text(); + int srow = t.toInt(); + int drow = index.row(); + if(drow != -1 && drow != srow/* && r.contains(evt->pos())*/) + { + QList<QStandardItem*> dragItems = m->takeRow(srow); + m->insertRow(index.row(), dragItems); + emit rowOrderChanged(); + } + } + else { + evt->ignore(); + } +} + +void ProgramChangeTable::mousePressEvent(QMouseEvent *evt) +{ + QModelIndex modidx = indexAt(evt->pos()); + QRect arect = visualRect ( modidx ); + arect.setWidth(20); + if (evt->button() == Qt::LeftButton && !arect.contains(evt->pos()) /*&& ((QInputEvent*)evt)->modifiers() & Qt::ShiftModifier*/) { + //printf("Mouse Press Event fired\n"); + QTableView::mousePressEvent(evt); + QModelIndex index = currentIndex(); + QString plainText = QString::number(index.row()); + QMimeData *mimeData = new QMimeData; + mimeData->setText(plainText); + QDrag* drag = new QDrag(this); + drag->setMimeData(mimeData); + drag->setHotSpot(evt->pos() - rect().topLeft()); + drag->start(Qt::MoveAction); + } + else + { + QTableView::mousePressEvent(evt); + } +} + +void ProgramChangeTable::dragEnterEvent(QDragEnterEvent* evt) +{ + if (evt->mimeData()->hasText()) + { + evt->acceptProposedAction(); + //printf("dragEnterEvent fired\n"); + } + else + evt->ignore(); +} + +void ProgramChangeTable::dragMoveEvent(QDragMoveEvent* evt) +{ + dropSite = evt->answerRect(); + + ProgramChangeTableModel* m = (ProgramChangeTableModel*)model(); + m->emit_layoutChanged(); +} + +void ProgramChangeTable::paintEvent ( QPaintEvent* event ) +{ + QTableView::paintEvent (event); + QPainter painter ( viewport() ); + int x, y, w, h; + dropSite.getRect ( &x, &y, &w, &h ); + QPoint point(x,y); + QModelIndex modidx = indexAt ( point ); + QRect arect = visualRect ( modidx ); + int b = arect.y(); + QBrush brush(Qt::black, Qt::Dense4Pattern); + QPen pen; + pen.setWidth(2); + pen.setBrush(brush); + painter.setPen(pen); + painter.drawLine ( 0, b, width()-40, b ); + event->accept(); +} + +QList<int> ProgramChangeTable::getSelectedRows() +{ + QList<int> rv; + QItemSelectionModel* smodel = selectionModel(); + if(smodel->hasSelection()) + { + QModelIndexList indexes = smodel->selectedRows(); + QList<QModelIndex>::const_iterator id; + for (id = indexes.constBegin(); id != indexes.constEnd(); ++id) + { + int row = (*id).row(); + rv.append(row); + } + } + return rv; +} diff --git a/attic/muse2-oom/muse2/muse/widgets/pctable.h b/attic/muse2-oom/muse2/muse/widgets/pctable.h new file mode 100644 index 00000000..c8ba53bf --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/pctable.h @@ -0,0 +1,31 @@ +#ifndef _PCTABLE_ +#define _PCTABLE_ + +#include <QTableView> +#include <QDropEvent> +#include <QMouseEvent> +#include <QDragEnterEvent> +#include <QDragMoveEvent> +#include <QPaintEvent> +#include <QList> + +class ProgramChangeTable : public QTableView +{ + Q_OBJECT + virtual void dragEnterEvent(QDragEnterEvent*); + virtual void dragMoveEvent(QDragMoveEvent*); + virtual void paintEvent(QPaintEvent*); + QRect dropSite; + + signals: + void rowOrderChanged(); + + public: + ProgramChangeTable(QWidget *parent = 0); + void dropEvent(QDropEvent *evt); + void mousePressEvent(QMouseEvent* evt); + + public slots: + QList<int> getSelectedRows(); +}; +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/pctablemodel.cpp b/attic/muse2-oom/muse2/muse/widgets/pctablemodel.cpp new file mode 100644 index 00000000..24c3b1c1 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/pctablemodel.cpp @@ -0,0 +1,18 @@ +#include "pctablemodel.h" +#include <QTableView> + +ProgramChangeTableModel::ProgramChangeTableModel(QObject *parent) : QStandardItemModel(parent) +{ +} + +QStringList ProgramChangeTableModel::mimeTypes() +{ + QStringList list; + list << "text/plain"; + return list; +} + +void ProgramChangeTableModel::emit_layoutChanged() +{ + emit layoutChanged(); +} diff --git a/attic/muse2-oom/muse2/muse/widgets/pctablemodel.h b/attic/muse2-oom/muse2/muse/widgets/pctablemodel.h new file mode 100644 index 00000000..fe6da658 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/pctablemodel.h @@ -0,0 +1,16 @@ +#ifndef _PROGRAMCHAMGETABLEMODEL_ +#define _PROGRAMCHAMGETABLEMODEL_ + +#include <QStandardItemModel> +#include <QStringList> + +class ProgramChangeTableModel : public QStandardItemModel +{ + Q_OBJECT + virtual QStringList mimeTypes(); + + public: + ProgramChangeTableModel(QObject *parent = 0); + void emit_layoutChanged(); +}; +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/pitchedit.cpp b/attic/muse2-oom/muse2/muse/widgets/pitchedit.cpp new file mode 100644 index 00000000..563cd6a8 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/pitchedit.cpp @@ -0,0 +1,64 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: pitchedit.cpp,v 1.2 2004/01/09 17:12:54 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> +#include "pitchedit.h" +#include "helper.h" + +//--------------------------------------------------------- +// PitchEdit +//--------------------------------------------------------- + +PitchEdit::PitchEdit(QWidget* parent) + : QSpinBox(parent) + { + setMinimum(0); + setMaximum(127); + setSingleStep(1); + deltaMode = false; + } + +//--------------------------------------------------------- +// mapValueToText +//--------------------------------------------------------- + +QString PitchEdit::mapValueToText(int v) + { + if (deltaMode) { + QString s; + s.setNum(v); + return s; + } + else + return pitch2string(v); + } + +//--------------------------------------------------------- +// mapTextToValue +//--------------------------------------------------------- + +int PitchEdit::mapTextToValue(bool* ok) + { + printf("PitchEdit: mapTextToValue: not impl.\n"); + if (ok) + *ok = false; + return 0; + } + +//--------------------------------------------------------- +// setDeltaMode +//--------------------------------------------------------- + +void PitchEdit::setDeltaMode(bool val) + { + deltaMode = val; + if (deltaMode) + setRange(-127, 127); + else + setRange(0, 127); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/pitchedit.h b/attic/muse2-oom/muse2/muse/widgets/pitchedit.h new file mode 100644 index 00000000..8d2c8789 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/pitchedit.h @@ -0,0 +1,33 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: pitchedit.h,v 1.2 2004/01/09 17:12:54 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __PITCHEDIT_H__ +#define __PITCHEDIT_H__ + +#include <QSpinBox> + +//--------------------------------------------------------- +// PitchEdit +//--------------------------------------------------------- + +class PitchEdit : public QSpinBox { + Q_OBJECT + + bool deltaMode; + + protected: + virtual QString mapValueToText(int v); + virtual int mapTextToValue(bool* ok); + + public: + PitchEdit(QWidget* parent=0); + void setDeltaMode(bool); + }; + +extern QString pitch2string(int v); + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/pitchlabel.cpp b/attic/muse2-oom/muse2/muse/widgets/pitchlabel.cpp new file mode 100644 index 00000000..91daf09f --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/pitchlabel.cpp @@ -0,0 +1,97 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: pitchlabel.cpp,v 1.2 2004/05/16 16:55:01 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QApplication> +#include <QStyle> + +#include "pitchedit.h" +#include "pitchlabel.h" +#include "helper.h" + +//--------------------------------------------------------- +// PitchLabel +//--------------------------------------------------------- + +PitchLabel::PitchLabel(QWidget* parent, const char* name) + : QLabel(parent) + { + setObjectName(name); + _pitchMode = true; + _value = -1; + setFrameStyle(WinPanel | Sunken); + setLineWidth(2); + setMidLineWidth(3); + setValue(0); + //int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this); // ddskrjo 0 + int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + setIndent(fw); + } + +//--------------------------------------------------------- +// setPitchMode +//--------------------------------------------------------- + +void PitchLabel::setPitchMode(bool val) + { + _pitchMode = val; + } + +//--------------------------------------------------------- +// sizeHint +//--------------------------------------------------------- + +QSize PitchLabel::sizeHint() const + { + QFontMetrics fm(font()); + //int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this); // ddskrjo 0 + int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + int h = fm.height() + fw * 2; +// int w = 2 + fm.width(QString("A#8")) + fw * 4; + int w = 2 + fm.width(QString("-9999")) + fw * 4; // must display 14Bit controller values + return QSize(w, h).expandedTo(QApplication::globalStrut()); + } + +//--------------------------------------------------------- +// setValue +//--------------------------------------------------------- + +void PitchLabel::setValue(int val) + { + if (val == _value) + return; + _value = val; + QString s; + if (_pitchMode) + s = pitch2string(_value); + else + s.sprintf("%d", _value); + setText(s); + } + +//--------------------------------------------------------- +// setInt +//--------------------------------------------------------- + +void PitchLabel::setInt(int val) + { + if (_pitchMode) + setPitchMode(false); + setValue(val); + } + +//--------------------------------------------------------- +// setPitch +//--------------------------------------------------------- + +void PitchLabel::setPitch(int val) + { + if (!_pitchMode) { + setPitchMode(true); + } + setValue(val); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/pitchlabel.h b/attic/muse2-oom/muse2/muse/widgets/pitchlabel.h new file mode 100644 index 00000000..6372f711 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/pitchlabel.h @@ -0,0 +1,41 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: pitchlabel.h,v 1.1.1.1 2003/10/27 18:54:49 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __PITCHLABEL_H__ +#define __PITCHLABEL_H__ + +#include <QLabel> + +//--------------------------------------------------------- +// PitchLabel +//--------------------------------------------------------- + +class PitchLabel : public QLabel { + bool _pitchMode; + int _value; + Q_OBJECT + + protected: + QSize sizeHint() const; + + public slots: + void setValue(int); + void setInt(int); + void setPitch(int); + + public: + PitchLabel(QWidget* parent, const char* name = 0); + int value() const { return _value; } + void setPitchMode(bool val); + bool pitchMode() const { return _pitchMode; } + }; + + +#endif + + + diff --git a/attic/muse2-oom/muse2/muse/widgets/popupmenu.cpp b/attic/muse2-oom/muse2/muse/widgets/popupmenu.cpp new file mode 100644 index 00000000..862bda91 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/popupmenu.cpp @@ -0,0 +1,137 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: popupmenu.cpp,v 1.1.1.1 2010/07/18 03:21:00 terminator356 Exp $ +// +// (C) Copyright 1999-2010 Werner Schweer (ws@seh.de) +// +// PopupMenu sub-class of QMenu created by Tim. +//========================================================= + +//#include <stdio.h> +#include <QMouseEvent> +#include <QAction> +#include <stdio.h> +//#include <QStandardItemModel> + +#include "popupmenu.h" + +//====================== +// PopupMenu +//====================== + +PopupMenu::PopupMenu(QWidget* parent) + : QMenu(parent) +{ + // Menus will trigger! Set to make sure our trigger handlers ignore menus. + menuAction()->setData(-1); +} + +PopupMenu::~PopupMenu() +{ + //printf("PopupMenu::~PopupMenu\n"); +} + +void PopupMenu::clear() +{ + QList<QAction*> list = actions(); + for(int i = 0; i < list.size(); ++i) + { + QAction* act = list[i]; + QMenu* menu = act->menu(); + if(menu) + { + menu->clear(); + act->setMenu(0); // CHECK: Is this OK? + delete menu; + } + } + + // Now let QT remove and delete this menu's actions. + QMenu::clear(); +} + +QAction* PopupMenu::findActionFromData(QVariant v) +{ + QList<QAction*> list = actions(); + for(int i = 0; i < list.size(); ++i) + { + QAction* act = list[i]; + PopupMenu* menu = (PopupMenu*)act->menu(); + if(menu) + { + if(QAction* actm = menu->findActionFromData(v)) + return actm; + } + if(act->data() == v) + return act; + } + return 0; +} + +void PopupMenu::mouseReleaseEvent(QMouseEvent *e) +{ + //Q_D(QMenu); + //if (d->mouseEventTaken(e)) + // return; + + //d->mouseDown = false; + //QAction *action = d->actionAt(e->pos()); + QAction *action = actionAt(e->pos()); + + //for(QWidget *caused = this; caused;) { + // if (QMenu *m = qobject_cast<QMenu*>(caused)) { + // QAction *currentAction = d->currentAction; + // if(currentAction && (!currentAction->isEnabled() || currentAction->menu() || currentAction->isSeparator())) + // currentAction = 0; + // caused = m->d_func()->causedPopup.widget; + // if (m->d_func()->eventLoop) + // m->d_func()->syncAction = currentAction; // synchronous operation + // } else { + // break; + // } + //} + + //if (action && action == d->currentAction) { + if (action && action == activeAction() && !action->isSeparator() && action->isEnabled()) + { + //if (action->menu()) + // action->menu()->d_func()->setFirstActionActive(); + //else + //d->activateAction(action, QAction::Trigger); + action->activate(QAction::Trigger); + } + else + //if (d->motions > 6) { + // d->hideUpToMenuBar(); + // } + QMenu::mouseReleaseEvent(e); +} + +/* +//====================== +// PopupView +//====================== + +PopupView::PopupView(QWidget* parent) + : QColumnView(parent) +{ + _model= new QStandardItemModel(this); + // FIXME: After clearing, then re-filling, no items seen. + // But if setModel is called FOR THE FIRST TIME after clearing the model, + // then it works. Calling setModel any time after that does not work. + setModel(_model); +} + +PopupView::~PopupView() +{ + // Make sure to clear the popup so that any child popups are also deleted ! + //popup->clear(); +} + +void PopupView::clear() +{ + _model->clear(); +} +*/ + diff --git a/attic/muse2-oom/muse2/muse/widgets/popupmenu.h b/attic/muse2-oom/muse2/muse/widgets/popupmenu.h new file mode 100644 index 00000000..c06d51f4 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/popupmenu.h @@ -0,0 +1,59 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: popupmenu.h,v 1.1.1.1 2010/07/18 03:18:00 terminator356 Exp $ +// +// (C) Copyright 1999-2010 Werner Schweer (ws@seh.de) +// +// PopupMenu sub-class of QMenu created by Tim. +//========================================================= + +#ifndef __POPUPMENU_H__ +#define __POPUPMENU_H__ + +#include <QMenu> +//#include <QMouseEvent> +//#include <QColumnView> + +class QWidget; +class QMouseEvent; +class QVariant; +class QAction; +//class QStandardItemModel; + +class PopupMenu : public QMenu +{ + Q_OBJECT + + protected: + void mouseReleaseEvent(QMouseEvent *); + + public: + PopupMenu(QWidget* parent=0); + ~PopupMenu(); + void clear(); + QAction* findActionFromData(QVariant); +}; + + +/* +class PopupView : public QColumnView +{ + Q_OBJECT + private: + QStandardItemModel* _model; + + protected: + + public: + PopupView(QWidget* parent=0); + ~PopupView(); + + void clear(); + QStandardItemModel* model() { return _model; } +}; +*/ + + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/posedit.cpp b/attic/muse2-oom/muse2/muse/widgets/posedit.cpp new file mode 100644 index 00000000..3accf557 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/posedit.cpp @@ -0,0 +1,854 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: posedit.cpp,v 1.3.2.2 2008/05/21 00:28:54 terminator356 Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <values.h> + +#include <QApplication> +#include <QKeyEvent> +#include <QMouseEvent> +#include <QPaintEvent> +#include <QPainter> +#include <QResizeEvent> +#include <QString> +#include <QStyle> +#include <QTimerEvent> + +#include "posedit.h" +#include "sig.h" +#include "spinbox.h" + +extern int mtcType; + +//--------------------------------------------------------- +// QNumberSection +//--------------------------------------------------------- + +class QNumberSection + { + int selstart; + int selend; + + public: + QNumberSection(int selStart = 0, int selEnd = 0) + : selstart(selStart), selend(selEnd ) {} + int selectionStart() const { return selstart; } + void setSelectionStart(int s) { selstart = s; } + int selectionEnd() const { return selend; } + void setSelectionEnd( int s ) { selend = s; } + int width() const { return selend - selstart; } + }; + +//--------------------------------------------------------- +// PosEditor +//--------------------------------------------------------- + +class PosEditor : public QLineEdit + { + PosEdit* cw; + bool frm; + QPixmap *pm; + int focusSec; + QList<QNumberSection> sections; + QString sep; + int offset; + + int section(const QPoint&); + + protected: + void init(); + bool event(QEvent *e); + void resizeEvent(QResizeEvent*); + void paintEvent(QPaintEvent*); + void mousePressEvent(QMouseEvent *e); + void keyPressEvent(QKeyEvent * event ); + void applyFocusSelection() {} + + public: + PosEditor(PosEdit* Q_PARENT, const char * Q_NAME ); + ~PosEditor(); + + void setControlWidget(PosEdit * widget); + PosEdit* controlWidget() const; + + void setSeparator(const QString& s) { sep = s; } + QString separator() const { return sep; } + int focusSection() const { return focusSec; } + + bool setFocusSection(int s); + void appendSection(const QNumberSection& sec); + void clearSections(); + void setSectionSelection(int sec, int selstart, int selend); + }; + +//--------------------------------------------------------- +// section +//--------------------------------------------------------- + +int PosEditor::section(const QPoint& pt) + { + if (pm->isNull()) + return -1; + QPainter p(pm); + int fw = frm ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth) : 0; + int x = 2 + fw; + int y = 0; + int w = width(); + int h = height(); + for (int i = 0; i < sections.count(); ++i) { + QString s = cw->sectionFormattedText(i); + QRect bb = p.boundingRect(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s); + int nx = bb.x() + bb.width(); + if (pt.x() >= x && pt.x() < nx) + return i; + x = nx; + if (i < sections.count()-1) { + QString s = sep; + p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb); + x = bb.x() + bb.width(); + } + } + return -1; + } + +//--------------------------------------------------------- +// PosEditor +//--------------------------------------------------------- + +PosEditor::PosEditor(PosEdit* parent, const char* name) + : QLineEdit(parent), sep(".") + { + setObjectName(name); + cw = parent; + frm = true; + focusSec = 0; + pm = new QPixmap; + offset = 0; + init(); + } + +//--------------------------------------------------------- +// ~PosEditor +//--------------------------------------------------------- + +PosEditor::~PosEditor() + { + delete pm; + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +void PosEditor::init() + { + setBackgroundMode(Qt::PaletteBase); + setFocusSection(-1); + setKeyCompression(true); + setFocusPolicy(Qt::WheelFocus); + } + +//--------------------------------------------------------- +// event +//--------------------------------------------------------- + +bool PosEditor::event(QEvent *e) + { + if (e->type() == QEvent::FocusIn || e->type() == QEvent::FocusOut) { + repaint( rect(), false); + } + else if (e->type() == QEvent::ShortcutOverride) { + QKeyEvent* ke = (QKeyEvent*) e; + switch (ke->key()) { + case Qt::Key_Delete: + case Qt::Key_Backspace: + case Qt::Key_Up: + case Qt::Key_Down: + case Qt::Key_Left: + case Qt::Key_Right: + ke->accept(); + default: + break; + } + } + return QWidget::event(e); + } + +void PosEditor::resizeEvent(QResizeEvent *e) + { + pm->resize(e->size()); + QWidget::resizeEvent(e); + } + +//--------------------------------------------------------- +// paintEvent +//--------------------------------------------------------- + +void PosEditor::paintEvent(QPaintEvent *) + { + if (pm->isNull()) + return; + + const QColorGroup & cg = colorGroup(); + QPainter p(pm); + p.setPen(colorGroup().text()); + QBrush bg = cg.brush(QColorGroup::Base); + + int fw = frm ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth) : 0; + int x = 2 + fw; + int y = 0; + int w = width(); + int h = height(); + p.fillRect(0, 0, w, h, bg); + + for (int i = 0; i < sections.count(); ++i) { + QRect bb; + QString s = cw->sectionFormattedText(i); + + if (hasFocus() && (int(i) == focusSec)) { + QBrush bg = cg.brush(QColorGroup::Highlight); + QRect r = p.boundingRect(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1); + p.setPen(colorGroup().highlightedText()); + p.fillRect(r, bg); + } + else + p.setPen(colorGroup().text()); + p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb); + x = bb.x() + bb.width(); + if (i < sections.count()-1) { + QString s = sep; + p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb); + x = bb.x() + bb.width(); + } + } + p.end(); + bitBlt(this, 0, 0, pm); + } + +//--------------------------------------------------------- +// mousePressEvent +//--------------------------------------------------------- + +void PosEditor::mousePressEvent(QMouseEvent *e) + { + QPoint p(e->pos().x(), 0); + int sec = section(p); + if (sec != -1) { + cw->setFocusSection(sec); + repaint(rect(), false); + } + } + +//--------------------------------------------------------- +// keyPressEvent +//--------------------------------------------------------- + +void PosEditor::keyPressEvent(QKeyEvent *e) + { + switch (e->key()) { + case Qt::Key_Right: + if (unsigned(focusSec) <= sections.count()) { + if (cw->setFocusSection(focusSec+1)) + repaint(rect(), false); + } + case Qt::Key_Left: + if (focusSec > 0 ) { + if (cw->setFocusSection(focusSec-1)) + repaint(rect(), false); + } + case Qt::Key_Up: + cw->stepUp(); + case Qt::Key_Down: + cw->stepDown(); + case Qt::Key_Backspace: + case Qt::Key_Delete: + cw->removeLastNumber(focusSec); + case Qt::Key_Return: + cw->enterPressed(); + default: + QString txt = e->text(); + if (!txt.isEmpty() && !sep.isEmpty() && txt[0] == sep[0]) { + // do the same thing as KEY_RIGHT when the user presses the separator key + if (unsigned(focusSec) < sections.count()) { + if (cw->setFocusSection(focusSec+1)) + repaint(rect(), false); + } + } + int num = txt[0].digitValue(); + if (num != -1) { + cw->addNumber(focusSec, num); + } + } + } + +void PosEditor::appendSection(const QNumberSection& sec) + { + sections.append(sec); + } +void PosEditor::clearSections() + { + sections.clear(); + } + +//--------------------------------------------------------- +// setSectionSelection +//--------------------------------------------------------- + +void PosEditor::setSectionSelection(int secNo, int selstart, int selend) + { + if (secNo < 0 || secNo > (int)sections.count()) + return; + sections[secNo].setSelectionStart(selstart); + sections[secNo].setSelectionEnd(selend); + } + +//--------------------------------------------------------- +// setFocusSection +//--------------------------------------------------------- + +bool PosEditor::setFocusSection(int idx) + { + if (idx > (int)sections.count()-1 || idx < 0) + return false; + if (idx != focusSec) { + focusSec = idx; + applyFocusSelection(); + return true; + } + return false; + } + +//--------------------------------------------------------- +// PosEdit +//--------------------------------------------------------- + +PosEdit::PosEdit(QWidget* parent, const char* name) + : QWidget(parent) + { + setObjectName(name); + init(); + updateButtons(); + } + +PosEdit::PosEdit(const Pos& time, QWidget* parent, const char* name) + : QWidget(parent, name) + { + init(); + setValue(time); + updateButtons(); + } + +PosEdit::~PosEdit() + { + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +void PosEdit::init() + { + ed = new PosEditor(this, "pos editor"); + controls = new SpinBox(this); + controls->setEditor(ed); + setFocusProxy(ed); + connect(controls, SIGNAL(stepUpPressed()), SLOT(stepUp())); + connect(controls, SIGNAL(stepDownPressed()), SLOT(stepDown())); + connect(this, SIGNAL(valueChanged(const Pos&)),SLOT(updateButtons())); + + overwrite = false; + timerId = 0; + typing = false; + min = Pos(0); + max = Pos(MAX_TICK); + changed = false; + adv = false; + + + static Section s_midiSections[3] = { // measure, beat, tick + { 0, 4, 1, 0 }, + { 5, 2, 1, 0 }, + { 8, 3, 0, 0 } + }; + static Section s_smpteSections[4] = { // minute second frame subframe + { 0, 3, 0, 0 }, + { 4, 2, 0, 0 }, + { 7, 2, 0, 0 }, + { 10, 2, 0, 0 } + }; + memcpy(midiSections, s_midiSections, sizeof(s_midiSections)); + memcpy(smpteSections, s_smpteSections, sizeof(s_smpteSections)); + + _smpte = false; // show position in smpte format + sec = midiSections; + setSections(); + setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed)); + } + +//--------------------------------------------------------- +// setSetions +//--------------------------------------------------------- + +void PosEdit::setSections() + { + ed->clearSections(); + ed->appendSection(QNumberSection(0,0)); + ed->appendSection(QNumberSection(0,0)); + ed->appendSection(QNumberSection(0,0)); + if (_smpte) { + ed->appendSection(QNumberSection(0,0)); + ed->setSeparator(QString(":")); + } + else { + ed->setSeparator(QString(".")); + } + } + +//--------------------------------------------------------- +// smpte +//--------------------------------------------------------- + +bool PosEdit::smpte() const + { + return _smpte; + } + +//--------------------------------------------------------- +// setSmpte +//--------------------------------------------------------- + +void PosEdit::setSmpte(bool f) + { + _smpte = f; + sec = f ? smpteSections : midiSections; + setSections(); + ed->repaint(ed->rect(), false); + } + +//--------------------------------------------------------- +// minValue +//--------------------------------------------------------- + +Pos PosEdit::minValue() const + { + return min; + } + +//--------------------------------------------------------- +// maxValue +//--------------------------------------------------------- + +Pos PosEdit::maxValue() const + { + return max; + } + +//--------------------------------------------------------- +// setRange +//--------------------------------------------------------- + +void PosEdit::setRange(const Pos& _min, const Pos& _max) + { + if (min.isValid()) + min = _min; + if (max.isValid()) + max = _max; + } + +//--------------------------------------------------------- +// setValue +//--------------------------------------------------------- + +void PosEdit::setValue(const Pos& time) + { + if (time > maxValue() || time < minValue()) + return; + if (_smpte) + time.msf(&(sec[0].val), &(sec[1].val), &(sec[2].val), + &(sec[3].val)); + else + time.mbt(&(sec[0].val), &(sec[1].val), &(sec[2].val)); + changed = false; + + updateButtons(); + ed->repaint(ed->rect(), false); + } + +void PosEdit::setValue(const QString& s) + { + Pos time(s); + setValue(time); + } + +void PosEdit::setValue(int t) + { + Pos time(t); + setValue(time); + } + +Pos PosEdit::pos() const + { + if (_smpte) { + if (Pos::isValid(sec[0].val, sec[1].val, sec[2].val, sec[3].val)) + return Pos(sec[0].val, sec[1].val, sec[2].val, sec[3].val); + } + else { + if (Pos::isValid(sec[0].val, sec[1].val, sec[2].val)) + return Pos(sec[0].val, sec[1].val, sec[2].val); + } + return Pos(); + } + +void PosEdit::setSeparator(const QString& s) + { + ed->setSeparator(s); + } + +QString PosEdit::separator() const + { + return ed->separator(); + } + +bool PosEdit::event(QEvent *e) + { + if (e->type() == QEvent::FocusOut) { + typing = false; + if (changed) { + emit valueChanged(pos() ); + changed = false; + } + } + return QWidget::event(e); + } + +void PosEdit::timerEvent(QTimerEvent *) + { + overwrite = true; + } + +//--------------------------------------------------------- +// stepUp +//--------------------------------------------------------- + +void PosEdit::stepUp() + { + int secNo = ed->focusSection(); + bool accepted = false; + + if (!outOfRange(secNo, sec[secNo].val+1)) { + accepted = true; + setSec(secNo, sec[secNo].val+1); + } + if (accepted) { + changed = true; + Pos p = pos(); + emit valueChanged(p); + } + ed->repaint(ed->rect(), false); + } + +//--------------------------------------------------------- +// stepDown +//--------------------------------------------------------- + +void PosEdit::stepDown() + { + int secNo = ed->focusSection(); + bool accepted = false; + if (!outOfRange(secNo, sec[secNo].val-1)) { + accepted = true; + setSec(secNo, sec[secNo].val-1); + } + if (accepted) { + changed = true; + emit valueChanged(pos()); + } + ed->repaint(ed->rect(), false); + } + +//--------------------------------------------------------- +// sectionFormattedText +// Returns the formatted number for section sec. +//--------------------------------------------------------- + +QString PosEdit::sectionFormattedText(int secNo) + { + QString txt = sectionText(secNo); + int so = sec[secNo].offset; + int len = sec[secNo].len; + int eo = so + len; + + if (typing && secNo == ed->focusSection()) + ed->setSectionSelection(secNo, eo - txt.length(), eo); + else + ed->setSectionSelection(secNo, so, eo); + txt = txt.rightJustify(len, '0'); + return txt; + } + +//--------------------------------------------------------- +// setFocusSection +//--------------------------------------------------------- + +bool PosEdit::setFocusSection(int s) + { + if (s != ed->focusSection()) { + killTimer(timerId); + overwrite = true; + typing = false; + int so = sec[s].offset; + int eo = so + sec[s].len; + ed->setSectionSelection(s, so, eo); + if (changed) { + emit valueChanged(pos()); + changed = false; + } + } + return ed->setFocusSection(s); + } + +//--------------------------------------------------------- +// setSec +//--------------------------------------------------------- + +void PosEdit::setSec(int secNo, int val) + { + if (val < 0) + val = 0; + if (_smpte) { + switch(secNo) { + case 0: + break; + case 1: + if (val > 59) + val = 59; + break; + case 2: + switch(mtcType) { + case 0: // 24 frames sec + if (val > 23) + val = 23; + break; + case 1: + if (val > 24) + val = 24; + break; + case 2: // 30 drop frame + case 3: // 30 non drop frame + if (val > 29) + val = 29; + break; + } + break; + case 3: + if (val > 99) + val = 99; + } + } + else { + switch(secNo) { + case 0: + break; + case 1: + { + int z, n; + int tick = sigmap.bar2tick(sec[0].val, val, sec[2].val); + sigmap.timesig(tick, z, n); + if (val >= n) + val = n-1; + } + break; + case 2: + { + int tick = sigmap.bar2tick(sec[0].val, sec[1].val, val); + int tb = sigmap.ticksBeat(tick); + if (val >= tb) + val = tb-1; + } + break; + } + } + sec[secNo].val = val; + } + +//--------------------------------------------------------- +// sectionText +// Returns the text of section \a sec. +//--------------------------------------------------------- + +QString PosEdit::sectionText(int secNo) + { + return QString::number(sec[secNo].val + sec[secNo].voff); + } + +//--------------------------------------------------------- +// outOfRange +// return true if out of range +//--------------------------------------------------------- + +bool PosEdit::outOfRange(int secNo, int val) const + { + if (val < 0) + return true; + int limit = MAXINT; + if (_smpte) { + switch(secNo) { + case 0: + break; + case 1: + limit = 59; + break; + case 2: + switch(mtcType) { + case 0: // 24 frames sec + limit = 23; + break; + case 1: + limit = 24; + break; + case 2: // 30 drop frame + case 3: // 30 non drop frame + limit = 29; + break; + } + break; + case 3: + limit = 99; + break; + } + } + else { + switch(secNo) { + case 0: + break; + case 1: + { + int z; + int tick = sigmap.bar2tick(sec[0].val, val, sec[2].val); + sigmap.timesig(tick, z, limit); + limit -= 1; + } + break; + case 2: + int tick = sigmap.bar2tick(sec[0].val, sec[1].val, val); + limit = sigmap.ticksBeat(tick) - 1; + break; + } + } + return val > limit; + } + +//--------------------------------------------------------- +// addNumber +//--------------------------------------------------------- + +void PosEdit::addNumber(int secNo, int num) + { + if (secNo == -1) + return; + killTimer(timerId); + bool accepted = false; + typing = true; + int voff = sec[secNo].voff; + + QString txt = sectionText(secNo); + + if ((unsigned) txt.length() == sec[secNo].len) { + if (!outOfRange(secNo, num - voff)) { + accepted = true; + sec[secNo].val = num - voff; + } + } + else { + txt += QString::number(num); + int temp = txt.toInt() - voff; + if (outOfRange(secNo, temp)) + txt = sectionText(secNo); + else { + accepted = true; + sec[secNo].val = temp; + } + if (adv && ((unsigned) txt.length() == sec[secNo].len)) { + setFocusSection(ed->focusSection() + 1); + } + } + changed = accepted; + if (accepted) + emit valueChanged(pos()); + timerId = startTimer(qApp->doubleClickInterval()*4); + ed->repaint(ed->rect(), false); + } + +//--------------------------------------------------------- +// removeLastNumber +//--------------------------------------------------------- + +void PosEdit::removeLastNumber(int secNo) + { + if (secNo == -1) + return; + QString txt = QString::number(sec[secNo].val); + txt = txt.mid(0, txt.length() - 1); + sec[secNo].val = txt.toInt() - sec[secNo].voff; + ed->repaint(ed->rect(), false); + } + +//--------------------------------------------------------- +// resizeEvent +//--------------------------------------------------------- + +void PosEdit::resizeEvent(QResizeEvent *) + { + controls->resize(width(), height()); + } + +//--------------------------------------------------------- +// sizeHint +//--------------------------------------------------------- + +QSize PosEdit::sizeHint() const + { + QFontMetrics fm(font()); + int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth,0, this); // ddskrjo 0 + int h = fm.height() + fw * 2; + int w = 4 + controls->arrowWidth() + fw * 4; + if (_smpte) + w += fm.width('9') * 10 + fm.width(ed->separator()) * 3; + else + w += fm.width('9') * 10 + fm.width(ed->separator()) * 2; + return QSize(w, h).expandedTo(QApplication::globalStrut()); + } + +//--------------------------------------------------------- +// updateButtons +//--------------------------------------------------------- + +void PosEdit::updateButtons() + { + bool upEnabled = isEnabled() && (pos() < maxValue()); + bool downEnabled = isEnabled() && (pos() > minValue()); + + //printf("PosEdit::updateButtons smpte:%d upEnabled:%d downEnabled:%d\n", smpte(), upEnabled, downEnabled); + + controls->setStepEnabled(upEnabled, downEnabled); + } + +//--------------------------------------------------------- +// enterPressed +//--------------------------------------------------------- +void PosEdit::enterPressed() + { + emit returnPressed(); + } + +//--------------------------------------------------------- +// setEnabled +//--------------------------------------------------------- +void PosEdit::setEnabled(bool v) +{ + QWidget::setEnabled(v); + updateButtons(); +} diff --git a/attic/muse2-oom/muse2/muse/widgets/posedit.h b/attic/muse2-oom/muse2/muse/widgets/posedit.h new file mode 100644 index 00000000..e17da3a2 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/posedit.h @@ -0,0 +1,104 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: posedit.h,v 1.1.1.1.2.1 2004/12/27 19:47:25 lunar_shuttle Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __POSEDIT_H__ +#define __POSEDIT_H__ + +#include <QWidget> + +#include "pos.h" +#include "section.h" + +class QResizeEvent; +class QTimerEvent; + +class PosEditor; +class SpinBox; + +//--------------------------------------------------------- +// PosEdit +//--------------------------------------------------------- + +class PosEdit : public QWidget + { + Q_OBJECT + Q_PROPERTY(QString separator READ separator WRITE setSeparator) + Q_PROPERTY(bool smpte READ smpte WRITE setSmpte) + + void init(); + void setSections(); + QString sectionText(int sec); + Section midiSections[3]; + Section smpteSections[4]; + Section* sec; + + bool _smpte; + + bool adv; + bool overwrite; + int timerId; + bool typing; + Pos min; + Pos max; + bool changed; + PosEditor *ed; + SpinBox* controls; + + private slots: + void stepUp(); + void stepDown(); + + signals: + void valueChanged(const Pos&); + void returnPressed(); + + protected: + bool event(QEvent *e ); + void timerEvent(QTimerEvent* e); + void resizeEvent(QResizeEvent*); + QString sectionFormattedText(int sec); + void addNumber(int sec, int num); + void removeLastNumber(int sec); + bool setFocusSection(int s); + + virtual bool outOfRange(int, int) const; + virtual void setSec(int, int); + friend class PosEditor; + + protected slots: + void updateButtons(); + + public slots: + virtual void setValue(const Pos& time); + void setValue(int t); + void setValue(const QString& s); + // Added p3.3.43 + virtual void setEnabled(bool); + + public: + PosEdit(QWidget* = 0, const char* = 0); + PosEdit(const Pos& time, QWidget*, const char* = 0); + ~PosEdit(); + + QSize sizeHint() const; + Pos pos() const; + virtual void setAutoAdvance(bool advance) { adv = advance; } + bool autoAdvance() const { return adv; } + + virtual void setMinValue(const Pos& d) { setRange(d, maxValue()); } + Pos minValue() const; + virtual void setMaxValue( const Pos& d ) { setRange(minValue(), d ); } + Pos maxValue() const; + virtual void setRange(const Pos& min, const Pos& max); + QString separator() const; + virtual void setSeparator(const QString& s); + void setSmpte(bool); + bool smpte() const; + void enterPressed(); + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/poslabel.cpp b/attic/muse2-oom/muse2/muse/widgets/poslabel.cpp new file mode 100644 index 00000000..78903a1f --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/poslabel.cpp @@ -0,0 +1,156 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: poslabel.cpp,v 1.2.2.2 2009/04/06 01:24:55 terminator356 Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdlib.h> +#include <cmath> + +#include <QApplication> +#include <QStyle> + + +#include "poslabel.h" +///#include "sig.h" +#include "al/sig.h" +#include "tempo.h" +#include "globals.h" + +extern int mtcType; + +//--------------------------------------------------------- +// PosLabel +//--------------------------------------------------------- + +PosLabel::PosLabel(QWidget* parent, const char* name) + : QLabel(parent) + { + setObjectName(name); + _tickValue = 0; + _sampleValue = 0; + _smpte = false; + setFrameStyle(WinPanel | Sunken); + setLineWidth(2); + setMidLineWidth(3); + //int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this); // ddskrjo 0 + int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + setIndent(fw); + updateValue(); + } + +//--------------------------------------------------------- +// sizeHint +//--------------------------------------------------------- + +QSize PosLabel::sizeHint() const + { + QFontMetrics fm(font()); + //int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this); // ddskrjo 0 + int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + int h = fm.height() + fw * 2; + int w; + if (_smpte) + w = 2 + fm.width('9') * 9 + fm.width(':') * 3 + fw * 4; + else + w = 2 + fm.width('9') * 9 + fm.width('.') * 2 + fw * 4; + return QSize(w, h).expandedTo(QApplication::globalStrut()); + } + +//--------------------------------------------------------- +// updateValue +//--------------------------------------------------------- + +void PosLabel::updateValue() + { + QString s; + if (_smpte) { + double time = double(_sampleValue) / double(sampleRate); + int min = int(time) / 60; + int sec = int(time) % 60; + double rest = time - (min * 60 + sec); + switch(mtcType) { + case 0: // 24 frames sec + rest *= 24; + break; + case 1: // 25 + rest *= 25; + break; + case 2: // 30 drop frame + rest *= 30; + break; + case 3: // 30 non drop frame + rest *= 30; + break; + } + int frame = int(rest); + int subframe = int((rest-frame)*100); + s.sprintf("%03d:%02d:%02d:%02d", min, sec, frame, subframe); + } + else { + int bar, beat; + unsigned tick; + AL::sigmap.tickValues(_tickValue, &bar, &beat, &tick); + //s.sprintf("%04d.%02d.%03ud", bar+1, beat+1, tick); + s.sprintf("%04d.%02d.%03u", bar+1, beat+1, tick); + } + setText(s); + } + +//--------------------------------------------------------- +// setSampleValue +//--------------------------------------------------------- + +void PosLabel::setSampleValue(unsigned val) + { + if (val == _sampleValue) + return; + _sampleValue = val; + updateValue(); + } + +//--------------------------------------------------------- +// setTickValue +//--------------------------------------------------------- + +void PosLabel::setTickValue(unsigned val) + { + if (val == _tickValue) + return; + if (val >= MAX_TICK) + abort(); + _tickValue = val; + updateValue(); + } + +//--------------------------------------------------------- +// setValue +//--------------------------------------------------------- + +void PosLabel::setValue(unsigned val) + { + unsigned oval = _smpte ? _sampleValue : _tickValue; + if (val == oval) + return; + if (_smpte) + _sampleValue = val; + else + _tickValue = val; + updateValue(); + } + +//--------------------------------------------------------- +// setSmpte +//--------------------------------------------------------- + +void PosLabel::setSmpte(bool val) + { + _smpte = val; + if (val) + _sampleValue = tempomap.tick2frame(_tickValue); + else + _tickValue = tempomap.frame2tick(_sampleValue); + updateValue(); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/poslabel.h b/attic/muse2-oom/muse2/muse/widgets/poslabel.h new file mode 100644 index 00000000..29c5297d --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/poslabel.h @@ -0,0 +1,45 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: poslabel.h,v 1.2 2004/01/11 18:55:37 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __POSLABEL_H__ +#define __POSLABEL_H__ + +#include <QLabel> + +//--------------------------------------------------------- +// PosLabel +//--------------------------------------------------------- + +class PosLabel : public QLabel { + bool _smpte; + unsigned _tickValue; + unsigned _sampleValue; + Q_OBJECT + + void updateValue(); + + protected: + QSize sizeHint() const; + + public slots: + void setTickValue(unsigned); + void setSampleValue(unsigned); + void setValue(unsigned); + + public: + PosLabel(QWidget* parent, const char* name = 0); + unsigned value() const { return _smpte ? _sampleValue : _tickValue; } + unsigned tickValue() const { return _tickValue; } + unsigned sampleValue() const { return _sampleValue; } + void setSmpte(bool); + bool smpte() const { return _smpte; } + }; + + +#endif + + diff --git a/attic/muse2-oom/muse2/muse/widgets/projectcreate.ui b/attic/muse2-oom/muse2/muse/widgets/projectcreate.ui new file mode 100644 index 00000000..406c83d6 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/projectcreate.ui @@ -0,0 +1,145 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ProjectCreate</class> + <widget class="QDialog" name="ProjectCreate"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>569</width> + <height>340</height> + </rect> + </property> + <property name="windowTitle"> + <string>Create Project</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Project Name:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLineEdit" name="projectNameEdit"/> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>75</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Project Path to song file:</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QCheckBox" name="createFolderCheckbox"> + <property name="text"> + <string>Create project folder (recommended for audio projects)</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLineEdit" name="storageDirEdit"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="browseDirButton"> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Song information:</string> + </property> + </widget> + </item> + <item> + <widget class="QPlainTextEdit" name="commentEdit"/> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>ProjectCreate</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.cpp b/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.cpp new file mode 100644 index 00000000..a019df95 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.cpp @@ -0,0 +1,65 @@ +#include <stdio.h> +#include <qfiledialog.h> +#include <qdir.h> +#include "projectcreateimpl.h" +#include "gconfig.h" +#include "globals.h" +#include "app.h" + +ProjectCreateImpl::ProjectCreateImpl(QWidget *parent) : + QDialog(parent) +{ + setupUi(this); + + createFolderCheckbox->setChecked(config.projectStoreInFolder); + connect(browseDirButton,SIGNAL(clicked()), this, SLOT(selectDirectory())); + connect(projectNameEdit,SIGNAL(textChanged(QString)), this, SLOT(updateDirectoryPath())); + connect(createFolderCheckbox,SIGNAL(clicked()), this, SLOT(updateDirectoryPath())); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(ok())); +#if QT_VERSION >= 0x040700 + projectNameEdit->setPlaceholderText("<Project Name>"); + // Orcan: Commented out since there is no QPlainTextEdit::setPlaceholderText() + // as of Qt-4.7.1 + //commentEdit->setPlaceholderText("<Add information about project here>"); +#endif + directoryPath = config.projectBaseFolder; + updateDirectoryPath(); + show(); +} + +void ProjectCreateImpl::selectDirectory() +{ + QFileDialog qfd; + qfd.selectFile(directoryPath); + qfd.setFileMode(QFileDialog::DirectoryOnly); + if (qfd.exec() == QDialog::Rejected) { + return; + } + directoryPath=qfd.selectedFiles().first(); + updateDirectoryPath(); +} + +void ProjectCreateImpl::updateDirectoryPath() +{ + if (createFolderCheckbox->isChecked()) { + storageDirEdit->setText(directoryPath + projectNameEdit->text() + "/" + projectNameEdit->text() + ".med"); + } else { + storageDirEdit->setText(directoryPath + projectNameEdit->text() + ".med"); + } +} + +QString ProjectCreateImpl::getProjectPath() +{ + return storageDirEdit->text(); +} +QString ProjectCreateImpl::getSongInfo() +{ + return commentEdit->toPlainText(); +} +void ProjectCreateImpl::ok() +{ + config.projectStoreInFolder = createFolderCheckbox->isChecked(); + config.projectBaseFolder = directoryPath; + muse->changeConfig(true); + emit accept(); +} diff --git a/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.h b/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.h new file mode 100644 index 00000000..77547c1a --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.h @@ -0,0 +1,26 @@ +#ifndef PROJECTCREATEIMPL_H +#define PROJECTCREATEIMPL_H + +#include <QDialog> +#include "ui_projectcreate.h" + +class ProjectCreateImpl : public QDialog, Ui::ProjectCreate +{ +Q_OBJECT + + QString directoryPath; +public: + explicit ProjectCreateImpl(QWidget *parent = 0); + QString getProjectPath(); + QString getSongInfo(); + +signals: + +public slots: + void updateDirectoryPath(); + void selectDirectory(); + void ok(); + +}; + +#endif // PROJECTCREATEIMPL_H diff --git a/attic/muse2-oom/muse2/muse/widgets/scldiv.cpp b/attic/muse2-oom/muse2/muse/widgets/scldiv.cpp new file mode 100644 index 00000000..0a75cbd4 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/scldiv.cpp @@ -0,0 +1,655 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: scldiv.cpp,v 1.1.1.1 2003/10/27 18:54:32 wschweer Exp $ +// +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include <cmath> +#include "scldiv.h" +#include "mmath.h" + +// ScaleDiv - A class for building scale divisions +// +// The ScaleDiv class can build +// linear and logarithmic scale divisions for specified +// intervals. It uses an adjustable algorithm to +// generate the major and minor step widths automatically. +// A scale division has a minimum value, a maximum value, +// a vector of major marks, and a vector of minor marks. +// +// ScaleDiv uses implicit sharing for the mark vectors. +// +// Build a logarithmic scale division from 0.01 to 1000 +// and print out the major and minor marks. +//.c +// #include <scldiv.h> +// #include <iostream.h> +// +// main() +// { +// int i,k; +// ScaleDiv sd; +// +// sd.rebuild(0.01, 100, 10, 10, TRUE, 0.0); +// +// k=0; +// for (i=0;i<sd.majCnt();i++) +// { +// while(k < sd.minCnt()) +// { +// if(sd.minMark(k) < sd.majMark(i)) +// { +// cout << " - " << sd.minMark(i) << "\n"; +// k++; +// } +// else +// break; +// } +// cout << "-- " << sd.majMark(i) << "\n"; +// } +// while(k < sd.minCnt()) +// { +// cout << " - " << sd.minMark(i) << "\n"; +// k++; +// } +// } +// +//------------------------------------------------------------ + +static const double step_eps = 1.0e-3; +static const double border_eps = 1.0e-10; + +static bool limRange(double &val, double v1, double v2, double eps_rel = 0.0, + double eps_abs = 0.0) + { + + bool rv = TRUE; + double vmin = qwtMin(v1, v2); + double vmax = qwtMax(v1, v2); + double delta_min = qwtMax(qwtAbs(eps_rel * vmin), qwtAbs(eps_abs)); + double delta_max = qwtMax(qwtAbs(eps_rel * vmax), qwtAbs(eps_abs)); + + if (val < vmin) + { + if (val < vmin - delta_min) rv = FALSE; + val = vmin; + } + else if (val > vmax) + { + if (val > vmax + delta_max) rv = FALSE; + val = vmax; + } + return rv; + +} + +//------------------------------------------------------------ +//.F ScaleDiv::ScaleDiv +// Construct a ScaleDiv instance. +// +//.u Syntax +//.f ScaleDiv::ScaleDiv() +//------------------------------------------------------------ + +ScaleDiv::ScaleDiv() + { + d_lBound = 0.0; + d_hBound = 0.0; + d_majStep = 0.0; + d_log = FALSE; + } + +//------------------------------------------------------------ +//.F ScaleDiv::~ScaleDiv +// Destroy a ScaleDiv instance. +// +//.u Syntax +//.f ScaleDiv::~ScaleDiv() +//------------------------------------------------------------ + +ScaleDiv::~ScaleDiv() + { + } + +//------------------------------------------------------------ +//.F ScaleDiv::ScaleDiv +// Copy Constructor +// +//.u Syntax +//.f ScaleDiv::ScaleDiv(const ScaleDiv &s) +// +//.u Parameters +//.p const ScaleDiv &s -- scale division to be copied +//------------------------------------------------------------ + +ScaleDiv::ScaleDiv(const ScaleDiv &s) + { + copy(s); + } + +//------------------------------------------------------------ +//.F ScaleDiv::operator= +// Assignment operator +// +//.u Syntax +//.f ScaleDiv & ScaleDiv::operator=(const ScaleDiv &s) +// +//.u Parameters +//.p const ScaleDiv &s -- scale divison to be assigned +//------------------------------------------------------------ + +ScaleDiv& ScaleDiv::operator=(const ScaleDiv &s) + { + copy(s); + return *this; + } + +//------------------------------------------------------------ +//.F ScaleDiv::copy +// Copy member data from another ScaleDiv instance. +// +//.u Syntax +//.f void ScaleDiv::copy(const ScaleDiv &s) +// +//.u Parameters +//.p const ScaleDiv &s +//------------------------------------------------------------ + +void ScaleDiv::copy(const ScaleDiv &s) + { + d_lBound = s.d_lBound; + d_hBound = s.d_hBound; + d_log = s.d_log; + d_majStep = s.d_majStep; + d_minMarks = s.d_minMarks; + d_majMarks = s.d_majMarks; + } + +//------------------------------------------------------------ +//.F ScaleDiv::rebuild +// Build a scale width major and minor divisions +// +//.p +// double x1 -- first boundary value +// double x2 -- second boundary value +// int maxMajSteps -- max. number of major step intervals +// int maxMinSteps -- max. number of minor step intervals +// bool log -- logarithmic division (TRUE/FALSE) +// double step -- fixed major step width. Defaults to 0.0. +// bool ascend -- if TRUE, sort in ascending order from min(x1, x2) +// to max(x1, x2). If FALSE, sort in the direction +// from x1 to x2. Defaults to TRUE. +// +//.u Return Value +// True if the arrays have been allocated successfully. +// +//.u Description +// If no fixed step width is specified or if it is set to 0, the +// major step width will be calculated automatically according to the +// the value of maxMajSteps. The maxMajSteps parameter has no effect +// if a fixed step size is specified. The minor step width is always +// calculated automatically. +// If the step width is to be calculated automatically, the algorithm +// tries to find reasonable values fitting into the scheme {1,2,5}*10^n +// with an integer number n for linear scales. +// For logarithmic scales, there are three different cases: +//.i +// -- If the major step width is one decade, the minor marks +// will fit into one of the schemes {1,2,...9}, {2,4,6,8}, {2,5} or {5}, +// depending on the maxMinSteps parameter. +// -- If the major step size spans +// more than one decade, the minor step size will be {1,2,5}*10^n decades +// with a natural number n. +// -- If the whole range is less than one decade, a linear scale +// division will be built +// +//.u Note +// For logarithmic scales, the step width is measured in decades. +//------------------------------------------------------------ + +bool ScaleDiv::rebuild(double x1, double x2, int maxMajSteps, int maxMinSteps, + bool log, double step, bool ascend) +{ + + int rv; + + d_lBound = qwtMin(x1, x2); + d_hBound = qwtMax(x1, x2); + d_log = log; + + if (d_log) + rv = buildLogDiv(maxMajSteps,maxMinSteps,step); + else + rv = buildLinDiv(maxMajSteps, maxMinSteps, step); + + if ((!ascend) && (x2 < x1)) + { + d_lBound = x1; + d_hBound = x2; + qwtTwistArray(d_majMarks.data(), d_majMarks.size()); + qwtTwistArray(d_minMarks.data(), d_minMarks.size()); + } + + return rv; + +} + +//------------------------------------------------------------ +//.F ScaleDiv::buildLinDiv +// Build a linear scale division in ascending order +// +//.u Syntax +//.f bool ScaleDiv::buildLinDiv(int majSteps, int minSteps, double step) +// +//.u Parameters +//.p int maxSteps -- max. number of step intervals +// double step -- fixed step width +// +//.u Return Value +// TRUE if array has been successfully resized +// +//.u Description +// If the 'step' parameter is set to 0.0, this function +// cal[culates the step width automatically according to +// the value of 'maxSteps'. MaxSteps must be greater than or +// equal to 2. It will be guessed if an invalid value is specified. +// The maximum possible number of steps is limited to 10000. +// The maxSteps parameter has no effect if a fixed step width is +// specified. +// +//.u Note +// This function uses the data members d_lBound and d_hBound and assumes +// that d_hBound > d_lBound. +//------------------------------------------------------------ + +bool ScaleDiv::buildLinDiv(int maxMajSteps, int maxMinSteps, double step) + { + + int nMaj, nMin, minSize, i0,i,k; + double val, mval; + double firstTick, lastTick; + double minStep; + QVector<double> buffer; + bool rv = TRUE; + + // parameter range check + maxMajSteps = qwtMax(1, maxMajSteps); + maxMinSteps = qwtMax(0, maxMinSteps); + step = qwtAbs(step); + + // reset vectors + d_minMarks.resize(0); + d_majMarks.resize(0); + + if (d_lBound == d_hBound) return TRUE; + + // + // Set up major divisions + // + if (step == 0.0) + d_majStep = qwtCeil125(qwtAbs(d_hBound - d_lBound) * 0.999999 + / double(maxMajSteps)); + else + d_majStep = step; + + if (d_majStep == 0.0) return TRUE; + + firstTick = ceil( (d_lBound - step_eps * d_majStep) / d_majStep) * d_majStep; + lastTick = floor( (d_hBound + step_eps * d_majStep) / d_majStep) * d_majStep; + + nMaj = qwtMin(10000, int(rint((lastTick - firstTick) / d_majStep)) + 1); + + d_majMarks.resize(nMaj); + qwtLinSpace(d_majMarks.data(), d_majMarks.size(), firstTick, lastTick); + + // + // Set up minor divisions + // + if (maxMinSteps < 1) // no minor divs + return TRUE; + + minStep = qwtCeil125( d_majStep / double(maxMinSteps) ); + + if (minStep == 0.0) return TRUE; + + nMin = qwtAbs(int(rint(d_majStep / minStep))) - 1; // # minor steps per interval + + // Do the minor steps fit into the interval? + if ( qwtAbs(double(nMin + 1) * minStep - d_majStep) > step_eps * d_majStep) + { + nMin = 1; + minStep = d_majStep * 0.5; + } + + // Are there minor ticks below the first major tick? + if (d_majMarks[0] > d_lBound ) + i0 = -1; + else + i0 = 0; + + // resize buffer to the maximum possible number of minor ticks + buffer.resize(nMin * (nMaj + 1)); + + // calculate minor ticks + if (rv) + { + minSize = 0; + for (i = i0; i < (int)d_majMarks.size(); i++) + { + if (i >= 0) + val = d_majMarks[i]; + else + val = d_majMarks[0] - d_majStep; + + for (k=0; k< nMin; k++) + { + mval = (val += minStep); + if (limRange(mval, d_lBound, d_hBound, border_eps)) + { + buffer[minSize] = mval; + minSize++; + } + } + } + //d_minMarks.duplicate(buffer.data(), minSize); + d_minMarks.resize(minSize); + qCopy(buffer.data(), buffer.data() + minSize, d_minMarks.begin()); + } + + return rv; + } + +//------------------------------------------------------------ +//.F ScaleDiv::buildLogDiv +// Build a logarithmic scale division +// +//.u Syntax +//.f bool ScaleDiv::buildLogDiv(int maxMajSteps, int maxMinSteps, int majStep) +// +//.u Parameters +//.p int maxMajSteps, int maxMinSteps, int majStep +// +//.u Return Value +// True if memory has been successfully allocated +// +//.u Note +// This function uses the data members d_lBound and d_hBound and assumes +// that d_hBound > d_lBound. +//------------------------------------------------------------ + +bool ScaleDiv::buildLogDiv(int maxMajSteps, int maxMinSteps, double majStep) + { + double firstTick, lastTick; + double lFirst, lLast; + double val, sval, minStep, minFactor; + int nMaj, nMin, minSize, i, k, k0, kstep, kmax, i0; + int rv = TRUE; + double width; + + QVector<double> buffer; + + + // Parameter range check + maxMajSteps = qwtMax(1, qwtAbs(maxMajSteps)); + maxMinSteps = qwtMax(0, qwtAbs(maxMinSteps)); + majStep = qwtAbs(majStep); + + // boundary check + limRange(d_hBound, LOG_MIN, LOG_MAX); + limRange(d_lBound, LOG_MIN, LOG_MAX); + + // reset vectors + d_minMarks.resize(0); + d_majMarks.resize(0); + + if (d_lBound == d_hBound) return TRUE; + + // scale width in decades + width = log10(d_hBound) - log10(d_lBound); + + // scale width is less than one decade -> build linear scale + if (width < 1.0) + { + rv = buildLinDiv(maxMajSteps, maxMinSteps, 0.0); + // convert step width to decades + if (d_majStep > 0) + d_majStep = log10(d_majStep); + + return rv; + } + + // + // Set up major scale divisions + // + if (majStep == 0.0) + d_majStep = qwtCeil125( width * 0.999999 / double(maxMajSteps)); + else + d_majStep = majStep; + + // major step must be >= 1 decade + d_majStep = qwtMax(d_majStep, 1.0); + + + lFirst = ceil((log10(d_lBound) - step_eps * d_majStep) / d_majStep) * d_majStep; + lLast = floor((log10(d_hBound) + step_eps * d_majStep) / d_majStep) * d_majStep; + + firstTick = pow(10.0, lFirst); + lastTick = pow(10.0, lLast); + + nMaj = qwtMin(10000, int(rint(qwtAbs(lLast - lFirst) / d_majStep)) + 1); + + d_majMarks.resize(nMaj); + qwtLogSpace(d_majMarks.data(), d_majMarks.size(), firstTick, lastTick); + + + // + // Set up minor scale divisions + // + + if ((d_majMarks.size() < 1) || (maxMinSteps < 1)) return TRUE; // no minor marks + + if (d_majStep < 1.1) // major step width is one decade + { + if (maxMinSteps >= 8) + { + k0 = 2; + kmax = 9; + kstep = 1; + minSize = (d_majMarks.size() + 1) * 8; + } + else if (maxMinSteps >= 4) + { + k0 = 2; + kmax = 8; + kstep = 2; + minSize = (d_majMarks.size() + 1) * 4; + } + else if (maxMinSteps >= 2) + { + k0 = 2; + kmax = 5; + kstep = 3; + minSize = (d_majMarks.size() + 1) * 2; + } + else + { + k0 = 5; + kmax = 5; + kstep = 1; + minSize = (d_majMarks.size() + 1); + } + + // resize buffer to the max. possible number of minor marks + buffer.resize(minSize); + + // Are there minor ticks below the first major tick? + if ( d_lBound < firstTick ) + i0 = -1; + else + i0 = 0; + + minSize = 0; + for (i = i0; i< (int)d_majMarks.size(); i++) + { + if (i >= 0) + val = d_majMarks[i]; + else + val = d_majMarks[0] / pow(10.0, d_majStep); + + for (k=k0; k<= kmax; k+=kstep) + { + sval = val * double(k); + if (limRange(sval, d_lBound, d_hBound, border_eps)) + { + buffer[minSize] = sval; + minSize++; + } + } + } + + // copy values into the minMarks array + //d_minMarks.duplicate(buffer.data(), minSize); + d_minMarks.resize(minSize); + qCopy(buffer.data(), buffer.data() + minSize, d_minMarks.begin()); + + + } + else // major step > one decade + { + + // substep width in decades, at least one decade + minStep = qwtCeil125( (d_majStep - step_eps * (d_majStep / double(maxMinSteps))) + / double(maxMinSteps) ); + minStep = qwtMax(1.0, minStep); + + // # subticks per interval + nMin = int(rint(d_majStep / minStep)) - 1; + + // Do the minor steps fit into the interval? + if ( qwtAbs( double(nMin + 1) * minStep - d_majStep) > step_eps * d_majStep) + nMin = 0; + + if (nMin < 1) return TRUE; // no subticks + + // resize buffer to max. possible number of subticks + buffer.resize((d_majMarks.size() + 1) * nMin ); + + // substep factor = 10^substeps + minFactor = qwtMax(pow(10,minStep), 10.0); + + // Are there minor ticks below the first major tick? + if ( d_lBound < firstTick ) + i0 = -1; + else + i0 = 0; + + minSize = 0; + for (i = i0; i< (int)d_majMarks.size(); i++) + { + if (i >= 0) + val = d_majMarks[i]; + else + val = firstTick / pow(10.0, d_majStep); + + for (k=0; k< nMin; k++) + { + sval = (val *= minFactor); + if (limRange(sval, d_lBound, d_hBound, border_eps)) + { + buffer[minSize] = sval; + minSize++; + } + } + } + //d_minMarks.duplicate(buffer.data(), minSize); + d_minMarks.resize(minSize); + qCopy(buffer.data(), buffer.data() + minSize, d_minMarks.begin()); + + } + + return rv; +} + +//------------------------------------------------------------ +//.F ScaleDiv::operator== +// Equality operator +// +//.u Syntax +//.f int ScaleDiv::operator==(const ScaleDiv &s) +// +//.u Parameters +//.p const ScaleDiv &s +// +//.u Return Value +// TRUE if this instance is equal to s +//------------------------------------------------------------ + +int ScaleDiv::operator==(const ScaleDiv &s) const + { + if (d_lBound != s.d_lBound) + return 0; + if (d_hBound != s.d_hBound) + return 0; + if (d_log != s.d_log) + return 0; + if (d_majStep != s.d_majStep) + return 0; + if (d_majMarks != s.d_majMarks) + return 0; + return (d_minMarks == s.d_minMarks); + } + +//------------------------------------------------------------ +//.F ScaleDiv::operator!= +// Inequality +// +//.u Syntax +//.f int ScaleDiv::operator!=(const ScaleDiv &s) +// +//.u Parameters +//.p const ScaleDiv &s +// +//.u Return Value +// TRUE if this instance is not equal to s +//------------------------------------------------------------ + +int ScaleDiv::operator!=(const ScaleDiv &s) const + { + return (!(*this == s)); + } + +//------------------------------------------------------------ +//.F ScaleDiv::reset +// Detach the shared data and set everything to zero. +// +//.u Syntax +//.f void ScaleDiv::reset() +//------------------------------------------------------------ + +void ScaleDiv::reset() + { + // reset vectors + d_minMarks.resize(0); + d_majMarks.resize(0); + + + d_lBound = 0.0; + d_hBound = 0.0; + d_majStep = 0.0; + d_log = FALSE; + } + + + + + + + + diff --git a/attic/muse2-oom/muse2/muse/widgets/scldiv.h b/attic/muse2-oom/muse2/muse/widgets/scldiv.h new file mode 100644 index 00000000..3d1e1d58 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/scldiv.h @@ -0,0 +1,56 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: scldiv.h,v 1.1.1.1 2003/10/27 18:54:43 wschweer Exp $ +// +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SCLDIV_H__ +#define __SCLDIV_H__ + +#include <QVector> + +class ScaleDiv + { + double d_lBound; + double d_hBound; + double d_majStep; + bool d_log; + + QVector<double> d_majMarks; + QVector<double> d_minMarks; + + void copy(const ScaleDiv &s); + + bool buildLinDiv(int maxMajMark, int maxMinMark, double step = 0.0); + bool buildLogDiv(int maxMajMark, int maxMinMark, double step = 0.0); + + public: + ScaleDiv (); + virtual ~ScaleDiv(); + ScaleDiv(const ScaleDiv& s); + + ScaleDiv& operator= (const ScaleDiv &s); + int operator== (const ScaleDiv &s) const; + int operator!= (const ScaleDiv &s) const; + + double lBound() const { return d_lBound; } + double hBound() const { return d_hBound; } + int minCnt() const { return d_minMarks.size(); } + int majCnt() const { return d_majMarks.size(); } + bool logScale() const { return d_log; } + double majMark(int i) const { return d_majMarks[i]; } + double minMark(int i) const { return d_minMarks[i]; } + double majStep() const { return d_majStep; } + void reset(); + bool rebuild(double lBound, double hBound, int maxMaj, int maxMin, + bool log, double step = 0.0, bool ascend = TRUE); + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/scldraw.cpp b/attic/muse2-oom/muse2/muse/widgets/scldraw.cpp new file mode 100644 index 00000000..709e104a --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/scldraw.cpp @@ -0,0 +1,881 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: scldraw.cpp,v 1.1.1.1 2003/10/27 18:54:36 wschweer Exp $ +// +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include <cmath> + +#include <QPainter> + +#include "mmath.h" +#include "scldraw.h" + + +int const ScaleDraw::minLen = 10; + +const double step_eps = 1.0e-6; +static const double WorstCase = -8.8888888888888888888888e-88; + +//------------------------------------------------------------ +//.H ScaleDraw | 3 | 30/08/97 | Qwt Widget Library | Qwt Programmer's Manual +//.I scldraw Different Scales +//.U NAME +// ScaleDraw - A class for drawing scales +// +//.U SYNOPSIS +// #include <qwt_scldraw.h> +// +//.U DESCRIPTION +// ScaleDraw can be used to draw linear or logarithmic scales. +// A scale has an origin, +// an orientation and a length, which all can be specified with +// @ScaleDraw::setGeometry@. +// After a scale division has been specified as a @^QwtScaleDiv@ object +// using @ScaleDraw::setScale (1)@ +// or determined internally using @ScaleDraw::setScale (2)@, +// the scale can be drawn with the @QwtScaleDiv::draw@ member. +// +//.U INHERITED CLASSES +// @QwtDiMap@ +// +//.U PUBLIC MEMBERS +//.R +// ScaleDraw::ScaleDraw -- constructor +// ScaleDraw::setScale (1) -- set scale using QwtScaleDiv +// ScaleDraw::setScale (2) -- set scale directly +// ScaleDraw::setGeometry -- specify geometry +// ScaleDraw::setAngleRange -- specify angle range for round scales +// ScaleDraw::setLabelFormat -- set number format +// ScaleDraw::scalediv -- return scale division +// ScaleDraw::orientation -- return orientation +// ScaleDraw::maxBoundingRect -- return maximum bounding rectangle +// ScaleDraw::maxWidth -- return maximum width +// ScaleDraw::maxHeight -- return maximum height +// ScaleDraw::maxLabelWidth -- return maximum width of the number labels +// ScaleDraw::draw -- draw the scale +// +//.U STATIC DATA MEMBERS +//.t +// enum ScaleDraw::Orientation { Left, Right, Top, Bottom, Round } -- +// Scale orientation +//------------------------------------------------------------ + +//------------------------------------------------------------ +//.U MEMBER FUNCTION DESCRIPTION +//------------------------------------------------------------ + +//------------------------------------------------------------ +// +//.F ScaleDraw::ScaleDraw +// +// Constructor +//.u Description +// The range of the scale is initialized to [0, 100], +// the angle range is set to [-135, 135], the geometry +// is initialized such that the origin is at (0,0), the +// length is 100, and the orientation is ScaleDraw::Bottom. +// +//------------------------------------------------------------ +ScaleDraw::ScaleDraw() +{ +/* d_hpad = 6; + d_vpad = 3; + d_majLen = 8; + d_medLen = 6; + d_minLen = 4; + */ + + d_hpad = 3; + d_vpad = 1; + d_majLen = 4; + d_medLen = 3; + d_minLen = 2; + + d_minAngle = -135 * 16; + d_maxAngle = 135 * 16; + d_fmt = 'g'; + d_prec = 4; + + // initialize scale and geometry + setGeometry(0,0,100,Bottom); + setScale(0,100,0,0,10); +} + + +//------------------------------------------------------------ +// +//.F ScaleDraw::setScale (1) +// Adjust the range of the scale +// +//.u Syntax +//.f void ScaleDraw::setScale(double x1, double x2, double step, int logscale) +// +//.u Parameters +//.p double x1 -- value at the left/low endpoint of the scale +// double x2 -- value at the right/high endpoint of the scale +// double step -- step size (default : 0.0) +// int logscale -- logarithmic scale (default : 0) +// +//.u Description +// If step == 0.0, the step width is calculated automatically +// dependent on the maximal number of scale ticks. +// +//------------------------------------------------------------ +void ScaleDraw::setScale(double x1, double x2, int maxMajIntv, + int maxMinIntv, double step, int logscale) +{ + d_scldiv.rebuild( x1, x2, maxMajIntv, maxMinIntv, logscale, step, FALSE ); + setDblRange( d_scldiv.lBound(), d_scldiv.hBound(), d_scldiv.logScale()); +} + + +//------------------------------------------------------------ +// +//.F ScaleDraw::setScale (2) +// Change the scale division +// +//.u Syntax +//.f void ScaleDraw::setScale(QwtAutoScale &as) +// +//.u Parameters +//.p const QwtScaleDiv& sd -- new scale division +// +//------------------------------------------------------------ + +void ScaleDraw::setScale(const ScaleDiv &s) +{ + d_scldiv = s; + setDblRange(d_scldiv.lBound(),d_scldiv.hBound(),d_scldiv.logScale()); +} + + + +//------------------------------------------------------------ +//.F ScaleDraw::draw +// Draw the scale +//.u Parameters +//.p QPainter *p -- the painter +//------------------------------------------------------------ + +void ScaleDraw::draw(QPainter *p) const + { + double val,hval,majTick; + + int i,k,kmax; + + for (i=0; i< d_scldiv.majCnt(); i++) + { + val = d_scldiv.majMark(i); + drawTick(p, val, d_majLen); + drawLabel(p, val); + } + + if (d_scldiv.logScale()) + { + for (i=0; i< d_scldiv.minCnt(); i++) + { + drawTick(p,d_scldiv.minMark(i),d_minLen); + } + } + else + { + k = 0; + kmax = d_scldiv.majCnt() - 1; + if (kmax > 0) + { + majTick = d_scldiv.majMark(0); + hval = majTick - 0.5 * d_scldiv.majStep(); + + for (i=0; i< d_scldiv.minCnt(); i++) + { + val = d_scldiv.minMark(i); + if (val > majTick) + { + if (k < kmax) + { + k++; + majTick = d_scldiv.majMark(k); + } + else + { + majTick += d_scldiv.majMark(kmax) + d_scldiv.majStep(); + } + hval = majTick - 0.5 * d_scldiv.majStep(); + + } + if (qwtAbs(val-hval) < step_eps * d_scldiv.majStep()) + drawTick(p, val, d_medLen); + else + drawTick(p, val, d_minLen); + } + } + } + + // + // draw backbone + // + //if (d_baseEnabled) + drawBackbone(p); + +} + + +//------------------------------------------------------------ +//.F ScaleDraw::drawTick +// Draws a singls scale tick +// +//.u Parameters +//.p QPainter *p, double val, int len +//------------------------------------------------------------ + +void ScaleDraw::drawTick(QPainter *p, double val, int len) const + { + int tval = transform(val); + double arc; + int x1, x2, y1, y2; + + switch(d_orient) + { + case Right: + + p->drawLine(d_xorg, tval, d_xorg + len, tval); + break; + + case Bottom: + + p->drawLine(tval, d_yorg, tval, d_yorg + len); + break; + + case Left: + + p->drawLine(d_xorg, tval, d_xorg - len, tval); + break; + + case Round: + + if ((tval <= d_minAngle + 359 * 16) || (tval >= d_minAngle - 359 * 16)) + { + arc = double(tval) / 16.0 * M_PI / 180.0; + x1 = qwtInt(d_xCenter + sin(arc) * d_radius); + x2 = qwtInt(d_xCenter + sin(arc) * (d_radius + double(len))); + y1 = qwtInt(d_yCenter - cos(arc) * d_radius); + y2 = qwtInt(d_yCenter - cos(arc) * (d_radius + double(len))); + p->drawLine(x1, y1, x2, y2); + } + break; + + case Top: + default: + + p->drawLine(tval, d_yorg, tval, d_yorg - len); + break; + + + } + +} + + + + +//------------------------------------------------------------ +//.- +//.F ScaleDraw::drawLabel +// Draws the number label for a major scale tick +// +//.u Parameters +//.p QPainter *p, double val +// +//------------------------------------------------------------ +void ScaleDraw::drawLabel(QPainter *p, double val) const +{ + + static QString label; + static double pi_4 = M_PI * 0.25; + static double pi_75 = M_PI * 0.75; + + double arc; + int xpos, ypos; + int tval; + + QFontMetrics fm = p->fontMetrics(); + + tval = transform(val); + + // correct rounding errors if val = 0 + if ((!d_scldiv.logScale()) && (qwtAbs(val) < qwtAbs(step_eps * d_scldiv.majStep()))) + val = 0.0; + + label.setNum(val, d_fmt, d_prec); + + switch(d_orient) + { + case Right: + p->drawText(d_xorg + d_majLen + d_hpad, + tval + (fm.ascent()-1) / 2, + label); + break; + case Left: + p->drawText(d_xorg - d_majLen - d_hpad - fm.width(label), + tval + (fm.ascent() -1) / 2, + label); + break; + case Bottom: + p->drawText(tval - (fm.width(label)-1) / 2, d_yorg + d_majLen + d_vpad + fm.ascent(), label); + break; + case Round: + + if ((tval > d_minAngle + 359 * 16) || (tval < d_minAngle - 359 * 16)) + break; + + arc = double(tval) / 16.0 * M_PI / 180.0; + + // Map arc into the interval -pi <= arc <= pi + if ((arc < -M_PI) || (arc > M_PI)) + arc -= floor((arc + M_PI) / M_PI * 0.5) * 2.0 * M_PI; + + xpos = 1 + qwtInt(d_xCenter + (d_radius + double(d_majLen + d_vpad)) * sin(arc)); + ypos = qwtInt(d_yCenter - (d_radius + double(d_majLen + d_vpad)) * cos(arc)); + + if (arc < -pi_75) + { + p->drawText(xpos - qwtInt(double(fm.width(label)) + * (1.0 + (arc + pi_75) * M_2_PI) ), + ypos + fm.ascent() - 1, + label); + } + else if (arc < -M_PI_4) + { + p->drawText(xpos - fm.width(label), + + + ypos - qwtInt(double(fm.ascent() - 1) + * (arc + M_PI_4) * M_2_PI), + label); + } + else if (arc < pi_4) + { + p->drawText(xpos + qwtInt(double(fm.width(label)) + * ( arc - M_PI_4 ) * M_2_PI ), + ypos, + label); + } + else if (arc < pi_75) + { + p->drawText(xpos, + ypos + qwtInt(double(fm.ascent() - 1) + * (arc - M_PI_4) * M_2_PI), + label); + } + else + { + p->drawText(xpos - qwtInt(double(fm.width(label)) + * ( arc - pi_75) * M_2_PI ), + ypos + fm.ascent() - 1, + label); + } + break; + case Top: + default: + p->drawText(tval - (fm.width(label)-1) / 2, d_yorg - d_majLen - d_vpad, label); + break; + } + + + +} + +//------------------------------------------------------------ +//.- +//.F ScaleDraw::drawBackbone +// Draws the baseline of the scale +// +// +//.u Parameters +//.p QPainter *p +// +//------------------------------------------------------------ +void ScaleDraw::drawBackbone(QPainter *p) const +{ + int bw2; + int a1, a2; + bw2 = p->pen().width() / 2; + + + switch(d_orient) + { + case Left: + p->drawLine(d_xorg - bw2, d_yorg, d_xorg - bw2, d_yorg + d_len - 1); + break; + case Right: + p->drawLine(d_xorg + bw2, d_yorg, d_xorg + bw2, d_yorg + d_len - 1); + break; + case Round: + + a1 = qwtMin(i1(), i2()) - 90 * 16; + a2 = qwtMax(i1(), i2()) - 90 * 16; + + p->drawArc(d_xorg, d_yorg, d_len, + d_len, + -a2, a2 - a1 + 1); // counterclockwise + + break; + + case Top: + p->drawLine(d_xorg, d_yorg - bw2, d_xorg + d_len - 1, d_yorg-bw2); + break; + case Bottom: + p->drawLine(d_xorg, d_yorg+bw2, d_xorg + d_len - 1, d_yorg+bw2); + break; + default: + p->drawLine(d_xorg, d_yorg, d_xorg + d_len - 1, d_yorg); + break; + } + +} + + +//------------------------------------------------------------ +// +//.F ScaleDraw::setGeometry +// Specify the geometry of the scale +// +// +//.u Parameters +//.p int xorigin -- x coordinate of the origin +// int yorigin -- y coordinate of the origin +// int length -- length or diameter of the scale +// Orientation o -- The orientation +// +//.u Description +// +// The parameters xorigin, yorigin and length have different meanings, +// dependent on the +// orientation: +//.t +// ScaleDraw::Left -- The origin is the topmost point of the +// baseline. The baseline is a vertical line with the +// specified length. Scale marks and labels are drawn +// at the left of the baseline. +// +// ScaleDraw::Right -- The origin is the topmost point of the +// baseline. The baseline is a vertical line with the +// specified length. Scale marks and labels are drawn +// at the right of the baseline. +// +// ScaleDraw::Top -- The origin is the leftmost point of the +// baseline. The baseline is a horizontal line with the +// specified length. Scale marks and labels are drawn +// above the baseline. +// +// ScaleDraw::Bottom -- The origin is the leftmost point of the +// baseline. The baseline is a horizontal line with the +// specified length. Scale marks and labels are drawn +// below the baseline. +// +// ScaleDraw::Round -- The origin is the top left corner of the +// bounding rectangle of the baseline circle. The baseline +// is the segment of a circle with a diameter of the specified length. +// Scale marks and labels are drawn outside the baseline +// circle. +// +//------------------------------------------------------------ +void ScaleDraw::setGeometry(int xorigin, int yorigin, int length, OrientationX o) +{ + + d_xorg = xorigin; + d_yorg = yorigin; + d_radius = double(length) * 0.5; + d_xCenter = double(xorigin) + double(length) * 0.5; + d_yCenter = double(yorigin) + double(length) * 0.5; + + if (length > minLen) + d_len = length; + else + d_len = minLen; + + d_orient = o; + + switch(d_orient) + { + case Left: + case Right: + setIntRange(d_yorg + d_len - 1, d_yorg); + break; + case Round: + setIntRange(d_minAngle, d_maxAngle); + break; + case Top: + case Bottom: + default: + setIntRange(d_xorg, d_xorg + d_len - 1); + break; + } +} + + + +//------------------------------------------------------------ +// +//.F ScaleDraw::maxWidth +// Return the maximum width of the scale for a specified QPainter +// +//.u Syntax +//.f int ScaleDraw::maxWidth(QPainter *p) +// +//.u Parameters +//.p QPainter *p -- painter +// bool worst -- if TRUE, assume the worst possible case. If FALSE, +// calculate the real maximum width, which is more +// CPU intensive. +// +//------------------------------------------------------------ +int ScaleDraw::maxWidth(QPainter *p, bool worst) const +{ + int rv = 0; + int bw = p->pen().width(); + + QString s; + + QFontMetrics fm = p->fontMetrics(); + + rv = maxLabelWidth(p,worst); + + switch (d_orient) + { + case Left: + case Right: + rv += (bw + d_hpad + d_majLen); + break; + case Round: + rv += (bw + d_vpad + d_majLen); + break; + case Top: + case Bottom: + default: + rv += d_len; + } + + return rv; + +} + +//------------------------------------------------------------ +// +//.F ScaleDraw::maxHeight +// Return the maximum height of the scale for the +// specified painter +// +//.u Syntax +//.f int ScaleDraw::maxHeight(QPainter *p) +// +//.u Parameters +//.p QPainter *p +// +//------------------------------------------------------------ +int ScaleDraw::maxHeight(QPainter *p) const +{ + + int rv = 0; + int bw = p->pen().width(); + + p->save(); + QFontMetrics fm = p->fontMetrics(); + + switch (d_orient) + { + case Top: + case Bottom: + case Round: + rv = bw + d_vpad + d_majLen + fm.height(); + break; + case Left: + case Right: + default: + rv = d_len + ((fm.height() + 1) / 2); + } + + return rv; + +} + +//------------------------------------------------------------ +// +//.F ScaleDraw:maxBoundingRect +// Return the maximum bounding rectangle of the scale +// for a specified painter +// +//.u Parameters +//.p QPainter *p -- painter +// +//.u Description +// The bounding rectangle is not very exact for round scales +// with strange angle ranges. +// +//------------------------------------------------------------ +QRect ScaleDraw::maxBoundingRect(QPainter *p) const +{ + int i, wl,h,wmax; + int a, ar, amin, amax; + double arc; + + QRect r; + + QFontMetrics fm = p->fontMetrics(); + + wl = maxLabelWidth(p, TRUE); + h = fm.height(); + + switch(d_orient) + { + case Left: + + r = QRect( d_xorg - d_hpad - d_majLen - wl, + d_yorg - fm.ascent(), + d_majLen + d_hpad + wl, + d_len + fm.height()); + break; + + case Right: + + r = QRect( d_xorg, + d_yorg - fm.ascent(), + d_majLen + d_hpad + wl, + d_len + fm.height()); + break; + + case Top: + + r = QRect ( d_xorg - wl / 2, + d_yorg - d_majLen - fm.ascent(), + d_len + wl, + d_majLen + d_vpad + fm.ascent()); + break; + + case Bottom: + + r = QRect ( d_xorg - wl / 2, + d_yorg, + d_len + wl, + d_majLen + d_vpad + fm.height()); + break; + + case Round: + + amin = 2880; + amax = 0; + ar = 0; + + for (i=0; i< d_scldiv.majCnt(); i++) + { + a = transform(d_scldiv.majMark(i)); + + while (a > 2880) a -= 5760; + while (a < - 2880) a += 5760; + + ar = qwtAbs(a); + + if (ar < amin) amin = ar; + if (ar > amax) amax = ar; + + } + + for (i=0; i< d_scldiv.minCnt(); i++) + { + a = transform(d_scldiv.majMark(i)); + + while (a > 2880) a -= 5760; + while (a < - 2880) a += 5760; + + ar = qwtAbs(a); + + if (ar < amin) amin = ar; + if (ar > amax) amax = ar; + } + + arc = double(amin) / 16.0 * M_PI / 180.0; + r.setTop(qwtInt(d_yCenter - (d_radius + double(d_majLen + d_vpad)) * cos(arc)) + + fm.ascent() ); + + arc = double(amax) / 16.0 * M_PI / 180.0; + r.setBottom(qwtInt(d_yCenter - (d_radius + double(d_majLen + d_vpad)) * cos(arc)) + + fm.height() ); + + wmax = d_len + d_majLen + d_hpad + wl; + + r.setLeft(d_xorg - d_majLen - d_hpad - wl); + r.setWidth(d_len + 2*(d_majLen + d_hpad + wl)); + break; + } + + return r; + +} + +//------------------------------------------------------------ +// +//.F ScaleDraw::setAngleRange +// Adjust the baseline circle segment for round scales. +// +//.u Syntax +//.f void ScaleDraw::setAngleRange(double angle1, double angle2) +// +//.u Parameters +//.p double angle1, double angle2 +// boundaries of the angle interval in degrees. +// +//.u Description +// The baseline will be drawn from min(angle1,angle2) to max(angle1, angle2). +// The settings have no effect if the scale orientation is not set to +// ScaleDraw::Round. The default setting is [ -135, 135 ]. +// An angle of 0 degrees corresponds to the 12 o'clock position, +// and positive angles count in a clockwise direction. +// +//.u Note +//.i +// -- The angle range is limited to [-360, 360] degrees. Angles exceeding +// this range will be clipped. +// -- For angles more than 359 degrees above or below min(angle1, angle2), +// scale marks will not be drawn. +// -- If you need a counterclockwise scale, use @QwtScaleDiv::setRange (1)@ +// or @QwtScaleDiv::setRange (2)@. +//------------------------------------------------------------ +void ScaleDraw::setAngleRange(double angle1, double angle2) +{ + int amin, amax; + + angle1 = qwtLim(angle1, -360.0, 360.0); + angle2 = qwtLim(angle2, -360.0, 360.0); + amin = int(rint(qwtMin(angle1, angle2) * 16.0)); + amax = int(rint(qwtMax(angle1, angle2) * 16.0)); + + if (amin == amax) + { + amin -= 1; + amax += 1; + } + + d_minAngle = amin; + d_maxAngle = amax; + setIntRange(d_minAngle, d_maxAngle); + +} + + +//------------------------------------------------------------ +// +//.F ScaleDraw::setLabelFormat +// Set the number format for the major scale labels +// +//.u Syntax +//.f void ScaleDraw::setLabelFormat(char f, int prec) +// +//.u Parameters +//.p char f -- format character +// int prec -- precision +// +//.u Description +// Format character and precision have the same meaning as for the +// QString class. +// +//.u See also +// QString::setNum in the Qt manual +// +//------------------------------------------------------------ +void ScaleDraw::setLabelFormat(char f, int prec) +{ + d_fmt = f; + d_prec = prec; +} + +//------------------------------------------------------------ +// +//.F ScaleDraw::maxLabelWidth +// Return the maximum width of a label +// +//.u Syntax +//.f int ScaleDraw::maxLabelWidth(QPainter *p, int worst) +// +//.u Parameters +//.p QPainter *p -- painter +// int worst -- If TRUE, take the worst case. If FALSE, take +// the actual width of the largest label. +// +//------------------------------------------------------------ +int ScaleDraw::maxLabelWidth(QPainter *p, int worst) const +{ + + int i,rv = 0; + double val; + QString s; + + + QFontMetrics fm = p->fontMetrics(); + + if (worst) // worst case + { + s.setNum(WorstCase, d_fmt, d_prec); + rv = fm.width(s); + } + else // actual width + { + for (i=0;i<d_scldiv.majCnt(); i++) + { + val = d_scldiv.majMark(i); + // correct rounding errors if val = 0 + if ((!d_scldiv.logScale()) && (qwtAbs(val) < step_eps * qwtAbs(d_scldiv.majStep()))) + val = 0.0; + s.setNum(val, d_fmt, d_prec); + rv = qwtMax(rv,fm.width(s)); + } + } + + + return rv; + +} + + +//------------------------------------------------------------ +// +//.F ScaleDraw::scaleDiv +// Return the scale division +// +//.u Syntax +//.f const QwtScaleDiv & ScaleDraw::scaleDiv() const +// +//.u See also +// @^QwtScaleDiv@ +//------------------------------------------------------------ + +//------------------------------------------------------------ +// +//.F ScaleDraw::orientation +// Return the orientation +// +//.u Syntax +//.f int ScaleDraw::orientation() const +// +//.u See also +// @ScaleDraw::setGeometry@ +// +//------------------------------------------------------------ + + + + + + + + + + + diff --git a/attic/muse2-oom/muse2/muse/widgets/scldraw.h b/attic/muse2-oom/muse2/muse/widgets/scldraw.h new file mode 100644 index 00000000..08a198ca --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/scldraw.h @@ -0,0 +1,86 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: scldraw.h,v 1.1.1.1 2003/10/27 18:55:08 wschweer Exp $ +// +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SCLDRAW_H__ +#define __SCLDRAW_H__ + +#include "dimap.h" +#include "scldiv.h" + +class QPainter; +class QRect; + +class AutoScale; + +class ScaleDraw : public DiMap { + public: + enum OrientationX { Bottom, Top, Left, Right, Round }; + + private: + ScaleDiv d_scldiv; + static const int minLen; + OrientationX d_orient; + + int d_xorg; + int d_yorg; + int d_len; + + int d_hpad; + int d_vpad; + + int d_medLen; + int d_majLen; + int d_minLen; + + int d_minAngle; + int d_maxAngle; + + double d_xCenter; + double d_yCenter; + double d_radius; + + char d_fmt; + int d_prec; + + void drawTick(QPainter *p, double val, int len) const; + void drawBackbone(QPainter *p) const; + void drawLabel(QPainter *p, double val) const; + + public: + + ScaleDraw(); + + void setScale(const ScaleDiv &s); + void setScale(double vmin, double vmax, int maxMajIntv, int maxMinIntv, + double step = 0.0, int logarithmic = 0); + void setGeometry(int xorigin, int yorigin, int length, OrientationX o); + void setAngleRange(double angle1, double angle2); + void setLabelFormat(char f, int prec); + + const ScaleDiv& scaleDiv() const { return d_scldiv; } + OrientationX orientation() const { return d_orient; } + QRect maxBoundingRect(QPainter *p) const; + int maxWidth(QPainter *p, bool worst = TRUE) const; + int maxHeight(QPainter *p) const; + int maxLabelWidth(QPainter *p, int worst = TRUE) const; + void draw(QPainter *p) const; + }; + +#endif + + + + + + + diff --git a/attic/muse2-oom/muse2/muse/widgets/sclif.cpp b/attic/muse2-oom/muse2/muse/widgets/sclif.cpp new file mode 100644 index 00000000..8740bc53 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/sclif.cpp @@ -0,0 +1,205 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: sclif.cpp,v 1.1.1.1 2003/10/27 18:55:10 wschweer Exp $ + +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include "sclif.h" + +// ScaleIf - An interface class for widgets containing a scale +// +// This interface class is used to provide classes +// with a protected ScaleDraw member and a public +// interface to access that scale. +// +// The primary purpose of this class is to define +// a common interface for classes which are supposed to +// contain a ScaleDraw class. It provides a protected +// ScaleDraw member +// called d_scale and a couple of public member functions +// which allow direct but restricted access +// to this scale by the user. +// Widgets derived from this class have +// to implement the member function scaleChange(), +// which is called to notify changes of the +// scale parameters and usually requires repainting or +// resizing respectively. +// In general, a class derived from ScaleIf is +// expected to manage the division and the position of its scale internally +// when no user-defined scale is set. It should take the d_maxMinor +// and d_maxMajor members into account, which can be set by the user. +// An implementation can check if a user-defined scale is set by calling the +// @ScaleIf::hasUserScale@ member. + +//------------------------------------------------------------ +// ScaleIf::ScaleIf +// Construct a ScaleIf instance +// +// Syntax +// ScaleIf::ScaleIf() +//------------------------------------------------------------ + +ScaleIf::ScaleIf() + { + d_userScale = FALSE; + d_maxMajor = 5; + d_maxMinor = 3; + d_scale.setScale(0.0,100.0,d_maxMajor, d_maxMinor); + } + +//------------------------------------------------------------ +// ScaleIf::setScale (1) +// Specify a user-defined scale. +// +// Syntax +// void ScaleIf::setScale(double vmin, double vmax, int logarithmic) +// +// Parameters +// double vmin, double vmax -- boundary values +// int logarithmic -- If != 0, Build a logarithmic scale +// +// Description +// By default, the widget is supposed to control the range of its scale +// automatically, but sometimes it is desirable to have a user-defined +// scale which is not in sync with +// the widget's range, e.g. if a logarithmic scale is needed +// (sliders don't support that) or if the scale is required +// to have a fixed range (say 0...100%), independent of the +// widget's range. +// +// See also +// @ScaleIf::autoScale@ +//------------------------------------------------------------ + +void ScaleIf::setScale(double vmin, double vmax, int logarithmic) + { + setScale(vmin,vmax,0.0,logarithmic); + } + +//------------------------------------------------------------ +// ScaleIf::setScale (2) +// Specify a user-defined scale. +// +// Syntax +// void ScaleIf::setScale(double vmin, double vmax, int logarithmic) +// +// Parameters +// double vmin, double vmax -- interval boundaries +// int step -- major step size +// int logarithmic -- If != 0, build a logarithmic scale +// +// Description +// By default, the widget is supposed to control the range of its scale +// automatically, but sometimes it is desirable to have a user-defined +// scale which is not in sync with +// the widget's range, e.g. if a logarithmic scale is needed +// (sliders don't support that) or if the scale is required +// to have a fixed range (say 0...100%), independent of the +// widget's range. +//------------------------------------------------------------ + +void ScaleIf::setScale(double vmin, double vmax, double step, int logarithmic) + { + ScaleDiv oldscl(d_scale.scaleDiv()); + + d_scale.setScale(vmin, vmax, d_maxMajor, d_maxMinor, step, logarithmic); + d_userScale = TRUE; + if (oldscl != d_scale.scaleDiv()) + scaleChange(); + } + +//------------------------------------------------------------ +// Scale::setScale +// Assign a user-defined scale division +// +// Syntax +// void Scale::setScale(const ScaleDiv &s) +// +// Parameters +// const ScaleDiv &s -- scale division +//------------------------------------------------------------ + +void ScaleIf::setScale(const ScaleDiv &s) + { + d_scale.setScale(s); + scaleChange(); + } + +//------------------------------------------------------------ +// ScaleIf::autoScale +// Advise the widget to control the scale range +// internally. +// Syntax +// void ScaleIf::autoScale +// +// Description +// Autoscaling is on by default. +//------------------------------------------------------------ + +void ScaleIf::autoScale() + { + if (!d_userScale) { + d_userScale = FALSE; + scaleChange(); + } + } + +//------------------------------------------------------------ +// ScaleIf::setScaleMaxMajor +// Set the maximum number of major tick intervals. +// +// Syntax +// void ScaleIf::setScaleMaxMajor(int ticks) +// +// Parameters +// int ticks -- maximal number of major ticks. +// +// Description +// The scale's major ticks are calculated automatically such that +// the number of major intervals does not exceed <ticks>. +// The default value is 5. +//------------------------------------------------------------ + +void ScaleIf::setScaleMaxMajor(int ticks) + { + if (ticks != d_maxMajor) { + d_maxMajor = ticks; + d_scale.setScale(d_scale.scaleDiv().lBound(), d_scale.scaleDiv().hBound(), + d_maxMajor, d_maxMinor, 0.0,d_scale.scaleDiv().logScale()); + scaleChange(); + } + } + +//------------------------------------------------------------ +// ScaleIf::setScaleMaxMinor +// Set the maximum number of minor tick intervals +// +// Syntax +// void ScaleIf::setScaleMaxMinor(int ticks) +// +// Parameters +// int ticks +// +// Description +// The scale's minor ticks are calculated automatically such that +// the number of minor intervals does not exceed <ticks>. +// The default value is 3. +//------------------------------------------------------------ + +void ScaleIf::setScaleMaxMinor(int ticks) + { + if ( ticks != d_maxMinor) { + d_maxMinor = ticks; + d_scale.setScale(d_scale.scaleDiv().lBound(), d_scale.scaleDiv().hBound(), + d_maxMajor, d_maxMinor, 0.0, d_scale.scaleDiv().logScale()); + scaleChange(); + } + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/sclif.h b/attic/muse2-oom/muse2/muse/widgets/sclif.h new file mode 100644 index 00000000..ec8eafc9 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/sclif.h @@ -0,0 +1,50 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: sclif.h,v 1.1.1.1 2003/10/27 18:54:33 wschweer Exp $ + +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SCALE_IF_H__ +#define __SCALE_IF_H__ + +#include "scldraw.h" + +//--------------------------------------------------------- +// ScaleIf +//--------------------------------------------------------- + +class ScaleIf + { + bool d_userScale; + + protected: + ScaleDraw d_scale; + int d_maxMajor; + int d_maxMinor; + bool hasUserScale() {return d_userScale;} + virtual void scaleChange() = 0; + + public: + ScaleIf(); + virtual ~ScaleIf() {}; + + void setScale (double vmin, double vmax, int logarithmic = 0); + void setScale (double vmin, double vmax, double step, int logarithmic = 0); + void setScale(const ScaleDiv &s); + void setScaleMaxMajor( int ticks); + void setScaleMaxMinor( int ticks); + void autoScale(); + + int scaleMaxMinor() const {return d_maxMinor;} + int scaleMaxMajor() const {return d_maxMinor;} + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/scrollscale.cpp b/attic/muse2-oom/muse2/muse/widgets/scrollscale.cpp new file mode 100644 index 00000000..de383deb --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/scrollscale.cpp @@ -0,0 +1,509 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: scrollscale.cpp,v 1.2.2.2 2009/11/04 17:43:25 lunar_shuttle Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> +#include <cmath> + +#include <QBoxLayout> +#include <QLabel> +#include <QResizeEvent> +#include <QScrollBar> +#include <QSlider> +#include <QToolButton> +#include <QToolTip> + +// #include "globals.h" +#include "scrollscale.h" +#include "icons.h" + +//--------------------------------------------------------- +// setScale +// "val" - slider value in range 0-1024 +//--------------------------------------------------------- + +void ScrollScale::setScale ( int val ) +{ + int off = offset(); + if ( invers ) + val = 1024 - val; + double min, max; + if ( scaleMin < 0 ) + min = 1.0/ ( -scaleMin ); + else + min = double ( scaleMin ); + + if ( scaleMax < 0 ) + max = 1.0/ ( -scaleMax ); + else + max = double ( scaleMax ); + + double diff = max-min; + double fkt = double ( val ) /1024.0; + double v = ( pow ( logbase, fkt )-1 ) / ( logbase-1 ); + double scale; + if ( invers ) + scale = max - v * diff; + else + scale = min + v * diff; + + if ( scale < 1.0 ) + scaleVal = - ( int ( 1.0 / scale ) ); + else + scaleVal = int ( scale ); + if ( scaleVal == -1 ) // nur so + scaleVal = 1; + +#if 0 + if ( scaleMax > scaleMin ) + { + if ( scale < scaleMin ) + scale = scaleMin; + else if ( scale > scaleMax ) + scale = scaleMax; + } + else + { + if ( scale < scaleMax ) + scale = scaleMax; + else if ( scale > scaleMin ) + scale = scaleMin; + } +#endif + + emit scaleChanged ( scaleVal ); + if ( !noScale ) + setRange ( minVal, maxVal ); + + int i = ( scroll->orientation() == Qt::Horizontal ) ? width() : height(); + int pos, pmax; + if ( scaleVal < 1 ) + { + pos = ( off-scaleVal/2 ) / ( -scaleVal ); + pmax = ( maxVal-scaleVal-1 ) / ( -scaleVal ) - i; + } + else + { + pos = off * scaleVal; + pmax = maxVal * scaleVal - i; + } + if(pos > pmax) + pos = pmax; + setPos(pos); +} + +//--------------------------------------------------------- +// setMag +//--------------------------------------------------------- + +void ScrollScale::setMag ( int cs ) +{ + scale->setValue ( cs ); + setScale ( cs ); +} + +//--------------------------------------------------------- +// setRange +// min,max ticks +//--------------------------------------------------------- + +void ScrollScale::setRange ( int min, int max ) +{ +// if ((min != minVal) && (max != maxVal)) +// return; + minVal = min; + maxVal = max; + int i = ( scroll->orientation() == Qt::Horizontal ) ? width() : height(); + + if ( !noScale ) + { + if ( scaleVal < 1 ) + { + min = minVal / ( -scaleVal ); + max = ( maxVal-scaleVal-1 ) / ( -scaleVal ) - i; + } + else + { + min = minVal * scaleVal; + max = maxVal * scaleVal - i; + } + } + else + max -= i; + if ( max < 0 ) + max = 0; + if ( min < 0 ) + min = 0; + if ( min > max ) + max = min; + + scroll->setRange ( min, max ); + + // qt doesn't check this... + if ( scroll->value() < min ) + scroll->setValue ( min ); + if ( scroll->value() > max ) + scroll->setValue ( max ); + scroll->setSingleStep(20); + scroll->setPageStep(i); +} + +//--------------------------------------------------------- +// setPos +// pos in pixel +//--------------------------------------------------------- + +void ScrollScale::setPos ( unsigned pos ) +{ + + scroll->setValue ( pos ); +} + +//--------------------------------------------------------- +// setPosNoLimit +// pos in pixel +//--------------------------------------------------------- + +void ScrollScale::setPosNoLimit ( unsigned pos ) +{ + //printf ( "ScrollScale::setPosNoLimit pos:%d scaleVal:%d offset ticks:%d\n", pos, scaleVal, pos2offset ( pos ) ); + + if((int)pos > scroll->maximum()) + scroll->setMaximum(pos); + scroll->setValue(pos); +} + +//--------------------------------------------------------- +// resizeEvent +//--------------------------------------------------------- + +void ScrollScale::resizeEvent ( QResizeEvent* ) +{ + setScale ( scale->value() ); +} + +//--------------------------------------------------------- +// ScrollScale +//--------------------------------------------------------- + +ScrollScale::ScrollScale ( int s1, int s2, int cs, int max_, Qt::Orientation o, + QWidget* parent, int min_, bool inv, double bas ) + : QWidget ( parent ) +{ + noScale = false; + _page = 0; + _pages = 1; + pageButtons = false; + showMagFlag = true; + scaleMin = s1; + scaleMax = s2; + minVal = min_; + maxVal = max_; + up = 0; + down = 0; + logbase = bas; + invers = inv; + + double min, max; + if ( scaleMin < 0 ) + min = 1.0/ ( -scaleMin ); + else + min = double ( scaleMin ); + + if ( scaleMax < 0 ) + max = 1.0/ ( -scaleMax ); + else + max = double ( scaleMax ); + + double cmag = ( cs < 0 ) ? ( 1.0/ ( -cs ) ) : double ( cs ); + double diff = max-min; + + // + // search initial value for slider + // + int cur = 512; + int delta = 256; + for ( int i = 0; i < 8; ++i ) + { + int tryVal = invers ? 1025 - cur : cur; + double fkt = double ( tryVal ) /1024.0; + double v = ( pow ( logbase, fkt )-1 ) / ( logbase-1 ); + double scale = invers ? ( max - v * diff ) : ( min + v * diff ); + if ( scale == cmag ) // not very likely + break; + //printf("iteration %d invers:%d soll %f(cur:%d) - ist %f\n", i, invers, scale, cur, cmag); + int dd = invers ? -delta : delta; + cur += ( scale < cmag ) ? dd : -dd; + delta/=2; + } + + scale = new QSlider (o); + // Added by Tim. For some reason focus was on. + // It messes up tabbing, and really should have a shortcut instead. + scale->setFocusPolicy(Qt::NoFocus); + scale->setMinimum(0); + scale->setMaximum(1024); + scale->setPageStep(1); + scale->setValue(cur); + + scroll = new QScrollBar ( o ); + //scroll->setFocusPolicy(Qt::NoFocus); // Tim. + setScale ( cur ); + + if ( o == Qt::Horizontal ) + { + box = new QBoxLayout ( QBoxLayout::LeftToRight); + scale->setMaximumWidth ( 70 ); + scroll->setMinimumWidth ( 50 ); + } + else + { + box = new QBoxLayout ( QBoxLayout::TopToBottom); + scroll->setMinimumHeight ( 50 ); + scale->setMaximumHeight ( 70 ); + } + box->addWidget ( scroll, 10 ); + box->addWidget ( scale, 5 ); + setLayout(box); + connect ( scale, SIGNAL ( valueChanged ( int ) ), SLOT ( setScale ( int ) ) ); + ///connect ( scale, SIGNAL ( valueChanged ( int ) ), SIGNAL ( lscaleChanged ( int ) ) ); // ?? + connect ( scroll, SIGNAL ( valueChanged ( int ) ), SIGNAL ( scrollChanged ( int ) ) ); +} + +//--------------------------------------------------------- +// setPageButtons +//--------------------------------------------------------- + +void ScrollScale::setPageButtons ( bool flag ) +{ + if ( flag == pageButtons ) + return; + + if ( flag ) + { + if ( up == 0 ) + { + up = new QToolButton; + up->setIcon ( QIcon(*upIcon) ); + down = new QToolButton; + down->setIcon ( QIcon(*downIcon) ); + pageNo = new QLabel; + QString s; + s.setNum ( _page+1 ); + pageNo->setText ( s ); + down->setToolTip(tr ( "next page" ) ); + up->setToolTip(tr ( "previous page" ) ); + pageNo->setToolTip(tr ( "current page number" ) ); + box->insertWidget ( 1, up ); + box->insertWidget ( 2, down ); + box->insertSpacing ( 3, 5 ); + box->insertWidget ( 4, pageNo ); + box->insertSpacing ( 5, 5 ); + connect ( up, SIGNAL ( clicked() ), SLOT ( pageUp() ) ); + connect ( down, SIGNAL ( clicked() ), SLOT ( pageDown() ) ); + } + up->show(); + down->show(); + pageNo->show(); + if ( _page == ( _pages-1 ) ) + down->setEnabled ( false ); + if ( _page == 0 ) + up->setEnabled ( false ); + } + else + { + up->hide(); + down->hide(); + } + pageButtons = flag; +} + +//--------------------------------------------------------- +// showMag +//--------------------------------------------------------- + +void ScrollScale::showMag ( bool flag ) +{ + showMagFlag = flag; + if ( flag ) + scale->show(); + else + scale->hide(); + box->activate(); +} + +//--------------------------------------------------------- +// offset +//--------------------------------------------------------- +int ScrollScale::offset() +{ + return pos2offset ( scroll->value() ); +} + +//--------------------------------------------------------- +// pos2offset +//--------------------------------------------------------- +int ScrollScale::pos2offset ( int pos ) +{ + if ( scaleVal < 1 ) + return pos * ( -scaleVal ) + scaleVal/2; + else + return pos / scaleVal; +} + +//--------------------------------------------------------- +// setOffset +// val in tick +//--------------------------------------------------------- + +void ScrollScale::setOffset ( int val ) +{ + int i = ( scroll->orientation() == Qt::Horizontal ) ? width() : height(); + int pos, max; + + if ( scaleVal < 1 ) + { + pos = ( val-scaleVal/2 ) / ( -scaleVal ); + max = ( maxVal-scaleVal-1 ) / ( -scaleVal ) - i; + } + else + { + pos = val * scaleVal; + max = maxVal * scaleVal - i; + } + if ( pos > max ) + { + int min; + if ( scaleVal < 1 ) + { + maxVal = ( pos + width() ) * ( -scaleVal ); + min = ( minVal-scaleVal/2 ) / ( -scaleVal ); + max = ( maxVal-scaleVal/2 ) / ( -scaleVal ) - i; + } + else + { + maxVal = ( pos + width() + scaleVal/2 ) /scaleVal; + min = minVal * scaleVal; + max = maxVal * scaleVal - i; + } + + if ( max < 0 ) + max = 0; + if ( min < 0 ) + min = 0; + if ( min > max ) + max = min; + scroll->setRange ( min, max ); + } + + setPos ( pos ); +} + +//--------------------------------------------------------- +// pageUp +// goto previous page +//--------------------------------------------------------- + +void ScrollScale::pageUp() +{ + if ( _page ) + { + --_page; + emit newPage ( _page ); + QString s; + s.setNum ( _page+1 ); + pageNo->setText ( s ); + if ( _page == 0 ) + up->setEnabled ( false ); + if ( _page == ( _pages-2 ) ) + down->setEnabled ( true ); + } +} + +//--------------------------------------------------------- +// pageDown +// goto next page +//--------------------------------------------------------- + +void ScrollScale::pageDown() +{ + if ( _page + 1 < _pages ) + { + ++_page; + emit newPage ( _page ); + QString s; + s.setNum ( _page+1 ); + pageNo->setText ( s ); + if ( _page == ( _pages-1 ) ) + down->setEnabled ( false ); + if ( _page == 1 ) + up->setEnabled ( true ); + } +} + +//--------------------------------------------------------- +// setPages +//--------------------------------------------------------- + +void ScrollScale::setPages ( int n ) +{ + _pages = n; + if ( _page >= _pages ) + { + _page = _pages-1; + emit newPage ( _page ); + QString s; + s.setNum ( _page+1 ); + pageNo->setText ( s ); + } + up->setEnabled ( _page ); + down->setEnabled ( _page < ( _pages-1 ) ); +} + +int ScrollScale::pos() const +{ + return scroll->value(); +} + +int ScrollScale::mag() const +{ + return scale->value(); +} + +/** + * Hardcoded hackish function that corresponds to the values used for the scrollscales in PianoRoll and DrumEditor + * since I couldn't easily create any inverse function from the [0,1024]-range to detect where a zoom actually occurs + * (mg) + */ +int ScrollScale::getQuickZoomLevel(int mag) +{ + if (mag == 0) + return 0; + + for (int i=0; i<24; i++) { + int val1 = ScrollScale::convertQuickZoomLevelToMag(i); + int val2 = ScrollScale::convertQuickZoomLevelToMag(i + 1); + if (mag > val1 && mag <= val2) + return i + 1; + } + + return -1; + +} + +/** + * Function returning the boundary values for a zoom change, hardcoded corresponding to the values used in PianoRoll + * and DrumEditor + */ +int ScrollScale::convertQuickZoomLevelToMag(int zoomlevel) +{ + int vals[] = { 0, 1, 15, 30, 46, 62, 80, 99, 119, 140, 163, + 187, 214, 242, 274, 308, 346, 388, 436, 491, 555, 631, + 726, 849, 1024 }; + + return vals[zoomlevel]; +} + diff --git a/attic/muse2-oom/muse2/muse/widgets/scrollscale.h b/attic/muse2-oom/muse2/muse/widgets/scrollscale.h new file mode 100644 index 00000000..32043070 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/scrollscale.h @@ -0,0 +1,85 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: scrollscale.h,v 1.2.2.3 2009/11/04 17:43:26 lunar_shuttle Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SCROLLSCALE_H__ +#define __SCROLLSCALE_H__ + +#include <QSlider> + +class QBoxLayout; +class QLabel; +class QResizeEvent; +class QScrollBar; +class QToolButton; + +//--------------------------------------------------------- +// ScrollScale +//--------------------------------------------------------- + +class ScrollScale : public QWidget { + QSlider* scale; + QScrollBar* scroll; + int minVal, maxVal; + int scaleVal, scaleMin, scaleMax; + bool showMagFlag; + QBoxLayout* box; + bool noScale; + bool pageButtons; + int _page; + int _pages; + QToolButton* up; + QToolButton* down; + QLabel* pageNo; + bool invers; + double logbase; + + virtual void resizeEvent(QResizeEvent*); + Q_OBJECT + + private slots: + void pageUp(); + void pageDown(); + + public slots: + void setPos(unsigned); + void setPosNoLimit(unsigned); + void setMag(int); + void setOffset(int val); + void setScale(int); + + signals: + void scaleChanged(int); + void lscaleChanged(int); + void scrollChanged(int); + void newPage(int); + + public: + ScrollScale(int, int, int, int max, Qt::Orientation, + QWidget*, int min = 0, bool i=false, double vv = 10.0); + int xmag() const { return scale->value(); } + void setXmag(int val) { scale->setValue(val); } + void setRange(int, int); + void showMag(bool); + void setNoScale(bool flag) { noScale = flag; } + void setPageButtons(bool flag); + void setPage(int n) { _page = n; } + int page() const { return _page; } + int pages() const { return _pages; } + void setPages(int n); + int pos() const; + int mag() const; + int getScaleValue() const { return scaleVal; } + void range(int* b, int* e) const { *b = minVal; *e = maxVal; } + + int offset(); + int pos2offset(int pos); + static int getQuickZoomLevel(int mag); + static int convertQuickZoomLevelToMag(int zoomlvl); + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/section.h b/attic/muse2-oom/muse2/muse/widgets/section.h new file mode 100644 index 00000000..7aaa4778 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/section.h @@ -0,0 +1,19 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: section.h,v 1.1.1.1 2003/10/27 18:54:27 wschweer Exp $ +// (C) Copyright 2002 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SECTION_H__ +#define __SECTION_H__ + +struct Section { + int offset; + unsigned len; + int voff; + int val; + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.cpp b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.cpp new file mode 100644 index 00000000..ca627661 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.cpp @@ -0,0 +1,99 @@ +// +// C++ Implementation: shortcutcapturedialog +// +// Description: +// Dialog window for capturing keyboard shortcuts +// +// Author: Mathias Lundgren <lunar_shuttle@users.sourceforge.net>, (C) 2003 +// +// Copyright: Mathias Lundgren (lunar_shuttle@users.sourceforge.net) (C) 2003 +// +// +#include "shortcutcapturedialog.h" +#include "shortcuts.h" + +#include <QKeyEvent> +#include <QKeySequence> +#include <QInputEvent> +#include <QChar> + +ShortcutCaptureDialog::ShortcutCaptureDialog(QWidget* parent, int index) + : QDialog(parent) + { + setupUi(this); + QKeySequence q = QKeySequence(shortcuts[index].key); + oshrtLabel->setText(q); + connect(okButton, SIGNAL( clicked() ), this, SLOT( apply() ) ); + connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancel())); + shortcutindex = index; + grabKeyboard(); + okButton->setText(tr("Ok")); + cancelButton->setText(tr("Cancel")); + } + +ShortcutCaptureDialog::~ShortcutCaptureDialog() + { + releaseKeyboard(); + } + +void ShortcutCaptureDialog::keyPressEvent(QKeyEvent* e) + { + bool shift, alt, ctrl, meta, conflict = false, realkey = false; + QString msgString = ""; + int temp_key; + Qt::KeyboardModifiers mods = ((QInputEvent*)e)->modifiers(); + shift = mods & Qt::ShiftModifier; + ctrl = mods & Qt::ControlModifier; + alt = mods & Qt::AltModifier; + meta = mods & Qt::MetaModifier; + //printf("Key total: %d, alt: %d, ctrl: %d shift: %d\n",e->key(), alt, ctrl, shift); + temp_key = e->key(); + + QChar keychar(temp_key); + bool ispunct = keychar.isPunct(); + bool issymbol = keychar.isSymbol(); + //printf("Key:%x, alt:%d, ctrl:%d shift:%d ispunct:%d issymbol:%d text:%s\n", + // e->key(), alt, ctrl, shift, ispunct, issymbol, e->text().toLatin1().constData()); // REMOVE Tim. + + temp_key += (shift ? (int)Qt::SHIFT : 0); // (int) Tim + temp_key += (ctrl ? (int)Qt::CTRL : 0); // + temp_key += (alt ? (int)Qt::ALT : 0); // + temp_key += (meta ? (int)Qt::META : 0); + //printf("Final key assembled: %d\n",temp_key); + + // Check if this is a "real" key that completes a valid shortcut: + int k = e->key(); + if (k < 256 || k == Qt::Key_Enter || k == Qt::Key_Return || (k >= Qt::Key_F1 && k <= Qt::Key_F12) || k == Qt::Key_Home || k == Qt::Key_PageUp + || k == Qt::Key_PageDown || k == Qt::Key_End || k == Qt::Key_Insert || k == Qt::Key_Delete + || k == Qt::Key_Up || k == Qt::Key_Down || k == Qt::Key_Left || k == Qt::Key_Right) { + key = temp_key; + realkey = true; + QKeySequence q = QKeySequence(key); + //QKeySequence q = QKeySequence(k, mods); + QString keyString = q; + if (keyString != QString::null) + nshrtLabel->setText(q); + + // Check against conflicting shortcuts + for (int i=0; i < SHRT_NUM_OF_ELEMENTS; i++) { + if (shortcuts[i].key == key && (shortcuts[i].type & (shortcuts[shortcutindex].type | GLOBAL_SHRT | INVIS_SHRT))) { + msgString = tr("Shortcut conflicts with ") + QString(shortcuts[i].descr); + conflict = true; + break; + } + } + } + messageLabel->setText(msgString); + okButton->setEnabled(conflict == false && realkey); + if (!realkey) + nshrtLabel->setText(tr("Undefined")); + + + } + +void ShortcutCaptureDialog::apply() + { + //return the shortcut to configurator widget: + done(key); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.h b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.h new file mode 100644 index 00000000..a7ba69c7 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.h @@ -0,0 +1,35 @@ +// +// C++ Interface: shortcutcapturedialog +// +// Description: +// Dialog window for capturing keyboard shortcuts +// +// Author: Mathias Lundgren <lunar_shuttle@users.sourceforge.net>, (C) 2003 +// +// Copyright: Mathias Lundgren (lunar_shuttle@users.sourceforge.net) (C) 2003 +// +// + +#include "shortcuts.h" +#include "filedialog.h" +#include "ui_shortcutcapturedialogbase.h" + +class QKeyEvent; + +class ShortcutCaptureDialog : public QDialog, public Ui::ShortcutCaptureDialogBase + { + Q_OBJECT + private: + int shortcutindex; + void keyPressEvent(QKeyEvent* e); + int key; + + private slots: + void apply(); + void cancel() { reject(); }; + + public: + ShortcutCaptureDialog(QWidget* parent, int index=0); + ~ShortcutCaptureDialog(); + }; + diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialogbase.ui b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialogbase.ui new file mode 100644 index 00000000..61157890 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialogbase.ui @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ShortcutCaptureDialogBase</class> + <widget class="QDialog" name="ShortcutCaptureDialogBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>323</width> + <height>285</height> + </rect> + </property> + <property name="windowTitle"> + <string>Enter shortcut sequence</string> + </property> + <property name="modal"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout"> + <item> + <widget class="QLabel" name="descrLabel"> + <property name="text"> + <string>Press keys to enter shortcut sequence!</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="messageLabel"> + <property name="text"> + <string/> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QLabel" name="oshrtTextLabel"> + <property name="text"> + <string>Old shortcut:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="oshrtLabel"> + <property name="text"> + <string>Undefined</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QLabel" name="nshrtTextLabel"> + <property name="text"> + <string>New shortcut:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="nshrtLabel"> + <property name="text"> + <string>Undefined</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QPushButton" name="okButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>OK</string> + </property> + <property name="shortcut"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton"> + <property name="text"> + <string>Cancel</string> + </property> + <property name="shortcut"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections/> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.cpp b/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.cpp new file mode 100644 index 00000000..78162f50 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.cpp @@ -0,0 +1,127 @@ +// +// C++ Implementation: shortcutconfig +// +// Description: +// Dialog for configuring keyboard shortcuts +// +// Author: Mathias Lundgren <lunar_shuttle@users.sourceforge.net>, (C) 2003 +// +// Copyright: Mathias Lundgren (lunar_shuttle@users.sourceforge.net) (C) 2003 +// +// +#include <QCloseEvent> +#include <QKeySequence> +#include <QString> + +#include "shortcutconfig.h" +#include "shortcutcapturedialog.h" +#include "shortcuts.h" + +ShortcutConfig::ShortcutConfig(QWidget* parent) + : QDialog(parent) + { + setupUi(this); + connect(cgListView, SIGNAL(itemActivated(QTreeWidgetItem*, int )), + this, SLOT(categorySelChanged(QTreeWidgetItem*, int))); + connect(scListView, SIGNAL(itemActivated(QTreeWidgetItem*, int )), + this, SLOT(shortcutSelChanged(QTreeWidgetItem*, int))); + + connect(defineButton, SIGNAL(pressed()), this, SLOT(assignShortcut())); + connect(clearButton, SIGNAL(pressed()), this, SLOT(clearShortcut())); + connect(applyButton, SIGNAL(pressed()), this, SLOT(assignAll())); + + current_category = ALL_SHRT; + cgListView->sortItems(SHRT_CATEGORY_COL, Qt::AscendingOrder); + _config_changed = false; + + //Fill up category listview: + SCListViewItem* newItem; + SCListViewItem* selItem = 0; + for (int i=0; i < SHRT_NUM_OF_CATEGORIES; i++) { + newItem = new SCListViewItem(cgListView, i); + newItem->setText(SHRT_CATEGORY_COL, shortcut_category[i].name); + if(shortcut_category[i].id_flag == current_category) + selItem = newItem; + } + if(selItem) + cgListView->setCurrentItem(selItem); // Tim + updateSCListView(); + } + +void ShortcutConfig::updateSCListView(int category) + { + scListView->clear(); + SCListViewItem* newItem; + //QString catpre; + for (int i=0; i < SHRT_NUM_OF_ELEMENTS; i++) { + if (shortcuts[i].type & category) { + newItem = new SCListViewItem(scListView, i); + newItem->setText(SHRT_DESCR_COL, tr(shortcuts[i].descr)); + //if(category == ALL_SHRT) + // catpre = QString(shortcut_category[shortcuts[i].type].name) + QString(": "); + //else + // catpre.clear(); + //newItem->setText(SHRT_DESCR_COL, catpre + tr(shortcuts[i].descr)); // Tim + QKeySequence key = QKeySequence(shortcuts[i].key); + newItem->setText(SHRT_SHRTCUT_COL, key); + } + } + } + +void ShortcutConfig::assignShortcut() + { + SCListViewItem* active = (SCListViewItem*) scListView->selectedItems()[0]; + int shortcutindex = active->getIndex(); + ShortcutCaptureDialog* sc = new ShortcutCaptureDialog(this, shortcutindex); + int key = sc->exec(); + delete(sc); + if (key != Rejected) { + shortcuts[shortcutindex].key = key; + QKeySequence keySequence = QKeySequence(key); + active->setText(SHRT_SHRTCUT_COL, keySequence); + _config_changed = true; + } + clearButton->setEnabled(true); + defineButton->setDown(false); + } + +void ShortcutConfig::clearShortcut() + { + SCListViewItem* active = (SCListViewItem*) scListView->selectedItems()[0]; + int shortcutindex = active->getIndex(); + shortcuts[shortcutindex].key = 0; //Cleared + active->setText(SHRT_SHRTCUT_COL,""); + clearButton->setDown(false); + clearButton->setEnabled(false); + _config_changed = true; + } + +void ShortcutConfig::categorySelChanged(QTreeWidgetItem* i, int /*column*/) + { + SCListViewItem* item = (SCListViewItem*) i; + current_category = shortcut_category[item->getIndex()].id_flag; + updateSCListView(current_category); + } + +void ShortcutConfig::shortcutSelChanged(QTreeWidgetItem* in_item, int /*column*/) + { + defineButton->setEnabled(true); + SCListViewItem* active = (SCListViewItem*) in_item; + int index = active->getIndex(); + if (shortcuts[index].key != 0) + clearButton->setEnabled(true); + else + clearButton->setEnabled(false); + } + +void ShortcutConfig::closeEvent(QCloseEvent* /*e*/) // prevent compiler warning : unused variable + { + done(_config_changed); + } + + +void ShortcutConfig::assignAll() + { + applyButton->setDown(false); + done(_config_changed); + } diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.h b/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.h new file mode 100644 index 00000000..0cc11dd7 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.h @@ -0,0 +1,60 @@ +// +// C++ Interface: shortcutconfig +// +// Description: +// Dialog for configuring keyboard shortcuts +// +// Author: Mathias Lundgren <lunar_shuttle@users.sourceforge.net>, (C) 2003 +// +// Copyright: Mathias Lundgren (lunar_shuttle@users.sourceforge.net) (C) 2003 +// +// +#ifndef __SHORTCUTCONFIG_H +#define __SHORTCUTCONFIG_H + +class QCloseEvent; + +#include "ui_shortcutconfigbase.h" + +#define SHRT_CATEGORY_COL 0 +enum + { + SHRT_DESCR_COL = 0, + SHRT_SHRTCUT_COL + }; + +class SCListViewItem : public QTreeWidgetItem { + private: + int index; + + public: + SCListViewItem(QTreeWidget* parent, int i) + : QTreeWidgetItem(parent), index(i) { } + int getIndex() { return index; } + +}; + + +class ShortcutConfig : public QDialog, public Ui::ShortcutConfigBase { + Q_OBJECT + private: + int current_category; + void updateSCListView(int category); + void updateSCListView() { updateSCListView(current_category); } + void closeEvent(QCloseEvent *e); + + private slots: + void categorySelChanged(QTreeWidgetItem*, int); + void shortcutSelChanged(QTreeWidgetItem*, int); + void assignShortcut(); + void clearShortcut(); + void assignAll(); + + + public: + ShortcutConfig(QWidget* parent); + bool _config_changed; + +}; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutconfigbase.ui b/attic/muse2-oom/muse2/muse/widgets/shortcutconfigbase.ui new file mode 100644 index 00000000..892cc7c3 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/shortcutconfigbase.ui @@ -0,0 +1,177 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ShortcutConfigBase</class> + <widget class="QDialog" name="ShortcutConfigBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>466</width> + <height>403</height> + </rect> + </property> + <property name="windowTitle"> + <string>Configure Keyboard Shortcuts</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout"> + <item> + <widget class="QGroupBox" name="groupBox3"> + <property name="title"> + <string/> + </property> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>3</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QTreeWidget" name="cgListView"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>105</width> + <height>200</height> + </size> + </property> + <column> + <property name="text"> + <string>Shortcut Category</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>false</bool> + </property> + </column> + </widget> + </item> + <item> + <widget class="QTreeWidget" name="scListView"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>170</width> + <height>230</height> + </size> + </property> + <column> + <property name="text"> + <string>Description</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Shortcut</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <item> + <spacer name="spacer3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>150</width> + <height>21</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="clearButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Clear</string> + </property> + <property name="shortcut"> + <string>Alt+C</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="defineButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Define</string> + </property> + <property name="shortcut"> + <string>Alt+D</string> + </property> + </widget> + </item> + <item> + <spacer name="spacer2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>30</width> + <height>21</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="applyButton"> + <property name="text"> + <string>&Apply</string> + </property> + <property name="shortcut"> + <string>Alt+A</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections/> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/sigedit.cpp b/attic/muse2-oom/muse2/muse/widgets/sigedit.cpp new file mode 100644 index 00000000..d4c210e4 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/sigedit.cpp @@ -0,0 +1,739 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: sigedit.cpp,v 1.1.1.1.2.1 2004/12/28 23:23:51 lunar_shuttle Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> +#include <values.h> + +#include <QEvent> +#include <QKeyEvent> +#include <QList> +#include <QMouseEvent> +#include <QPainter> +#include <QPaintEvent> +#include <QPixmap> +#include <QResizeEvent> +#include <QString> +#include <QStyle> +#include <QTimerEvent> + +///#include "sig.h" +#include "al/sig.h" +#include "sigedit.h" +#include "spinbox.h" + +extern int mtcType; + +bool Sig::isValid() const +{ + if((z < 1) || (z > 63)) + return false; + + switch(n) + { + case 1: + case 2: + case 3: + case 4: + case 8: + case 16: + case 32: + case 64: + case 128: + return true; + default: + return false; + } +} + + +//--------------------------------------------------------- +// NumberSection +//--------------------------------------------------------- + +class NumberSection + { + int selstart; + int selend; + + public: + NumberSection(int selStart = 0, int selEnd = 0) + : selstart(selStart), selend(selEnd ) {} + int selectionStart() const { return selstart; } + void setSelectionStart(int s) { selstart = s; } + int selectionEnd() const { return selend; } + void setSelectionEnd( int s ) { selend = s; } + int width() const { return selend - selstart; } + }; + +//--------------------------------------------------------- +// SigEditor +//--------------------------------------------------------- + +class SigEditor : public QLineEdit + { + SigEdit* cw; + bool frm; + QPixmap *pm; + int focusSec; + QList<NumberSection> sections; + int offset; + + int section(const QPoint&); + + protected: + void init(); + bool event(QEvent *e); + void resizeEvent(QResizeEvent*); + void paintEvent(QPaintEvent*); + void mousePressEvent(QMouseEvent *e); + void keyPressEvent(QKeyEvent * event ); + void applyFocusSelection() {} + + public: + SigEditor(SigEdit* parent, const char* name); + ~SigEditor(); + + void setControlWidget(SigEdit * widget); + SigEdit* controlWidget() const; + + int focusSection() const { return focusSec; } + + bool setFocusSection(int s); + void appendSection(const NumberSection& sec); + void clearSections(); + void setSectionSelection(int sec, int selstart, int selend); + }; + +//--------------------------------------------------------- +// section +//--------------------------------------------------------- + +int SigEditor::section(const QPoint& pt) + { + if (pm->isNull()) + return -1; + QPainter p(pm); + int fw = frm ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth) : 0; + int x = 2 + fw; + int y = 0; + int w = width(); + int h = height(); + for (int i = 0; i < sections.count(); ++i) { + QString s = cw->sectionFormattedText(i); + QRect bb = p.boundingRect(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s); + int nx = bb.x() + bb.width(); + if (pt.x() >= x && pt.x() < nx) + return i; + x = nx; + if (i < sections.count()-1) { + QString s("/"); + p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb); + x = bb.x() + bb.width(); + } + } + return -1; + } + +//--------------------------------------------------------- +// SigEditor +//--------------------------------------------------------- + +SigEditor::SigEditor(SigEdit* parent, const char* name) + : QLineEdit(parent) + { + setObjectName(name); + cw = parent; + frm = true; + focusSec = 0; + pm = new QPixmap; + offset = 0; + init(); + } + +//--------------------------------------------------------- +// ~SigEditor +//--------------------------------------------------------- + +SigEditor::~SigEditor() + { + delete pm; + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +void SigEditor::init() + { + setBackgroundMode(Qt::PaletteBase); + setFocusSection(-1); + setKeyCompression(true); + setFocusPolicy(Qt::WheelFocus); + } + +//--------------------------------------------------------- +// event +//--------------------------------------------------------- + +bool SigEditor::event(QEvent *e) + { + if (e->type() == QEvent::FocusIn || e->type() == QEvent::FocusOut) { + repaint( rect(), false); + } + else if (e->type() == QEvent::ShortcutOverride) { + QKeyEvent* ke = (QKeyEvent*) e; + switch (ke->key()) { + case Qt::Key_Delete: + case Qt::Key_Backspace: + case Qt::Key_Up: + case Qt::Key_Down: + case Qt::Key_Left: + case Qt::Key_Right: + ke->accept(); + default: + break; + } + } + return QLineEdit::event(e); + } + +void SigEditor::resizeEvent(QResizeEvent *e) + { + pm->resize(e->size()); + QLineEdit::resizeEvent(e); + } + +//--------------------------------------------------------- +// paintEvent +//--------------------------------------------------------- + +void SigEditor::paintEvent(QPaintEvent *) + { + if (pm->isNull()) + return; + + const QColorGroup & cg = colorGroup(); + QPainter p(pm); + p.setPen(colorGroup().text()); + QBrush bg = cg.brush(QColorGroup::Base); + + int fw = frm ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth) : 0; + int x = 2 + fw; + int y = 0; + int w = width(); + int h = height(); + p.fillRect(0, 0, w, h, bg); + + for (int i = 0; i < sections.count(); ++i) { + QRect bb; + QString s = cw->sectionFormattedText(i); + + if (hasFocus() && (int(i) == focusSec)) { + QBrush bg = cg.brush(QColorGroup::Highlight); + QRect r = p.boundingRect(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1); + p.setPen(colorGroup().highlightedText()); + p.fillRect(r, bg); + } + else + p.setPen(colorGroup().text()); + p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb); + x = bb.x() + bb.width(); + if (i < sections.count()-1) { + QString s("/"); + p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb); + x = bb.x() + bb.width(); + } + } + p.end(); + bitBlt(this, 0, 0, pm); + } + +//--------------------------------------------------------- +// mousePressEvent +//--------------------------------------------------------- + +void SigEditor::mousePressEvent(QMouseEvent *e) + { + QPoint p(e->pos().x(), 0); + int sec = section(p); + if (sec != -1) { + cw->setFocusSection(sec); + repaint(rect(), false); + } + } + +//--------------------------------------------------------- +// keyPressEvent +//--------------------------------------------------------- + +void SigEditor::keyPressEvent(QKeyEvent * e ) + { + switch (e->key()) { + case Qt::Key_Right: + if (unsigned(focusSec) <= sections.count()) { + if (cw->setFocusSection(focusSec+1)) + repaint(rect(), false); + } + case Qt::Key_Left: + if (focusSec > 0 ) { + if (cw->setFocusSection(focusSec-1)) + repaint(rect(), false); + } + case Qt::Key_Up: + cw->stepUp(); + case Qt::Key_Down: + cw->stepDown(); + case Qt::Key_Backspace: + case Qt::Key_Delete: + cw->removeLastNumber(focusSec); + case Qt::Key_Enter: + case Qt::Key_Return: + cw->enterPressed(); + default: + QString txt = e->text(); + if (!txt.isEmpty() && txt[0] == '/') { + // do the same thing as KEY_RIGHT when the user presses the separator key + if (focusSec < (signed)(sections.count())) { + if (cw->setFocusSection(focusSec+1)) + repaint(rect(), false); + } + } + int num = txt[0].digitValue(); + + //printf("SigEditor::keyPressEvent num:%d\n", num); + + if (num != -1) { + cw->addNumber(focusSec, num); + } + } + } + +void SigEditor::appendSection(const NumberSection& sec) + { + sections.append(sec); + } +void SigEditor::clearSections() + { + sections.clear(); + } + +//--------------------------------------------------------- +// setSectionSelection +//--------------------------------------------------------- + +void SigEditor::setSectionSelection(int secNo, int selstart, int selend) + { + if (secNo < 0 || secNo > (int)sections.count()) + return; + sections[secNo].setSelectionStart(selstart); + sections[secNo].setSelectionEnd(selend); + } + +//--------------------------------------------------------- +// setFocusSection +//--------------------------------------------------------- + +bool SigEditor::setFocusSection(int idx) + { + if (idx > (int)sections.count()-1 || idx < 0) + return false; + if (idx != focusSec) { + focusSec = idx; + applyFocusSelection(); + return true; + } + return false; + } + +//--------------------------------------------------------- +// SigEdit +//--------------------------------------------------------- + +SigEdit::SigEdit(QWidget* parent, const char* name) + : QWidget(parent) + { + setObjectName(name); + init(); + updateButtons(); + } + +SigEdit::~SigEdit() + { + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +void SigEdit::init() + { + ed = new SigEditor(this, "pos editor"); + controls = new SpinBox(this); + controls->setEditor(ed); + setFocusProxy(ed); + connect(controls, SIGNAL(stepUpPressed()), SLOT(stepUp())); + connect(controls, SIGNAL(stepDownPressed()), SLOT(stepDown())); + connect(this, SIGNAL(valueChanged(int,int)),SLOT(updateButtons())); + + overwrite = false; + timerId = 0; + typing = false; + changed = false; + adv = false; + + sec[0].offset = 0; + sec[0].len = 2; + sec[0].val = 4; + sec[0].voff = 0; + sec[1].offset = 3; + sec[1].len = 3; + sec[1].val = 4; + sec[1].voff = 0; + ed->clearSections(); + ed->appendSection(NumberSection(0,0)); + ed->appendSection(NumberSection(0,0)); + setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed)); + } + +//--------------------------------------------------------- +// setValue +//--------------------------------------------------------- + +void SigEdit::setValue(const Sig& sig) + { + sec[0].val = sig.z; + sec[1].val = sig.n; + changed = false; + ed->repaint(ed->rect(), false); + } + +void SigEdit::setValue(const QString& s) + { + int z, n; + sscanf(s.toLatin1(), "%d/%d", &z, &n); + Sig sig(z, n); + setValue(sig); + } + +Sig SigEdit::sig() const + { + Sig sig(sec[0].val, sec[1].val); + return sig; + } + +bool SigEdit::event(QEvent *e) + { + if (e->type() == QEvent::FocusOut) { + typing = false; + if (changed) { + emit valueChanged(sig().z, sig().n); + changed = false; + } + } + return QWidget::event(e); + } + +void SigEdit::timerEvent(QTimerEvent *) + { + overwrite = true; + } + +//--------------------------------------------------------- +// stepUp +//--------------------------------------------------------- + +void SigEdit::stepUp() + { + bool accepted = false; + int secNo = ed->focusSection(); + int val = sec[secNo].val; + if (secNo == 0) { + if (val < 63) { + ++val; + accepted = true; + } + } + else { + accepted = true; + switch(val) { + case 1: val = 2; break; + case 2: val = 3; break; + case 3: val = 4; break; + case 4: val = 8; break; + case 8: val = 16; break; + case 16: val = 32; break; + case 32: val = 64; break; + case 64: val = 128; break; + case 128: accepted = false; break; + } + } + if (accepted) { + setSec(secNo, val); + changed = true; + emit valueChanged(sec[0].val, sec[1].val); + } + ed->repaint(ed->rect(), false); + } + +//--------------------------------------------------------- +// stepDown +//--------------------------------------------------------- + +void SigEdit::stepDown() + { + bool accepted = false; + int secNo = ed->focusSection(); + int val = sec[secNo].val; + if (secNo == 0) { + if (val > 1) { + --val; + accepted = true; + } + } + else { + accepted = true; + switch(val) { + case 1: accepted = false; break; + case 2: val = 1; break; + case 3: val = 2; break; + case 4: val = 3; break; + case 8: val = 4; break; + case 16: val = 8; break; + case 32: val = 16; break; + case 64: val = 32; break; + case 128: val = 64; break; + } + } + if (accepted) { + setSec(secNo, val); + changed = true; + emit valueChanged(sec[0].val, sec[1].val); + } + ed->repaint(ed->rect(), false); + } + +//--------------------------------------------------------- +// sectionFormattedText +// Returns the formatted number for section sec. +//--------------------------------------------------------- + +QString SigEdit::sectionFormattedText(int secNo) + { + QString txt = sectionText(secNo); + + int so = sec[secNo].offset; + int len = sec[secNo].len; + int eo = so + len; + + if (typing && secNo == ed->focusSection()) + ed->setSectionSelection(secNo, eo - txt.length(), eo); + else + ed->setSectionSelection(secNo, so, eo); + if (secNo == 0) + txt = txt.rightJustify(len, ' '); +// else +// txt = txt.leftJustify(len, ' '); + return txt; + } + +//--------------------------------------------------------- +// setFocusSection +//--------------------------------------------------------- + +bool SigEdit::setFocusSection(int s) + { + if (s != ed->focusSection()) { + killTimer(timerId); + overwrite = true; + typing = false; + int so = sec[s].offset; + int eo = so + sec[s].len; + ed->setSectionSelection(s, so, eo); + if (changed) { + emit valueChanged(sig().z, sig().n); + changed = false; + } + } + return ed->setFocusSection(s); + } + +//--------------------------------------------------------- +// setSec +//--------------------------------------------------------- + +void SigEdit::setSec(int secNo, int val) + { + sec[secNo].val = val; + } + +//--------------------------------------------------------- +// sectionText +// Returns the text of section \a sec. +//--------------------------------------------------------- + +QString SigEdit::sectionText(int secNo) + { + return QString::number(sec[secNo].val + sec[secNo].voff); + } + +//--------------------------------------------------------- +// outOfRange +// return true if out of range +//--------------------------------------------------------- + +bool SigEdit::outOfRange(int secNo, int val) const + { + if (secNo == 0) + return ((val < 1) || (val > 63)); + switch (val) { + case 1: + case 2: + case 3: + case 4: + case 8: + case 16: + case 32: + case 64: + case 128: + // Changed p3.3.43 + //return true; + return false; + default: + // Changed p3.3.43 + //return false; + return true; + } + } + +//--------------------------------------------------------- +// addNumber +//--------------------------------------------------------- + +void SigEdit::addNumber(int secNo, int num) + { + if (secNo == -1) + return; + killTimer(timerId); + bool accepted = false; + typing = true; + int voff = sec[secNo].voff; + + QString txt = sectionText(secNo); + + //printf("SigEdit::addNumber secNo:%d num:%d voff:%d txt:%s\n", secNo, num, voff, txt.toLatin1()); + + if ((unsigned) txt.length() == sec[secNo].len) { + //printf("SigEdit::addNumber txt.length() == sec[secNo].len (%d)\n", sec[secNo].len); + + if (!outOfRange(secNo, num - voff)) { + //printf("SigEdit::addNumber accepted\n"); + + accepted = true; + sec[secNo].val = num - voff; + } + } + else { + //printf("SigEdit::addNumber txt.length() != sec[secNo].len (%d)\n", sec[secNo].len); + + txt += QString::number(num); + int temp = txt.toInt() - voff; + if (outOfRange(secNo, temp)) + { + //printf("SigEdit::addNumber not accepted secNo:%d txt:%s temp:%d\n", secNo, txt.toLatin1(), temp); + + txt = sectionText(secNo); + } + else { + //printf("SigEdit::addNumber accepted\n"); + + accepted = true; + sec[secNo].val = temp; + } + if (adv && ((unsigned) txt.length() == sec[secNo].len)) { + setFocusSection(ed->focusSection() + 1); + } + } + changed = accepted; + if (accepted) + emit valueChanged(sig().z, sig().n); + timerId = startTimer(qApp->doubleClickInterval()*4); + ed->repaint(ed->rect(), false); + } + +//--------------------------------------------------------- +// removeLastNumber +//--------------------------------------------------------- + +void SigEdit::removeLastNumber(int secNo) + { + if (secNo == -1) + return; + QString txt = QString::number(sec[secNo].val); + txt = txt.mid(0, txt.length() - 1); + sec[secNo].val = txt.toInt() - sec[secNo].voff; + ed->repaint(ed->rect(), false); + } + +//--------------------------------------------------------- +// resizeEvent +//--------------------------------------------------------- + +void SigEdit::resizeEvent(QResizeEvent *) + { + controls->resize(width(), height()); + } + +//--------------------------------------------------------- +// sizeHint +//--------------------------------------------------------- + +QSize SigEdit::sizeHint() const + { + QFontMetrics fm(font()); + int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this); // ddskrjo + int h = fm.height() + fw * 2; + + int w = 2 + controls->arrowWidth() + fw * 4; + w += fm.width('9') * 5 + fm.width('/'); + return QSize(w, h).expandedTo(QApplication::globalStrut()); + } + +//--------------------------------------------------------- +// updateButtons +//--------------------------------------------------------- + +void SigEdit::updateButtons() + { + int secNo = ed->focusSection(); + int val = sec[secNo].val; + + bool upEnabled; + bool downEnabled; + + if (secNo == 0) { + upEnabled = val < 63; + downEnabled = val > 1; + } + else { + upEnabled = true; + downEnabled = true; + switch (val) { + case 1: downEnabled = false; break; + case 128: upEnabled = false; break; + } + } + controls->setStepEnabled(isEnabled() & upEnabled, isEnabled() & downEnabled); + } + +//--------------------------------------------------------- +// enterPressed +//! emit returnPressed +//--------------------------------------------------------- +void SigEdit::enterPressed() + { + emit returnPressed(); + } diff --git a/attic/muse2-oom/muse2/muse/widgets/sigedit.h b/attic/muse2-oom/muse2/muse/widgets/sigedit.h new file mode 100644 index 00000000..07ae0741 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/sigedit.h @@ -0,0 +1,88 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: sigedit.h,v 1.1.1.1.2.1 2004/12/28 23:23:51 lunar_shuttle Exp $ +// (C) Copyright 2002 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SIGEDIT_H__ +#define __SIGEDIT_H__ + +#include <QWidget> + +#include "section.h" + +class QResizeEvent; +class QTimerEvent; + +class SigEditor; +class SpinBox; + +struct Sig { + int z; + int n; + public: + Sig(int _z, int _n) : z(_z), n(_n) {} + bool isValid() const; + }; + +//--------------------------------------------------------- +// SigEdit +//--------------------------------------------------------- + +class SigEdit : public QWidget + { + Q_OBJECT + void init(); + + QString sectionText(int sec); + Section sec[2]; + + bool adv; + bool overwrite; + int timerId; + bool typing; + bool changed; + SigEditor *ed; + SpinBox* controls; + + private slots: + void stepUp(); + void stepDown(); + + signals: + void valueChanged(int, int); + void returnPressed(); + + protected: + bool event(QEvent *e ); + void timerEvent(QTimerEvent* e); + void resizeEvent(QResizeEvent*); + QString sectionFormattedText(int sec); + void addNumber(int sec, int num); + void removeLastNumber(int sec); + bool setFocusSection(int s); + + virtual bool outOfRange(int, int) const; + virtual void setSec(int, int); + friend class SigEditor; + + protected slots: + void updateButtons(); + + public slots: + virtual void setValue(const Sig& sig); + void setValue(const QString& s); + + public: + SigEdit(QWidget*, const char* = 0); + ~SigEdit(); + + QSize sizeHint() const; + Sig sig() const; + virtual void setAutoAdvance(bool advance) { adv = advance; } + bool autoAdvance() const { return adv; } + void enterPressed(); + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/siglabel.cpp b/attic/muse2-oom/muse2/muse/widgets/siglabel.cpp new file mode 100644 index 00000000..47fcd2f8 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/siglabel.cpp @@ -0,0 +1,164 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: siglabel.cpp,v 1.1.1.1 2003/10/27 18:54:28 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include "siglabel.h" +#include <stdio.h> + +#define TIMER1 400 +#define TIMER2 200 +#define TIMEC 7 +#define TIMER3 100 +#define TIMEC2 20 +#define TIMER4 50 + +#include "globals.h" +#include <QMouseEvent> +#include <QWheelEvent> +#include <QLabel> + +//--------------------------------------------------------- +// SigLabel +// edit Signature Values (4/4) +//--------------------------------------------------------- + +SigLabel::SigLabel(int z, int n, QWidget* parent) : QLabel(parent) + { + z = n = 0; + setFocusPolicy(Qt::NoFocus); + setAlignment(Qt::AlignCenter); + setValue(z, n); + } + +SigLabel::SigLabel(const AL::TimeSignature& sig, QWidget* parent) : QLabel(parent) + { + z = n = 0; + setFocusPolicy(Qt::NoFocus); + setAlignment(Qt::AlignCenter); + setValue(sig.z, sig.n); + } + +//--------------------------------------------------------- +// mousePressEvent +//--------------------------------------------------------- + +void SigLabel::mousePressEvent(QMouseEvent* event) + { + int button = event->button(); + bool zaehler = event->x() < width() /2; + + int zz = z, nn = n; + switch (button) { + case Qt::LeftButton: + return; + case Qt::MidButton: + incValue(zaehler, false, zz, nn); + break; + case Qt::RightButton: + incValue(zaehler, true, zz, nn); + break; + default: + break; + } + if ((zz != z) || (nn != n)) { + setValue(zz, nn); + emit valueChanged(AL::TimeSignature(zz, nn)); + } + } + +//--------------------------------------------------------- +// incValue +//--------------------------------------------------------- + +void SigLabel::incValue(bool zaehler, bool up, int& zz, int& nn) + { + if (!up) { + if (zaehler) { + --zz; + if (zz < 1) + zz = 1; + } + else { + switch (nn) { + case 1: break; + case 2: nn = 1; break; + case 4: nn = 2; break; + case 8: nn = 4; break; + case 16: nn = 8; break; + case 32: nn = 16; break; + case 64: nn = 32; break; + case 128: nn = 64; break; + } + } + } + else { + if (zaehler) { + ++zz; + if (zz > 16) + zz = 16; + } + else { + switch (nn) { + case 1: nn = 2; break; + case 2: nn = 4; break; + case 4: nn = 8; break; + case 8: nn = 16; break; + case 16: nn = 32; break; + case 32: nn = 64; break; + case 64: nn = 128; break; + case 128: break; + } + } + } + } + +//--------------------------------------------------------- +// wheelEvent +//--------------------------------------------------------- + +void SigLabel::wheelEvent(QWheelEvent* event) + { + bool zaehler = event->x() < width() /2; + int delta = event->delta(); + int zz = z, nn = n; + + bool inc = delta >= 0; + incValue(zaehler, inc, zz, nn); + if ((zz != z) || (nn != n)) { + setValue(zz, nn); + emit valueChanged(AL::TimeSignature(zz, nn)); + } + } + +//--------------------------------------------------------- +// setValue +//--------------------------------------------------------- + +void SigLabel::setValue(int a, int b) + { + if (a == z && b == n) + return; + z = a; + n = b; + QString sa; + sa.setNum(a); + + QString sb; + sb.setNum(b); + + QString s = sa + QString("/") + sb; + setText(s); + } + +//--------------------------------------------------------- +// setFrame +//--------------------------------------------------------- + +void SigLabel::setFrame(bool flag) + { + setFrameStyle(flag ? Panel | Sunken : NoFrame); + setLineWidth(2); + } diff --git a/attic/muse2-oom/muse2/muse/widgets/siglabel.h b/attic/muse2-oom/muse2/muse/widgets/siglabel.h new file mode 100644 index 00000000..bf9e53b4 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/siglabel.h @@ -0,0 +1,47 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: siglabel.h,v 1.1.1.1 2003/10/27 18:54:56 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SIGLABEL_H__ +#define __SIGLABEL_H__ + +#include <al/sig.h> + +#include <QLabel> + +class QWheelEvent; +class QMouseEvent; + +//--------------------------------------------------------- +// SigLabel +// show/edit time signature +//--------------------------------------------------------- + +class SigLabel : public QLabel { + Q_OBJECT + virtual void mousePressEvent(QMouseEvent*); + virtual void wheelEvent(QWheelEvent*); + void incValue(bool zaehler, bool inc, int&, int&); + + protected: + int z, n; + + signals: + void valueChanged(const AL::TimeSignature&); + + public slots: + virtual void setValue(int, int); + virtual void setValue(const AL::TimeSignature& sig) { setValue(sig.z, sig.n); } + + public: + SigLabel(int z, int n, QWidget*); + SigLabel(const AL::TimeSignature&, QWidget*); + void value(int& a, int& b) const { a = z; b = n; } + AL::TimeSignature value() const { return AL::TimeSignature(z, n); } + void setFrame(bool); + }; +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/sigscale.cpp b/attic/muse2-oom/muse2/muse/widgets/sigscale.cpp new file mode 100644 index 00000000..74ed0bcb --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/sigscale.cpp @@ -0,0 +1,152 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: sigscale.cpp,v 1.6 2004/04/11 13:03:32 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <values.h> + +#include <QMouseEvent> +#include <QPainter> + +#include "al/sig.h" // Tim. +#include "globals.h" +#include "midieditor.h" +#include "sigscale.h" +#include "song.h" +#include "gconfig.h" + +//--------------------------------------------------------- +// SigScale +//--------------------------------------------------------- + +SigScale::SigScale(int* r, QWidget* parent, int xs) + : View(parent, xs, 1) + { + setToolTip(tr("signature scale")); + raster = r; + pos[0] = song->cpos(); + pos[1] = song->lpos(); + pos[2] = song->rpos(); + button = Qt::NoButton; + setMouseTracking(true); + connect(song, SIGNAL(posChanged(int, unsigned, bool)), this, SLOT(setPos(int, unsigned, bool))); + setFixedHeight(18); + } + +//--------------------------------------------------------- +// setPos +//--------------------------------------------------------- + +void SigScale::setPos(int idx, unsigned val, bool) + { + if (val == pos[idx]) + return; + unsigned opos = mapx(pos[idx]); + pos[idx] = val; + if (!isVisible()) + return; + val = mapx(val); + int x = -9; + int w = 18; + if (opos > val) { + w += opos - val; + x += val; + } + else { + w += val - opos; + x += opos; + } + redraw(QRect(x, 0, w, height())); + } + +void SigScale::viewMousePressEvent(QMouseEvent* event) + { + button = event->button(); + viewMouseMoveEvent(event); + } + +void SigScale::viewMouseReleaseEvent(QMouseEvent*) + { + button = Qt::NoButton; + } + +void SigScale::viewMouseMoveEvent(QMouseEvent* event) + { + int x = AL::sigmap.raster(event->x(), *raster); + emit timeChanged(x); + int i; + switch (button) { + case Qt::LeftButton: + i = 0; + break; + case Qt::MidButton: + i = 1; + break; + case Qt::RightButton: + i = 2; + break; + default: + return; + } + Pos p(x, true); + song->setPos(i, p); + } + +//--------------------------------------------------------- +// leaveEvent +//--------------------------------------------------------- + +void SigScale::leaveEvent(QEvent*) + { +// emit timeChanged(MAXINT); + } + +//--------------------------------------------------------- +// draw +//--------------------------------------------------------- + +void SigScale::pdraw(QPainter& p, const QRect& r) + { + int x = r.x(); + int w = r.width(); + int h = height(); + + if (x < 0) + x = 0; + p.setFont(config.fonts[3]); + ///for (ciSigEvent si = sigmap.begin(); si != sigmap.end(); ++si) { + for (AL::ciSigEvent si = AL::sigmap.begin(); si != AL::sigmap.end(); ++si) { + ///SigEvent* e = si->second; + AL::SigEvent* e = si->second; + int xp = mapx(e->tick); + if (xp > x+w) + break; + if (xp+40 < x) + continue; + p.drawLine(xp, 0, xp, h/2); + p.drawLine(xp, h/2, xp+5, h/2); + QString s; + s.sprintf("%d/%d", e->sig.z, e->sig.n); + p.drawText(xp+8, h-6, s); + } + + //--------------------------------------------------- + // draw location marker + //--------------------------------------------------- + + p.setPen(Qt::red); + int xp = mapx(pos[0]); + if (xp >= x && xp < x+w) + p.drawLine(xp, 0, xp, h); + p.setPen(Qt::blue); + xp = mapx(pos[1]); + if (xp >= x && xp < x+w) + p.drawLine(xp, 0, xp, h); + xp = mapx(pos[2]); + if (xp >= x && xp < x+w) + p.drawLine(xp, 0, xp, h); + } + + diff --git a/attic/muse2-oom/muse2/muse/widgets/sigscale.h b/attic/muse2-oom/muse2/muse/widgets/sigscale.h new file mode 100644 index 00000000..8c9ffea9 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/sigscale.h @@ -0,0 +1,46 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: sigscale.h,v 1.2 2004/01/11 18:55:37 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SIGSCALE_H__ +#define __SIGSCALE_H__ + +#include "view.h" + +class MidiEditor; + +//--------------------------------------------------------- +// SigScale +// Time Signature Scale +//--------------------------------------------------------- + +class SigScale : public View { + Q_OBJECT + int* raster; + unsigned pos[3]; + int button; + + signals: + void posChanged(unsigned, unsigned); + + protected: + virtual void pdraw(QPainter&, const QRect&); + virtual void viewMousePressEvent(QMouseEvent* event); + virtual void viewMouseMoveEvent(QMouseEvent* event); + virtual void viewMouseReleaseEvent(QMouseEvent* event); + virtual void leaveEvent(QEvent*e); + + signals: + void timeChanged(unsigned); + + public slots: + void setPos(int, unsigned, bool); + + public: + SigScale(int* raster, QWidget* parent, int xscale); + }; +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/slider.cpp b/attic/muse2-oom/muse2/muse/widgets/slider.cpp new file mode 100644 index 00000000..9776d4e1 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/slider.cpp @@ -0,0 +1,975 @@ +#include <cmath> +#include "mmath.h" + +#include <QPainter> +#include <QResizeEvent> + +#include "slider.h" + +//------------------------------------------------------------- +// Slider - The Slider Widget +// +// Slider is a slider widget which operates on an interval +// of type double. Slider supports different layouts as +// well as a scale. +//------------------------------------------------------------ + +//------------------------------------------------------------ +//.F Slider::Slider +// +// Constructor +// +//.u Syntax: +//.f Slider::Slider(QWidget *parent, const char *name, Orientation orient = Horizontal, ScalePos scalePos = None, int bgStyle = BgTrough) +// +//.u Parameters +//.p +// QWidget *parent -- parent widget +// const char *name -- The Widget's name. Default = 0. +// Orientation Orient -- Orientation of the slider. Can be Slider::Horizontal +// or Slider::Vertical. +// Defaults to Horizontal. +// ScalePos scalePos -- Position of the scale. Can be Slider::None, +// Slider::Left, Slider::Right, Slider::Top, +// or Slider::Bottom. Defaults to Slider::None. +// int bgStyle -- Background style. Slider::BgTrough draws the +// slider button in a trough, Slider::BgSlot draws +// a slot underneath the button. An or-combination of both +// may also be used. The default is Slider::BgTrough. +//------------------------------------------------------------ + +Slider::Slider(QWidget *parent, const char *name, + Qt::Orientation orient, ScalePos scalePos, int bgStyle) + : SliderBase(parent,name) + { + if (bgStyle == BgSlot) { + d_thumbLength = 16; + d_thumbHalf = 8; + d_thumbWidth = 30; + } + else { + //d_thumbLength = 30; + d_thumbLength = 32; + d_thumbHalf = 16; + d_thumbWidth = 16; + } + + d_borderWidth = 2; + d_scaleDist = 4; + d_scaleStep = 0.0; + d_scalePos = scalePos; + d_xMargin = 0; + d_yMargin = 0; + d_bgStyle = bgStyle; + + + if (bgStyle & BgTrough) + d_bwTrough = d_borderWidth; + else + d_bwTrough = 0; + + d_sliderRect.setRect(0, 0, 8, 8); + setOrientation(orient); + } + +//------------------------------------------------------------ +//.F Slider::~Slider +// Destructor +//.u Syntax +//.f Slider::~Slider() +//------------------------------------------------------------ + +Slider::~Slider() + { + } + +//------------------------------------------------------------ +// +//.F Slider::setBorderWidth +// Change the slider's border width +// +//.u Syntax +//.f void Slider::setBorderWidth(int bd) +// +//.u Parameters +//.p int bd -- border width +// +//------------------------------------------------------------ + +void Slider::setBorderWidth(int bd) +{ + d_borderWidth = qwtMin(qwtMax(bd,0),10); + if (d_bgStyle & BgTrough) + d_bwTrough = d_borderWidth; + else + d_bwTrough = 0; +} + +//---------------------------------------------------- +// +//.F Slider::setThumbLength +// +// Set the slider's thumb length +// +//.u Syntax +// void Slider::setThumbLength(int l) +// +//.u Parameters +//.p int l -- new length +// +//----------------------------------------------------- +void Slider::setThumbLength(int l) +{ + d_thumbLength = qwtMax(l,8); + d_thumbHalf = d_thumbLength / 2; + resize(size()); +} + +//------------------------------------------------------------ +// +//.F Slider::setThumbWidth +// Change the width of the thumb +// +//.u Syntax +//.p void Slider::setThumbWidth(int w) +// +//.u Parameters +//.p int w -- new width +// +//------------------------------------------------------------ +void Slider::setThumbWidth(int w) +{ + d_thumbWidth = qwtMax(w,4); + resize(size()); +} + + +//------------------------------------------------------------ +//.- +//.F Slider::scaleChange +// Notify changed scale +// +//.u Syntax +//.f void Slider::scaleChange() +// +//.u Description +// Called by QwtScaledWidget +// +//------------------------------------------------------------ +void Slider::scaleChange() +{ + if (!hasUserScale()) + d_scale.setScale(minValue(), maxValue(), d_maxMajor, d_maxMinor); + update(); +} + + +//------------------------------------------------------------ +//.- +//.F Slider::fontChange +// Notify change in font +// +//.u Syntax +//.f Slider::fontChange(const QFont &oldFont) +// +//------------------------------------------------------------ +void Slider::fontChange(const QFont & /*oldFont*/) +{ + repaint(); +} + +//------------------------------------------------------------ +// drawSlider +// Draw the slider into the specified rectangle. +//------------------------------------------------------------ + +void Slider::drawSlider(QPainter *p, const QRect &r) +{ + const QPalette& pal = palette(); + QBrush brBack(pal.window()); + QBrush brMid; + QBrush brDark(pal.dark()); + + QRect cr; + + int ipos,dist1; + double rpos; + int lineDist; + + if (d_bwTrough > 0) { + // qDrawShadePanel(p, r.x(), r.y(), + //r.width(), r.height(), + //pal, TRUE, d_bwTrough,0); + cr.setRect(r.x() + d_bwTrough, + r.y() + d_bwTrough, + r.width() - 2*d_bwTrough, + r.height() - 2*d_bwTrough); + brMid = pal.mid(); + } + else { + cr = r; + brMid = brBack; + } + + rpos = (value() - minValue()) / (maxValue() - minValue()); + + lineDist = d_borderWidth - 1; + if (lineDist < 1) lineDist = 1; + + if (d_orient == Qt::Horizontal) + { + + dist1 = int(double(cr.width() - d_thumbLength) * rpos); + ipos = cr.x() + dist1; + markerPos = ipos + d_thumbHalf; + + // + // draw background + // + if (d_bgStyle & BgSlot) + { + drawHsBgSlot(p, cr, QRect(ipos, cr.y(), d_thumbLength, cr.height()), brMid); + } + else + { + p->fillRect(cr.x(),cr.y(),dist1,cr.height(),brMid); + p->fillRect(ipos + d_thumbLength, cr.y(), + cr.width() - d_thumbLength - dist1, cr.height(),brMid); + } + + // + // Draw thumb + // + //qDrawShadePanel(p,ipos, cr.y(), d_thumbLength, cr.height(), + // pal, FALSE, d_borderWidth, &brBack); + QPixmap thumbp; + bool loaded = thumbp.load(":images/slider_thumb_h.png"); + if(loaded) + p->drawPixmap(ipos, cr.y(), thumbp); + + if (lineDist > 1) + qDrawShadeLine(p,markerPos, cr.y() + lineDist , markerPos, + cr.y() + cr.height() - lineDist, + pal, TRUE, 1); + else + { + p->setPen(pal.dark().color()); + p->drawLine(markerPos -1 , cr.y() + lineDist, markerPos -1, + cr.y() + cr.height() - lineDist - 1); + p->setPen(pal.light().color()); + p->drawLine(markerPos, cr.y() + lineDist, markerPos, + cr.y() + cr.height() - lineDist - 1); + } + + + } + else + {//Vertical slider + dist1 = int(double(cr.height() - d_thumbLength) * (1.0 - rpos)); + ipos = cr.y() + dist1; + markerPos = ipos + d_thumbHalf; + + //NOTE: this is adding the middle line in the slider + if ( d_bgStyle & BgSlot) + { + drawVsBgSlot(p, cr, QRect(cr.left(), ipos, cr.width(), + d_thumbLength), brMid); + } + else + { + //p->fillRect(cr.x(),cr.y(),cr.width(),ipos,brMid); + //p->fillRect(cr.x(), ipos + d_thumbLength, cr.width(), + //cr.height() - d_thumbLength - dist1, brMid); + } + + //This adds the thumb slider + //qDrawShadePanel(p,cr.x(),ipos , cr.width(), d_thumbLength, + // pal,FALSE,d_borderWidth, &brBack); + QPixmap thumbp; + bool loaded = thumbp.load(":images/slider_thumb.png"); + int knobx = cr.x()+2; + int knoby = ipos-12; + QRect knobRect(knobx, knoby, 18, 33); + //printf("Slider: Knob position X: %d Y: %d\n", knobx, knoby); + if(loaded) + { + p->setCompositionMode(QPainter::CompositionMode_SourceAtop);//QPainter::CompositionMode_SourceOver); + //p->drawPixmap(knobx, knoby, thumbp); + p->setClipping(false); + p->drawPixmap(knobRect, thumbp); + } + // if (lineDist > 1) + // qDrawShadeLine(p, cr.x() + lineDist , markerPos, + // cr.x() + cr.width() - lineDist, markerPos, + // pal, TRUE, 1); + // else + // { + // + // p->setPen(pal.dark().color()); + // p->drawLine(cr.x() + lineDist, markerPos - 1 , + // cr.x() + cr.width() - lineDist - 1, markerPos - 1); + // p->setPen(pal.light().color()); + // p->drawLine(cr.x() + lineDist, markerPos, + // cr.x() + cr.width() - lineDist - 1 , markerPos); + // } + } + +} + +//------------------------------------------------------------ +//.- +//.F Slider::drawSlotBg +// +// +//.u Syntax +//.f void Slider::drawSlotBg(QPainter *p, const QRect &rBound, const QRect &rThumb, const QRect &rSlot, const QBrush &brBack) +// +//.u Parameters +//.p QPainter *p, const QRect &rBound, const QRect &rThumb, const QRect &rSlot, const QBrush &brBack +// +//------------------------------------------------------------ +void Slider::drawHsBgSlot(QPainter *p, const QRect &rBound, const QRect &rThumb, const QBrush &brBack) +{ + int ws, ds, dLeft; + int lPos, rPos; + QRect rSlot; + const QPalette& pal = palette(); + + ws = rBound.height(); + if ((ws / 2) * 2 != ws) + ws = 5; + else + ws = 4; + + ds = qwtMax(1, d_thumbLength/2 - 4); + dLeft = rThumb.left() - rBound.left(); + + rSlot = QRect(rBound.x() + ds, rBound.y() + (rBound.height() - ws) / 2, + rBound.width() - 2 * ds, ws); + + rPos = qwtMin(rSlot.x(), rThumb.left()); + + if (rThumb.left() > rBound.x()) + { + p->fillRect(rBound.x(),rBound.y(),dLeft, rSlot.top() - rBound.top(), brBack); + p->fillRect(rBound.x(),rSlot.bottom() + 1,dLeft, + rBound.bottom() - rSlot.bottom(),brBack); + if (rPos > rBound.left()) + p->fillRect(rBound.x(),rSlot.y(), + rPos - rBound.left(),ws,brBack); + + p->setPen(pal.dark().color()); + if (rSlot.x() < rThumb.left()) + p->drawLine(rSlot.x(), rSlot.bottom(), rSlot.x(), rSlot.top()); + if (rSlot.x() < rThumb.left() - 1) + { + p->drawLine(rSlot.x(), rSlot.top(), rThumb.left() - 1, rSlot.top()); + p->setPen(pal.light().color()); + p->drawLine(rSlot.x() + 1, rSlot.bottom(), + rThumb.left() - 1, rSlot.bottom()); + + p->fillRect(rSlot.x() + 1, rSlot.y() + 1, dLeft - ds -1, + rSlot.height() -2, QBrush(pal.currentColorGroup() == QPalette::Disabled ? + pal.color(QPalette::Disabled, QPalette::WindowText) : QColor(0,12,16))); + } + } + + lPos = qwtMax(rSlot.right(), rThumb.right()) + 1; + if (rThumb.right() < rBound.right()) + { + p->fillRect(rThumb.right() + 1,rBound.y(),rBound.right() - rThumb.right(), + rSlot.top() - rBound.top(), brBack); + p->fillRect(rThumb.right() + 1,rSlot.bottom() + 1, + rBound.right() - rThumb.right(), + rBound.bottom() - rSlot.bottom(),brBack); + if (lPos <= rBound.right()) + p->fillRect(lPos, rSlot.y() , rBound.right() - lPos + 1, ws ,brBack); + + p->setPen(pal.dark().color()); + if (rSlot.right() > rThumb.right()) + { + p->drawLine(rThumb.right() + 1, rSlot.top(), rSlot.right(), rSlot.top()); + p->setPen(pal.light().color()); + p->drawLine(rSlot.right(), rSlot.bottom(), rSlot.right(), rSlot.top() + 1); + } + + if (rSlot.right() > rThumb.right() + 1) + { + p->setPen(pal.light().color()); + p->drawLine(rThumb.right() + 1, rSlot.bottom(), + rSlot.right() -1, rSlot.bottom()); + p->fillRect(rThumb.right() + 1, rSlot.y() + 1, + rSlot.right() - rThumb.right() - 1, + rSlot.height() -2, QBrush(pal.currentColorGroup() == QPalette::Disabled ? + pal.color(QPalette::Disabled, QPalette::WindowText) : Qt::black)); + } + } + +} + +//------------------------------------------------------------ +//.- +//.F Slider::drawVsBgSlot +// +// +//.u Syntax +//.f void Slider::drawVsBgSlot(QPainter *p, const QRect &rBound, const QRect &rThumb, const QBrush &brBack) +// +//.u Parameters +//.p QPainter *p, const QRect &rBound, const QRect &rThumb, const QBrush &brBack +// +//.u Return Value +// +//.u Description +// +//------------------------------------------------------------ +void Slider::drawVsBgSlot(QPainter *p, const QRect &rBound, const QRect &rThumb, const QBrush &brBack) +{ + QColor green = QColor(49,175,197); + QColor yellow = QColor(156,85,115); + QColor red = QColor(197,49,87); + QLinearGradient vuGrad(QPointF(0, 0), QPointF(0, rBound.height())); + vuGrad.setColorAt(1, green); + //vuGrad.setColorAt(0.3, yellow); + vuGrad.setColorAt(0, red); + QPen myPen = QPen(); + //myPen.setCapStyle(Qt::RoundCap); + //myPen.setStyle(Qt::DashLine); + myPen.setBrush(QBrush(vuGrad)); + //myPen.setWidth(w-8); + myPen.setWidth(1); + + QColor darkColor = QColor(17,31,40); + QColor lightColor = QColor(80,96,109); + int ws, ds, dTop; + int lPos, hPos; + QRect rSlot; + const QPalette& pal = palette(); + + ws = rBound.width(); + if ((ws / 2) * 2 != ws) + ws = 5; + else + ws = 4; + + ds = qwtMax(1, d_thumbLength/2 - 4); + dTop = rThumb.top() - rBound.top(); + + rSlot = QRect(rBound.x() + (rBound.width() - ws) / 2, rBound.y() + ds, + ws, rBound.height() - 2 * ds); + + hPos = qwtMin(rSlot.y(), rThumb.top()); + + if (rThumb.top() > rBound.top()) + { + p->setPen(lightColor); + //p->fillRect(rBound.x(),rBound.y(), rSlot.left() - rBound.left(),dTop, brBack); + //p->fillRect(rSlot.right() + 1, rBound.y(), + // rBound.right() - rSlot.right(), dTop,brBack); + //if (hPos > rBound.top()) + // p->fillRect(rSlot.x(),rBound.y(), ws, hPos - rBound.top(),brBack); + + //p->setPen(pal.dark().color()); + p->setPen(darkColor); + if (rSlot.top() < rThumb.top()) + p->drawLine(rSlot.left(), rSlot.top(), rSlot.right(), rSlot.top()); + + + if (rSlot.top() < rThumb.top() - 1) + { + p->drawLine(rSlot.left(), rThumb.top() - 1, rSlot.left(), rSlot.top()); + //p->setPen(pal.light().color()); + p->setPen(lightColor); + p->drawLine(rSlot.right(), rSlot.top() + 1, rSlot.right(), rThumb.top() - 1); + + p->fillRect(rSlot.x() - 1, rSlot.y() + 1, rSlot.width() + 2, + dTop - ds -1, QBrush(pal.currentColorGroup() == QPalette::Disabled ? + pal.color(QPalette::Disabled, QPalette::WindowText) : QColor(0,12,16))); + + } + } + + lPos = qwtMax(rSlot.bottom(), rThumb.bottom()) + 1; + if (rThumb.bottom() < rBound.bottom()) + { + // p->fillRect(rBound.left(), rThumb.bottom() + 1, + // rSlot.left() - rBound.left(), + // rBound.bottom() - rThumb.bottom(), brBack); + // p->fillRect(rSlot.right() + 1, rThumb.bottom() + 1, + // rBound.right() - rSlot.right(), + // rBound.bottom() - rThumb.bottom(), brBack); + //if (lPos <= rBound.bottom()) + // p->fillRect(rSlot.left(), lPos, ws, rBound.bottom() - lPos + 1, brBack); + + p->setPen(lightColor); + //p->setPen(pal.dark().color()); + if (rSlot.bottom() > rThumb.bottom()) + { + p->drawLine(rSlot.left(), rThumb.bottom() + 1, rSlot.left(), rSlot.bottom()); + //p->setPen(pal.light().color()); + p->setPen(lightColor); + p->drawLine(rSlot.left() * 1, rSlot.bottom(), rSlot.right(), rSlot.bottom()); + } + + if (rSlot.bottom() > rThumb.bottom() + 1) + { + //p->setPen(pal.light().color()); + p->setPen(lightColor); + p->drawLine(rSlot.right(), rThumb.bottom() + 1, rSlot.right(), + rSlot.bottom()); + p->fillRect(rSlot.left() - 1, rThumb.bottom() + 1, + rSlot.width() + 2, rSlot.bottom() - rThumb.bottom() - 1, + QBrush(pal.currentColorGroup() == QPalette::Disabled ? + pal.color(QPalette::Disabled, QPalette::WindowText) : QColor(0,12,16))); + p->setPen(myPen); + int myoffset = rSlot.left() + 1; + int scrollTop = rSlot.bottom() - rThumb.bottom() - 1; + int scrollB = rThumb.bottom() + 1; + for(int i = 0; i < 2; i++) + { + p->drawLine(myoffset, scrollB, myoffset, rSlot.bottom()); + ++myoffset; + } + } + } + +} + +//------------------------------------------------------------ +//.- +//.F Slider::getValue +// Determine the value corresponding to a specified +// mouse location. +// +//.u Syntax +//.f double Slider::getValue(const QPoint &p) +// +//.u Parameters +//.p const QPoint &p -- +// +//.u Description +// Called by SliderBase +//------------------------------------------------------------ +double Slider::getValue( const QPoint &p) +{ + double rv; + int pos; + QRect r = d_sliderRect; + + r.setLeft(r.left() + d_bwTrough); + r.setRight(r.right() - d_bwTrough); + r.setTop(r.top() - d_bwTrough); + r.setBottom(r.bottom() - d_bwTrough); + + if (d_orient == Qt::Horizontal) + { + + if (r.width() <= d_thumbLength) + { + rv = 0.5 * (minValue() + maxValue()); + } + else + { + pos = p.x() - r.x() - d_thumbHalf; + rv = minValue() + + rint( (maxValue() - minValue()) * double(pos) + / double(r.width() - d_thumbLength) + / step() ) * step(); + } + + } + else + { + if (r.height() <= d_thumbLength) + { + rv = 0.5 * (minValue() + maxValue()); + } + else + { + pos = p.y() - r.y() - d_thumbHalf; + rv = minValue() + + rint( (maxValue() - minValue()) * + (1.0 - double(pos) + / double(r.height() - d_thumbLength)) + / step() ) * step(); + } + + } + + return(rv); +} + + +//------------------------------------------------------------ +//.- +//.F Slider::getScrollMode +// Determine scrolling mode and direction +// +//.u Syntax +//.f void Slider::getScrollMode( const QPoint &p, int &scrollMode, int &direction ) +// +//.u Parameters +//.p const QPoint &p -- point +// +//.u Description +// Called by SliderBase +// +//------------------------------------------------------------ +void Slider::getScrollMode( QPoint &p, const Qt::MouseButton &button, int &scrollMode, int &direction ) +{ + if(cursorHoming() && button == Qt::LeftButton) + { + if(d_sliderRect.contains(p)) + { + scrollMode = ScrMouse; + direction = 0; + + int mp = 0; + QRect cr; + QPoint cp; + int ipos,dist1; + double rpos; + int lineDist; + + if(d_bwTrough > 0) + cr.setRect(d_sliderRect.x() + d_bwTrough, + d_sliderRect.y() + d_bwTrough, + d_sliderRect.width() - 2*d_bwTrough, + d_sliderRect.height() - 2*d_bwTrough); + else + cr = d_sliderRect; + + rpos = (value() - minValue()) / (maxValue() - minValue()); + + lineDist = d_borderWidth - 1; + if(lineDist < 1) lineDist = 1; + + if(d_orient == Qt::Horizontal) + { + dist1 = int(double(cr.width() - d_thumbLength) * rpos); + ipos = cr.x() + dist1; + mp = ipos + d_thumbHalf; + + p.setX(mp); + cp = mapToGlobal( QPoint(mp, p.y()) ); + } + else + { + dist1 = int(double(cr.height() - d_thumbLength) * (1.0 - rpos)); + ipos = cr.y() + dist1; + mp = ipos + d_thumbHalf; + p.setY(mp); + cp = mapToGlobal( QPoint(p.x(), mp) ); + } + cursor().setPos(cp.x(), cp.y()); + } + } + else + { + int currentPos; + if (d_orient == Qt::Horizontal) + currentPos = p.x(); + else + currentPos = p.y(); + + if (d_sliderRect.contains(p)) + { + if ((currentPos > markerPos - d_thumbHalf) + && (currentPos < markerPos + d_thumbHalf)) + { + scrollMode = ScrMouse; + direction = 0; + } + else + { + scrollMode = ScrPage; + if (((currentPos > markerPos) && (d_orient == Qt::Horizontal)) + || ((currentPos <= markerPos) && (d_orient != Qt::Horizontal))) + direction = 1; + else + direction = -1; + } + } + else + { + scrollMode = ScrNone; + direction = 0; + } + + } +} + +//------------------------------------------------------------ +//.F Slider::paintEvent +// Qt paint event +// +//.u Syntax +//.f void Slider::paintEvent(QPaintEvent *e) +//------------------------------------------------------------ + +void Slider::paintEvent(QPaintEvent* /*e*/) + { + QPainter p; + + if (p.begin(this)) { + if (d_scalePos != None) { + p.fillRect(rect(), palette().window()); + d_scale.draw(&p); + } + drawSlider(&p, d_sliderRect); + } + p.end(); + } + +//------------------------------------------------------------ +//.F Slider::resizeEvent +// Qt resize event +// +//.u Parameters +//.p QResizeEvent *e +// +//.u Syntax +//.f void Slider::resizeEvent(QResizeEvent *e) +//------------------------------------------------------------ + +void Slider::resizeEvent(QResizeEvent *e) +{ + + d_resized = TRUE; + QSize s = e->size(); + int sliderWidth = d_thumbWidth + 2 * d_bwTrough; + + // reposition slider + if(d_orient == Qt::Horizontal) + { + switch(d_scalePos) + { + case Top: + + d_sliderRect.setRect(this->rect().x() + d_xMargin, + this->rect().y() + s.height() - 1 + - d_yMargin - sliderWidth, + s.width() - 2 * d_xMargin, + sliderWidth); + d_scale.setGeometry(d_sliderRect.x() + d_bwTrough + d_thumbHalf, + d_sliderRect.y() - d_scaleDist, + d_sliderRect.width() - d_thumbLength - 2*d_bwTrough, + ScaleDraw::Top); + + break; + + case Bottom: + + d_sliderRect.setRect(this->rect().x() + d_xMargin, + this->rect().y() + d_yMargin, + s.width() - 2*d_xMargin, + sliderWidth); + d_scale.setGeometry(d_sliderRect.x() + d_bwTrough + d_thumbHalf, + d_sliderRect.y() + d_sliderRect.height() + d_scaleDist, + d_sliderRect.width() - d_thumbLength - 2*d_bwTrough, + ScaleDraw::Bottom); + + break; + + default: + d_sliderRect.setRect(this->rect().x(), this->rect().x(), + s.width(), s.height()); + break; + } + } + else + { + switch(d_scalePos) + { + case Left: + d_sliderRect.setRect(this->rect().x() + s.width() + - sliderWidth - 1 - d_xMargin, + this->rect().y() + d_yMargin, + sliderWidth, + s.height() - 2 * d_yMargin); + d_scale.setGeometry(d_sliderRect.x() - d_scaleDist, + d_sliderRect.y() + d_thumbHalf + d_bwTrough, + s.height() - d_thumbLength - 2*d_bwTrough, + ScaleDraw::Left); + + break; + case Right: + d_sliderRect.setRect(this->rect().x() + d_xMargin, + this->rect().y() + d_yMargin, + sliderWidth, + s.height() - 2* d_yMargin); + d_scale.setGeometry(this->rect().x() + d_sliderRect.width() + + d_scaleDist, + d_sliderRect.y() + d_thumbHalf + d_bwTrough, + s.height() - d_thumbLength - 2*d_bwTrough, + ScaleDraw::Right); + break; + default: + d_sliderRect.setRect(this->rect().x(), this->rect().x(), + s.width(), s.height()); + break; + } + } + +} + +//------------------------------------------------------------ +//.- +//.F Slider::valueChange +// Notify change of value +// +//.u Syntax +//.f void Slider::valueChange() +// +//------------------------------------------------------------ + +void Slider::valueChange() + { + update(); + SliderBase::valueChange(); + } + +//------------------------------------------------------------ +//.- +//.F Slider::rangeChange +// Notify change of range +// +//.u Description +// +//.u Syntax +//.f void Slider::rangeChange() +// +//------------------------------------------------------------ +void Slider::rangeChange() +{ + if (!hasUserScale()) + d_scale.setScale(minValue(), maxValue(), d_maxMajor, d_maxMinor); + SliderBase::rangeChange(); + repaint(); +} + +//------------------------------------------------------------ +// +//.F Slider::setMargins +// Set distances between the widget's border and +// internals. +// +//.u Syntax +//.f void Slider::setMargins(int hor, int vert) +// +//.u Parameters +//.p int hor, int vert -- Margins +// +//------------------------------------------------------------ +void Slider::setMargins(int hor, int vert) +{ + d_xMargin = qwtMax(0, hor); + d_yMargin = qwtMin(0, vert); + resize(this->size()); +} + +//------------------------------------------------------------ +// +//.F Slider::sizeHint +// Return a recommended size +// +//.u Syntax +//.f QSize Slider::sizeHint() const +// +//.u Note +// The return value of sizeHint() depends on the font and the +// scale. +//------------------------------------------------------------ + +QSize Slider::sizeHint() //const ddskrjo + { + QPainter p; + int msWidth = 0, msHeight = 0; + + int w = 40; + int h = 40; + if (d_scalePos != None) { + if (p.begin(this)) { + msWidth = d_scale.maxWidth(&p, FALSE); + msHeight = d_scale.maxHeight(&p); + } + p.end(); + + switch(d_orient) { + case Qt::Vertical: + w = 2*d_xMargin + d_thumbWidth + 2*d_bwTrough + msWidth + d_scaleDist + 2; + break; + case Qt::Horizontal: + h = 2*d_yMargin + d_thumbWidth + 2*d_bwTrough + msHeight + d_scaleDist; + break; + } + } + else { // no scale + switch(d_orient) { + case Qt::Vertical: + w = 16 + 2 * d_bwTrough; + break; + case Qt::Horizontal: + h = 16 + 2 * d_bwTrough; + break; + } + } + return QSize(w, h); + } + +//--------------------------------------------------------- +// setOrientation +//--------------------------------------------------------- + +void Slider::setOrientation(Qt::Orientation o) + { + d_orient = o; + ScaleDraw::OrientationX so = ScaleDraw::Bottom; + switch(d_orient) { + case Qt::Vertical: + if (d_scalePos == Right) + so = ScaleDraw::Right; + else + so = ScaleDraw::Left; + break; + case Qt::Horizontal: + if (d_scalePos == Bottom) + so = ScaleDraw::Bottom; + else + so = ScaleDraw::Top; + break; + } + + d_scale.setGeometry(0, 0, 40, so); + if (d_orient == Qt::Vertical) + setMinimumSize(10,20); + else + setMinimumSize(20,10); + QRect r = geometry(); + setGeometry(r.x(), r.y(), r.height(), r.width()); + update(); + } + +Qt::Orientation Slider::orientation() const + { + return d_orient; + } + +double Slider::lineStep() const + { + return 1.0; + } + +double Slider::pageStep() const + { + return 1.0; + } + +void Slider::setLineStep(double) + { + } + +void Slider::setPageStep(double) + { + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/slider.h b/attic/muse2-oom/muse2/muse/widgets/slider.h new file mode 100644 index 00000000..4addc5f4 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/slider.h @@ -0,0 +1,96 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: slider.h,v 1.3.2.2 2008/01/19 13:33:47 wschweer Exp $ +// +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SLIDER_H__ +#define __SLIDER_H__ + +#include "sclif.h" +#include "sliderbase.h" +#include "scldraw.h" +#include <QPixmap> + +//--------------------------------------------------------- +// Slider +//--------------------------------------------------------- + +class Slider : public SliderBase, public ScaleIf + { + Q_OBJECT + + public: + enum ScalePos { None, Left, Right, Top, Bottom }; + enum { BgTrough = 0x1, BgSlot = 0x2 }; + + private: + Q_PROPERTY( double lineStep READ lineStep WRITE setLineStep ) + Q_PROPERTY( double pageStep READ pageStep WRITE setPageStep ) + Q_PROPERTY( Qt::Orientation orientation READ orientation WRITE setOrientation ) + + QRect d_sliderRect; + + int d_thumbLength; + int d_thumbHalf; + int d_thumbWidth; + int d_borderWidth; + int d_bwTrough; + int d_scaleDist; + int d_xMargin; + int d_yMargin; + + int d_resized; + bool d_autoResize; + double d_scaleStep; + + Qt::Orientation d_orient; + ScalePos d_scalePos; + int d_bgStyle; + int markerPos; + + void drawHsBgSlot(QPainter *, const QRect&, const QRect&,const QBrush&); + void drawVsBgSlot(QPainter *, const QRect&, const QRect&,const QBrush&); + + protected: + virtual void drawSlider (QPainter *p, const QRect &r); + double getValue(const QPoint &p); + void getScrollMode( QPoint &p, const Qt::MouseButton &button, int &scrollMode, int &direction); + void resizeEvent(QResizeEvent *e); + void paintEvent (QPaintEvent *e); + void valueChange(); + void rangeChange(); + void scaleChange(); + void fontChange(const QFont &oldFont); + + public: + Slider(QWidget *parent, const char *name = 0, + Qt::Orientation orient = Qt::Vertical, + ScalePos scalePos = None, + int bgStyle = BgTrough); + + ~Slider(); + void setThumbLength(int l); + void setThumbWidth(int w); + + void setOrientation(Qt::Orientation o); + Qt::Orientation orientation() const; + + double lineStep() const; + double pageStep() const; + + void setLineStep(double); + void setPageStep(double); + + void setBorderWidth(int bw); + void setMargins(int x, int y); + QSize sizeHint(); // const; + }; +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/sliderbase.cpp b/attic/muse2-oom/muse2/muse/widgets/sliderbase.cpp new file mode 100644 index 00000000..320e1bc3 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/sliderbase.cpp @@ -0,0 +1,726 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: sliderbase.cpp,v 1.4.2.4 2007/01/27 14:52:43 spamatica Exp $ + +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <cmath> +#include "sliderbase.h" +#include "mmath.h" +#include <QWheelEvent> +#include <QMouseEvent> +#include <QTimerEvent> + +// DESCRIPTION +// SliderBase is a base class for +// slider widgets. QwtSliderBase handles the mouse events +// and updates the slider's value accordingly. Derived classes +// only have to implement the @QwtSliderBase::getValue@ and +// @QwtSliderBase::getScrollMode@ members, and should react to a +// @QwtSliderbase::valueChange@, which normally requires repainting. + +//------------------------------------------------------------ +//.F SliderBase::SliderBase +// Constructor +// +//.u Syntax +//.f SliderBase::SliderBase(QWidget *parent, const char *name) +// +//.u Parameters +//.p QWidget *parent, const char *name +// +//------------------------------------------------------------ + +SliderBase::SliderBase(QWidget *parent, const char *name) +: QWidget(parent) + { + setObjectName(name); + _id = -1; + _cursorHoming = false; + _ignoreMouseMove = false; + d_tmrID = 0; + d_updTime = 150; + d_mass = 0.0; + d_tracking = true; + d_mouseOffset = 0.0; + d_scrollMode = ScrNone; + setRange(0.0, 1.0, 0.1); + } + +//------------------------------------------------------------ +//.F SliderBase::~SliderBase +// Destructor +// +//.u Syntax +//.f SliderBase::~SliderBase() +//------------------------------------------------------------ + +SliderBase::~SliderBase() + { + if (d_tmrID) + killTimer(d_tmrID); + } + + +//------------------------------------------------------------ +//.F void SliderBase::wheelEvent(QWheelEvent *e) +// Add wheel event handling +// +//.u Syntax +//.f void SliderBase::wheelEvent(QWheelEvent *e) +//------------------------------------------------------------ +void SliderBase::wheelEvent(QWheelEvent *e) +{ + // Avoid unwanted wheel events from outside the control. + // Just in case it grabs focus somehow. + // Tested: No go, can't seem to determine where event came from. + /* + const QPoint gp = mapToGlobal(e->pos()); + const QRect gr = QRect(mapToGlobal(rect().topLeft()), mapToGlobal(rect().bottomRight())); + if(!gr.contains(gp)) + { + e->ignore(); + return; + } */ + + e->accept(); + + float inc = (maxValue() - minValue()) / 40; + if (e->modifiers() == Qt::ShiftModifier) + inc = inc / 10; + + if(inc < step()) + inc = step(); + + if(e->delta() > 0) + setValue(value()+inc); + else + setValue(value()-inc); + + emit sliderMoved(value(), _id); +} + + +//------------------------------------------------------------ +//.F SliderBase::stopMoving +// Stop updating if automatic scrolling is active +// +//.u Syntax +//.f void SliderBase::stopMoving() +//------------------------------------------------------------ + +void SliderBase::stopMoving() + { + if(d_tmrID) { + killTimer(d_tmrID); + d_tmrID = 0; + } + } + +//------------------------------------------------------------ +//.F SliderBase::setUpdateTime +// Specify the update interval for automatic scrolling +// +//.u Syntax +//.f void SliderBase::setUpdateTime(int t) +// +//.u Parameters +//.p int t -- update interval in milliseconds +// +//.u See also +// @SliderBase::getScrollMode@ +//------------------------------------------------------------ + +void SliderBase::setUpdateTime(int t) + { + if (t < 50) + t = 50; + d_updTime = t; + } + +//------------------------------------------------------------ +//.F SliderBase::mousePressEvent +// Mouse press event handler +// +//.u Syntax +//.f void SliderBase::mousePressEvent(QMouseEvent *e) +// +//.u Parameters +//.p QMouseEvent *e -- Qt Mouse press event +//------------------------------------------------------------ + +void SliderBase::mousePressEvent(QMouseEvent *e) + { + QPoint p = e->pos(); + const Qt::MouseButton button = e->button(); + d_timerTick = 0; + + getScrollMode(p, button, d_scrollMode, d_direction); + stopMoving(); + + switch(d_scrollMode) { + case ScrPage: + case ScrTimer: + d_mouseOffset = 0; + DoubleRange::incPages(d_direction); + emit sliderMoved(value(), _id); + d_tmrID = startTimer(qwtMax(250, 2 * d_updTime)); + break; + + case ScrMouse: + d_speed = 0; + if(button == Qt::RightButton) + { + emit sliderRightClicked(e->globalPos(), _id); + break; + } + d_time.start(); + if(_cursorHoming && button == Qt::LeftButton) + { + _ignoreMouseMove = true; + d_mouseOffset = 0.0; + } + else + d_mouseOffset = getValue(p) - value(); + + emit sliderPressed(_id); + break; + + default: + d_mouseOffset = 0; + d_direction = 0; + break; + } + } + + +//------------------------------------------------------------ +//.- +//.F SliderBase::buttonRelease +// Emit a valueChanged() signal if necessary +// +//.u Syntax +//.f void SliderBase::buttonReleased() +// +//------------------------------------------------------------ +void SliderBase::buttonReleased() +{ + if ((!d_tracking) || (value() != prevValue())) + emit valueChanged(value(), _id); +} + + +//------------------------------------------------------------ +// +//.F SliderBase::mouseReleaseEvent +// Mouse Release Event handler +// +//.u Syntax +//.f void SliderBase::mouseReleaseEvent(QMouseEvent *e) +// +//.u Parameters +//.p QMouseEvent *e -- Qt Mouse Event +// +//------------------------------------------------------------ +void SliderBase::mouseReleaseEvent(QMouseEvent *e) +{ + int ms = 0; + /*double inc = step(); */ // prevent compiler warning: unused variable + _ignoreMouseMove = false; + const Qt::MouseButton button = e->button(); + + switch(d_scrollMode) + { + + case ScrMouse: + + if(button == Qt::RightButton) + { + d_scrollMode = ScrNone; + break; + } + if(_cursorHoming && button == Qt::LeftButton) + d_scrollMode = ScrNone; + else + { + setPosition(e->pos()); + d_direction = 0; + d_mouseOffset = 0; + if (d_mass > 0.0) + { + ms = d_time.elapsed(); + if ((fabs(d_speed) > 0.0) && (ms < 50)) + d_tmrID = startTimer(d_updTime); + } + else + { + d_scrollMode = ScrNone; + buttonReleased(); + } + } + emit sliderReleased(_id); + + break; + + case ScrDirect: + + setPosition(e->pos()); + d_direction = 0; + d_mouseOffset = 0; + d_scrollMode = ScrNone; + buttonReleased(); + break; + + case ScrPage: + stopMoving(); + d_timerTick = 0; + buttonReleased(); + d_scrollMode = ScrNone; + break; + + case ScrTimer: + stopMoving(); + d_timerTick = 0; + buttonReleased(); + d_scrollMode = ScrNone; + break; + + default: + d_scrollMode = ScrNone; + buttonReleased(); + } +} + + +//------------------------------------------------------------ +// +//.F SliderBase::setPosition +// Move the slider to a specified point, adjust the value +// and emit signals if necessary +// +//.u Syntax +//.f void SliderBase::setPosition(const QPoint &p) +// +//.u Parameters +//.p const QPoint &p +// +//------------------------------------------------------------ +void SliderBase::setPosition(const QPoint &p) +{ + DoubleRange::fitValue(getValue(p) - d_mouseOffset); +} + + +//------------------------------------------------------------ +// +//.F SliderBase::setTracking +// +// Enables or disables tracking. +// +//.u Syntax +//.f void SliderBase::setTracking(bool enable) +// +//.u Parameters +//.p bool enable -- enable (TRUE) or disable (FALSE) tracking +// +//.u Description +// +// If tracking is enabled, the slider emits a +// valueChanged() signal whenever its value +// changes (the default behaviour). If tracking +// is disabled, the value changed() signal will only +// be emitted if +//.i -- the user releases the mouse +// button and the value has changed or +// -- at the end of automatic scrolling. +//.P +// Tracking is enabled by default. +//------------------------------------------------------------ +void SliderBase::setTracking(bool enable) +{ + d_tracking = enable; +} + +//------------------------------------------------------------ +//.- +//.F SliderBase::mouseMoveEvent +// Mouse Move Event handler +// +//.u Syntax +//.f void SliderBase::mouseMoveEvent(QMouseEvent *e) +// +//.u Parameters +//.p QMouseEvent *e -- Qt Mouse Move Event +// +//------------------------------------------------------------ +void SliderBase::mouseMoveEvent(QMouseEvent *e) +{ + if(_ignoreMouseMove) + { + _ignoreMouseMove = false; + return; + } + + double ms = 0.0; + if (d_scrollMode == ScrMouse ) + { + setPosition(e->pos()); + if (d_mass > 0.0) + { + ms = double(d_time.elapsed()); + if (ms < 1.0) ms = 1.0; + d_speed = (exactValue() - exactPrevValue()) / ms; + d_time.start(); + } + if (value() != prevValue()) + emit sliderMoved(value(), _id); + } + +} + + + +//------------------------------------------------------------ +// +//.F SliderBase::timerEvent +// Timer event handler +// +//.u Syntax +//.f void SliderBase::timerEvent(QTimerEvent *e) +// +//.u Parameters +//.p QTimerEvent *e -- Qt timer event +// +//------------------------------------------------------------ + +void SliderBase::timerEvent(QTimerEvent*) +{ + double newval; + double inc = step(); + + switch (d_scrollMode) + { + case ScrMouse: + if (d_mass > 0.0) + { + d_speed *= exp( - double(d_updTime) * 0.001 / d_mass ); + newval = exactValue() + d_speed * double(d_updTime); + DoubleRange::fitValue(newval); + // stop if d_speed < one step per second + if (fabs(d_speed) < 0.001 * fabs(step())) + { + d_speed = 0; + stopMoving(); + buttonReleased(); + } + + } + else + stopMoving(); + + break; + + case ScrPage: + DoubleRange::incPages(d_direction); + + if (value() != prevValue()) + emit sliderMoved(value(), _id); + + if (!d_timerTick) + { + killTimer(d_tmrID); + d_tmrID = startTimer(d_updTime); + } + break; + case ScrTimer: + DoubleRange::fitValue(value() + double(d_direction) * inc); + + if (value() != prevValue()) + emit sliderMoved(value(), _id); + + if (!d_timerTick) + { + killTimer(d_tmrID); + d_tmrID = startTimer(d_updTime); + } + break; + default: + stopMoving(); + break; + } + + d_timerTick = 1; +} + + +//------------------------------------------------------------ +// +//.F SliderBase::valueChange +// Notify change of value +// +//.u Syntax +//.f void SliderBase::valueChange() +// +//.u Parameters +//.p double x -- new value +// +//.u Description +// This function can be reimplemented by derived classes +// in order to keep track of changes, i.e. repaint the widget. +// The default implementation emits a valueChanged() signal +// if tracking is enabled. +// +//------------------------------------------------------------ +void SliderBase::valueChange() +{ + if (d_tracking) + emit valueChanged(value(), _id); +} + +//------------------------------------------------------------ +// +//.F SliderBase::setMass +// Set the slider's mass for flywheel effect. +// +//.u Syntax +//.f void SliderBase::setMass(double val) +// +//.u Parameters +//.p double val -- new mass in kg +// +//.u Description +// +// If the slider's mass is greater then 0, it will continue +// to move after the mouse button has been released. Its speed +// decreases with time at a rate depending on the slider's mass. +// A large mass means that it will continue to move for a +// long time. +// +// Limits: If the mass is smaller than 1g, it is set to zero. +// The maximal mass is limited to 100kg. +// +// Derived widgets may overload this function to make it public. +// +//------------------------------------------------------------ +void SliderBase::setMass(double val) +{ + if (val < 0.001) + d_mass = 0.0; + else if (val > 100.0) + d_mass = 100.0; + else + d_mass = val; +} + + +//------------------------------------------------------------ +// +//.F SliderBase::setValue +// Move the slider to a specified value +// +//.u Syntax +//.f void SliderBase::setValue(double val) +// +//.u Parameters +//.p double val -- new value +// +//.u Description +// This function can be used to move the slider to a value +// which is not an integer multiple of the step size. +// +//.u See also +// @SliderBase::fitValue@ +//------------------------------------------------------------ + +void SliderBase::setValue(double val) + { + if (d_scrollMode == ScrMouse) + stopMoving(); + DoubleRange::setValue(val); + } + + +//------------------------------------------------------------ +// +//.F QSlider::fitValue +// Set the slider's value to the nearest integer multiple +// of the step size. +// +//.u Syntax +//.f void SliderBase::fitValue(double val) +// +//.u See also: +// @SliderBase::setValue@ +//------------------------------------------------------------ +void SliderBase::fitValue(double val) +{ + if (d_scrollMode == ScrMouse) stopMoving(); + DoubleRange::fitValue(val); +} + + +//------------------------------------------------------------ +// +//.F SliderBase::incValue +// Increment the value by a specified number of steps +// +//.u Syntax +//.f void SliderBase::incValue(int steps) +// +//.u Parameters +//.p int steps -- number of steps +// +//------------------------------------------------------------ +void SliderBase::incValue(int steps) +{ + if (d_scrollMode == ScrMouse) stopMoving(); + DoubleRange::incValue(steps); +} + + +//------------------------------------------------------------ +// +//.F SliderBase::stepPage +// Increment the value by a specified number of steps +// +//.u Syntax +//.f void SliderBase::stepPages(int pages) +// +//.u Parameters +//.p int pages -- +/- number of pages +// +//.u Description +// Steps the control as if pager was clicked. +// Designed to be called from outside (like from a buddy label), rather than from +// the control itself. Calls DoubleRange::incPages, which normally causes valueChange() +// (and emits valueChanged), but also emits sliderMoved. +// +//------------------------------------------------------------ +void SliderBase::stepPages(int pages) +{ + DoubleRange::incPages(pages); + emit sliderMoved(value(), _id); +} + + +//------------------------------------------------------------ +// +//.F SliderBase::getValue +// Determine the value corresponding to a specified poind +// +//.u Syntax +//.f void SliderBase::getValue(const QPoint &p) +// +//.u Parameters +//.p const QPoint &p -- point +// +//.u Description +// This is an abstract virtual function which is called when +// the user presses or releases a mouse button or moves the +// mouse. It has to be implemented by the derived class. +// +//------------------------------------------------------------ + +//------------------------------------------------------------ +// +//.F SliderBase::getScrollMode +// Determine what to do when the user presses a mouse button. +// +//.u Syntax +//.f void SliderBase::getScrollMode(const QPoint &p, int &scrollMode, int &direction) +// +//.u Input Parameters +//.p const QPoint &p -- point where the mouse was pressed +// +//.u Output parameters +// int &scrollMode -- The scrolling mode +// int &direction -- direction: 1, 0, or -1. +// +//.u Description +// This function is abstract and has to be implemented by derived classes. +// It is called on a mousePress event. The derived class can determine +// what should happen next in dependence of the position where the mouse +// was pressed by returning scrolling mode and direction. SliderBase +// knows the following modes: +//.t +// SliderBase::ScrNone -- Scrolling switched off. Don't change the value. +// SliderBase::ScrMouse -- Change the value while the user keeps the +// button pressed and moves the mouse. +// SliderBase::ScrTimer -- Automatic scrolling. Increment the value +// in the specified direction as long as +// the user keeps the button pressed. +// SliderBase::ScrPage -- Automatic scrolling. Same as ScrTimer, but +// increment by page size. +// +// +//------------------------------------------------------------ + +//------------------------------------------------------------ +// +//.F SliderBase::valueChanged +// Notify a change of value. +// +//.u Syntax +//.f void SliderBase::valueChanged(double value, int id) +// +//.u Parameters +//.p double value -- new value +// +//.u Description +// In the default setting +// (tracking enabled), this signal will be emitted every +// time the value changes ( see setTracking() ). +//------------------------------------------------------------ + +//------------------------------------------------------------ +// +//.F SliderBase::sliderPressed +// This signal is emitted when the user presses the +// movable part of the slider (start ScrMouse Mode). +// +//.u Syntax +//.f void SliderBase::sliderPressed() +// +//------------------------------------------------------------ + +//------------------------------------------------------------ +// +//.F SliderBase::SliderReleased +// This signal is emitted when the user releases the +// movable part of the slider. +// +//.u Syntax +//.f void QwtSliderbase::SliderReleased() +// +//------------------------------------------------------------ + + +//------------------------------------------------------------ +// +//.F SliderBase::sliderMoved +// This signal is emitted when the user moves the +// slider with the mouse. +// +//.u Syntax +//.f void SliderBase::sliderMoved(double value, int _id) +// +//.u Parameters +//.p double value -- new value +// +//------------------------------------------------------------ + + + + + + + + + diff --git a/attic/muse2-oom/muse2/muse/widgets/sliderbase.h b/attic/muse2-oom/muse2/muse/widgets/sliderbase.h new file mode 100644 index 00000000..8bfac9c3 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/sliderbase.h @@ -0,0 +1,101 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: sliderbase.h,v 1.4.2.3 2006/11/14 06:28:37 terminator356 Exp $ + +// Copyright (C) 1997 Josef Wilgen +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License, version 2, +// as published by the Free Software Foundation. +// +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SLIDERBASE_H__ +#define __SLIDERBASE_H__ + +#include "drange.h" + +#include <QTime> +#include <QWidget> + +//--------------------------------------------------------- +// SliderBase +//--------------------------------------------------------- + +class SliderBase : public QWidget, public DoubleRange + { + Q_OBJECT + Q_PROPERTY( int id READ id WRITE setId ) + Q_PROPERTY( double minValue READ minValue WRITE setMinValue ) + Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue ) + Q_PROPERTY( double value READ value WRITE setValue ) + + int _id; + int d_tmrID; + int d_updTime; + int d_timerTick; + QTime d_time; + double d_speed; + double d_mass; + bool _cursorHoming; + bool _ignoreMouseMove; + + void buttonReleased(); + + protected: + int d_scrollMode; + double d_mouseOffset; + int d_direction; + int d_tracking; + + virtual void setMass(double val); + void setPosition(const QPoint &p); + virtual void valueChange(); + virtual double mass() const { return d_mass; } + + void wheelEvent(QWheelEvent *e); + void timerEvent(QTimerEvent *e); + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + void mouseMoveEvent(QMouseEvent *e); + virtual double getValue(const QPoint & p) = 0; + virtual void getScrollMode( QPoint &p, const Qt::MouseButton &button, + int &scrollMode, int &direction) = 0; + + public slots: + void setValue(double val); + void fitValue(double val); + void incValue(int steps); + + signals: + void valueChanged(double value, int id); + void sliderPressed(int id); + void sliderReleased(int id); + void sliderMoved(double value, int id); + void sliderRightClicked(const QPoint &p, int id); + + public: + enum { ScrNone, ScrMouse, ScrTimer, ScrDirect, ScrPage }; + + SliderBase( QWidget *parent = 0, const char *name = 0 ); + ~SliderBase(); + + bool cursorHoming() const { return _cursorHoming; } + void setCursorHoming(bool b) { _cursorHoming = b; } + void setUpdateTime(int t); + // void incValue(double nSteps); + void stopMoving(); + void setTracking(bool enable); + + double value() const { return DoubleRange::value(); } + void stepPages(int pages); + double minValue() const { return DoubleRange::minValue(); } + double maxValue() const { return DoubleRange::maxValue(); } + void setMinValue(double v) { DoubleRange::setRange(v, maxValue(), 0.0, 1); } + void setMaxValue(double v) { DoubleRange::setRange(minValue(), v, 0.0, 1); } + int id() const { return _id; } + void setId(int i) { _id = i; } + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/songinfo.h b/attic/muse2-oom/muse2/muse/widgets/songinfo.h new file mode 100644 index 00000000..d566e00a --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/songinfo.h @@ -0,0 +1,37 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id: songinfo.h,v 1.0.0.0 2010/11/17 01:01:01 ogetbilo Exp $ +// +// Copyright (C) 1999-2010 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// This program 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 this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#include "ui_songinfo.h" + +class QDialog; + + +//--------------------------------------------------------- +// SongInfoWidget +// Wrapper around Ui::SongInfo +//--------------------------------------------------------- + +class SongInfoWidget : public QDialog, public Ui::SongInfo +{ + Q_OBJECT + + public: + SongInfoWidget(QDialog *parent = 0) : QDialog(parent) { setupUi(this); } +}; diff --git a/attic/muse2-oom/muse2/muse/widgets/songinfo.ui b/attic/muse2-oom/muse2/muse/widgets/songinfo.ui new file mode 100644 index 00000000..0944ce93 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/songinfo.ui @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SongInfo</class> + <widget class="QDialog" name="SongInfo"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>403</width> + <height>274</height> + </rect> + </property> + <property name="windowTitle"> + <string>Song Information</string> + </property> + <layout class="QVBoxLayout"> + <item> + <layout class="QVBoxLayout"> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QTextEdit" name="songInfoText"/> + </item> + <item> + <layout class="QHBoxLayout"> + <item> + <spacer name="spacer1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>311</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonCancel"> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="shortcut"> + <string>Alt+C</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonOk"> + <property name="text"> + <string>&Ok</string> + </property> + <property name="shortcut"> + <string>Alt+O</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>SongInfo</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>SongInfo</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/spinbox.cpp b/attic/muse2-oom/muse2/muse/widgets/spinbox.cpp new file mode 100644 index 00000000..ee585da7 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/spinbox.cpp @@ -0,0 +1,84 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: spinbox.cpp,v 1.1.2.3 2009/07/09 18:27:11 terminator356 Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QKeyEvent> +#include <QEvent> +#include "spinbox.h" + +//--------------------------------------------------------- +// SpinBox +//--------------------------------------------------------- + +SpinBox::SpinBox(QWidget* parent) + : QSpinBox(parent) +{ + _clearFocus = true; +} + +SpinBox::SpinBox(int minValue, int maxValue, int step, QWidget* parent) + : QSpinBox(parent) +{ + setRange(minValue, maxValue); + setSingleStep(step); + _clearFocus = true; +} + +bool SpinBox::eventFilter(QObject* o, QEvent* ev) +{ + // if (o != (QObject*)editor()) ddskrjo can't find editor() + // return QSpinBox::eventFilter(o,ev); + + bool retval = FALSE; + if(ev->type() == QEvent::KeyPress) + { + QKeyEvent* k = (QKeyEvent*)ev; + if(k->key() == Qt::Key_Up || k->key() == Qt::Key_Down) + { + // stepUp/stepDown will be called. Set this now. + _clearFocus = false; + } + else if (k->key() == Qt::Key_Enter || k->key() == Qt::Key_Return) + { + // With this line, two enter presses after an edit will clear focus. + // Without, just one enter press clears the focus. + //if(!editor()->isModified()) + { + clearFocus(); + return TRUE; + } + } + } + else + if(ev->type() == QEvent::MouseButtonDblClick) + { + emit doubleClicked(); + return TRUE; + } + + retval = QSpinBox::eventFilter(o, ev); + + return retval; +} + +void SpinBox::stepUp() +{ + QSpinBox::stepUp(); + if(_clearFocus) + clearFocus(); + else + _clearFocus = true; +} + +void SpinBox::stepDown() +{ + QSpinBox::stepDown(); + if(_clearFocus) + clearFocus(); + else + _clearFocus = true; +} + diff --git a/attic/muse2-oom/muse2/muse/widgets/spinbox.h b/attic/muse2-oom/muse2/muse/widgets/spinbox.h new file mode 100644 index 00000000..43ff85be --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/spinbox.h @@ -0,0 +1,43 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: spinbox.h,v 1.1.2.2 2009/02/02 21:38:01 terminator356 Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +// SpinBox: +// Click up/down, or mousewheel, or hit enter with un-modified text (which means enter TWICE for modified text), +// and the control will give up focus, thereby allowing you to use global shortcut keys afterwards. +// Up/down keys still keep the focus. +#ifndef __SPINBOX_H__ +#define __SPINBOX_H__ + +#include <QSpinBox> +#include <QEvent> + +//--------------------------------------------------------- +// SpinBox +//--------------------------------------------------------- + +class SpinBox : public QSpinBox { + Q_OBJECT + + bool _clearFocus; + + protected: + bool eventFilter(QObject* obj, QEvent* ev); + + public slots: + virtual void stepUp(); + virtual void stepDown(); + + signals: + void doubleClicked(); + + public: + SpinBox(QWidget* parent=0); + SpinBox(int minValue, int maxValue, int step = 1, QWidget* parent=0); +}; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/spinboxFP.cpp b/attic/muse2-oom/muse2/muse/widgets/spinboxFP.cpp new file mode 100644 index 00000000..2d8f3372 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/spinboxFP.cpp @@ -0,0 +1,172 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: spinboxFP.cpp,v 1.1.1.1 2003/10/27 18:55:03 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> +#include <cmath> + +//#include <QtGui> +//#include <QDoubleValidator> +//#include <QLineEdit> + +#include "spinboxFP.h" + +//--------------------------------------------------------- +// SpinBoxFP +//--------------------------------------------------------- + +SpinBoxFP::SpinBoxFP(QWidget* parent) + //: QSpinBox(parent) + : QDoubleSpinBox(parent) + { + //validator = new QDoubleValidator(this); + //lineEdit()->setValidator(validator = new QDoubleValidator(this)); + //validator->setNotation(QDoubleValidator::StandardNotation); + + //_decimals = 0; + setDecimals(0); + + connect(this, SIGNAL(valueChanged(double)), SLOT(valueChange(double))); + } + +SpinBoxFP::SpinBoxFP(int minValue, int maxValue, int step, QWidget* parent) +//SpinBoxFP::SpinBoxFP(double minValue, double maxValue, double step, QWidget* parent) + //: QSpinBox(parent) + : QDoubleSpinBox(parent) + { + //validator = new QDoubleValidator(this); + //lineEdit()->setValidator(validator = new QDoubleValidator(this)); + //validator->setNotation(QDoubleValidator::StandardNotation); + + //_decimals = 0; + QDoubleSpinBox::setDecimals(0); + + setRange(minValue, maxValue); + setSingleStep(step); + + connect(this, SIGNAL(valueChanged(double)), SLOT(valueChange(double))); + } + +//--------------------------------------------------------- +// valueChange +//--------------------------------------------------------- + +void SpinBoxFP::valueChange(double) +{ + double div = exp10(decimals()); + emit valueChanged(int(value() * div)); +} + +//--------------------------------------------------------- +// setValue +//--------------------------------------------------------- + +void SpinBoxFP::setValue(int val) + { + double div = exp10(decimals()); + QDoubleSpinBox::setValue(double(val) / div ); + } + +//--------------------------------------------------------- +// intValue +//--------------------------------------------------------- + +int SpinBoxFP::intValue() + { + double div = exp10(decimals()); + return int(value() * div); + } + +//--------------------------------------------------------- +// setDecimals +//--------------------------------------------------------- + +void SpinBoxFP::setDecimals(int val) + { + //_decimals = val; + + //updateDisplay(); + //interpretText(); // TODO: Check - is this what we need? Will send out signals? + //setValue(value()); // Try this. "setValue() will emit valueChanged() if the new value is different from the old one." + + QDoubleSpinBox::setDecimals(val); + double step = 1.0 / exp10(val); + setSingleStep(step); + } + +/* +//--------------------------------------------------------- +// validate +//--------------------------------------------------------- + +QValidator::State SpinBoxFP::validate(QString& input, int& pos) const +{ + // Must set these dynamically as settings may have changed. + validator->setRange(minimum(), maximum(), _decimals); + + QValidator::State s = validator->validate(input, pos); + return s; +} + +//--------------------------------------------------------- +// mapValueToText +//--------------------------------------------------------- + +QString SpinBoxFP::textFromValue(int value) const + { + if (_decimals) { + QString s; + int div = int(exp10(_decimals)); +// printf("val %d, prec %d, div %d\n", value, _precision, div); + + s.sprintf("%d.%0*d", value/div, _decimals, value%div); + //s.sprintf("%0*f", value, _decimals); + + return s; + } + return QSpinBox::textFromValue(value); + } + +//--------------------------------------------------------- +// mapTextToValue +//--------------------------------------------------------- + +int SpinBoxFP::valueFromText(const QString& text) const + { + //QString qs = cleanText(); + if (_decimals) { + //const char* s = qs.toLatin1(); + //const char* s = cleanText().toAscii().data(); + + //int a, b; + bool ok; + double f = text.toDouble(&ok); + + //int n = sscanf(s, "%d.%d", &a, &b); + //int n = sscanf(s, "%f", &f); + + //if (n != 2) { + //if (n != 1) { + if (!ok) { + + // *ok = false; + //return 0; + // TODO: Check - Hmm, no OK parameter. Why return 0? Let's try: + // Keep returning the current value until something valid comes in... + return value(); + } + + //int div = int(exp10(_decimals)); + double div = int(exp10(_decimals)); + + //return a * div + b; + return (f * div); + + } + return QSpinBox::valueFromText(text); + } + +*/
\ No newline at end of file diff --git a/attic/muse2-oom/muse2/muse/widgets/spinboxFP.h b/attic/muse2-oom/muse2/muse/widgets/spinboxFP.h new file mode 100644 index 00000000..4c0b75db --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/spinboxFP.h @@ -0,0 +1,53 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: spinboxFP.h,v 1.1.1.1.2.1 2008/05/21 00:28:54 terminator356 Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SPINBOXFP_H__ +#define __SPINBOXFP_H__ + +//#include <QSpinBox> +#include <QDoubleSpinBox> + +//class QValidator; +//class QDoubleValidator; + +//--------------------------------------------------------- +// SpinBoxFP +//--------------------------------------------------------- + +//class SpinBoxFP : public QSpinBox { +class SpinBoxFP : public QDoubleSpinBox { + Q_OBJECT + //Q_PROPERTY( int decimals READ decimals WRITE setDecimals ) + + //int _decimals; + //QDoubleValidator* validator; + + signals: + void valueChanged(int); + + private slots: + void valueChange(double); + + protected: + //virtual QString textFromValue(int) const; + //virtual int valueFromText(const QString&) const; + //virtual QValidator::State validate(QString&, int&) const; + + public: + SpinBoxFP(QWidget* parent=0); + SpinBoxFP(int minValue, int maxValue, int step = 1, QWidget* parent=0); + //SpinBoxFP(double minValue, double maxValue, double step = 1.0, QWidget* parent=0); + + void setValue(int val); + int intValue(); + + void setDecimals(int); + //int decimals() const { return _decimals; } + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/splitter.cpp b/attic/muse2-oom/muse2/muse/widgets/splitter.cpp new file mode 100644 index 00000000..96fe2378 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/splitter.cpp @@ -0,0 +1,79 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: splitter.cpp,v 1.1.1.1 2003/10/27 18:54:59 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include "splitter.h" +#include "xml.h" + +#include <QList> +#include <QStringList> + +//--------------------------------------------------------- +// Splitter +//--------------------------------------------------------- + +Splitter::Splitter(Qt::Orientation o, QWidget* parent, const char* name) + : QSplitter(o, parent) + { + setObjectName(name); + setOpaqueResize(true); + } + +//--------------------------------------------------------- +// saveConfiguration +//--------------------------------------------------------- + +void Splitter::writeStatus(int level, Xml& xml) + { + QList<int> vl = sizes(); + //xml.nput(level++, "<%s>", name()); + xml.nput(level++, "<%s>", Xml::xmlString(objectName()).toLatin1().constData()); + QList<int>::iterator ivl = vl.begin(); + for (; ivl != vl.end(); ++ivl) { + xml.nput("%d ", *ivl); + } + //xml.nput("</%s>\n", name()); + xml.nput("</%s>\n", Xml::xmlString(objectName()).toLatin1().constData()); + } + +//--------------------------------------------------------- +// loadConfiguration +//--------------------------------------------------------- + +void Splitter::readStatus(Xml& xml) + { + QList<int> vl; + + for (;;) { + Xml::Token token = xml.parse(); + const QString& tag = xml.s1(); + switch (token) { + case Xml::Error: + case Xml::End: + return; + case Xml::TagStart: + xml.unknown("Splitter"); + break; + case Xml::Text: + { + //QStringList sl = QStringList::split(' ', tag); + QStringList sl = tag.split(QString(" "), QString::SkipEmptyParts); + for (QStringList::Iterator it = sl.begin(); it != sl.end(); ++it) { + int val = (*it).toInt(); + vl.append(val); + } + } + break; + case Xml::TagEnd: + if (tag == objectName()) { + setSizes(vl); + return; + } + default: + break; + } + } + } diff --git a/attic/muse2-oom/muse2/muse/widgets/splitter.h b/attic/muse2-oom/muse2/muse/widgets/splitter.h new file mode 100644 index 00000000..98a64087 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/splitter.h @@ -0,0 +1,29 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: splitter.h,v 1.1.1.1 2003/10/27 18:54:51 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SPLITTER_H__ +#define __SPLITTER_H__ + +#include <QSplitter> + +class Xml; + +//--------------------------------------------------------- +// Splitter +//--------------------------------------------------------- + +class Splitter : public QSplitter { + Q_OBJECT + + public: + Splitter(Qt::Orientation o, QWidget* parent, const char* name); + void writeStatus(int level, Xml&); + void readStatus(Xml&); + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/swidget.cpp b/attic/muse2-oom/muse2/muse/widgets/swidget.cpp new file mode 100644 index 00000000..79f5b845 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/swidget.cpp @@ -0,0 +1,20 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: swidget.cpp,v 1.1.1.1 2003/10/27 18:54:27 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include "swidget.h" + +#include <QResizeEvent> + +//--------------------------------------------------------- +// resizeEvent +//--------------------------------------------------------- + +void SWidget::resizeEvent(QResizeEvent* ev) + { + emit heightChanged(ev->size().height()); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/swidget.h b/attic/muse2-oom/muse2/muse/widgets/swidget.h new file mode 100644 index 00000000..c5f4fd6a --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/swidget.h @@ -0,0 +1,31 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: swidget.h,v 1.1.1.1 2003/10/27 18:54:49 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __SWIDGET_H__ +#define __SWIDGET_H__ + +#include <QWidget> + +//--------------------------------------------------------- +// SWidget +// a simple widget which emits a heighChanged signal +// on received ResizeEventīs +//--------------------------------------------------------- + +class SWidget : public QWidget { + virtual void resizeEvent(QResizeEvent*); + Q_OBJECT + + signals: + void heightChanged(int); + + public: + SWidget(QWidget* parent) : QWidget(parent) {} + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/synthconfigbase.ui b/attic/muse2-oom/muse2/muse/widgets/synthconfigbase.ui new file mode 100644 index 00000000..97f0beaa --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/synthconfigbase.ui @@ -0,0 +1,168 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SynthConfigBase</class> + <widget class="QDialog" name="SynthConfigBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>630</width> + <height>492</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Synth Configuration</string> + </property> + <layout class="QGridLayout"> + <item row="1" column="1"> + <widget class="QGroupBox" name="GroupBox3"> + <property name="title"> + <string>Instances</string> + </property> + <layout class="QGridLayout"> + <item row="0" column="0"> + <widget class="QTreeWidget" name="instanceList"> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <column> + <property name="text"> + <string>Name</string> + </property> + </column> + <column> + <property name="text"> + <string>Midi Port</string> + </property> + </column> + </widget> + </item> + <item row="1" column="0"> + <layout class="QHBoxLayout"> + <item> + <widget class="QPushButton" name="removeInstance"> + <property name="text"> + <string>Remove Instance</string> + </property> + </widget> + </item> + <item> + <spacer name="Spacer2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>113</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item row="0" column="0" colspan="2"> + <widget class="QGroupBox" name="groupBox10"> + <property name="title"> + <string>Midi connections</string> + </property> + <layout class="QVBoxLayout"> + <item> + <widget class="QTableWidget" name="mdevView"> + <attribute name="verticalHeaderDefaultSectionSize"> + <number>18</number> + </attribute> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="GroupBox2"> + <property name="title"> + <string>Soft Synthesizer</string> + </property> + <layout class="QGridLayout"> + <item row="1" column="0"> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QPushButton" name="addInstance"> + <property name="text"> + <string>Add Instance</string> + </property> + </widget> + </item> + <item> + <spacer name="Spacer1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="0" column="0"> + <widget class="QTreeWidget" name="synthList"> + <property name="toolTip"> + <string>list of available software synthesizers</string> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <column> + <property name="text"> + <string>File</string> + </property> + </column> + <column> + <property name="text"> + <string>Inst</string> + </property> + </column> + <column> + <property name="text"> + <string>Name</string> + </property> + </column> + <column> + <property name="text"> + <string>Version</string> + </property> + </column> + <column> + <property name="text"> + <string>Description</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections/> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/tb1.cpp b/attic/muse2-oom/muse2/muse/widgets/tb1.cpp new file mode 100644 index 00000000..510e15d1 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/tb1.cpp @@ -0,0 +1,268 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: tb1.cpp,v 1.3.2.2 2007/01/04 00:35:17 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +//#include <assert.h> +#include <stdio.h> +#include <values.h> + +#include <QHeaderView> +#include <QTableWidget> +#include <QToolButton> + +#include "config.h" +#include "lcombo.h" +#include "tb1.h" +#include "globals.h" +#include "poslabel.h" +#include "pitchlabel.h" + +static int rasterTable[] = { + //------ 8 4 2 + 1, 4, 8, 16, 32, 64, 128, 256, 512, 1024, + 1, 6, 12, 24, 48, 96, 192, 384, 768, 1536, + 1, 9, 18, 36, 72, 144, 288, 576, 1152, 2304 + }; + +static const char* rasterStrings[] = +{ + QT_TRANSLATE_NOOP("@default", "Off"), "2pp", "5pp", "64T", "32T", "16T", "8T", "4T", "2T", "1T", + QT_TRANSLATE_NOOP("@default", "Off"), "3pp", "6pp", "64", "32", "16", "8", "4", "2", "1", + QT_TRANSLATE_NOOP("@default", "Off"), "4pp", "7pp", "64.", "32.", "16.", "8.", "4.", "2.", "1." +}; + +static int quantTable[] = { + 1, 16, 32, 64, 128, 256, 512, 1024, + 1, 24, 48, 96, 192, 384, 768, 1536, + 1, 36, 72, 144, 288, 576, 1152, 2304 + }; + +static const char* quantStrings[] = { + QT_TRANSLATE_NOOP("@default", "Off"), "64T", "32T", "16T", "8T", "4T", "2T", "1T", + QT_TRANSLATE_NOOP("@default", "Off"), "64", "32", "16", "8", "4", "2", "1", + QT_TRANSLATE_NOOP("@default", "Off"), "64.", "32.", "16.", "8.", "4.", "2.", "1." + }; + +//--------------------------------------------------------- +// genToolbar +// solo time pitch raster quant +//--------------------------------------------------------- + +Toolbar1::Toolbar1(QWidget* parent, int r, int q, bool sp) + : QToolBar(QString("Quant'n'Snap-tools"), parent) + { + pitch = 0; + showPitch = sp; + // ORCAN - FIXME: Check this: + //setHorizontalStretchable(false); + //setHorizontalPolicy(QSizePolicy::Minimum); + //setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); + + solo = new QToolButton(); + solo->setText(tr("Solo")); + solo->setCheckable(true); + addWidget(solo); + + //--------------------------------------------------- + // Cursor Position + //--------------------------------------------------- + + QLabel* label = new QLabel(tr("Cursor")); + label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + label->setIndent(3); + //addWidget(label); + pos = new PosLabel(0, "pos"); + pos->setFixedHeight(22); + pos->setObjectName("Cursor"); + addWidget(pos); + if (showPitch) { + pitch = new PitchLabel(0); + //pitch->setEnabled(false); + pitch->setFixedHeight(22); + pitch->setObjectName("pitchLabel"); + addWidget(pitch); + } + + //--------------------------------------------------- + // Raster, Quant. + //--------------------------------------------------- + + raster = new LabelCombo(tr("Snap"), 0); + quant = new LabelCombo(tr("Quantize"), 0); + + rlist = new QTableWidget(10, 3); + qlist = new QTableWidget(8, 3); + rlist->verticalHeader()->setDefaultSectionSize(22); + rlist->horizontalHeader()->setDefaultSectionSize(32); + rlist->setSelectionMode(QAbstractItemView::SingleSelection); + rlist->verticalHeader()->hide(); + rlist->horizontalHeader()->hide(); + qlist->verticalHeader()->setDefaultSectionSize(22); + qlist->horizontalHeader()->setDefaultSectionSize(32); + qlist->setSelectionMode(QAbstractItemView::SingleSelection); + qlist->verticalHeader()->hide(); + qlist->horizontalHeader()->hide(); + + rlist->setMinimumWidth(96); + qlist->setMinimumWidth(96); + + raster->setView(rlist); + quant->setView(qlist); + + for (int j = 0; j < 3; j++) + for (int i = 0; i < 10; i++) + rlist->setItem(i, j, new QTableWidgetItem(tr(rasterStrings[i + j * 10]))); + for (int j = 0; j < 3; j++) + for (int i = 0; i < 8; i++) + qlist->setItem(i, j, new QTableWidgetItem(tr(quantStrings[i + j * 8]))); + + setRaster(r); + setQuant(q); + + addWidget(raster); + addWidget(quant); + + // FIXME: Not working right. + raster->setFixedHeight(38); + quant->setFixedHeight(38); + + //--------------------------------------------------- + // To Menu + //--------------------------------------------------- + + addWidget(new QLabel(tr("To"))); + QComboBox* toList = new QComboBox; + toList->setFixedHeight(22); + toList->insertItem(0, tr("All Events")); + toList->insertItem(CMD_RANGE_LOOP, tr("Looped Ev.")); + toList->insertItem(CMD_RANGE_SELECTED, tr("Selected Ev.")); + toList->insertItem(CMD_RANGE_LOOP | CMD_RANGE_SELECTED, tr("Looped+Sel.")); + addWidget(toList); + + connect(raster, SIGNAL(activated(int)), SLOT(_rasterChanged(int))); + connect(quant, SIGNAL(activated(int)), SLOT(_quantChanged(int))); + //connect(rlist, SIGNAL(cellClicked(int,int)), SLOT(_rasterChanged(int, int))); + //connect(qlist, SIGNAL(cellClicked(int,int)), SLOT(_quantChanged(int,int))); + connect(toList, SIGNAL(activated(int)), SIGNAL(toChanged(int))); + connect(solo, SIGNAL(toggled(bool)), SIGNAL(soloChanged(bool))); + //pos->setEnabled(false); + } + +//--------------------------------------------------------- +// rasterChanged +//--------------------------------------------------------- + +void Toolbar1::_rasterChanged(int /*i*/) +//void Toolbar1::_rasterChanged(int r, int c) + { + emit rasterChanged(rasterTable[rlist->currentRow() + rlist->currentColumn() * 10]); + //emit rasterChanged(rasterTable[r + c * 10]); + } + +//--------------------------------------------------------- +// quantChanged +//--------------------------------------------------------- + +void Toolbar1::_quantChanged(int /*i*/) +//void Toolbar1::_quantChanged(int r, int c) + { + emit quantChanged(quantTable[qlist->currentRow() + qlist->currentColumn() * 8]); + //emit quantChanged(quantTable[r + c * 8]); + } + +//--------------------------------------------------------- +// setPitch +//--------------------------------------------------------- + +void Toolbar1::setPitch(int val) + { + if (pitch && showPitch) { + //pitch->setEnabled(val != -1); //Removed by Andrew there is no need for this as its not a control item + pitch->setPitch(val); + } + } + +void Toolbar1::setInt(int val) + { + if (pitch && showPitch) { + //pitch->setEnabled(val != -1); //Removed by Andrew there is no need for this as its not a control item + pitch->setInt(val); + } + } + +//--------------------------------------------------------- +// setTime +//--------------------------------------------------------- + +void Toolbar1::setTime(unsigned val) + { + if (!pos->isVisible()) { + //printf("NOT visible\n"); + return; + } + if (val != MAXINT) + pos->setValue(val); + //if (val == MAXINT) + // pos->setEnabled(false); + //else { + //pos->setEnabled(true); + //pos->setValue(val); + //} + } + +//--------------------------------------------------------- +// setRaster +//--------------------------------------------------------- + +void Toolbar1::setRaster(int val) + { + for (unsigned i = 0; i < sizeof(rasterTable)/sizeof(*rasterTable); i++) { + if (val == rasterTable[i]) { + raster->setCurrentIndex(i); + return; + } + } + printf("setRaster(%d) not defined\n", val); + raster->setCurrentIndex(0); + } + +//--------------------------------------------------------- +// setQuant +//--------------------------------------------------------- + +void Toolbar1::setQuant(int val) + { + for (unsigned i = 0; i < sizeof(quantTable)/sizeof(*quantTable); i++) { + if (val == quantTable[i]) { + quant->setCurrentIndex(i); + return; + } + } + printf("setQuant(%d) not defined\n", val); + quant->setCurrentIndex(0); + } + +//--------------------------------------------------------- +// setSolo +//--------------------------------------------------------- + +void Toolbar1::setSolo(bool flag) + { + solo->blockSignals(true); + solo->setChecked(flag); + solo->blockSignals(false); + } + +//--------------------------------------------------------- +// setPitchMode +//--------------------------------------------------------- + +void Toolbar1::setPitchMode(bool /*flag*/) + { + // if(pitch) +// pitch->setPitchMode(flag); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/tb1.h b/attic/muse2-oom/muse2/muse/widgets/tb1.h new file mode 100644 index 00000000..fbed13b1 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/tb1.h @@ -0,0 +1,61 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: tb1.h,v 1.2 2004/01/11 18:55:37 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __TB1_H__ +#define __TB1_H__ + +#include <QToolBar> + +class QToolButton; +class QTableWidget; + +class PosLabel; +class PitchLabel; +class Track; +class LabelCombo; + +//--------------------------------------------------------- +// Toolbar1 +//--------------------------------------------------------- + +class Toolbar1 : public QToolBar { + QToolButton* solo; + PosLabel* pos; + PitchLabel* pitch; + LabelCombo* quant; + QTableWidget* qlist; + LabelCombo* raster; + QTableWidget* rlist; + bool showPitch; + Q_OBJECT + + private slots: + void _rasterChanged(int); + void _quantChanged(int); + + public slots: + void setTime(unsigned); + void setPitch(int); + void setInt(int); + void setRaster(int); + void setQuant(int); + + signals: + void rasterChanged(int); + void quantChanged(int); + void soloChanged(bool); + void toChanged(int); + + public: + //Toolbar1(QMainWindow* parent = 0, int r=96, + Toolbar1(QWidget* parent, int r=96, + int q=96, bool showPitch=true); + void setSolo(bool val); + void setPitchMode(bool flag); + }; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/tempolabel.cpp b/attic/muse2-oom/muse2/muse/widgets/tempolabel.cpp new file mode 100644 index 00000000..a26b0b69 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/tempolabel.cpp @@ -0,0 +1,123 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: tempolabel.cpp,v 1.1.1.1 2003/10/27 18:54:29 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QApplication> +#include <QStyle> + +#include "tempolabel.h" + +//--------------------------------------------------------- +// TempoLabel +//--------------------------------------------------------- + +TempoLabel::TempoLabel(QWidget* parent, const char* name) + : QLabel(parent) + { + setObjectName(name); + setFrameStyle(WinPanel | Sunken); + setLineWidth(2); + setMidLineWidth(3); + _value = 1.0; + setValue(0.0); + setIndent(3); + setMinimumSize(sizeHint()); + } + +//--------------------------------------------------------- +// setVal +//--------------------------------------------------------- + +void TempoLabel::setValue(int val) + { + setValue(double(val/1000.0)); + } + +void TempoLabel::setValue(double val) + { + if (val == _value) + return; + _value = val; + QString s = QString("%1").arg(val, 3, 'f', 2); + setText(s); + } + +//--------------------------------------------------------- +// sizeHint +//--------------------------------------------------------- + +QSize TempoLabel::sizeHint() const + { + QFontMetrics fm(font()); + int fw = 4; + int h = fm.height() + fw * 2; + int w = 6 + fm.width(QString("000.00")) + fw * 2; // 6=indent + return QSize(w, h).expandedTo(QApplication::globalStrut()); + } + +//--------------------------------------------------------- +// TempoSpinBox +//--------------------------------------------------------- + +TempoEdit::TempoEdit(QWidget* parent) + : QDoubleSpinBox(parent) + { + curVal = -1.0; + setSingleStep(1.0); + setRange(30.0, 600.0); + connect(this, SIGNAL(valueChanged(double)), SLOT(newValue(double))); + } + +//--------------------------------------------------------- +// sizeHint +//--------------------------------------------------------- + +QSize TempoEdit::sizeHint() const + { + QFontMetrics fm(font()); + int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + int h = fm.height() + fw * 2; + int w = 2 + fm.width(QString("000.00")) + fw * 4 + 30; + return QSize(w, h).expandedTo(QApplication::globalStrut()); + } + +//--------------------------------------------------------- +// tempoChanged +//--------------------------------------------------------- + +void TempoEdit::newValue(double val) + { + if (val != curVal) { + curVal = val; + emit tempoChanged(curVal); + } + } + +//--------------------------------------------------------- +// setValue +//--------------------------------------------------------- + +void TempoEdit::setValue(double val) + { + if (val != curVal) { + curVal = val; + blockSignals(true); + QDoubleSpinBox::setValue(val); + blockSignals(false); + } + } + + +//--------------------------------------------------------- +// tempo +//--------------------------------------------------------- + +//int TempoEdit::tempo() const +// { +// return lrint(60000000.0/value()); +// } + + diff --git a/attic/muse2-oom/muse2/muse/widgets/tempolabel.h b/attic/muse2-oom/muse2/muse/widgets/tempolabel.h new file mode 100644 index 00000000..71aeb4b8 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/tempolabel.h @@ -0,0 +1,61 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: tempolabel.h,v 1.1.1.1 2003/10/27 18:55:05 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __TEMPOLABEL_H__ +#define __TEMPOLABEL_H__ + +#include <QLabel> +#include <QDoubleSpinBox> + +//--------------------------------------------------------- +// TempoLabel +//--------------------------------------------------------- + +class TempoLabel : public QLabel { + double _value; + + Q_OBJECT + + protected: + QSize sizeHint() const; + + public slots: + void setValue(int); + void setValue(double); + + public: + TempoLabel(QWidget*, const char* name = 0); + }; + +//--------------------------------------------------------- +// TempoEdit +//--------------------------------------------------------- + +class TempoEdit : public QDoubleSpinBox { + Q_OBJECT + + double curVal; + + protected: + QSize sizeHint() const; + + private slots: + void newValue(double); + + public slots: + void setValue(double); + + signals: + void tempoChanged(double); + + public: + TempoEdit(QWidget*); + //int tempo() const; + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/tools.cpp b/attic/muse2-oom/muse2/muse/widgets/tools.cpp new file mode 100644 index 00000000..32f42ad9 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/tools.cpp @@ -0,0 +1,142 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: tools.cpp,v 1.2 2004/04/28 21:56:13 spamatica Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> +#include "tools.h" + +#include <QActionGroup> + +#include "icons.h" +#include "action.h" + +const char* infoPointer = QT_TRANSLATE_NOOP("@default", "select Pointer Tool:\n" + "with the pointer tool you can:\n" + " select parts\n" + " move parts\n" + " copy parts"); +const char* infoPencil = QT_TRANSLATE_NOOP("@default", "select Pencil Tool:\n" + "with the pencil tool you can:\n" + " create new parts\n" + " modify length of parts"); +const char* infoDel = QT_TRANSLATE_NOOP("@default", "select Delete Tool:\n" + "with the delete tool you can delete parts"); +const char* infoCut = QT_TRANSLATE_NOOP("@default", "select Cut Tool:\n" + "with the cut tool you can split a part"); +const char* infoGlue = QT_TRANSLATE_NOOP("@default", "select Glue Tool:\n" + "with the glue tool you can glue two parts"); +const char* infoScore = QT_TRANSLATE_NOOP("@default", "select Score Tool:\n"); +const char* infoQuant = QT_TRANSLATE_NOOP("@default", "select Quantize Tool:\n" + "insert display quantize event"); +const char* infoDraw = QT_TRANSLATE_NOOP("@default", "select Drawing Tool"); +const char* infoMute = QT_TRANSLATE_NOOP("@default", "select Muting Tool:\n" + "click on part to mute/unmute"); + +ToolB toolList[] = { + {&pointerIcon, QT_TRANSLATE_NOOP("@default", "pointer"), infoPointer }, + {&pencilIcon, QT_TRANSLATE_NOOP("@default", "pencil"), infoPencil }, + {&deleteIcon, QT_TRANSLATE_NOOP("@default", "eraser"), infoDel }, + {&cutIcon, QT_TRANSLATE_NOOP("@default", "cutter"), infoCut }, + {¬e1Icon, QT_TRANSLATE_NOOP("@default", "score"), infoScore }, + {&glueIcon, QT_TRANSLATE_NOOP("@default", "glue"), infoGlue }, + {&quantIcon, QT_TRANSLATE_NOOP("@default", "quantize"), infoQuant }, + {&drawIcon, QT_TRANSLATE_NOOP("@default", "draw"), infoDraw }, + {&editmuteIcon, QT_TRANSLATE_NOOP("@default", "mute parts"), infoMute }, + }; + +//--------------------------------------------------------- +// EditToolBar +//--------------------------------------------------------- + +//EditToolBar::EditToolBar(QMainWindow* parent, int tools, const char*) +EditToolBar::EditToolBar(QWidget* parent, int tools, const char*) + : QToolBar(tr("Edit Tools"), parent) + { + QActionGroup* action = new QActionGroup(parent); // Parent needed. + action->setExclusive(true); + + nactions = 0; + for (unsigned i = 0; i < sizeof(toolList)/sizeof(*toolList); ++i) { + if ((tools & (1 << i))==0) + continue; + ++nactions; + } + actions = new Action*[nactions]; + bool first = true; + int n = 0; + for (unsigned i = 0; i < sizeof(toolList)/sizeof(*toolList); ++i) { + if ((tools & (1 << i))==0) + continue; + ToolB* t = &toolList[i]; + + Action* a = new Action(action, 1<<i, t->tip, true); + actions[n] = a; + //a->setIconSet(QIcon(**(t->icon))); + a->setIcon(QIcon(**(t->icon))); + a->setToolTip(tr(t->tip)); + a->setWhatsThis(tr(t->ltip)); + if (first) { + a->setChecked(true); + first = false; + } + ++n; + } + action->setVisible(true); + //action->addTo(this); + // Note: Does not take ownership. + addActions(action->actions()); + + connect(action, SIGNAL(selected(QAction*)), SLOT(toolChanged(QAction*))); + } + +//--------------------------------------------------------- +// toolChanged +//--------------------------------------------------------- + +void EditToolBar::toolChanged(QAction* action) + { + emit toolChanged(((Action*)action)->id()); + } + +//--------------------------------------------------------- +// ~EditToolBar +//--------------------------------------------------------- + +EditToolBar::~EditToolBar() + { + delete actions; + } + +//--------------------------------------------------------- +// set +//--------------------------------------------------------- + +void EditToolBar::set(int id) + { + for (int i = 0; i < nactions; ++i) { + Action* action = actions[i]; + if (action->id() == id) { + action->setChecked(true); + toolChanged(action); + return; + } + } + } + +//--------------------------------------------------------- +// curTool +//--------------------------------------------------------- + +int EditToolBar::curTool() + { + for (int i = 0; i < nactions; ++i) { + Action* action = actions[i]; + if (action->isChecked()) + return action->id(); + } + return -1; + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/tools.h b/attic/muse2-oom/muse2/muse/widgets/tools.h new file mode 100644 index 00000000..7cc5e62c --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/tools.h @@ -0,0 +1,58 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: tools.h,v 1.1.1.1 2003/10/27 18:54:49 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __TOOLS_H__ +#define __TOOLS_H__ + +#include <QToolBar> + +class Action; + +class QAction; +class QPixmap; +class QWidget; + +enum Tool { PointerTool=1, PencilTool=2, RubberTool=4, CutTool=8, + ScoreTool=16, GlueTool=32, QuantTool=64, DrawTool=128, MuteTool=256}; + +const int arrangerTools = PointerTool | PencilTool | RubberTool | CutTool | GlueTool | MuteTool; + +struct ToolB { + QPixmap** icon; + const char* tip; + const char* ltip; + }; + +extern ToolB toolList[]; + +//--------------------------------------------------------- +// EditToolBar +//--------------------------------------------------------- + +class EditToolBar : public QToolBar { + Q_OBJECT + Action** actions; + int nactions; + + private slots: + void toolChanged(QAction* action); + + signals: + void toolChanged(int); + + public slots: + void set(int id); + + public: + //EditToolBar(QMainWindow*, int, const char* name = 0); + EditToolBar(QWidget* /*parent*/, int /*tools*/, const char* name = 0); // Needs a parent ! + ~EditToolBar(); + int curTool(); + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/trackvieweditorbase.ui b/attic/muse2-oom/muse2/muse/widgets/trackvieweditorbase.ui new file mode 100644 index 00000000..0d04f461 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/trackvieweditorbase.ui @@ -0,0 +1,282 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <author>Andrew Williams</author> + <class>TrackViewEditorBase</class> + <widget class="QDialog" name="TrackViewEditorBase"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>754</width> + <height>550</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>MusE: Track View</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <property name="modal"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>12</number> + </property> + <item> + <layout class="QHBoxLayout" name="groupLayout"> + <item> + <widget class="QLabel" name="lblGroup"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>32</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Views:</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="cmbViews"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>80</width> + <height>32</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="nameLayout"> + <item> + <widget class="QLabel" name="lblName"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>32</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>63</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Name:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="txtName"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>32</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="typeLayout"> + <item> + <widget class="QLabel" name="lblType"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>32</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Type:</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="cmbType"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>80</width> + <height>32</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="listLayout"> + <item> + <widget class="QListView" name="listAllTracks"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="horizontalScrollBarPolicy"> + <enum>Qt::ScrollBarAsNeeded</enum> + </property> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="selectionMode"> + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="actionBox"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::No|QDialogButtonBox::Yes</set> + </property> + <property name="centerButtons"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QListView" name="listSelectedTracks"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="horizontalScrollBarPolicy"> + <enum>Qt::ScrollBarAsNeeded</enum> + </property> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="selectionMode"> + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="9"/> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>TrackViewEditorBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>TrackViewEditorBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> + <designerdata> + <property name="gridDeltaX"> + <number>10</number> + </property> + <property name="gridDeltaY"> + <number>10</number> + </property> + <property name="gridSnapX"> + <bool>true</bool> + </property> + <property name="gridSnapY"> + <bool>true</bool> + </property> + <property name="gridVisible"> + <bool>true</bool> + </property> + </designerdata> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/transformbase.ui b/attic/muse2-oom/muse2/muse/widgets/transformbase.ui new file mode 100644 index 00000000..578b4a97 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/transformbase.ui @@ -0,0 +1,1068 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MidiTransformDialogBase</class> + <widget class="QDialog" name="MidiTransformDialogBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>826</width> + <height>545</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Midi Transformator</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="3" column="0" colspan="2"> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QPushButton" name="buttonNew"> + <property name="text"> + <string>&New</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonDelete"> + <property name="text"> + <string>&Delete</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="Horizontal Spacing2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonApply"> + <property name="text"> + <string>&Apply</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonOk"> + <property name="text"> + <string>&OK</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonCancel"> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="0" rowspan="3"> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="TextLabel1_2"> + <property name="text"> + <string>PresetList</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QListWidget" name="presetList"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="1"> + <widget class="QGroupBox" name="GroupBox5"> + <property name="title"> + <string>Processing</string> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel5"> + <property name="text"> + <string>Event Type</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QComboBox" name="procEventOp"> + <item> + <property name="text"> + <string>Keep</string> + </property> + </item> + <item> + <property name="text"> + <string>Fix</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0"> + <widget class="QComboBox" name="procType"> + <property name="enabled"> + <bool>false</bool> + </property> + <item> + <property name="text"> + <string>Note</string> + </property> + </item> + <item> + <property name="text"> + <string>Poly Pressure</string> + </property> + </item> + <item> + <property name="text"> + <string>Control Change</string> + </property> + </item> + <item> + <property name="text"> + <string>Aftertouch</string> + </property> + </item> + <item> + <property name="text"> + <string>Pitch Bend</string> + </property> + </item> + <item> + <property name="text"> + <string>NRPN</string> + </property> + </item> + <item> + <property name="text"> + <string>RPN</string> + </property> + </item> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="procVal1Op"> + <item> + <property name="text"> + <string>Keep</string> + </property> + </item> + <item> + <property name="text"> + <string>Plus</string> + </property> + </item> + <item> + <property name="text"> + <string>Minus</string> + </property> + </item> + <item> + <property name="text"> + <string>Multiply</string> + </property> + </item> + <item> + <property name="text"> + <string>Divide</string> + </property> + </item> + <item> + <property name="text"> + <string>Fix</string> + </property> + </item> + <item> + <property name="text"> + <string>Value 2</string> + </property> + </item> + <item> + <property name="text"> + <string>Invert</string> + </property> + </item> + <item> + <property name="text"> + <string>ScaleMap</string> + </property> + </item> + <item> + <property name="text"> + <string>Flip</string> + </property> + </item> + <item> + <property name="text"> + <string>Dyn</string> + </property> + </item> + <item> + <property name="text"> + <string>Random</string> + </property> + </item> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="TextLabel6"> + <property name="text"> + <string>Value 1</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="TextLabel7"> + <property name="text"> + <string>Value 2</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QLabel" name="TextLabel10_2"> + <property name="text"> + <string>Length</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="QLabel" name="TextLabel12"> + <property name="text"> + <string>Position</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QComboBox" name="procVal2Op"> + <item> + <property name="text"> + <string>Keep</string> + </property> + </item> + <item> + <property name="text"> + <string>Plus</string> + </property> + </item> + <item> + <property name="text"> + <string>Minus</string> + </property> + </item> + <item> + <property name="text"> + <string>Multiply</string> + </property> + </item> + <item> + <property name="text"> + <string>Divide</string> + </property> + </item> + <item> + <property name="text"> + <string>Fix</string> + </property> + </item> + <item> + <property name="text"> + <string>Value 1</string> + </property> + </item> + <item> + <property name="text"> + <string>Invert</string> + </property> + </item> + <item> + <property name="text"> + <string>Dyn</string> + </property> + </item> + <item> + <property name="text"> + <string>Random</string> + </property> + </item> + </widget> + </item> + <item row="1" column="3"> + <widget class="QComboBox" name="procLenOp"> + <item> + <property name="text"> + <string>Keep</string> + </property> + </item> + <item> + <property name="text"> + <string>Plus</string> + </property> + </item> + <item> + <property name="text"> + <string>Minus</string> + </property> + </item> + <item> + <property name="text"> + <string>Multiply</string> + </property> + </item> + <item> + <property name="text"> + <string>Divide</string> + </property> + </item> + <item> + <property name="text"> + <string>Fix</string> + </property> + </item> + </widget> + </item> + <item row="3" column="1"> + <widget class="QSpinBox" name="procVal1b"> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QSpinBox" name="procVal2b"> + <property name="maximum"> + <number>9999</number> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="SpinBoxFP" name="procVal1a"> + <property name="maximum" stdset="0"> + <number>99999999</number> + </property> + </widget> + </item> + <item row="1" column="4"> + <widget class="QComboBox" name="procPosOp"> + <item> + <property name="text"> + <string>Keep</string> + </property> + </item> + <item> + <property name="text"> + <string>Plus</string> + </property> + </item> + <item> + <property name="text"> + <string>Minus</string> + </property> + </item> + <item> + <property name="text"> + <string>Multiply</string> + </property> + </item> + <item> + <property name="text"> + <string>Divide</string> + </property> + </item> + </widget> + </item> + <item row="2" column="2"> + <widget class="SpinBoxFP" name="procVal2a"> + <property name="maximum" stdset="0"> + <number>99999999</number> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="SpinBoxFP" name="procLenA"> + <property name="maximum" stdset="0"> + <number>99999999</number> + </property> + </widget> + </item> + <item row="2" column="4"> + <widget class="SpinBoxFP" name="procPosA"> + <property name="maximum" stdset="0"> + <number>99999999</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="1"> + <widget class="QGroupBox" name="GroupBox3"> + <property name="title"> + <string>Filter</string> + </property> + <layout class="QGridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="1" column="0"> + <widget class="QComboBox" name="selEventOp"> + <item> + <property name="text"> + <string>All</string> + </property> + </item> + <item> + <property name="text"> + <string>Equal</string> + </property> + </item> + <item> + <property name="text"> + <string>Unequal</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0"> + <widget class="QComboBox" name="selType"> + <property name="enabled"> + <bool>false</bool> + </property> + <item> + <property name="text"> + <string>Note</string> + </property> + </item> + <item> + <property name="text"> + <string>Poly Pressure</string> + </property> + </item> + <item> + <property name="text"> + <string>Control Change</string> + </property> + </item> + <item> + <property name="text"> + <string>Aftertouch</string> + </property> + </item> + <item> + <property name="text"> + <string>Pitch Bend</string> + </property> + </item> + <item> + <property name="text"> + <string>NRPN</string> + </property> + </item> + <item> + <property name="text"> + <string>RPN</string> + </property> + </item> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="TextLabel3"> + <property name="text"> + <string>Value 2</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="TextLabel2"> + <property name="text"> + <string>Value 1</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> + <string>Event Type</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="selVal1Op"> + <item> + <property name="text"> + <string>Ignore</string> + </property> + </item> + <item> + <property name="text"> + <string>Equal</string> + </property> + </item> + <item> + <property name="text"> + <string>Unequal</string> + </property> + </item> + <item> + <property name="text"> + <string>Higher</string> + </property> + </item> + <item> + <property name="text"> + <string>Lower</string> + </property> + </item> + <item> + <property name="text"> + <string>Inside</string> + </property> + </item> + <item> + <property name="text"> + <string>Outside</string> + </property> + </item> + </widget> + </item> + <item row="0" column="3"> + <widget class="QLabel" name="TextLabel10"> + <property name="text"> + <string>Length</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="QLabel" name="TextLabel11"> + <property name="text"> + <string>Bar Range</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QComboBox" name="selVal2Op"> + <item> + <property name="text"> + <string>Ignore</string> + </property> + </item> + <item> + <property name="text"> + <string>Equal</string> + </property> + </item> + <item> + <property name="text"> + <string>Unequal</string> + </property> + </item> + <item> + <property name="text"> + <string>Higher</string> + </property> + </item> + <item> + <property name="text"> + <string>Lower</string> + </property> + </item> + <item> + <property name="text"> + <string>Inside</string> + </property> + </item> + <item> + <property name="text"> + <string>Outside</string> + </property> + </item> + </widget> + </item> + <item row="1" column="3"> + <widget class="QComboBox" name="selLenOp"> + <item> + <property name="text"> + <string>Ignore</string> + </property> + </item> + <item> + <property name="text"> + <string>Equal</string> + </property> + </item> + <item> + <property name="text"> + <string>Unequal</string> + </property> + </item> + <item> + <property name="text"> + <string>Higher</string> + </property> + </item> + <item> + <property name="text"> + <string>Lower</string> + </property> + </item> + <item> + <property name="text"> + <string>Inside</string> + </property> + </item> + <item> + <property name="text"> + <string>Outside</string> + </property> + </item> + </widget> + </item> + <item row="1" column="4"> + <widget class="QComboBox" name="selRangeOp"> + <item> + <property name="text"> + <string>Ignore</string> + </property> + </item> + <item> + <property name="text"> + <string>Equal</string> + </property> + </item> + <item> + <property name="text"> + <string>Unequal</string> + </property> + </item> + <item> + <property name="text"> + <string>Higher</string> + </property> + </item> + <item> + <property name="text"> + <string>Lower</string> + </property> + </item> + <item> + <property name="text"> + <string>Inside</string> + </property> + </item> + <item> + <property name="text"> + <string>Outside</string> + </property> + </item> + </widget> + </item> + <item row="3" column="1"> + <widget class="QSpinBox" name="selVal1b"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QSpinBox" name="selLenA"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QSpinBox" name="selLenB"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QSpinBox" name="selVal2a"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QSpinBox" name="selVal2b"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QSpinBox" name="selVal1a"> + <property name="maximum"> + <number>127</number> + </property> + </widget> + </item> + <item row="3" column="4"> + <widget class="SpinBoxFP" name="selBarB"> + <property name="decimals" stdset="0"> + <number>3</number> + </property> + </widget> + </item> + <item row="2" column="4"> + <widget class="SpinBoxFP" name="selBarA"> + <property name="minimum" stdset="0"> + <number>1000</number> + </property> + <property name="decimals" stdset="0"> + <number>3</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="1"> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QGroupBox" name="GroupBox6_2"> + <property name="title"> + <string>Preset</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="TextLabel13_2"> + <property name="text"> + <string>Name:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="nameEntry"/> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="TextLabel14_2"> + <property name="text"> + <string>Comment:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QTextEdit" name="commentEntry"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="GroupBox5_2"> + <property name="title"> + <string>Range</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QCheckBox" name="processAll"> + <property name="text"> + <string>process all events</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="selectedTracks"> + <property name="text"> + <string>selected tracks</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="insideLoop"> + <property name="text"> + <string>inside loop</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="GroupBox7_2"> + <property name="title"> + <string>Function</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QComboBox" name="funcOp"> + <item> + <property name="text"> + <string>Select</string> + </property> + </item> + <item> + <property name="text"> + <string>Quantize</string> + </property> + </item> + <item> + <property name="text"> + <string>Delete</string> + </property> + </item> + <item> + <property name="text"> + <string>Transform</string> + </property> + </item> + <item> + <property name="text"> + <string>Insert</string> + </property> + </item> + <item> + <property name="text"> + <string>Copy</string> + </property> + </item> + <item> + <property name="text"> + <string>Extract</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel9_2"> + <property name="text"> + <string>Quantize Value</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="ComboQuant" name="funcQuantVal" native="true"/> + </item> + </layout> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <customwidgets> + <customwidget> + <class>SpinBoxFP</class> + <extends>QDoubleSpinBox</extends> + <header>spinboxFP.h</header> + </customwidget> + <customwidget> + <class>ComboQuant</class> + <extends>QComboBox</extends> + <header>comboQuant.h</header> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>selEventOp</tabstop> + <tabstop>selType</tabstop> + <tabstop>selVal1Op</tabstop> + <tabstop>selVal1a</tabstop> + <tabstop>selVal1b</tabstop> + <tabstop>selVal2Op</tabstop> + <tabstop>selVal2a</tabstop> + <tabstop>selVal2b</tabstop> + <tabstop>selLenOp</tabstop> + <tabstop>selLenA</tabstop> + <tabstop>selLenB</tabstop> + <tabstop>selRangeOp</tabstop> + <tabstop>procEventOp</tabstop> + <tabstop>procType</tabstop> + <tabstop>procVal1Op</tabstop> + <tabstop>procVal1b</tabstop> + <tabstop>procVal2Op</tabstop> + <tabstop>procVal2b</tabstop> + <tabstop>procLenOp</tabstop> + <tabstop>procPosOp</tabstop> + <tabstop>nameEntry</tabstop> + <tabstop>commentEntry</tabstop> + <tabstop>processAll</tabstop> + <tabstop>selectedTracks</tabstop> + <tabstop>insideLoop</tabstop> + <tabstop>funcOp</tabstop> + <tabstop>presetList</tabstop> + <tabstop>buttonNew</tabstop> + <tabstop>buttonDelete</tabstop> + <tabstop>buttonApply</tabstop> + <tabstop>buttonOk</tabstop> + <tabstop>buttonCancel</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>MidiTransformDialogBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>MidiTransformDialogBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/transposebase.ui b/attic/muse2-oom/muse2/muse/widgets/transposebase.ui new file mode 100644 index 00000000..63ac74a6 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/transposebase.ui @@ -0,0 +1,228 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>TransposeDialogBase</class> + <widget class="QDialog" name="TransposeDialogBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>289</width> + <height>340</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Midi Transpose</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QGroupBox" name="GroupBox1"> + <property name="title"> + <string>Value</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="delta"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimum"> + <number>-99</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>halftones</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="ButtonBox1"> + <property name="title"> + <string>Time</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QRadioButton" name="time_all"> + <property name="text"> + <string>all</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="time_selected"> + <property name="text"> + <string>between markers</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="ButtonBox2"> + <property name="title"> + <string>Parts</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QRadioButton" name="parts_all"> + <property name="text"> + <string>all</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="parts_selected"> + <property name="windowTitle"> + <string/> + </property> + <property name="text"> + <string>all in selected tracks</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <spacer name="Spacer1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="okButton"> + <property name="text"> + <string>OK</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton"> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections> + <connection> + <sender>okButton</sender> + <signal>clicked()</signal> + <receiver>TransposeDialogBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>cancelButton</sender> + <signal>clicked()</signal> + <receiver>TransposeDialogBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/ttoolbar.cpp b/attic/muse2-oom/muse2/muse/widgets/ttoolbar.cpp new file mode 100644 index 00000000..774cb34d --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/ttoolbar.cpp @@ -0,0 +1,24 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: ttoolbar.cpp,v 1.1.1.1 2003/10/27 18:54:46 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QAction> +#include "globals.h" + +//--------------------------------------------------------- +// syncChanged +//--------------------------------------------------------- + +void syncChanged(bool flag) + { + startAction->setEnabled(!flag); + forwardAction->setEnabled(!flag); + rewindAction->setEnabled(!flag); + stopAction->setEnabled(!flag); + playAction->setEnabled(!flag); + } + + diff --git a/attic/muse2-oom/muse2/muse/widgets/ttoolbar.h b/attic/muse2-oom/muse2/muse/widgets/ttoolbar.h new file mode 100644 index 00000000..b7d34b2d --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/ttoolbar.h @@ -0,0 +1,9 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: ttoolbar.h,v 1.1.1.1 2003/10/27 18:54:52 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +extern void syncChanged(bool flag); + diff --git a/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.cpp b/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.cpp new file mode 100644 index 00000000..324b5fca --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.cpp @@ -0,0 +1,29 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: ttoolbutton.cpp,v 1.1 2004/02/21 16:53:50 wschweer Exp $ +// (C) Copyright 2004 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QPainter> +#include <QStyle> + +#include "ttoolbutton.h" +#include "gconfig.h" +#include "icons.h" + +//--------------------------------------------------------- +// drawButton +//--------------------------------------------------------- + +void TransparentToolButton::drawButton(QPainter* p) + { + int w = width(); + int h = height(); + QIcon::Mode mode = isEnabled() ? QIcon::Normal : QIcon::Disabled; + QIcon::State state = isChecked() ? QIcon::On : QIcon::Off; + const QPixmap pm(icon().pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize), mode, state)); + p->drawPixmap(QPoint((w - pm.width())/2, (h - pm.height())/2), pm); + } + + diff --git a/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.h b/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.h new file mode 100644 index 00000000..b4c54401 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.h @@ -0,0 +1,28 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: ttoolbutton.h,v 1.1 2004/02/21 16:53:51 wschweer Exp $ +// (C) Copyright 2004 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __TTOOLBUTTON_H__ +#define __TTOOLBUTTON_H__ + +#include <QToolButton> + +//--------------------------------------------------------- +// TransparentToolButton +//--------------------------------------------------------- + +class TransparentToolButton : public QToolButton { + Q_OBJECT + + virtual void drawButton(QPainter*); + + public: + TransparentToolButton(QWidget* parent, const char* name = 0) + : QToolButton(parent) {setObjectName(name);} + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/tvieweditor.cpp b/attic/muse2-oom/muse2/muse/widgets/tvieweditor.cpp new file mode 100644 index 00000000..583eae57 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/tvieweditor.cpp @@ -0,0 +1,196 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: $ +// +// (C) Copyright 2010 Andrew Williams and Christopher Cherrett +//========================================================= + + +#include <QMessageBox> +#include <QDialog> +#include <QStringListModel> +#include <QPushButton> +#include <QItemSelectionModel> +#include <QModelIndexList> +#include <QModelIndex> + +#include <math.h> +#include <string.h> +#include "tvieweditor.h" +#include "song.h" +#include "globals.h" +#include "config.h" +#include "gconfig.h" +#include "utils.h" +#include "audio.h" +#include "midi.h" +#include "icons.h" +#include "app.h" +#include "popupmenu.h" +#include "track.h" +#include "trackview.h" +#include "synth.h" + +TrackViewEditor::TrackViewEditor(QWidget* parent, TrackViewList* vl) : QDialog(parent) +{ + setupUi(this); + _allTracks = song->tracks(); + _viewList = vl; + //MIDI=0, DRUM, WAVE, AUDIO_OUTPUT, AUDIO_INPUT, AUDIO_GROUP,AUDIO_AUX + _trackTypes = (QStringList() << "Audio_Out" << "Audio_In" << "Audio_Aux" << "Audio_Group" << "Midi" << "Soft_Synth"); //new QStringList(); + //Populate trackTypes and pass it to cmbTypes + cmbType->addItems(_trackTypes); + QStringList stracks; + for(ciTrack t = _allTracks->begin(); t != _allTracks->end(); ++t) + { + _tracks.push_back((*t)); + switch((*t)->type()) {/*{{{*/ + case Track::MIDI: + case Track::DRUM: + _midis.push_back((MidiTrack*)(*t)); + break; + case Track::WAVE: + _waves.push_back((WaveTrack*)(*t)); + break; + case Track::AUDIO_OUTPUT: + _outputs.push_back((AudioOutput*)(*t)); + stracks << (*t)->name(); + break; + case Track::AUDIO_GROUP: + _groups.push_back((AudioGroup*)(*t)); + break; + case Track::AUDIO_AUX: + _auxs.push_back((AudioAux*)(*t)); + break; + case Track::AUDIO_INPUT: + _inputs.push_back((AudioInput*)(*t)); + break; + case Track::AUDIO_SOFTSYNTH: + SynthI* s = (SynthI*)(*t); + _synthIs.push_back(s); + break; + }/*}}}*/ + } + listAllTracks->setModel(new QStringListModel(stracks)); + btnAdd = actionBox->button(QDialogButtonBox::Yes); + btnAdd->setText(tr("Add Track")); + connect(btnAdd, SIGNAL(clicked(bool)), SLOT(btnAddTrack(bool))); + btnRemove = actionBox->button(QDialogButtonBox::No); + btnRemove->setText(tr("Remove Track")); + btnRemove->setFocusPolicy(btnAdd->focusPolicy()); + connect(btnRemove, SIGNAL(clicked(bool)), SLOT(btnRemoveTrack(bool))); + + connect(cmbViews, SIGNAL(currentIndexChanged(QString&)), SLOT(cmbViewSelected(QString&))); + connect(cmbType, SIGNAL(currentIndexChanged(int)), SLOT(cmbTypeSelected(int))); +} + + +//---------------------------------------------- +// Slots +//---------------------------------------------- +void TrackViewEditor::cmbViewSelected(QString& sl) +{ + //Perform actions to populate list below based on selected view +} + +void TrackViewEditor::cmbTypeSelected(int type) +{ + //Perform actions to populate list below based on selected type + //We need to repopulate and filter the allTrackList + //"Audio_Out" "Audio_In" "Audio_Aux" "Audio_Group" "Midi" "Soft_Synth" + QStringList stracks; + switch(type) {/*{{{*/ + case 0: + for(ciTrack t = _outputs.begin(); t != _outputs.end(); ++t) + { + //This should be checked against track in other views + stracks << (*t)->name(); + } + case 1: + for(ciTrack t = _inputs.begin(); t != _inputs.end(); ++t) + { + //This should be checked against track in other views + stracks << (*t)->name(); + } + break; + case 2: + for(ciTrack t = _auxs.begin(); t != _auxs.end(); ++t) + { + //This should be checked against track in other views + stracks << (*t)->name(); + } + break; + case 3: + for(ciTrack t = _groups.begin(); t != _groups.end(); ++t) + { + //This should be checked against track in other views + stracks << (*t)->name(); + } + break; + case 4: + for(ciTrack t = _midis.begin(); t != _midis.end(); ++t) + { + //This should be checked against track in other views + stracks << (*t)->name(); + } + break; + case 5: + for(ciTrack t = _synthIs.begin(); t != _synthIs.end(); ++t) + { + //This should be checked against track in other views + stracks << (*t)->name(); + } + break; + }/*}}}*/ + listAllTracks->setModel(new QStringListModel(stracks)); +} + +void TrackViewEditor::btnAddTrack(bool state) +{ + //Perform actions to add action to right list and remove from left + printf("Add button clicked\n"); + QItemSelectionModel* model = listAllTracks->selectionModel(); + if(model->hasSelection()) + { + QModelIndexList sel = model->selectedRows(0); + QList<QModelIndex>::const_iterator id; + for (id = sel.constBegin(); id != sel.constEnd(); ++id) + //for(QModelIndex* id = sel.begin(); id != sel.end(); ++id) + { + //We have to index we will get the row. + int row = (*id).row(); + /*QStringListModel* m = */QAbstractItemModel* m = listAllTracks->model(); + QVariant v = m->data((*id)); + QString val = v.toString(); + Track* trk = song->findTrack(val); + if(trk) + printf("Adding Track from row: %d\n", row); + //printf("Found Track %s at index %d with type %d\n", val, row, trk->type()); + } + } +} + +void TrackViewEditor::btnRemoveTrack(bool state) +{ + //Perform action to remove track from the selectedTracks list + printf("Remove button clicked\n"); +} + +void TrackViewEditor::setSelectedTracks(TrackList* t) +{ + _selected = t; + //Call methods to update the display +} + +void TrackViewEditor::setTypes(QStringList t) +{ + _trackTypes = t; + //Call methods to update the display +} + +void TrackViewEditor::setViews(TrackViewList* l) +{ + _viewList = l; + //Call methods to update the display +} diff --git a/attic/muse2-oom/muse2/muse/widgets/tvieweditor.h b/attic/muse2-oom/muse2/muse/widgets/tvieweditor.h new file mode 100644 index 00000000..e9835fbd --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/tvieweditor.h @@ -0,0 +1,67 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: $ +// +// (C) Copyright 2010 Andrew Williams and Christopher Cherrett +//========================================================= + +#ifndef __TRACKVIEWEDITOR_H__ +#define __TRACKVIEWEDITOR_H__ + +#include "ui_trackvieweditorbase.h" +#include <QList> +#include <QObject> +#include "trackview.h" +#include "track.h" + +class TrackView; +class Track; +class QDialog; +class QPushButton; + +class TrackViewEditor : public QDialog, public Ui::TrackViewEditorBase +{ + Q_OBJECT + TrackList* _allTracks; + TrackViewList* _viewList; + TrackList* _selected; + TrackList _tracks; // tracklist as seen by arranger + MidiTrackList _midis; + WaveTrackList _waves; + InputList _inputs; // audio input ports + OutputList _outputs; // audio output ports + GroupList _groups; // mixer groups + AuxList _auxs; // aux sends + SynthIList _synthIs; + + QStringList _trackTypes; + QPushButton* btnAdd; + QPushButton* btnRemove; + + private slots: + void cmbViewSelected(QString&); + void cmbTypeSelected(int); + void btnAddTrack(bool); + void btnRemoveTrack(bool); + + public: + TrackViewEditor(QWidget*, TrackViewList* = 0); + void setSelectedTracks(TrackList*); + TrackList* selectedTracks( ) { return _selected; } + void setTypes(QStringList); + void setViews(TrackViewList*); + QStringList trackTypes(){return _trackTypes;} + TrackViewList* views(){return _viewList;} + + TrackList* tracks() { return &_tracks; } + MidiTrackList* midis() { return &_midis; } + WaveTrackList* waves() { return &_waves; } + InputList* inputs() { return &_inputs; } + OutputList* outputs() { return &_outputs; } + GroupList* groups() { return &_groups; } + AuxList* auxs() { return &_auxs; } + SynthIList* syntis() { return &_synthIs; } +}; + +#endif diff --git a/attic/muse2-oom/muse2/muse/widgets/utils.cpp b/attic/muse2-oom/muse2/muse/widgets/utils.cpp new file mode 100644 index 00000000..1bf4ca64 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/utils.cpp @@ -0,0 +1,356 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: utils.cpp,v 1.1.1.1.2.3 2009/11/14 03:37:48 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <sys/time.h> + +#include <QFrame> + +#include "utils.h" + +//--------------------------------------------------------- +// curTime +//--------------------------------------------------------- + +double curTime() + { + struct timeval t; + gettimeofday(&t, 0); + return (double)((double)t.tv_sec + (t.tv_usec / 1000000.0)); + } + +//--------------------------------------------------------- +// dump +// simple debug output +//--------------------------------------------------------- + +void dump(const unsigned char* p, int n) + { + printf("dump %d\n", n); + for (int i = 0; i < n; ++i) { + printf("%02x ", *p++); + if ((i > 0) && (i % 16 == 0) && (i+1 < n)) + printf("\n"); + } + printf("\n"); + } + +//--------------------------------------------------------- +// num2cols +//--------------------------------------------------------- + +int num2cols(int min, int max) + { + int amin = abs(min); + int amax = abs(max); + int l = amin > amax ? amin : amax; + return int(log10(l)) + 1; + } + +//--------------------------------------------------------- +// hLine +//--------------------------------------------------------- + +QFrame* hLine(QWidget* w) + { + QFrame* delim = new QFrame(w); + delim->setFrameStyle(QFrame::HLine | QFrame::Sunken); + return delim; + } + +//--------------------------------------------------------- +// vLine +//--------------------------------------------------------- + +QFrame* vLine(QWidget* w) + { + QFrame* delim = new QFrame(w); + delim->setFrameStyle(QFrame::VLine | QFrame::Sunken); + return delim; + } + +//--------------------------------------------------------- +// bitmap2String +// 5c -> 1-4 1-6 +// +// 01011100 +// +//--------------------------------------------------------- + +QString bitmap2String(int bm) + { + QString s; +//printf("bitmap2string: bm %04x", bm); + if (bm == 0xffff) + s = "all"; + else if (bm == 0) + s = "none"; + else { + bool range = false; + int first = 0; + bool needSpace = false; + bm &= 0xffff; + for (int i = 0; i < 17; ++i) { + //for (int i = 0; i < 16; ++i) { + if ((1 << i) & bm) { + if (!range) { + range = true; + first = i; + } + } + else { + if (range) { + if (needSpace) + s += " "; + QString ns; + if (first == i-1) + ns.sprintf("%d", first+1); + else + ns.sprintf("%d-%d", first+1, i); + s += ns; + needSpace = true; + } + range = false; + } + } + } +//printf(" -> <%s>\n", s.toLatin1()); + return s; + } + +//--------------------------------------------------------- +// u32bitmap2String +//--------------------------------------------------------- +// Added by Tim. p3.3.8 + +QString u32bitmap2String(unsigned int bm) + { + QString s; +//printf("bitmap2string: bm %04x", bm); + //if (bm == 0xffff) + if (bm == 0xffffffff) + s = "all"; + else if (bm == 0) + s = "none"; + else { + bool range = false; + int first = 0; + //unsigned int first = 0; + bool needSpace = false; + //bm &= 0xffff; + //for (int i = 0; i < 17; ++i) { + for (int i = 0; i < 33; ++i) { + if ((i < 32) && ((1U << i) & bm)) { + if (!range) { + range = true; + first = i; + } + } + else { + if (range) { + if (needSpace) + s += " "; + QString ns; + if (first == i-1) + ns.sprintf("%d", first+1); + //ns.sprintf("%u", first+1); + else + ns.sprintf("%d-%d", first+1, i); + //ns.sprintf("%u-%u", first+1, i); + s += ns; + needSpace = true; + } + range = false; + } + } + } +//printf(" -> <%s>\n", s.toLatin1()); + return s; + } + +//--------------------------------------------------------- +// string2bitmap +//--------------------------------------------------------- + +int string2bitmap(const QString& str) + { + int val = 0; + QString ss = str.simplified(); + QByteArray ba = ss.toLatin1(); + const char* s = ba.constData(); +//printf("string2bitmap <%s>\n", s); + + if (s == 0) + return 0; + if (strcmp(s, "all") == 0) + return 0xffff; + if (strcmp(s, "none") == 0) + return 0; +// printf("str2bitmap: <%s> ", str.toLatin1); + int tval = 0; + bool range = false; + int sval = 0; + while (*s == ' ') + ++s; + while (*s) { + if (*s >= '0' && *s <= '9') { + tval *= 10; + tval += *s - '0'; + } + else if (*s == ' ' || *s == ',') { + if (range) { + for (int i = sval-1; i < tval; ++i) + val |= (1 << i); + range = false; + } + else { + val |= (1 << (tval-1)); + } + tval = 0; + } + else if (*s == '-') { + range = true; + sval = tval; + tval = 0; + } + ++s; + } + if (range && tval) { + for (int i = sval-1; i < tval; ++i) + val |= (1 << i); + } + else if (tval) { + val |= (1 << (tval-1)); + } + return val & 0xffff; + } + +//--------------------------------------------------------- +// string2u32bitmap +//--------------------------------------------------------- +// Added by Tim. p3.3.8 + +unsigned int string2u32bitmap(const QString& str) + { + //int val = 0; + unsigned int val = 0; + QString ss = str.simplified(); + QByteArray ba = ss.toLatin1(); + const char* s = ba.constData(); +//printf("string2bitmap <%s>\n", s); + + if (s == 0) + return 0; + if (strcmp(s, "all") == 0) + //return 0xffff; + return 0xffffffff; + if (strcmp(s, "none") == 0) + return 0; +// printf("str2bitmap: <%s> ", str.toLatin1); + int tval = 0; + //unsigned int tval = 0; + bool range = false; + int sval = 0; + //unsigned int sval = 0; + while (*s == ' ') + ++s; + while (*s) { + if (*s >= '0' && *s <= '9') { + tval *= 10; + tval += *s - '0'; + } + else if (*s == ' ' || *s == ',') { + if (range) { + for (int i = sval-1; i < tval; ++i) + //for (unsigned int i = sval-1; i < tval; ++i) + val |= (1U << i); + range = false; + } + else { + val |= (1U << (tval-1)); + } + tval = 0; + } + else if (*s == '-') { + range = true; + sval = tval; + tval = 0; + } + ++s; + } + if (range && tval) { + for (int i = sval-1; i < tval; ++i) + //for (unsigned int i = sval-1; i < tval; ++i) + val |= (1U << i); + } + else if (tval) { + val |= (1U << (tval-1)); + } + //return val & 0xffff; + return val; + } + +//--------------------------------------------------------- +// autoAdjustFontSize +// w: Widget to auto adjust font size +// s: String to fit +// ignoreWidth: Set if dealing with a vertically constrained widget - one which is free to resize horizontally. +// ignoreHeight: Set if dealing with a horizontally constrained widget - one which is free to resize vertically. +//--------------------------------------------------------- +// Added by Tim. p3.3.8 + +bool autoAdjustFontSize(QFrame* w, const QString& s, bool ignoreWidth, bool ignoreHeight, int max, int min) +{ + // In case the max or min was obtained from QFont::pointSize() which returns -1 + // if the font is a pixel font, or if min is greater than max... + if(!w || (min < 0) || (max < 0) || (min > max)) + return false; + + // Limit the minimum and maximum sizes to something at least readable. + if(max < 4) + max = 4; + if(min < 4) + min = 4; + + QRect cr = w->contentsRect(); + QRect r; + QFont fnt = w->font(); + // An extra amount just to be sure - I found it was still breaking up two words which would fit on one line. + int extra = 4; + // Allow at least one loop. min can be equal to max. + for(int i = max; i >= min; --i) + { + fnt.setPointSize(i); + QFontMetrics fm(fnt); + r = fm.boundingRect(s); + // Would the text fit within the widget? + if((ignoreWidth || (r.width() <= (cr.width() - extra))) && (ignoreHeight || (r.height() <= cr.height()))) + break; + } + // Added by Tim. p3.3.9 + //printf("autoAdjustFontSize: ptsz:%d widget:%s before setFont x:%d y:%d w:%d h:%d\n", fnt.pointSize(), w->name(), w->x(), w->y(), w->width(), w->height()); + + // Here we will always have a font ranging from min to max point size. + w->setFont(fnt); + // Added by Tim. p3.3.9 + //printf("autoAdjustFontSize: ptsz:%d widget:%s x:%d y:%d w:%d h:%d frame w:%d rw:%d rh:%d\n", fnt.pointSize(), w->name(), w->x(), w->y(), w->width(), w->height(), w->frameWidth(), cr.width(), cr.height()); + + // Force minimum height. Use the expected height for the highest given point size. + // This way the mixer strips aren't all different label heights, but can be larger if necessary. + // Only if ignoreHeight is set (therefore the height is adjustable). + if(ignoreHeight) + { + fnt.setPointSize(max); + QFontMetrics fm(fnt); + // Set the label's minimum height equal to the height of the font. + w->setMinimumHeight(fm.height() + 2 * w->frameWidth()); + } + + return true; +} diff --git a/attic/muse2-oom/muse2/muse/widgets/utils.h b/attic/muse2-oom/muse2/muse/widgets/utils.h new file mode 100644 index 00000000..654a7834 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/utils.h @@ -0,0 +1,29 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: utils.h,v 1.1.1.1.2.3 2009/11/14 03:37:48 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __UTILS_H__ +#define __UTILS_H__ + +class QFrame; +class QString; +class QWidget; + + +extern QString bitmap2String(int bm); +extern int string2bitmap(const QString& str); +extern QString u32bitmap2String(unsigned int bm); +extern unsigned int string2u32bitmap(const QString& str); +extern bool autoAdjustFontSize(QFrame* w, const QString& s, bool ignoreWidth = false, bool ignoreHeight = false, int max = 10, int min = 4); + +extern int num2cols(int min, int max); +extern QFrame* hLine(QWidget* parent); +extern QFrame* vLine(QWidget* parent); +extern void dump(const unsigned char* p, int n); +extern double curTime(); + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/velocity.cpp b/attic/muse2-oom/muse2/muse/widgets/velocity.cpp new file mode 100644 index 00000000..309beb4d --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/velocity.cpp @@ -0,0 +1,46 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: velocity.cpp,v 1.1.1.1 2003/10/27 18:55:04 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#include <QButtonGroup> +#include "velocity.h" + +//--------------------------------------------------------- +// Velocity +//--------------------------------------------------------- + +Velocity::Velocity(QDialog* parent) + : QDialog(parent) + { + setupUi(this); + rangeGroup = new QButtonGroup; + rangeGroup->addButton(allEvents,0); + rangeGroup->addButton(selectedEvents,1); + rangeGroup->addButton(loopedEvents,2); + rangeGroup->addButton(selectedLooped,3); + } + +//--------------------------------------------------------- +// accept +//--------------------------------------------------------- + +void Velocity::accept() + { + _range = rangeGroup->checkedId(); + _rateVal = rate->value(); + _offsetVal = offset->value(); + QDialog::accept(); + } + +//--------------------------------------------------------- +// setRange +//--------------------------------------------------------- + +void Velocity::setRange(int id) + { + rangeGroup->button(id)->setChecked(true); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/velocity.h b/attic/muse2-oom/muse2/muse/widgets/velocity.h new file mode 100644 index 00000000..cf5b2779 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/velocity.h @@ -0,0 +1,39 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: velocity.h,v 1.1.1.1 2003/10/27 18:54:51 wschweer Exp $ +// (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __VELOCITY_H__ +#define __VELOCITY_H__ + +#include "ui_velocitybase.h" + +class QButtonGroup; + +//--------------------------------------------------------- +// Velocity +//--------------------------------------------------------- + +class Velocity : public QDialog, public Ui::VelocityBase { + int _range; + int _rateVal; + int _offsetVal; + + Q_OBJECT + QButtonGroup* rangeGroup; + + protected slots: + void accept(); + + public: + Velocity(QDialog* parent = 0); + void setRange(int id); + int range() const { return _range; } + int rateVal() const { return _rateVal; } + int offsetVal() const { return _offsetVal; } + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/velocitybase.ui b/attic/muse2-oom/muse2/muse/widgets/velocitybase.ui new file mode 100644 index 00000000..1e386e11 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/velocitybase.ui @@ -0,0 +1,211 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>VelocityBase</class> + <widget class="QDialog" name="VelocityBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>275</width> + <height>316</height> + </rect> + </property> + <property name="windowTitle"> + <string>MusE: Modify Velocity</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QGroupBox" name="rangeBox"> + <property name="title"> + <string>Range</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QRadioButton" name="allEvents"> + <property name="text"> + <string>All Events</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="selectedEvents"> + <property name="text"> + <string>Selected Events</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="loopedEvents"> + <property name="text"> + <string>Looped Events</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="selectedLooped"> + <property name="text"> + <string>Selected & Looped</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Values</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel3"> + <property name="text"> + <string>Rate:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QSpinBox" name="rate"> + <property name="suffix"> + <string>%</string> + </property> + <property name="maximum"> + <number>200</number> + </property> + <property name="value"> + <number>100</number> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="TextLabel4"> + <property name="text"> + <string>Offset:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="offset"> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>127</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>6</number> + </property> + <item> + <spacer name="Spacer1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="okButton"> + <property name="text"> + <string>OK</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton"> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections> + <connection> + <sender>okButton</sender> + <signal>clicked()</signal> + <receiver>VelocityBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + <connection> + <sender>cancelButton</sender> + <signal>clicked()</signal> + <receiver>VelocityBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>20</x> + <y>20</y> + </hint> + <hint type="destinationlabel"> + <x>20</x> + <y>20</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse2-oom/muse2/muse/widgets/view.cpp b/attic/muse2-oom/muse2/muse/widgets/view.cpp new file mode 100644 index 00000000..31cc212e --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/view.cpp @@ -0,0 +1,639 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: view.cpp,v 1.3.2.2 2009/04/06 01:24:55 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include "view.h" +#include <cmath> +#include <stdio.h> +#include <QPainter> +#include <QPixmap> +#include <QResizeEvent> +#include <QDropEvent> +#include <QMouseEvent> +#include <QKeyEvent> +#include <QPaintEvent> + +// Don't use this, it was just for debugging. +// It's much slower than muse-1 no matter how hard I tried. +// The left/right pixmap shifters in seXPos setYPos +// just ate up all the time no matter what I tried. +//#defines VIEW_USE_DOUBLE_BUFFERING 1 + +//--------------------------------------------------------- +// View::View +// double xMag = (xmag < 0) ? 1.0/-xmag : double(xmag) +//--------------------------------------------------------- + +View::View(QWidget* w, int xm, int ym, const char* name) + : QWidget(w) + { + setAttribute(Qt::WA_NoSystemBackground); + setAttribute(Qt::WA_StaticContents); + // This is absolutely required for speed! Otherwise painfully slow because we get + // full rect paint events even on small scrolls! See help on QPainter::scroll(). + setAttribute(Qt::WA_OpaquePaintEvent); + + setObjectName(QString(name)); + xmag = xm; + ymag = ym; + xpos = 0; + ypos = 0; + xorg = 0; + yorg = 0; + _virt = true; + setBackgroundRole(QPalette::NoRole); + brush.setStyle(Qt::SolidPattern); + brush.setColor(Qt::lightGray); + #ifdef VIEW_USE_DOUBLE_BUFFERING + pmValid = false; + #endif + } + +//--------------------------------------------------------- +// setOrigin +//--------------------------------------------------------- + +void View::setOrigin(int x, int y) + { + xorg = x; + yorg = y; + redraw(); + } + +//--------------------------------------------------------- +// setXMag +//--------------------------------------------------------- + +void View::setXMag(int xs) + { + xmag = xs; + redraw(); + } + +//--------------------------------------------------------- +// seqYMag +//--------------------------------------------------------- + +void View::setYMag(int ys) + { + ymag = ys; + redraw(); + } + +//--------------------------------------------------------- +// setXPos +// x - phys offset +//--------------------------------------------------------- + +void View::setXPos(int x) + { + int delta = xpos - x; // - -> shift left + xpos = x; + + #ifdef VIEW_USE_DOUBLE_BUFFERING + if (pm.isNull()) + return; + if (!pmValid) { + //printf("View::setXPos !pmValid x:%d width:%d delta:%d\n", x, width(), delta); + redraw(); + return; + } + + int w = width(); + int h = height(); + + QRect r; + if (delta >= w || delta <= -w) + r = QRect(0, 0, w, h); + else if (delta < 0) { // shift left + //bitBlt(&pm, 0, 0, &pm, -delta, 0, w + delta, h, CopyROP, true); + QPainter p(&pm); + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing, false); + //printf("View::setXPos x:%d w:%d delta:%d r.x:%d r.w:%d\n", + // x, w, delta, r.x(), r.width()); + p.drawPixmap(0, 0, pm, -delta, 0, w + delta, h); + r = QRect(w + delta, 0, -delta, h); + } + else { // shift right + //bitBlt(&pm, delta, 0, &pm, 0, 0, w-delta, h, CopyROP, true); + QPainter p(&pm); + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing, false); + //printf("View::setXPos x:%d w:%d delta:%d r.x:%d r.w:%d\n", + // x, w, delta, r.x(), r.width()); + p.drawPixmap(delta, 0, pm, 0, 0, w-delta, h); + r = QRect(0, 0, delta, h); + } + QRect olr = overlayRect(); + QRect olr1(olr); + olr1.translate(delta, 0); + + r |= olr; + r |= olr1; + + //printf("View::setXPos x:%d w:%d delta:%d r.x:%d r.w:%d\n", x, w, delta, r.x(), r.width()); + //printf("View::setXPos paint delta:%d r.x:%d r.y:%d r.w:%d r.h:%d\n", delta, r.x(), r.y(), r.width(), r.height()); + + paint(r); + update(); + + #else + scroll(delta, 0); + #endif + } + +//--------------------------------------------------------- +// setYPos +//--------------------------------------------------------- + +void View::setYPos(int y) + { + int delta = ypos - y; // - -> shift up + ypos = y; + + #ifdef VIEW_USE_DOUBLE_BUFFERING + if (pm.isNull()) + return; + if (!pmValid) { + //printf("View::setYPos !pmValid y:%d height:%d delta:%d\n", y, height(), delta); + + redraw(); + return; + } + + int w = width(); + int h = height(); + + QRect r; + if (delta >= h || delta <= -h) + r = QRect(0, 0, w, h); + else if (delta < 0) { // shift up + //bitBlt(&pm, 0, 0, &pm, 0, -delta, w, h + delta, CopyROP, true); + QPainter p(&pm); + p.drawPixmap(0, 0, pm, 0, -delta, w, h + delta); + r = QRect(0, h + delta, w, -delta); + } + else { // shift down + //bitBlt(&pm, 0, delta, &pm, 0, 0, w, h-delta, CopyROP, true); + QPainter p(&pm); + p.drawPixmap(0, delta, pm, 0, 0, w, h-delta); + r = QRect(0, 0, w, delta); + } + QRect olr = overlayRect(); + QRect olr1(olr); + olr1.translate(0, delta); + + r |= olr; + r |= olr1; + + //printf("View::setYPos paint delta:%d r.x:%d r.y:%d r.w:%d r.h:%d\n", delta, r.x(), r.y(), r.width(), r.height()); + + paint(r); + update(); + + #else + scroll(0, delta); + #endif + } + +//--------------------------------------------------------- +// resizeEvent +//--------------------------------------------------------- + +void View::resizeEvent(QResizeEvent* ev) + { + #ifdef VIEW_USE_DOUBLE_BUFFERING + //pm.resize(ev->size()); + //printf("View::resizeEvent width:%d height:%d\n", + // ev->size().width(), ev->size().height()); + + if(pm.isNull()) + { + //printf("View::resizeEvent pixmap is null\n"); + pm = QPixmap(ev->size().width(), ev->size().height()); + } + else + pm = pm.copy(QRect(QPoint(0, 0), ev->size())); + pmValid = false; + #endif + } + +//--------------------------------------------------------- +// paintEvent +//--------------------------------------------------------- + +void View::paintEvent(QPaintEvent* ev) + { + //printf("View::paintEvent x:%d width:%d y:%d height:%d\n", + // ev->rect().x(), ev->rect().width(), ev->rect().y(), ev->rect().height()); + + #ifdef VIEW_USE_DOUBLE_BUFFERING + if (!pmValid) + paint(ev->rect()); + + //bitBlt(this, ev->rect().topLeft(), &pm, ev->rect(), CopyROP, true); + QPainter p(this); + //p.setCompositionMode(QPainter::CompositionMode_Source); + p.drawPixmap(ev->rect().topLeft(), pm, ev->rect()); + + #else + paint(ev->rect()); + #endif + } + +//--------------------------------------------------------- +// redraw +//--------------------------------------------------------- + +void View::redraw() + { + //printf("View::redraw()\n"); + + #ifdef VIEW_USE_DOUBLE_BUFFERING + QRect r(0, 0, pm.width(), pm.height()); + //printf("View::redraw() r.x:%d r.w:%d\n", r.x(), r.width()); + paint(r); + #endif + + update(); + } + +//--------------------------------------------------------- +// redraw +//--------------------------------------------------------- + +void View::redraw(const QRect& r) + { + //printf("View::redraw(QRect& r) r.x:%d r.w:%d\n", r.x(), r.width()); + + #ifdef VIEW_USE_DOUBLE_BUFFERING + paint(r); + #endif + + update(r); + } + +//--------------------------------------------------------- +// paint +// r - phys coord system +//--------------------------------------------------------- + +void View::paint(const QRect& r) + { + #ifdef VIEW_USE_DOUBLE_BUFFERING + if (pm.isNull()) + return; + #endif + + QRect rr(r); + + //printf("View::paint x:%d width:%d y:%d height:%d\n", r.x(), r.width(), r.y(), r.height()); + + #ifdef VIEW_USE_DOUBLE_BUFFERING + if (!pmValid) { + pmValid = true; + rr = QRect(0, 0, pm.width(), pm.height()); + } + + QPainter p(&pm); + #else + QPainter p(this); + #endif + + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing, false); + + if (bgPixmap.isNull()) + p.fillRect(rr, brush); + else + p.drawTiledPixmap(rr, bgPixmap, QPoint(xpos + rmapx(xorg) + + rr.x(), ypos + rmapy(yorg) + rr.y())); + + p.setClipRegion(rr); + + //printf("View::paint r.x:%d w:%d\n", rr.x(), rr.width()); + pdraw(p, rr); // draw into pixmap + + p.resetMatrix(); // Q3 support says use resetMatrix instead, but resetMatrix advises resetTransform instead... + //p.resetTransform(); + + drawOverlay(p); + } + +//--------------------------------------------------------- +// keyPressEvent +//--------------------------------------------------------- + +void View::keyPressEvent(QKeyEvent* event) + { + viewKeyPressEvent(event); + } + +//--------------------------------------------------------- +// viewKeyPressEvent +//--------------------------------------------------------- + +void View::viewKeyPressEvent(QKeyEvent* event) + { + event->ignore(); + } + +//--------------------------------------------------------- +// mousePressEvent +//--------------------------------------------------------- + +void View::mousePressEvent(QMouseEvent* ev) + { + QMouseEvent e(ev->type(), mapDev(ev->pos()), + ev->globalPos(), ev->button(), ev->buttons(), ev->modifiers()); + viewMousePressEvent(&e); + } + +//--------------------------------------------------------- +// mouseDoubleClickEvent +//--------------------------------------------------------- + +void View::mouseDoubleClickEvent(QMouseEvent* ev) + { + QMouseEvent e(ev->type(), mapDev(ev->pos()), + ev->globalPos(), ev->button(), ev->buttons(), ev->modifiers()); + viewMouseDoubleClickEvent(&e); + } + +//--------------------------------------------------------- +// mouseMoveEvent +//--------------------------------------------------------- + +void View::mouseMoveEvent(QMouseEvent* ev) + { + QMouseEvent e(ev->type(), mapDev(ev->pos()), + ev->globalPos(), ev->button(), ev->buttons(), ev->modifiers()); + viewMouseMoveEvent(&e); + } + +//--------------------------------------------------------- +// mouseReleaseEvent +//--------------------------------------------------------- + +void View::mouseReleaseEvent(QMouseEvent* ev) + { + QMouseEvent e(ev->type(), mapDev(ev->pos()), + ev->globalPos(), ev->button(), ev->buttons(), ev->modifiers()); + viewMouseReleaseEvent(&e); + } + +//--------------------------------------------------------- +// dropEvent +//--------------------------------------------------------- + +void View::dropEvent(QDropEvent* ev) + { + // From Q3 support: + // "Sets the drop to happen at the given point. You do not normally need to use this + // as it will be set internally before your widget receives the drop event." + // But we need to remap it here... + //ev->setPoint(mapDev(ev->pos())); + QDropEvent nev(mapDev(ev->pos()), ev->possibleActions(), ev->mimeData(), ev->mouseButtons(), ev->keyboardModifiers(), ev->type()); + //viewDropEvent(ev); + viewDropEvent(&nev); + } + +//--------------------------------------------------------- +// setBg +//--------------------------------------------------------- + +void View::setBg(const QPixmap& bgpm) + { + bgPixmap = bgpm; + redraw(); + } + +//--------------------------------------------------------- +// pdraw +// r - phys coords +//--------------------------------------------------------- + +void View::pdraw(QPainter& p, const QRect& r) + { + //printf("View::pdraw virt:%d x:%d width:%d y:%d height:%d\n", virt(), r.x(), r.width(), r.y(), r.height()); + + if (virt()) { + setPainter(p); + int x = r.x(); + int y = r.y(); + int w = r.width(); + int h = r.height(); + if (xmag <= 0) { + x -= 1; + w += 2; + x = (x + xpos + rmapx(xorg)) * (-xmag); + w = w * (-xmag); + } + else { + x = (x + xpos + rmapx(xorg)) / xmag; + w = (w + xmag - 1) / xmag; + x -= 1; + w += 2; + } + if (ymag <= 0) { + y -= 1; + h += 2; + y = (y + ypos + rmapy(yorg)) * (-ymag); + h = h * (-ymag); + } + else { + y = (y + ypos + rmapy(yorg)) / ymag; + h = (h + ymag - 1) / ymag; + y -= 1; + h += 2; + } + + if (x < 0) + x = 0; + if (y < 0) + y = 0; + + draw(p, QRect(x, y, w, h)); + } + else + draw(p, r); + } + +//--------------------------------------------------------- +// setPainter +//--------------------------------------------------------- + +void View::setPainter(QPainter& p) + { + p.resetMatrix(); // Q3 support says use resetMatrix instead, but resetMatrix advises resetTransform instead... + //p.resetTransform(); + + p.translate(double(-(xpos+rmapx(xorg))), double(-(ypos+rmapy(yorg)))); + double xMag = (xmag < 0) ? 1.0/(-xmag) : double(xmag); + double yMag = (ymag < 0) ? 1.0/(-ymag) : double(ymag); + p.scale(xMag, yMag); + } + +//--------------------------------------------------------- +// map +//--------------------------------------------------------- + +QRect View::map(const QRect& r) const + { + int x, y, w, h; + if (xmag < 0) { + x = r.x()/(-xmag) - (xpos + rmapx(xorg)); // round down + w = (r.width()-xmag-1) / (-xmag); // round up + } + else { + x = r.x()*xmag - (xpos + rmapx(xorg)); + w = r.width() * xmag; + } + if (ymag < 0) { + y = r.y()/-ymag - (ypos + rmapy(yorg)); + h = (r.height()-ymag-1) / (-ymag); + } + else { + y = r.y() * ymag - (ypos + rmapy(yorg)); + h = r.height() * ymag; + } + return QRect(x, y, w, h); + } + +QPoint View::map(const QPoint& p) const + { + int x, y; + if (xmag < 0) { + x = p.x()/(-xmag) - (xpos + rmapx(xorg)); // round down + } + else { + x = p.x()*xmag - (xpos + rmapx(xorg)); + } + if (ymag < 0) { + y = p.y()/-ymag - (ypos + rmapy(yorg)); + } + else { + y = p.y() * ymag - (ypos + rmapy(yorg)); + } + return QPoint(x, y); + } + +QRect View::mapDev(const QRect& r) const + { + return QRect(mapxDev(r.x()), mapyDev(r.y()), + rmapxDev(r.width()), rmapyDev(r.height())); + } + +QPoint View::mapDev(const QPoint& r) const + { + return QPoint(mapxDev(r.x()), mapyDev(r.y())); + } + +int View::mapx(int x) const + { + if (xmag < 0) { + return (x-xmag/2)/(-xmag) - (xpos + rmapx(xorg)); // round + } + else { + return (x * xmag) - (xpos + rmapx(xorg)); + } + } +int View::mapy(int y) const + { + if (ymag < 0) { + return (y-ymag/2)/(-ymag) - (ypos + rmapy(yorg)); // round + } + else { + return (y * ymag) - (ypos + rmapy(yorg)); + } + } +int View::mapxDev(int x) const + { + int val; + if (xmag <= 0) + val = (x + xpos + rmapx(xorg)) * (-xmag); + else + val = (x + xpos + rmapx(xorg) + xmag / 2) / xmag; + if (val < 0) // DEBUG + val = 0; + return val; + } + +int View::mapyDev(int y) const + { + if (ymag <= 0) + return (y + ypos + rmapy(yorg)) * (-ymag); + else + return (y + ypos + rmapy(yorg) + ymag / 2) / ymag; + } + +int View::rmapx(int x) const + { + if (xmag < 0) + return (x-xmag/2) / (-xmag); + else + return x * xmag; + } +int View::rmapy(int y) const + { + if (ymag < 0) + return (y-ymag/2) / (-ymag); + else + return y * ymag; + } +int View::rmapxDev(int x) const + { + if (xmag <= 0) + return x * (-xmag); + else + return (x + xmag/2) / xmag; + } +int View::rmapyDev(int y) const + { + if (ymag <= 0) + return y * (-ymag); + else + return (y + ymag/2) / ymag; + } + +/* +QRect View::devToVirt(const QRect& r) +{ + int x = r.x(); + int y = r.y(); + int w = r.width(); + int h = r.height(); + if (xmag <= 0) { + x -= 1; + w += 2; + x = (x + xpos + rmapx(xorg)) * (-xmag); + w = w * (-xmag); + } + else { + x = (x + xpos + rmapx(xorg)) / xmag; + w = (w + xmag - 1) / xmag; + x -= 1; + w += 2; + } + if (ymag <= 0) { + y -= 1; + h += 2; + y = (y + ypos + rmapy(yorg)) * (-ymag); + h = h * (-ymag); + } + else { + y = (y + ypos + rmapy(yorg)) / ymag; + h = (h + ymag - 1) / ymag; + y -= 1; + h += 2; + } + + if (x < 0) + x = 0; + if (y < 0) + y = 0; + + return QRect(x, y, w, h); +} +*/
\ No newline at end of file diff --git a/attic/muse2-oom/muse2/muse/widgets/view.h b/attic/muse2-oom/muse2/muse/widgets/view.h new file mode 100644 index 00000000..f8b0c90f --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/view.h @@ -0,0 +1,107 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: view.h,v 1.2.2.1 2008/01/26 07:23:21 terminator356 Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __VIEW_H__ +#define __VIEW_H__ + +#include <QWidget> + +class QDropEvent; +class QKeyEvent; +class QMouseEvent; +class QPaintEvent; +class QPainter; +class QPixmap; +class QResizeEvent; + +//--------------------------------------------------------- +// View +// horizontal View with double buffering +//--------------------------------------------------------- + +class View : public QWidget { + QPixmap pm; // for double buffering + bool pmValid; + QPixmap bgPixmap; // background Pixmap + QBrush brush; + bool _virt; + Q_OBJECT + + protected: + int xorg; + int yorg; + int xpos, ypos; + int xmag, ymag; + + virtual void keyPressEvent(QKeyEvent* event); + virtual void mousePressEvent(QMouseEvent* event); + virtual void mouseDoubleClickEvent(QMouseEvent* event); + virtual void mouseMoveEvent(QMouseEvent* event); + virtual void mouseReleaseEvent(QMouseEvent* event); + virtual void dropEvent(QDropEvent* event); + + virtual void draw(QPainter&, const QRect&) {} + virtual void drawOverlay(QPainter&) {} + virtual QRect overlayRect() const { return QRect(0, 0, 0, 0); } + + virtual void pdraw(QPainter&, const QRect&); + + virtual void paintEvent(QPaintEvent* ev); + void redraw(const QRect&); + + void paint(const QRect& r); + + virtual void resizeEvent(QResizeEvent*); + virtual void viewKeyPressEvent(QKeyEvent*); + virtual void viewMousePressEvent(QMouseEvent*) {} + virtual void viewMouseDoubleClickEvent(QMouseEvent*) {} + virtual void viewMouseMoveEvent(QMouseEvent*) {} + virtual void viewMouseReleaseEvent(QMouseEvent*) {} + virtual void viewDropEvent(QDropEvent*) {} + + QRect map(const QRect&) const; + QPoint map(const QPoint&) const; + QRect mapDev(const QRect&) const; + QPoint mapDev(const QPoint&) const; + + int mapx(int x) const; + int mapy(int y) const; + int mapyDev(int y) const; + int mapxDev(int x) const; + int rmapy(int y) const; + int rmapyDev(int y) const; + //QRect devToVirt(const QRect&); + + void setPainter(QPainter& p); + + public slots: + void setXPos(int); + void setYPos(int); + void setXMag(int xs); + void setYMag(int ys); + void redraw(); + + public: + View(QWidget*, int, int, const char* name = 0); + void setBg(const QPixmap& pm); + void setBg(const QColor& color) { brush.setColor(color); redraw(); } + void setXOffset(int v) { setXPos(mapx(v)); } + int xOffset() const { return mapxDev(xpos)-xorg; } + int xOffsetDev() const { return xpos-rmapx(xorg); } + + int yOffset() const { return mapyDev(ypos)-yorg; } + int getXScale() const { return xmag; } + int getYScale() const { return ymag; } + void setOrigin(int x, int y); + void setVirt(bool flag) { _virt = flag; } + bool virt() const { return _virt; } + int rmapxDev(int x) const; + int rmapx(int x) const; + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/vscale.cpp b/attic/muse2-oom/muse2/muse/widgets/vscale.cpp new file mode 100644 index 00000000..943124e5 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/vscale.cpp @@ -0,0 +1,28 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: vscale.cpp,v 1.1.1.1 2003/10/27 18:54:41 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#include "vscale.h" + +#include <QPainter> +#include <QPaintEvent> + +//--------------------------------------------------------- +// paintEvent +//--------------------------------------------------------- + +void VScale::paintEvent(QPaintEvent*) + { + int h = height(); + int w = width(); + QPainter p; + p.begin(this); + p.drawLine(w/2, h/4, w, h/4); + p.drawLine(0, h/2, w, h/2); + p.drawLine(w/2, (3*h)/4, w, (3*h)/4); + p.end(); + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/vscale.h b/attic/muse2-oom/muse2/muse/widgets/vscale.h new file mode 100644 index 00000000..100c5fb2 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/vscale.h @@ -0,0 +1,29 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: vscale.h,v 1.1.1.1.2.1 2008/01/19 13:33:47 wschweer Exp $ +// (C) Copyright 1999 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __VSCALE_H__ +#define __VSCALE_H__ + +#include <QWidget> + +class QPaintEvent; + +//--------------------------------------------------------- +// VScale +//--------------------------------------------------------- + +class VScale : public QWidget { + Q_OBJECT + + virtual void paintEvent(QPaintEvent*); + + public: + VScale(QWidget* parent=0) : QWidget(parent) {setFixedWidth(18);} + }; + +#endif + diff --git a/attic/muse2-oom/muse2/muse/widgets/wtscale.cpp b/attic/muse2-oom/muse2/muse/widgets/wtscale.cpp new file mode 100644 index 00000000..2c02b631 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/wtscale.cpp @@ -0,0 +1,286 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: wtscale.cpp,v 1.3 2004/04/11 13:03:32 wschweer Exp $ +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include <values.h> + +#include <QPainter> +#include <QRect> +#include <QToolTip> + +#include "wtscale.h" +#include "midieditor.h" +#include "globals.h" +#include "song.h" +#include "../marker/marker.h" +#include "icons.h" + +//--------------------------------------------------------- +// WTScale +// Wave Time Scale +//--------------------------------------------------------- + +WTScale::WTScale(int* r, QWidget* parent, int xs) + : View(parent, xs, 1) + { + QToolTip::add(this, tr("bar scale")); + barLocator = false; + raster = r; + pos[0] = int(song->tempomap()->tick2time(song->cpos()) * sampleRate); + pos[1] = int(song->tempomap()->tick2time(song->lpos()) * sampleRate); + pos[2] = int(song->tempomap()->tick2time(song->rpos()) * sampleRate); + pos[3] = -1; // do not show + button = Qt::NoButton; + setMouseTracking(true); + connect(song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool))); + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + connect(song, SIGNAL(markerChanged(int)), SLOT(redraw())); + setFixedHeight(28); + setBg(QColor(0xe0, 0xe0, 0xe0)); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void WTScale::songChanged(int /*type*/) + { + } + +//--------------------------------------------------------- +// setPos +//--------------------------------------------------------- + +void WTScale::setPos(int idx, unsigned val, bool adjustScrollbar) + { + val = int(song->tempomap()->tick2time(val) * sampleRate); + if (val == pos[idx]) + return; + int opos = mapx(pos[idx] == -1 ? val : pos[idx]); + pos[idx] = val; + if (!isVisible()) + return; + val = mapx(val); + int x = -9; + int w = 18; + if (opos > val) { + w += opos - val; + x += val; + } + else { + w += val - opos; + x += opos; + } + redraw(QRect(x, 0, w, height())); + } + +//--------------------------------------------------------- +// viewMousePressEvent +//--------------------------------------------------------- + +void WTScale::viewMousePressEvent(QMouseEvent* event) + { + button = event->button(); + viewMouseMoveEvent(event); + } + +//--------------------------------------------------------- +// viewMouseReleaseEvent +//--------------------------------------------------------- + +void WTScale::viewMouseReleaseEvent(QMouseEvent* event) + { + button = Qt::NoButton; + } + +//--------------------------------------------------------- +// viewMouseMoveEvent +//--------------------------------------------------------- + +void WTScale::viewMouseMoveEvent(QMouseEvent* event) + { + int x= song->tempomap()->time2tick(double(event->x())/double(sampleRate)); + x = song->raster(x, *raster); + if (x < 0) + x = 0; + emit timeChanged(x); + int i; + switch (button) { + case Qt::LeftButton: + i = 0; + break; + case Qt::MidButton: + i = 1; + break; + case Qt::RightButton: + i = 2; + break; + default: + return; + } + song->setPos(i, x); + } + +//--------------------------------------------------------- +// leaveEvent +//--------------------------------------------------------- + +void WTScale::leaveEvent(QEvent*) + { +// emit timeChanged(MAXINT); + } + +//--------------------------------------------------------- +// draw +//--------------------------------------------------------- + +void WTScale::pdraw(QPainter& p, const QRect& r) + { + int x = r.x(); + int w = r.width(); + + x -= 20; + w += 40; // wg. Text + + // + // draw Marker + // + int y = 12; + p.setPen(Qt::black); + p.setFont(font4); + p.drawLine(r.x(), y+1, r.x() + r.width(), y+1); + QRect tr(r); + tr.setHeight(12); + MarkerList* marker = song->marker(); + for (iMarker m = marker->begin(); m != marker->end(); ++m) { + int xp = mapx(int(m->second.time() * sampleRate)); + if (xp > x+w) + break; + int xe = r.x() + r.width(); + iMarker mm = m; + ++mm; + if (mm != marker->end()) { + xe = mapx(mm->first); + } + QRect tr(xp, 0, xe-xp, 13); + if (m->second.current()) { + p.fillRect(tr, Qt::white); + } + if (r.intersects(tr)) { + int x2; + iMarker mm = m; + ++mm; + if (mm != marker->end()) + x2 = mapx(mm->first); + else + x2 = xp+200; + QRect r = QRect(xp+10, 0, x2-xp, 12); + p.drawPixmap(xp, 0, *flagIconS); + p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter, m->second.name()); + } + } + + //--------------------------------------------------- + // draw location marker + //--------------------------------------------------- + + int h = height()-12; + + if (barLocator) { + p.setPen(Qt::red); + int xp = mapx(pos[0]); + if (xp >= x && xp < x+w) + p.drawLine(xp, y, xp, h); + p.setPen(Qt::blue); + xp = mapx(pos[1]); + if (xp >= x && xp < x+w) + p.drawLine(xp, y, xp, h); + xp = mapx(pos[2]); + if (xp >= x && xp < x+w) + p.drawLine(xp, y, xp, h); + } + else { + for (int i = 0; i < 3; ++i) { + int xp = mapx(pos[i]); + if (xp >= x && xp < x+w) { + QPixmap* pm = markIcon[i]; + p.drawPixmap(xp - pm->width()/2, y-1, *pm); + } + } + } + p.setPen(Qt::black); + if (pos[3] != -1) { + int xp = mapx(pos[3]); + if (xp >= x && xp < x+w) + p.drawLine(xp, 0, xp, height()); + } + + int ctick = song->samples2tick(mapxDev(x)); + int bar1, bar2, beat, tick; + song->tickValues(ctick, &bar1, &beat, &tick); + song->tickValues(song->samples2tick(mapxDev(x+w)), &bar2, &beat, &tick); + +//printf("bar %d %d-%d=%d\n", bar, ntick, stick, ntick-stick); + + int stick = song->bar2tick(bar1, 0, 0); + int ntick; + for (int bar = bar1; bar <= bar2; bar++, stick = ntick) { + ntick = song->bar2tick(bar+1, 0, 0); + int a = song->tick2samples(ntick); + int b = song->tick2samples(stick); + int tpix = rmapx(a - b); + if (tpix < 64) { + // donīt show beats if measure is this small + int n = 1; + if (tpix < 32) + n = 2; + if (tpix <= 16) + n = 4; + if (tpix < 8) + n = 8; + if (tpix <= 4) + n = 16; + if (tpix <= 2) + n = 32; + if (bar % n) + continue; + p.setFont(font3); + int x = mapx(b); + QString s; + s.setNum(bar + 1); + p.drawLine(x, y+1, x, y+1+h); + QRect r = QRect(x+2, y, 0, h); + p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter|Qt::TextDontClip, s); + } + else { + int z, n; + song->timesig(stick, z, n); + for (int beat = 0; beat < z; beat++) { + int xx = song->tick2samples(song->bar2tick(bar, beat, 0)); + int xp = mapx(xx); + QString s; + QRect r(xp+2, y, 0, h); + int y1; + int num; + if (beat == 0) { + num = bar + 1; + y1 = y + 1; + p.setFont(font3); + } + else { + num = beat + 1; + y1 = y + 7; + p.setFont(font1); + r.setY(y+3); + } + s.setNum(num); + p.drawLine(xp, y1, xp, y+1+h); + p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter|Qt::TextDontClip, s); + } + } + } + } + diff --git a/attic/muse2-oom/muse2/muse/widgets/wtscale.h b/attic/muse2-oom/muse2/muse/widgets/wtscale.h new file mode 100644 index 00000000..f12bbc6f --- /dev/null +++ b/attic/muse2-oom/muse2/muse/widgets/wtscale.h @@ -0,0 +1,46 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: wtscale.h,v 1.2 2004/01/11 18:55:37 wschweer Exp $ +// (C) Copyright 2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __MTSCALE_H__ +#define __MTSCALE_H__ + +#include "view.h" + +//--------------------------------------------------------- +// WTScale +// scale for wave track +//--------------------------------------------------------- + +class WTScale : public View { + Q_OBJECT + int* raster; + unsigned pos[4]; + int button; + bool barLocator; + + private slots: + void songChanged(int); + + protected: + virtual void pdraw(QPainter&, const QRect&); + virtual void viewMousePressEvent(QMouseEvent* event); + virtual void viewMouseMoveEvent(QMouseEvent* event); + virtual void viewMouseReleaseEvent(QMouseEvent* event); + virtual void leaveEvent(QEvent*e); + + signals: + void timeChanged(unsigned); + + public slots: + void setPos(int, unsigned, bool); + + public: + WTScale(int* raster, QWidget* parent, int xscale); + void setBarLocator(bool f) { barLocator = f; } + }; +#endif + |