Implementation of Timer Toolbar

PRL:  Rebased onto recent master, fixed compilation and indentation, added new
files to the XCode project, added an EXPERIMENTAL flag
This commit is contained in:
Loss 2019-10-14 14:00:26 -03:00 committed by Paul Licameli
parent f1e5e96480
commit e787694f07
16 changed files with 344 additions and 25 deletions

View File

@ -640,6 +640,8 @@ src/toolbars/SelectionBarListener.h
src/toolbars/SpectralSelectionBar.cpp
src/toolbars/SpectralSelectionBar.h
src/toolbars/SpectralSelectionBarListener.h
src/toolbars/TimerToolBar.cpp
src/toolbars/TimerToolBar.h
src/toolbars/ToolBar.cpp
src/toolbars/ToolBar.h
src/toolbars/ToolDock.cpp

View File

@ -1334,6 +1334,7 @@
5ED1D0AE1CDE55BD00471E3C /* OverlayPanel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5ED1D0AB1CDE55BD00471E3C /* OverlayPanel.cpp */; };
5ED1D0B11CDE560C00471E3C /* BackedPanel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5ED1D0AF1CDE560C00471E3C /* BackedPanel.cpp */; };
5ED8FF8A239AB9960065BC5B /* noisegate.ny in Resources */ = {isa = PBXBuildFile; fileRef = 5ED8FF89239AB9960065BC5B /* noisegate.ny */; };
5EE2698323BBD4E800C58E4D /* TimerToolBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EE2698123BBD4E800C58E4D /* TimerToolBar.cpp */; };
5EF17C231D1F0A690090A642 /* ScrubbingToolBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF17C211D1F0A690090A642 /* ScrubbingToolBar.cpp */; };
5EF3E64D203FBAFB006C6882 /* AudacityCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E643203FBAFB006C6882 /* AudacityCommand.cpp */; };
5EF3E64E203FBAFB006C6882 /* CommandContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E645203FBAFB006C6882 /* CommandContext.cpp */; };
@ -3434,6 +3435,8 @@
5ED1D0AF1CDE560C00471E3C /* BackedPanel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackedPanel.cpp; sourceTree = "<group>"; };
5ED1D0B01CDE560C00471E3C /* BackedPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackedPanel.h; sourceTree = "<group>"; };
5ED8FF89239AB9960065BC5B /* noisegate.ny */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = noisegate.ny; path = "../plug-ins/noisegate.ny"; sourceTree = "<group>"; };
5EE2698123BBD4E800C58E4D /* TimerToolBar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimerToolBar.cpp; sourceTree = "<group>"; };
5EE2698223BBD4E800C58E4D /* TimerToolBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimerToolBar.h; sourceTree = "<group>"; };
5EE8984821D68D88006DE939 /* CommandManagerWindowClasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandManagerWindowClasses.h; sourceTree = "<group>"; };
5EEE942021F397C00038E68E /* AttachedVirtualFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttachedVirtualFunction.h; sourceTree = "<group>"; };
5EF17C211D1F0A690090A642 /* ScrubbingToolBar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrubbingToolBar.cpp; sourceTree = "<group>"; };
@ -5961,6 +5964,8 @@
28001B481A0F0EB6007DD161 /* SpectralSelectionBar.cpp */,
28001B491A0F0EB6007DD161 /* SpectralSelectionBar.h */,
28001B4A1A0F0EB6007DD161 /* SpectralSelectionBarListener.h */,
5EE2698123BBD4E800C58E4D /* TimerToolBar.cpp */,
5EE2698223BBD4E800C58E4D /* TimerToolBar.h */,
2897F6E60AB3DB5A003C20C5 /* ToolBar.cpp */,
2897F6E70AB3DB5A003C20C5 /* ToolBar.h */,
2897F6E80AB3DB5A003C20C5 /* ToolDock.cpp */,
@ -8968,6 +8973,7 @@
28884952131B6CF600B59735 /* fa.po in Sources */,
28884953131B6CF600B59735 /* fi.po in Sources */,
28884954131B6CF600B59735 /* fr.po in Sources */,
5EE2698323BBD4E800C58E4D /* TimerToolBar.cpp in Sources */,
5EBD1C9522D11DAF00299FD4 /* WaveformVZoomHandle.cpp in Sources */,
28884955131B6CF600B59735 /* ga.po in Sources */,
28884956131B6CF600B59735 /* gl.po in Sources */,

