MuseScore  3.4
Music composition and notation
fraction.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2009 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __PLUGIN_API_FRACTION_H__
14 #define __PLUGIN_API_FRACTION_H__
15 
16 #include "libmscore/fraction.h"
17 
18 namespace Ms {
19 namespace PluginAPI {
20 
21 //---------------------------------------------------------
22 // FractionWrapper
30 //---------------------------------------------------------
31 
32 class FractionWrapper : public QObject {
33  Q_OBJECT
35  Q_PROPERTY(int numerator READ numerator)
37  Q_PROPERTY(int denominator READ denominator)
42  Q_PROPERTY(int ticks READ ticks) // FIXME: fraction transition
44  Q_PROPERTY(QString str READ toString)
45 
47 
49  public slots:
50  void setFraction(Fraction _f) { f = _f; }
51 
52  public:
53  FractionWrapper() = default;
54  FractionWrapper(const Ms::Fraction& _f) : f(_f) {}
55 
56  Ms::Fraction fraction() const { return f; }
57  int numerator() const { return f.numerator(); }
58  int denominator() const { return f.denominator(); }
59  int ticks() const { return f.ticks(); }
60  QString toString() const { return f.toString(); }
62  };
63 
64 //---------------------------------------------------------
65 // wrap
68 //---------------------------------------------------------
69 
71  {
72  FractionWrapper* w = new FractionWrapper(f);
73  // All wrapper objects should belong to JavaScript code.
74  QQmlEngine::setObjectOwnership(w, QQmlEngine::JavaScriptOwnership);
75  return w;
76  }
77 
78 } // namespace PluginAPI
79 } // namespace Ms
80 
81 #endif
int numerator() const
Definition: fraction.h:62
int denominator() const
Definition: fraction.h:58
int denominator() const
Definition: fraction.h:63
FractionWrapper * wrap(Ms::Fraction f)
Definition: fraction.h:70
QString toString() const
Definition: fraction.h:244
Ms::Fraction fraction() const
Definition: fraction.h:56
int ticks() const
Definition: fraction.h:59
FractionWrapper(const Ms::Fraction &_f)
Definition: fraction.h:54
QString toString() const
Definition: fraction.h:60
Definition: aeolus.cpp:26
void setFraction(Fraction _f)
Definition: fraction.h:50
int ticks() const
Definition: fraction.h:228
Definition: fraction.h:46
Ms::Fraction f
Definition: fraction.h:46
Fraction object available to QML plugins.
Definition: fraction.h:32
int numerator() const
Definition: fraction.h:57
QString str
String representation of this fraction.
Definition: fraction.h:44