mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-10 09:01:13 +02:00
Facade class for basic UI, injection of a wxWidgets implementation...
... but none of the methods is defined yet. The intention is to inject dependencies on wxWidgets (or other) toolkit so that lower-level files have less build dependency on wxCore classes or on the event loop. Original commit: d20cf012556a819e68515d86bb66a2c047007539 Signed-off-by: Panagiotis Vasilopoulos <hello@alwayslivid.com>
This commit is contained in:
parent
6daf0a29b7
commit
2d0394796e
@ -7,6 +7,7 @@ set( LIBRARIES
|
|||||||
lib-strings
|
lib-strings
|
||||||
lib-utility
|
lib-utility
|
||||||
lib-components
|
lib-components
|
||||||
|
lib-basic-ui
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach( LIBRARY ${LIBRARIES} )
|
foreach( LIBRARY ${LIBRARIES} )
|
||||||
|
25
libraries/lib-basic-ui/BasicUI.cpp
Normal file
25
libraries/lib-basic-ui/BasicUI.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*!********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
@file BasicUI.cpp
|
||||||
|
|
||||||
|
Paul Licameli
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
#include "BasicUI.h"
|
||||||
|
|
||||||
|
namespace BasicUI {
|
||||||
|
Services::~Services() = default;
|
||||||
|
|
||||||
|
static Services *theInstance = nullptr;
|
||||||
|
|
||||||
|
Services *Get() { return theInstance; }
|
||||||
|
|
||||||
|
Services *Install(Services *pInstance)
|
||||||
|
{
|
||||||
|
auto result = theInstance;
|
||||||
|
theInstance = pInstance;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
47
libraries/lib-basic-ui/BasicUI.h
Normal file
47
libraries/lib-basic-ui/BasicUI.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*!********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
@file BasicUI.h
|
||||||
|
@brief Toolkit-neutral facade for basic user interface services
|
||||||
|
|
||||||
|
Paul Licameli
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
#ifndef __AUDACITY_BASIC_UI__
|
||||||
|
#define __AUDACITY_BASIC_UI__
|
||||||
|
|
||||||
|
namespace BasicUI {
|
||||||
|
|
||||||
|
//! @name Types used in the Services interface
|
||||||
|
//! @{
|
||||||
|
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
//! Abstract class defines a few user interface services, not mentioning particular toolkits
|
||||||
|
/*! The intention is that the application supplies a concrete implementation at
|
||||||
|
startup. Most code will not use this class directly, but call the inline
|
||||||
|
functions that follow. */
|
||||||
|
class BASIC_UI_API Services {
|
||||||
|
public:
|
||||||
|
virtual ~Services();
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Fetch the global instance, or nullptr if none is yet installed
|
||||||
|
BASIC_UI_API Services *Get();
|
||||||
|
|
||||||
|
//! Install an implementation; return the previously installed instance
|
||||||
|
BASIC_UI_API Services *Install(Services *pInstance);
|
||||||
|
|
||||||
|
/*! @name Functions that invoke global Services
|
||||||
|
These dispatch to the global Services, if supplied. If none was supplied,
|
||||||
|
they are mostly no-ops, with exceptions as noted. All should be called on
|
||||||
|
the main thread only, except as noted.
|
||||||
|
*/
|
||||||
|
//! @{
|
||||||
|
|
||||||
|
//! @}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
23
libraries/lib-basic-ui/CMakeLists.txt
Normal file
23
libraries/lib-basic-ui/CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#[[
|
||||||
|
This library defines a facade interface, BasicUI::Services, for a few basic
|
||||||
|
interactions with the user, such as showing simple dialog boxes, and for
|
||||||
|
enqueuing actions to the event loop, and yielding to to the event dispatcher.
|
||||||
|
|
||||||
|
The interface makes no mention of classes in wxWidgets. Using this library
|
||||||
|
instead of making direct use of wxWidgets enlarges the parts of the program
|
||||||
|
that are toolkit neutral.
|
||||||
|
|
||||||
|
There is a global pointer to an instance of Services, and the main program is
|
||||||
|
expected, at startup, to create a static instance of a subclass of Services and
|
||||||
|
set the pointer. If it does not, then calls to the non-member functions in
|
||||||
|
namespace BasicUI are no-ops.
|
||||||
|
]]#
|
||||||
|
|
||||||
|
set( SOURCES
|
||||||
|
BasicUI.cpp
|
||||||
|
BasicUI.h
|
||||||
|
)
|
||||||
|
audacity_library( lib-basic-ui "${SOURCES}"
|
||||||
|
""
|
||||||
|
"" ""
|
||||||
|
)
|
@ -110,6 +110,7 @@ It handles initialization and termination by subclassing wxApp.
|
|||||||
#include "tracks/ui/Scrubbing.h"
|
#include "tracks/ui/Scrubbing.h"
|
||||||
#include "widgets/FileConfig.h"
|
#include "widgets/FileConfig.h"
|
||||||
#include "widgets/FileHistory.h"
|
#include "widgets/FileHistory.h"
|
||||||
|
#include "widgets/wxWidgetsBasicUI.h"
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_EASY_CHANGE_KEY_BINDINGS
|
#ifdef EXPERIMENTAL_EASY_CHANGE_KEY_BINDINGS
|
||||||
#include "prefs/KeyConfigPrefs.h"
|
#include "prefs/KeyConfigPrefs.h"
|
||||||
@ -975,17 +976,22 @@ bool AudacityApp::OnInit() {
|
|||||||
// Ensure we have an event loop during initialization
|
// Ensure we have an event loop during initialization
|
||||||
wxEventLoopGuarantor eventLoop;
|
wxEventLoopGuarantor eventLoop;
|
||||||
|
|
||||||
// Fire up SQLite
|
// Inject basic GUI services behind the facade
|
||||||
if (!ProjectFileIO::InitializeSQL())
|
{
|
||||||
this->CallAfter([] {
|
static wxWidgetsBasicUI uiServices;
|
||||||
::AudacityMessageBox(
|
(void)BasicUI::Install(&uiServices);
|
||||||
XO("SQLite library failed to initialize. Audacity cannot continue."));
|
}
|
||||||
QuitAudacity(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// Fire up SQLite
|
||||||
|
if ( !ProjectFileIO::InitializeSQL() )
|
||||||
|
this->CallAfter([]{
|
||||||
|
::AudacityMessageBox(
|
||||||
|
XO("SQLite library failed to initialize. Audacity cannot continue.") );
|
||||||
|
QuitAudacity( true );
|
||||||
|
});
|
||||||
|
|
||||||
// cause initialization of wxWidgets' global logger target
|
// cause initialization of wxWidgets' global logger target
|
||||||
(void)AudacityLogger::Get();
|
(void)AudacityLogger::Get();
|
||||||
|
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
// Disable window animation
|
// Disable window animation
|
||||||
|
1082
src/CMakeLists.txt
1082
src/CMakeLists.txt
File diff suppressed because it is too large
Load Diff
12
src/widgets/wxWidgetsBasicUI.cpp
Normal file
12
src/widgets/wxWidgetsBasicUI.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/*!********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
@file wxWidgetsBasicUI.cpp
|
||||||
|
|
||||||
|
Paul Licameli
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
#include "wxWidgetsBasicUI.h"
|
||||||
|
|
||||||
|
wxWidgetsBasicUI::~wxWidgetsBasicUI() = default;
|
23
src/widgets/wxWidgetsBasicUI.h
Normal file
23
src/widgets/wxWidgetsBasicUI.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*!********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
@file wxWidgetsBasicUI.h
|
||||||
|
@brief Implementation of BasicUI using wxWidgets
|
||||||
|
|
||||||
|
Paul Licameli
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
#ifndef __WXWIDGETS_BASIC_UI__
|
||||||
|
#define __WXWIDGETS_BASIC_UI__
|
||||||
|
|
||||||
|
#include "BasicUI.h"
|
||||||
|
|
||||||
|
//! An implementation of BasicUI::Services in terms of the wxWidgets toolkit
|
||||||
|
/*! This is a singleton that doesn't need AUDACITY_DLL_API visibility */
|
||||||
|
class wxWidgetsBasicUI final : public BasicUI::Services {
|
||||||
|
public:
|
||||||
|
~wxWidgetsBasicUI() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user