Base toolkit upon which the software is built. More...
Detailed Description
Base toolkit upon which the software is built.
TODO. list in src/plugins/score-plugin-avnd/Crousti/Concepts.hpp#L139.
This namespace contains only non-domain specific classes and utilities : serialization, model-view, documents, etc.
It is split in two folders :
coreis the internal mechanic to set-up the software : the actual widget classes, the plug-in loading code, etc.scoreis the "public" part of the score API : this code can be used by plug-ins.
This file contains facilities to serialize an object into a QJsonObject.
This file contains base types for the events and transitions of the state machines in score.
See the documentation for explanation of the general pattern
Namespaces | |
| namespace | gfx |
| Graphics rendering pipeline for ossia score. | |
Typedefs | |
| using | JsonWriter = ossia::json_writer |
| using | GlobalSettingsPresenter = SettingsDelegatePresenter< SettingsDelegateModel > |
| using | ActionGroupKey = StringKey< ActionGroup > |
| using | ActionKey = StringKey< Action > |
| using | ActionConditionKey = StringKey< score::ActionCondition > |
| template<typename T1 , typename T2 > | |
| using | enable_if_base_of = std::enable_if< std::is_base_of< T1, T2 >::value, void * > |
| using | FindCommandKey = std::pair< CommandGroupKey, CommandKey > |
| using | MaybeDocument = const score::DocumentContext * |
| template<typename Component > | |
| using | ComponentHierarchy = ComponentHierarchyManager< Component, typename Component::model_t, typename Component::component_t > |
| template<typename Component , bool HasOwnership = true> | |
| using | PolymorphicComponentHierarchy = PolymorphicComponentHierarchyManager< Component, typename Component::model_t, typename Component::component_t, typename Component::component_factory_list_t, HasOwnership > |
| template<typename Model > | |
| using | HierarchicalComponents = HierarchicalMember< Model, score::Components, &Model::components > |
| using | InterfaceKey = UuidKey< InterfaceBase > |
| using | ProjectSettingsPresenter = SettingsDelegatePresenter< ProjectSettingsModel > |
| using | ProjectSettingsView = SettingsDelegateView< ProjectSettingsModel > |
| using | PluginKey = UuidKey< Plugin > |
| using | SettingsDelegateFactoryList = InterfaceList< score::SettingsDelegateFactory > |
| template<typename T > | |
| using | sp = SettingsParameterMetadata< T > |
| using | GlobalSettingsView = SettingsDelegateView< SettingsDelegateModel > |
| using | uuid_t = uuids::uuid |
| using | any_map = ossia::any_map |
| using | any_serializer_map = score::hash_map< std::string, std::unique_ptr< any_serializer > > |
| using | Press_Event = NumberedEvent< 1 > |
| using | Move_Event = NumberedEvent< 2 > |
| using | Release_Event = NumberedEvent< 3 > |
| using | Cancel_Event = NumberedEvent< 4 > |
| using | Shift_Event = NumberedEvent< 5 > |
| using | Press_Transition = MatchedTransition< Press_Event > |
| using | Move_Transition = MatchedTransition< Move_Event > |
| using | Release_Transition = MatchedTransition< Release_Event > |
| using | Cancel_Transition = MatchedTransition< Cancel_Event > |
| using | ShiftTransition = MatchedTransition< Shift_Event > |
| using | comparable_function = std::shared_ptr< std::function< void()> > |
| using | id_generator = score::linear_id_generator |
| template<class Key , class T > | |
| using | hash_map = ossia::hash_map< Key, T > |
| using | ZipProgress = std::function< bool(int, int)> |
| Called with (files written, total). Return false to abort the archive. | |
Enumerations | |
| enum | Modifier_tagme { Click = 100 , Move = 200 , Release = 300 } |
| enum class | FileKind { Unknown , Audio , Video , Image , Midi , Model3D , Shader , Script , Data , Folder , Plugin } |
| enum class | CopyMode { Copy , Symlink , Hardlink } |
| How a collected file is materialized in the project folder. More... | |
| enum | TimeMode { Bars , Seconds , Flicks } |
Functions | |
| const ApplicationContext & | AppContext () |
| const GUIApplicationContext & | GUIAppContext () |
| const ApplicationComponents & | AppComponents () |
| void | setQApplicationMetadata () |
| template<typename RedoFun > | |
| void | loadCommandStack (const score::ApplicationComponents &components, DataStreamWriter &writer, score::CommandStack &stack, RedoFun redo_fun) |
| QString | newProcessedFilePath (const QString &sourceFile, const QDir &destination) |
| Obtains a new file name in the project folder to save a processed file. | |
| Id< score::DocumentModel > | getStrongId (const std::vector< score::Document * > &v) |
| ApplicationServices & | AppServices () noexcept |
| QBrush | bangFill (const QPalette &fallback, bool lit) |
| The fill of a bang: the circle an impulse gets. | |
| void | retargetInputMethod (QObject *target) noexcept |
Point the platform input method at target. | |
| void | watchSceneInputMethod (QGraphicsScene &scene) |
| Keep the platform input method in sync with the scene's focus item. | |
| QPointer< QGraphicsProxyWidget > & | currentRightClickWidget () |
| The one type-in box a right-click may have open. | |
| void | closeRightClickWidget () |
| Takes down whatever right-click box is open, if any. | |
| QGraphicsProxyWidget * | showTypeInBox (QGraphicsScene &scene, QPointF scenePos, const std::vector< TypeInField > &fields, std::function< void(int, double)> onChanged, std::function< void()> onFinished) |
| The type-in box a right-click raises over a control with more than one number in it. | |
| QString | toNumber (double v) noexcept |
| QString | toNumber (int v) noexcept |
| template<typename T > | |
| double | operator* (double lhs, const ValueAssigner< T > &rhs) noexcept |
| template<typename T > | |
| T & | component (const score::Components &c) |
| component Fetch a Component from Components by type | |
| template<typename T > | |
| T * | findComponent (const score::Components &c) noexcept |
| findComponent Tryies to fetch a Component from Components by type. | |
| template<typename T > | |
| auto | id (const Path< T > &path) |
| SCORE_LIB_BASE_EXPORT QString | addonArchitecture () |
| addonArchitecture | |
| template<typename DocPlugin > | |
| auto & | addDocumentPlugin (score::Document &doc) |
| void | debug_types (const InterfaceBase *orig, const InterfaceBase *repl) noexcept |
| std::vector< Plugin_QtInterface * > & | staticPlugins () |
| template<typename T , typename Model > | |
| void | setupDefaultSettings (QSettings &set, const T &tuple, Model &model) |
| score::hash_map< std::string, std::unique_ptr< any_serializer > > & | anySerializers () |
| The serializers for types that go in ossia::any should fit in here. | |
| template<typename Obj , std::size_t N> | |
| bool | parseJsonField (const Obj &obj, const char(&key)[N], QString &out) |
Read one field of a JSON object, or leave out alone. | |
| template<typename Obj , std::size_t N> | |
| bool | parseJsonField (const Obj &obj, const char(&key)[N], bool &out) |
| template<typename T > | |
| bool | parseJsonNumber (double d, T &out) noexcept |
|
template<typename Obj , std::size_t N, typename T > requires ( (std::is_arithmetic_v<T> || std::is_enum_v<T>) && !std::is_same_v<T, bool>) | |
| bool | parseJsonField (const Obj &obj, const char(&key)[N], T &out) |
| template<typename Obj , std::size_t N> | |
| bool | parseJsonField (const Obj &obj, const char(&key)[N], QSize &out) |
| template<typename Object > | |
| auto | unmarshall (const JSONReader &obj) |
| const StringConstants & | StringConstant () |
| template<typename T > | |
| void | serialize_dyn_impl (DataStream::Serializer &v, const T &t) |
| template<typename T > | |
| void | serialize_dyn_impl (JSONObject::Serializer &v, const T &t) |
| template<typename TheClass > | |
| void | serialize_dyn (const VisitorVariant &vis, const TheClass &s) |
| template<typename TheClass > | |
| TheClass & | deserialize_dyn (const VisitorVariant &vis, TheClass &s) |
| template<typename TheClass > | |
| TheClass | deserialize_dyn (const VisitorVariant &vis) |
| template<typename Functor > | |
| auto | deserialize_dyn (const VisitorVariant &vis, Functor &&fun) |
| template<typename Type , typename Object > | |
| auto | marshall (const Object &obj) |
| marshall Serializes a single object | |
| template<typename Object > | |
| auto | unmarshall (const rapidjson::Value &obj) |
| template<typename Object > | |
| auto | unmarshall (const QByteArray &arr) |
| template<typename Transition , typename SourceState , typename TargetState , typename... Args> | |
| Transition * | make_transition (SourceState source, TargetState dest, Args &&... args) |
| std::pair< int, int > | availableCudaDevice () noexcept |
| bool | availableCudaToolkitDylibs (int major, int minor) noexcept |
| void | setCursorPos (QPointF pos) noexcept |
| void | moveCursorPos (QPointF pos) noexcept |
| QPoint | globalPos (QMouseEvent *event) |
| QPointF | globalPos (QWidget *viewport, QGraphicsSceneMouseEvent *event) |
| void | hideCursor (bool hasCursor) |
| void | showCursor () |
| template<typename T > | |
| void | clearAndDeleteLater (T &container, delete_later< T > &storage) noexcept |
| template<typename T > | |
| auto | clearAndDeleteLater (T &container) noexcept |
| std::optional< ossia::dylib_loader > | try_load_library (const char *name) noexcept |
| dlopen a library, reporting absence instead of throwing. | |
| std::optional< ossia::dylib_loader > | try_load_library (std::vector< std::string_view > names) noexcept |
Loads the first of names that can be found. | |
| QString | addUniqueSuffix (const QString &fileName) |
| QString | locateFilePath (const QString &filename) noexcept |
| QString | locateFilePath (const QString &filename, const score::DocumentContext &ctx) noexcept |
| QString | relativizeFilePath (const QString &filename, const score::DocumentContext &ctx) noexcept |
| bool | fast_contains (std::string_view data, std::string_view pattern) |
| bool | fileContains (QFile &f, std::string_view pattern) |
| QString | pickerStartFolder (const QString ¤t, const score::DocumentContext &ctx) noexcept |
| QString | pickerStartFolder (const QString ¤t) noexcept |
| QByteArray | mapAsByteArray (QFile &f) noexcept |
| std::string_view | mapAsStringView (QFile &f) noexcept |
| std::string | readFileAsString (QFile &f) noexcept |
| QString | readFileAsQString (QFile &f) noexcept |
| QStringList | list_ipv4_for_connecting () noexcept |
| QStringList | list_ipv4_for_listening () noexcept |
| bool | detectSystemEnrolment () |
| bool | isProjectRelativePath (const QString &path) noexcept |
| True if the path is one of the tokens score understands as a root. | |
| bool | isLibraryRelativePath (const QString &path) noexcept |
| FileKind | guessFileKind (const QString &path) noexcept |
| QString | mediaSubfolder (FileKind k) noexcept |
| Name of the project sub-folder collected files of that kind go into. | |
| PathRoots | pathRoots (const score::DocumentContext &ctx) noexcept |
| Roots of a live document. | |
| QString | locateFilePath (const QString &filename, const PathRoots &roots) noexcept |
| bool | isUnderFolder (const QString &path, const QString &root) noexcept |
| QString | relativizeFilePath (const QString &filename, const PathRoots &roots) noexcept |
| QString | sanitizeFileName (const QString &name) noexcept |
| bool | sameFileContents (const QString &lhs, const QString &rhs) noexcept |
| bool | materializeFile (const QString &source, const QString &destination, CopyMode mode, QString &error) |
| QString | pickerStartFolder (const QString ¤t, const PathRoots &roots, const QString &userDocuments, const QString &workingDir) noexcept |
| void | for_all_files (std::string_view root, std::function< void(std::string_view)> f) |
| template<typename Map > | |
| void | optimize_hash_map (Map &map) |
| template<typename T > | |
| indirect_iterator< T > | make_indirect_iterator (const T &it) noexcept |
| template<typename T > | |
| indirect_ptr_iterator< T > | make_indirect_ptr_iterator (const T &it) |
| template<typename T > | |
| indirect_map_iterator< T > | make_indirect_map_iterator (const T &it) |
| template<typename CastTo , typename T > | |
| indirect_cast_map_iterator< T, CastTo > | make_indirect_cast_map_iterator (const T &it) |
| template<typename T > | |
| auto | wrap_indirect (T &container) |
| bool | writeZipArchive (const QString &destination, const std::vector< ZipEntry > &entries, int level, QString &error, const ZipProgress &progress={}) |
Write entries into a zip archive at destination. | |
| void | setCursor (Qt::CursorShape c) |
| setCursor sets the cursor safely. | |
| SCORE_LIB_BASE_EXPORT const QPalette & | transparentPalette () |
| void | setHelp (QWidget *widg, const QString &shorttxt, const QString &txt) |
| void | setHelp (QAction *widg, const QString &shorttxt, const QString &txt) |
| void | setHelp (QWidget *widg, const QString &txt) |
| void | setHelp (QAction *widg, const QString &txt) |
| void | installDragImageWorkaround () |
| Keep Qt's temporary drag-image element out of sight. | |
| void | setItemViewDragPixmap (QDrag &drag, QAbstractItemView &view, const QStyleOptionViewItem &option, const QModelIndexList &indexes) |
| Give a QDrag the drag image QAbstractItemView::startDrag would have made. | |
| int | question (QWidget *parent, const QString &title, const QString &text) |
| int | information (QWidget *parent, const QString &title, const QString &text) |
| int | warning (QWidget *parent, const QString &title, const QString &text) |
| QImage | get_image (QString str, QString svg={}) |
| QPixmap | get_pixmap (QString str, QString svg={}) |
| QCursor | get_cursor (QString str, double hotspot_x, double hostpot_y) |
| void | setGlobalTimeMode (TimeMode mode) |
Variables | |
| thread_local char | g_file_search_buffer [16384] |
| std::array< QString, 5 > | arrow_name |
| TimeMode | globalTimeMode = TimeMode::Bars |
Enumeration Type Documentation
◆ CopyMode
|
strong |
◆ FileKind
|
strong |
Category of an external file referenced by a document. Drives the sub-folder a collected file is copied into.
Function Documentation
◆ addonArchitecture()
| SCORE_LIB_BASE_EXPORT QString score::addonArchitecture | ( | ) |
addonArchitecture
- Returns
- Architecture for the system score is compiled for.
◆ bangFill()
| QBrush score::bangFill | ( | const QPalette & | fallback, |
| bool | lit | ||
| ) |
The fill of a bang: the circle an impulse gets.
Shared by score::QGraphicsButton in the node view and the device explorer's tree rows and address panel.
Falls back to the palette when the skin has no brushes to give – a no-GUI application context leaves them default-constructed.
- Parameters
-
lit The pressed state.
◆ component()
| T & score::component | ( | const score::Components & | c | ) |
component Fetch a Component from Components by type
- Returns
- The component.
The component must have a member static const constexpr bool is_unique = true in order to use this function.
This guarantees that there will be a single component of a given type in the Components.
◆ currentRightClickWidget()
| QPointer< QGraphicsProxyWidget > & score::currentRightClickWidget | ( | ) |
The one type-in box a right-click may have open.
Right-clicking a second control – or the same one twice – used to leave the first box floating over the scene with nobody owning it: it is parented to the scene, not to the control, so nothing took it down.
A QPointer, so that a box torn down by its own control leaves nothing dangling here.
◆ findComponent()
|
noexcept |
findComponent Tryies to fetch a Component from Components by type.
This works similarly to components ; instead of aborting, it returns a null pointer if the component does not exist.
- See also
- components
◆ guessFileKind()
|
noexcept |
Guess a file's kind from its extension. Never fails: unknown extensions map to FileKind::Unknown.
◆ installDragImageWorkaround()
| void score::installDragImageWorkaround | ( | ) |
Keep Qt's temporary drag-image element out of sight.
No-op outside of WebAssembly. Idempotent, and safe to call before the platform plugin has built its shadow root.
◆ isUnderFolder()
|
noexcept |
True when path is folder itself or lives below it. Both must be absolute. Used as the containment guard by everything that writes or deletes inside a project.
◆ locateFilePath() [1/3]
|
noexcept |
Same, for callers that run before any document exists – a –script file is read while the application is still starting up. <LIBRARY>: is a settings lookup and resolves fine; <PROJECT>: and relative paths have no document to resolve against and are returned untouched.
◆ locateFilePath() [2/3]
|
noexcept |
Resolve a stored path (absolute, document-relative, <PROJECT>: or <LIBRARY>:-prefixed) into an absolute one.
◆ locateFilePath() [3/3]
|
noexcept |
Will also look where the save file is located. TODO in the future also look in a "common" library folder.
◆ marshall()
| auto score::marshall | ( | const Object & | obj | ) |
marshall Serializes a single object
- Parameters
-
obj The object to serialize.
This will create the relevant serialization datatype for Type. For instance, a QByteArray if it is DataStream and a QJSonObject if it is JSONObject
◆ materializeFile()
| bool score::materializeFile | ( | const QString & | source, |
| const QString & | destination, | ||
| CopyMode | mode, | ||
| QString & | error | ||
| ) |
Create destination (and its parent folders) from source according to mode. Returns false and fills error on failure; never overwrites an existing destination.
◆ newProcessedFilePath()
| QString score::newProcessedFilePath | ( | const QString & | sourceFile, |
| const QDir & | destination | ||
| ) |
Obtains a new file name in the project folder to save a processed file.
e.g. if the source file is /tmp/foo.wav, the output may be
/home/myself/Documents/My score project/Processed/foo-0003.wav
◆ parseJsonField()
| bool score::parseJsonField | ( | const Obj & | obj, |
| const char(&) | key[N], | ||
| QString & | out | ||
| ) |
Read one field of a JSON object, or leave out alone.
rapidjson's operator[] and GetString/GetInt/GetDouble are RAPIDJSON_ASSERT: an absent key, or one holding the wrong type, aborts rather than failing. These check presence and type first and report whether the field was usable, which is what a settings object arriving from a script or a saved document needs.
◆ parseJsonNumber()
|
noexcept |
Narrowing a double that does not fit the destination is undefined, so the range is part of the type check.
◆ pickerStartFolder() [1/3]
|
noexcept |
Same, outside of any document (application settings): the library, the user's documents folder, or the working directory.
◆ pickerStartFolder() [2/3]
|
noexcept |
Where a file / folder picker should open for a control whose current value is current (absolute, document-relative, <PROJECT>: or <LIBRARY>:-prefixed, or empty). In order: the folder of the current file (or the current folder itself) if it exists, the document's folder, the library, the user's documents folder, the working directory - the first one that exists. Never empty.
◆ pickerStartFolder() [3/3]
|
noexcept |
Where a file / folder picker should open for a control of this document whose current value is current: see the PathRoots overload.
◆ relativizeFilePath() [1/2]
|
noexcept |
Turn an absolute path into a <PROJECT>: / <LIBRARY>: one when it lives under one of the roots. Paths that are already prefixed, or that live elsewhere, come back unchanged.
◆ relativizeFilePath() [2/2]
|
noexcept |
Will try to convert an absolute path in a relative path from the document's point of view
◆ retargetInputMethod()
|
noexcept |
Point the platform input method at target.
target is the object that should receive keyboard input – for a graphics scene, the QGraphicsView. Passing nullptr falls back to QGuiApplication::focusObject(), which is only correct when the target's window is already the focus window.
No-op outside of WebAssembly. Must be called synchronously from the code handling the user gesture.
◆ sameFileContents()
|
noexcept |
Byte-exact comparison. Two paths pointing at the same file compare equal without being read.
◆ sanitizeFileName()
|
noexcept |
Rewrite name into something creatable on every filesystem score runs on: no reserved characters, no Windows device names, no trailing dot or space, and short enough to survive a deep destination folder. Any directory part is dropped: the result is a single path component.
◆ setItemViewDragPixmap()
| void score::setItemViewDragPixmap | ( | QDrag & | drag, |
| QAbstractItemView & | view, | ||
| const QStyleOptionViewItem & | option, | ||
| const QModelIndexList & | indexes | ||
| ) |
Give a QDrag the drag image QAbstractItemView::startDrag would have made.
Renders the dragged indices through the view's item delegate, the way the default startDrag implementation does. Views that override startDrag and do not set a pixmap otherwise leave QDrag::pixmap() null, which the platform plugin is then free to fill in with whatever it likes.
◆ showTypeInBox()
| QGraphicsProxyWidget * score::showTypeInBox | ( | QGraphicsScene & | scene, |
| QPointF | scenePos, | ||
| const std::vector< TypeInField > & | fields, | ||
| std::function< void(int, double)> | onChanged, | ||
| std::function< void()> | onFinished | ||
| ) |
The type-in box a right-click raises over a control with more than one number in it.
A single spin box can be closed on QAbstractSpinBox::editingFinished, which is what DefaultGraphicsSliderImpl does. Several of them cannot: that signal is also emitted when the focus merely leaves a box, and moving from x to y is such a focus-out. Closing on it made every field but the first unreachable – clicking y took the whole box down.
The box goes away when the focus leaves it as a whole, which is the proxy item losing the scene focus. QApplication::focusWidget() cannot answer that question: a widget embedded in a QGraphicsProxyWidget never becomes the application's focus widget, the view stays it whatever is typed into.
- Parameters
-
onChanged (field index, value), as a field is typed into. onFinished once per field actually edited, when that edit is done: the release that turns the ongoing command into one undo step.
The box registers itself as the one currentRightClickWidget(), so raising any other takes it down.
◆ try_load_library()
|
inlinenoexcept |
dlopen a library, reporting absence instead of throwing.
ossia::dylib_loader only signals failure by throwing from its constructor, which makes it unusable as a direct member of the optional-dependency loaders: a function-try-block around a constructor rethrows when it falls off the end of the handler, so the "unavailable" flag those loaders check is never reached and the exception escapes their instance() accessor instead.
◆ watchSceneInputMethod()
| void score::watchSceneInputMethod | ( | QGraphicsScene & | scene | ) |
Keep the platform input method in sync with the scene's focus item.
No-op outside of WebAssembly.
◆ writeZipArchive()
| bool score::writeZipArchive | ( | const QString & | destination, |
| const std::vector< ZipEntry > & | entries, | ||
| int | level, | ||
| QString & | error, | ||
| const ZipProgress & | progress = {} |
||
| ) |
Write entries into a zip archive at destination.
Aborting or failing leaves no half-written archive behind: the archive is built next to the destination and only moved into place once complete.
level is 0 (store) to 9 (smallest). Media is already compressed, so the default is deliberately low – spending minutes to shave a percent off a folder of video is not a trade anyone wants.
Variable Documentation
◆ arrow_name
| std::array<QString, 5> score::arrow_name |