View File

@ -3,7 +3,7 @@ project (Audacity)
find_package(wxWidgets REQUIRED COMPONENTS net core base html qa adv)
include(${wxWidgets_USE_FILE})
set_property(GLOBAL PROPERTY USE_FOLDERS On)
set_property(GLOBAL PROPERTY USE_FOLDERS On)
# Needed for configwin.h included by Audacity.h
@ -24,7 +24,7 @@ include_directories(${top_dir}/lib-src/libmad)
include_directories(${top_dir}/lib-src/libnyquist)
include_directories(${top_dir}/lib-src/libogg/include)
include_directories(${top_dir}/lib-src/libscorealign)
include_directories(${top_dir}/win/Projects/libsndfile)
include_directories(${top_dir}/win/Projects/libsndfile)
include_directories(${top_dir}/lib-src/libsoxr/src) #really? Src?
include_directories(${top_dir}/lib-src/libvamp)
include_directories(${top_dir}/lib-src/libvorbis/include)
@ -76,7 +76,7 @@ add_compile_options(/wd4996)
set( SOURCE
set( SOURCE
${CMAKE_SOURCE_DIRECTORY}AudacityHeaders.cpp #first so cotire can precompile
${CMAKE_SOURCE_DIRECTORY}AboutDialog.cpp
${CMAKE_SOURCE_DIRECTORY}AColor.cpp
@ -184,7 +184,7 @@ set( BLOCKFILE_SOURCE
${CMAKE_SOURCE_DIRECTORY}blockfile/PCMAliasBlockFile.cpp
${CMAKE_SOURCE_DIRECTORY}blockfile/SilentBlockFile.cpp
${CMAKE_SOURCE_DIRECTORY}blockfile/SimpleBlockFile.cpp
)
)
source_group( blockfile FILES ${BLOCKFILE_SOURCE} )
@ -379,6 +379,7 @@ set( TOOLBARS_SOURCE
${CMAKE_SOURCE_DIRECTORY}toolbars/ScrubbingToolBar.cpp
${CMAKE_SOURCE_DIRECTORY}toolbars/SelectionBar.cpp
${CMAKE_SOURCE_DIRECTORY}toolbars/SpectralSelectionBar.cpp
${CMAKE_SOURCE_DIRECTORY}toolbars/TimerToolBar.cpp
${CMAKE_SOURCE_DIRECTORY}toolbars/ToolBar.cpp
${CMAKE_SOURCE_DIRECTORY}toolbars/ToolDock.cpp
${CMAKE_SOURCE_DIRECTORY}toolbars/ToolManager.cpp
@ -471,7 +472,7 @@ set( XML_SOURCE
)
source_group( xml FILES ${XML_SOURCE} )
set( SOURCE
set( SOURCE
${SOURCE}
${BLOCKFILE_SOURCE}
${COMMANDS_SOURCE}
@ -507,8 +508,8 @@ if(MSVC)
endif()
#Use cotire to get precompiled headers, and a unity build.
set_target_properties(Audacity
PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT
set_target_properties(Audacity
PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT
"AudacityHeaders.h")
cotire(Audacity)

View File

@ -258,4 +258,7 @@
// it is dangerous and has too many bugs. See bug 536 for example.
//#do not define EXPERIMENTAL_OD_DATA
// Jonatã Bolzan Loss 31 Dec 2019
#define EXPERIMENTAL_TIMER_TOOLBAR
#endif

View File

@ -627,6 +627,7 @@ audacity_SOURCES = \
toolbars/SpectralSelectionBar.cpp \
toolbars/SpectralSelectionBar.h \
toolbars/SpectralSelectionBarListener.h \
toolbars/TimerToolBar.cpp \
toolbars/ToolBar.cpp \
toolbars/ToolBar.h \
toolbars/ToolDock.cpp \

View File

@ -494,7 +494,8 @@ am__audacity_SOURCES_DIST = BlockFile.cpp BlockFile.h DirManager.cpp \
toolbars/SelectionBar.cpp toolbars/SelectionBar.h \
toolbars/SpectralSelectionBar.cpp \
toolbars/SpectralSelectionBar.h \
toolbars/SpectralSelectionBarListener.h toolbars/ToolBar.cpp \
toolbars/SpectralSelectionBarListener.h \
toolbars/TimerToolBar.cpp toolbars/ToolBar.cpp \
toolbars/ToolBar.h toolbars/ToolDock.cpp toolbars/ToolDock.h \
toolbars/ToolManager.cpp toolbars/ToolManager.h \
toolbars/ToolsToolBar.cpp toolbars/ToolsToolBar.h \
@ -892,6 +893,7 @@ am_audacity_OBJECTS = $(am__objects_1) audacity-AboutDialog.$(OBJEXT) \
toolbars/audacity-ScrubbingToolBar.$(OBJEXT) \
toolbars/audacity-SelectionBar.$(OBJEXT) \
toolbars/audacity-SpectralSelectionBar.$(OBJEXT) \
toolbars/audacity-TimerToolBar.$(OBJEXT) \
toolbars/audacity-ToolBar.$(OBJEXT) \
toolbars/audacity-ToolDock.$(OBJEXT) \
toolbars/audacity-ToolManager.$(OBJEXT) \
@ -1334,6 +1336,7 @@ am__depfiles_remade = ./$(DEPDIR)/audacity-AColor.Po \
toolbars/$(DEPDIR)/audacity-ScrubbingToolBar.Po \
toolbars/$(DEPDIR)/audacity-SelectionBar.Po \
toolbars/$(DEPDIR)/audacity-SpectralSelectionBar.Po \
toolbars/$(DEPDIR)/audacity-TimerToolBar.Po \
toolbars/$(DEPDIR)/audacity-ToolBar.Po \
toolbars/$(DEPDIR)/audacity-ToolDock.Po \
toolbars/$(DEPDIR)/audacity-ToolManager.Po \
@ -2013,7 +2016,8 @@ audacity_SOURCES = $(libaudacity_la_SOURCES) AboutDialog.cpp \
toolbars/SelectionBar.cpp toolbars/SelectionBar.h \
toolbars/SpectralSelectionBar.cpp \
toolbars/SpectralSelectionBar.h \
toolbars/SpectralSelectionBarListener.h toolbars/ToolBar.cpp \
toolbars/SpectralSelectionBarListener.h \
toolbars/TimerToolBar.cpp toolbars/ToolBar.cpp \
toolbars/ToolBar.h toolbars/ToolDock.cpp toolbars/ToolDock.h \
toolbars/ToolManager.cpp toolbars/ToolManager.h \
toolbars/ToolsToolBar.cpp toolbars/ToolsToolBar.h \
@ -2669,6 +2673,8 @@ toolbars/audacity-SelectionBar.$(OBJEXT): toolbars/$(am__dirstamp) \
toolbars/$(DEPDIR)/$(am__dirstamp)
toolbars/audacity-SpectralSelectionBar.$(OBJEXT): \
toolbars/$(am__dirstamp) toolbars/$(DEPDIR)/$(am__dirstamp)
toolbars/audacity-TimerToolBar.$(OBJEXT): toolbars/$(am__dirstamp) \
toolbars/$(DEPDIR)/$(am__dirstamp)
toolbars/audacity-ToolBar.$(OBJEXT): toolbars/$(am__dirstamp) \
toolbars/$(DEPDIR)/$(am__dirstamp)
toolbars/audacity-ToolDock.$(OBJEXT): toolbars/$(am__dirstamp) \
@ -3347,6 +3353,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@toolbars/$(DEPDIR)/audacity-ScrubbingToolBar.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@toolbars/$(DEPDIR)/audacity-SelectionBar.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@toolbars/$(DEPDIR)/audacity-SpectralSelectionBar.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@toolbars/$(DEPDIR)/audacity-TimerToolBar.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@toolbars/$(DEPDIR)/audacity-ToolBar.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@toolbars/$(DEPDIR)/audacity-ToolDock.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@toolbars/$(DEPDIR)/audacity-ToolManager.Po@am__quote@ # am--include-marker
@ -7462,6 +7469,20 @@ toolbars/audacity-SpectralSelectionBar.obj: toolbars/SpectralSelectionBar.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o toolbars/audacity-SpectralSelectionBar.obj `if test -f 'toolbars/SpectralSelectionBar.cpp'; then $(CYGPATH_W) 'toolbars/SpectralSelectionBar.cpp'; else $(CYGPATH_W) '$(srcdir)/toolbars/SpectralSelectionBar.cpp'; fi`
toolbars/audacity-TimerToolBar.o: toolbars/TimerToolBar.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT toolbars/audacity-TimerToolBar.o -MD -MP -MF toolbars/$(DEPDIR)/audacity-TimerToolBar.Tpo -c -o toolbars/audacity-TimerToolBar.o `test -f 'toolbars/TimerToolBar.cpp' || echo '$(srcdir)/'`toolbars/TimerToolBar.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) toolbars/$(DEPDIR)/audacity-TimerToolBar.Tpo toolbars/$(DEPDIR)/audacity-TimerToolBar.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='toolbars/TimerToolBar.cpp' object='toolbars/audacity-TimerToolBar.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o toolbars/audacity-TimerToolBar.o `test -f 'toolbars/TimerToolBar.cpp' || echo '$(srcdir)/'`toolbars/TimerToolBar.cpp
toolbars/audacity-TimerToolBar.obj: toolbars/TimerToolBar.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT toolbars/audacity-TimerToolBar.obj -MD -MP -MF toolbars/$(DEPDIR)/audacity-TimerToolBar.Tpo -c -o toolbars/audacity-TimerToolBar.obj `if test -f 'toolbars/TimerToolBar.cpp'; then $(CYGPATH_W) 'toolbars/TimerToolBar.cpp'; else $(CYGPATH_W) '$(srcdir)/toolbars/TimerToolBar.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) toolbars/$(DEPDIR)/audacity-TimerToolBar.Tpo toolbars/$(DEPDIR)/audacity-TimerToolBar.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='toolbars/TimerToolBar.cpp' object='toolbars/audacity-TimerToolBar.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o toolbars/audacity-TimerToolBar.obj `if test -f 'toolbars/TimerToolBar.cpp'; then $(CYGPATH_W) 'toolbars/TimerToolBar.cpp'; else $(CYGPATH_W) '$(srcdir)/toolbars/TimerToolBar.cpp'; fi`
toolbars/audacity-ToolBar.o: toolbars/ToolBar.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT toolbars/audacity-ToolBar.o -MD -MP -MF toolbars/$(DEPDIR)/audacity-ToolBar.Tpo -c -o toolbars/audacity-ToolBar.o `test -f 'toolbars/ToolBar.cpp' || echo '$(srcdir)/'`toolbars/ToolBar.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) toolbars/$(DEPDIR)/audacity-ToolBar.Tpo toolbars/$(DEPDIR)/audacity-ToolBar.Po
@ -9456,6 +9477,7 @@ distclean: distclean-am
-rm -f toolbars/$(DEPDIR)/audacity-ScrubbingToolBar.Po
-rm -f toolbars/$(DEPDIR)/audacity-SelectionBar.Po
-rm -f toolbars/$(DEPDIR)/audacity-SpectralSelectionBar.Po
-rm -f toolbars/$(DEPDIR)/audacity-TimerToolBar.Po
-rm -f toolbars/$(DEPDIR)/audacity-ToolBar.Po
-rm -f toolbars/$(DEPDIR)/audacity-ToolDock.Po
-rm -f toolbars/$(DEPDIR)/audacity-ToolManager.Po
@ -9899,6 +9921,7 @@ maintainer-clean: maintainer-clean-am
-rm -f toolbars/$(DEPDIR)/audacity-ScrubbingToolBar.Po
-rm -f toolbars/$(DEPDIR)/audacity-SelectionBar.Po
-rm -f toolbars/$(DEPDIR)/audacity-SpectralSelectionBar.Po
-rm -f toolbars/$(DEPDIR)/audacity-TimerToolBar.Po
-rm -f toolbars/$(DEPDIR)/audacity-ToolBar.Po
-rm -f toolbars/$(DEPDIR)/audacity-ToolDock.Po
-rm -f toolbars/$(DEPDIR)/audacity-ToolManager.Po

View File

@ -197,9 +197,10 @@ enum
IdCaptureFullWindow,
IdCaptureWindowPlus,
IdCaptureFullScreen,
IdCaptureSelectionBar,
IdCaptureSpectralSelection,
IdCaptureTimer,
IdCaptureTools,
IdCaptureTransport,
IdCaptureMixer,
@ -399,6 +400,7 @@ void ScreenshotBigDialog::PopulateOrExchange(ShuttleGui & S)
{
S.Id(IdCaptureSelectionBar).AddButton(XO("SelectionBar"));
S.Id(IdCaptureSpectralSelection).AddButton(XO("Spectral Selection"));
S.Id(IdCaptureTimer).AddButton(XO("Timer"));
S.Id(IdCaptureTools).AddButton(XO("Tools"));
S.Id(IdCaptureTransport).AddButton(XO("Transport"));
}
@ -635,7 +637,7 @@ void ScreenshotBigDialog::OnCaptureSomething(wxCommandEvent & event)
IdCaptureFullWindow,
IdCaptureWindowPlus,
IdCaptureFullScreen,
IdCaptureSelectionBar,
IdCaptureSpectralSelection,
IdCaptureTools,

View File

@ -52,6 +52,15 @@ void OnShowTransportToolBar(const CommandContext &context)
MenuManager::Get(project).ModifyToolbarMenus(project);
}
void OnShowTimerToolBar(const CommandContext &context)
{
auto &project = context.project;
auto &toolManager = ToolManager::Get( project );
toolManager.ShowHide( TimerBarID );
MenuManager::Get(project).ModifyToolbarMenus(project);
}
void OnShowToolsToolBar(const CommandContext &context)
{
auto &project = context.project;
@ -249,7 +258,7 @@ MenuTable::BaseItemPtr ToolbarsMenu( AudacityProject& )
{
using namespace MenuTable;
using Options = CommandManager::Options;
static const auto checkOff = Options{}.CheckState( false );
return Menu( XO("&Toolbars"),
@ -306,6 +315,13 @@ MenuTable::BaseItemPtr ToolbarsMenu( AudacityProject& )
for selecting a time range of audio*/
Command( wxT("ShowSelectionTB"), XXO("&Selection Toolbar"),
FN(OnShowSelectionToolBar), AlwaysEnabledFlag, checkOff )
#ifdef EXPERIMENTAL_TIMER_TOOLBAR
,
/* i18n-hint: Clicking this menu item shows the toolbar
for viewing actual time of the cursor*/
Command( wxT("ShowTImerToolBarTB"), XXO("&Timer Toolbar"),
FN(OnShowTimerToolBar), AlwaysEnabledFlag, checkOff )
#endif
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
,
Command( wxT("ShowSpectralSelectionTB"),

View File

@ -0,0 +1,186 @@
/**********************************************************************
Audacity: A Digital Audio Editor
TimerToolBar.cpp
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*//*******************************************************************/
#include "../Audacity.h"
#include "SelectionBar.h"
#include "SelectionBarListener.h"
#include "ToolManager.h"
// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
#include <wx/setup.h> // for wxUSE_* macros
#ifndef WX_PRECOMP
#include <wx/choice.h>
#include <wx/intl.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/valtext.h>
#include <wx/stattext.h>
#endif
#include <wx/statline.h>
#include "SelectionBarListener.h"
#include "SelectionBar.h"
#include "TimerToolBar.h"
//#include "../widgets/AButton.h"
#include "../AudioIO.h"
#include "../AColor.h"
#include "../KeyboardCapture.h"
#include "../Prefs.h"
#include "../Project.h"
#include "../Snap.h"
#include "../widgets/NumericTextCtrl.h"
#include "../AllThemeResources.h"
#if wxUSE_ACCESSIBILITY
#include "../widgets/WindowAccessible.h"
#endif
IMPLEMENT_CLASS(TimerToolBar, ToolBar);
enum {
TimerToolBarFirstID = 2700,
AudioTimeID,
};
BEGIN_EVENT_TABLE(TimerToolBar, ToolBar)
EVT_SIZE(TimerToolBar::OnSize)
EVT_COMMAND(wxID_ANY, EVT_CAPTURE_KEY, TimerToolBar::OnCaptureKey)
END_EVENT_TABLE()
TimerToolBar::TimerToolBar( AudacityProject &project )
: ToolBar(project, TimerBarID, XO("TimerToolBar"), wxT("TimerToolBar"),true),
mListener(NULL), mAudioTime(NULL)
{
mRate = (double) gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"),
AudioIO::GetOptimalSupportedSampleRate());
}
TimerToolBar::~TimerToolBar()
{
}
TimerToolBar &TimerToolBar::Get( AudacityProject &project )
{
auto &toolManager = ToolManager::Get( project );
return *static_cast<TimerToolBar*>( toolManager.GetToolBar(TimerBarID) );
}
const TimerToolBar &TimerToolBar::Get( const AudacityProject &project )
{
return Get( const_cast<AudacityProject&>( project )) ;
}
void TimerToolBar::Create(wxWindow * parent)
{
ToolBar::Create(parent);
UpdatePrefs();
}
NumericTextCtrl * TimerToolBar::AddTime(
const TranslatableString &Name, int id)
{
auto formatName = mListener ? mListener->AS_GetSelectionFormat()
: NumericFormatSymbol{};
auto pCtrl = safenew NumericTextCtrl(
this, id, NumericConverter::TIME, formatName, 0.0, mRate);
pCtrl->SetName(Name);
return pCtrl;
}
void TimerToolBar::Populate()
{
mAudioTime = AddTime(XO("Audio Position"), AudioTimeID);
Add(mAudioTime, 0, wxALIGN_CENTER);
Layout();
SetMinSize(GetSizer()->GetMinSize());
}
void TimerToolBar::UpdatePrefs()
{
SetLabel(XO("TimerToolBar"));
ToolBar::UpdatePrefs();
}
void TimerToolBar::OnSize(wxSizeEvent & event)
{
event.Skip();
int sh = GetSize().GetHeight() - 10;
if (mAudioTime)
{
mAudioTime->SetDigitSize( sh*.63, sh );
wxSize ms = mAudioTime->GetSize();
//int mw = ms.GetWidth();
//mAudioTime->SetMinSize(GetSizer()->GetMinSize());
//printf("(size) %i %i\n", GetSizer()->GetSize());
}
//SetMinSize( GetSizer()->GetMinSize() );
//Layout();
//Fit();
//Refresh(true);
//evt.Skip();
}
void TimerToolBar::SetTimes(double audio)
{
mAudioTime->SetValue(audio);
}
void TimerToolBar::OnFocus(wxFocusEvent &event)
{
KeyboardCapture::OnFocus(*this, event);
}
void TimerToolBar::OnCaptureKey(wxCommandEvent &event)
{
wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject();
wxWindow *w = FindFocus();
int keyCode = kevent->GetKeyCode();
// Convert numeric keypad entries.
if ((keyCode >= WXK_NUMPAD0) && (keyCode <= WXK_NUMPAD9)) {
keyCode -= WXK_NUMPAD0 - '0';
}
if (keyCode >= '0' && keyCode <= '9') {
return;
}
event.Skip();
}
void TimerToolBar::SetDocked(ToolDock *dock, bool pushed) {
ToolBar::SetDocked(dock, pushed);
Fit();
}
void TimerToolBar::OnSnapTo(wxCommandEvent & WXUNUSED(event))
{
mListener->AS_SetSnapTo(mSnapTo->GetSelection());
}
static RegisteredToolbarFactory factory{ TimerBarID,
[]( AudacityProject &project ){
return ToolBar::Holder{ safenew TimerToolBar{ project } }; }
};

View File

@ -0,0 +1,63 @@
/**********************************************************************
Audacity: A Digital Audio Editor
TimerToolBar.h
Jonatã Bolzan Loss
**********************************************************************/
#ifndef __AUDACITY_BIG_COUNTER__
#define __AUDACITY_BIG_COUNTER__
#include <wx/defs.h>
#include "ToolBar.h"
#include "ToolManager.h"
class SelectionBarListener;
class NumericTextCtrl;
class TimerToolBar final : public ToolBar {
public:
TimerToolBar(AudacityProject &project);
virtual ~TimerToolBar();
static TimerToolBar &Get(AudacityProject &project);
static const TimerToolBar &Get(const AudacityProject &project);
void Create(wxWindow *parent) override;
void Populate() override;
void Repaint(wxDC * WXUNUSED(dc)) override {};
void EnableDisableButtons() override {};
void UpdatePrefs() override;
void SetTimes(double audio);
void RegenerateTooltips() override {};
private:
NumericTextCtrl * AddTime( const TranslatableString &Name, int id);
void OnFocus(wxFocusEvent &event);
void OnCaptureKey(wxCommandEvent &event);
void OnSize(wxSizeEvent &evt);
void OnSnapTo(wxCommandEvent & event);
virtual void SetDocked(ToolDock *dock, bool pushed) override;
SelectionBarListener * mListener;
double mRate;
double mAudio;
NumericTextCtrl *mAudioTime;
wxChoice *mSnapTo;
public:
DECLARE_CLASS(TimerToolBar)
DECLARE_EVENT_TABLE()
};
#endif

View File

@ -68,6 +68,7 @@ enum
{
NoBarID = -1,
TransportBarID,
TimerBarID,
ToolsBarID,
MeterBarID,
RecordMeterBarID,

View File

@ -178,7 +178,7 @@ void ToolFrame::OnPaint( wxPaintEvent & WXUNUSED(event) )
dc.SetPen( theTheme.Colour( clrTrackPanelText) );
#if !defined(__WXMAC__)
wxBrush clearer( theTheme.Colour( clrMedium ));
dc.SetBackground( clearer );
dc.SetBackground( clearer );
dc.Clear();
dc.SetBrush( *wxTRANSPARENT_BRUSH );
dc.DrawRectangle( 0, 0, sz.GetWidth(), sz.GetHeight() );
@ -563,7 +563,7 @@ void ToolManager::Reset()
}
// Decide which dock.
if (ndx == SelectionBarID
if (ndx == SelectionBarID
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|| ndx == SpectralSelectionBarID
#endif
@ -631,7 +631,7 @@ void ToolManager::Reset()
// This bar is undocked and invisible.
// We are doing a reset toolbars, so even the invisible undocked bars should
// be moved somewhere sensible. Put bar near center of window.
// If there were multiple hidden toobars the ndx * 10 adjustment means
// If there were multiple hidden toobars the ndx * 10 adjustment means
// they won't overlap too much.
floater->CentreOnParent( );
floater->Move( floater->GetPosition() + wxSize( ndx * 10 - 200, ndx * 10 ));
@ -721,7 +721,7 @@ void ToolManager::ReadConfig()
{
ToolBar *bar = mBars[ ndx ].get();
//wxPoint Center = mParent->GetPosition() + (mParent->GetSize() * 0.33);
//wxPoint Center(
//wxPoint Center(
// wxSystemSettings::GetMetric( wxSYS_SCREEN_X ) /2 ,
// wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) /2 );
@ -730,18 +730,20 @@ void ToolManager::ReadConfig()
bool bShownByDefault = true;
int defaultDock = TopDockID;
if( ndx == SelectionBarID )
defaultDock = BotDockID;
if( ndx == MeterBarID )
bShownByDefault = false;
if( ndx == ScrubbingBarID )
bShownByDefault = false;
if( ndx == TimerBarID )
bShownByDefault = false;
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
if( ndx == SpectralSelectionBarID ){
defaultDock = BotDockID;
bShownByDefault = false; // Only show if asked for.
bShownByDefault = false; // Only show if asked for.
}
#endif
@ -751,13 +753,13 @@ void ToolManager::ReadConfig()
gPrefs->Read( wxT("Dock"), &dock, -1); // legacy version of DockV2
else
gPrefs->Read( wxT("DockV2"), &dock, -1);
const bool found = (dock != -1);
if (found)
someFound = true;
if (!found)
dock = defaultDock;
ToolDock *d;
ToolBarConfiguration::Legacy *pLegacy;
switch(dock)
@ -833,7 +835,7 @@ void ToolManager::ReadConfig()
#endif
// make a note of docked and hidden toolbars
if (!show[ndx])
dockedAndHidden.push_back(bar);
dockedAndHidden.push_back(bar);
if (!ordered)
{
@ -955,7 +957,7 @@ void ToolManager::WriteConfig()
// its value is compatible with versions 2.1.3 to 2.2.1 which have this bug.
ToolDock* dock = bar->GetDock(); // dock for both shown and hidden toolbars
gPrefs->Write( wxT("DockV2"), static_cast<int>(dock == mTopDock ? TopDockID : dock == mBotDock ? BotDockID : NoDockID ));
gPrefs->Write( wxT("Dock"), static_cast<int>( to ? TopDockID : bo ? BotDockID : NoDockID));
dock = to ? mTopDock : bo ? mBotDock : nullptr; // dock for shown toolbars
@ -1184,11 +1186,11 @@ void ToolManager::OnMouse( wxMouseEvent & event )
br.SetPosition( mBotDock->GetParent()->ClientToScreen( br.GetPosition() ) );
// Add half the bar height. We could use the actual bar height, but that would be confusing as a
// Add half the bar height. We could use the actual bar height, but that would be confusing as a
// bar removed at a place might not dock back there if just let go.
// Also add 5 pixels in horizontal direction, so that a click without a move (or a very small move)
// Also add 5 pixels in horizontal direction, so that a click without a move (or a very small move)
// lands back where we started.
pos += wxPoint( 5, 20 );
pos += wxPoint( 5, 20 );
// To find which dock, rather than test against pos, test against the whole dragger rect.

View File

@ -1415,6 +1415,14 @@ void NumericTextCtrl::SetValue(double newValue)
ControlsToValue();
}
void NumericTextCtrl::SetDigitSize(int width, int height)
{
mDigitBoxW = width;
mDigitBoxH = height;
Layout();
Fit();
}
void NumericTextCtrl::SetReadOnly(bool readOnly)
{
mReadOnly = readOnly;

View File

@ -204,6 +204,7 @@ class NumericTextCtrl final : public wxControl, public NumericConverter
void SetFieldFocus(int /* digit */);
void SetDigitSize(int width, int height);
void SetReadOnly(bool readOnly = true);
void EnableMenu(bool enable = true);

View File

@ -491,6 +491,7 @@
<ClCompile Include="..\..\..\src\toolbars\MeterToolBar.cpp" />
<ClCompile Include="..\..\..\src\toolbars\MixerToolBar.cpp" />
<ClCompile Include="..\..\..\src\toolbars\SelectionBar.cpp" />
<ClCompile Include="..\..\..\src\toolbars\TimerToolBar.cpp" />
<ClCompile Include="..\..\..\src\toolbars\ToolBar.cpp" />
<ClCompile Include="..\..\..\src\toolbars\ToolDock.cpp" />
<ClCompile Include="..\..\..\src\toolbars\ToolManager.cpp" />

View File

@ -806,6 +806,9 @@
<ClCompile Include="..\..\..\src\toolbars\SelectionBar.cpp">
<Filter>src\toolbars</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\toolbars\TimerToolBar.cpp">
<Filter>src\toolbars</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\toolbars\ToolBar.cpp">
<Filter>src\toolbars</Filter>
</ClCompile>