Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include "actionicon.h"
24 :
25 : #include "dummyparent.h"
26 : #include "iengravingconfiguration.h" // IWYU pragma: keep
27 :
28 : #include "mscore.h"
29 : #include "property.h"
30 : #include "types/typesconv.h"
31 :
32 : using namespace mu;
33 : using namespace muse::draw;
34 : using namespace mu::engraving;
35 :
36 0 : ActionIcon::ActionIcon(DummyParent* parent)
37 0 : : EngravingItem(ElementType::ACTION_ICON, parent)
38 : {
39 0 : m_iconFont = Font(configuration()->iconsFontFamily(), Font::Type::Icon);
40 0 : m_iconFont.setPointSizeF(UI_ICONS_DEFAULT_FONT_SIZE);
41 0 : }
42 :
43 0 : ActionIcon* ActionIcon::clone() const
44 : {
45 0 : return new ActionIcon(*this);
46 : }
47 :
48 0 : void ActionIcon::setActionType(ActionIconType val)
49 : {
50 0 : m_actionType = val;
51 0 : }
52 :
53 0 : ActionIconType ActionIcon::actionType() const
54 : {
55 0 : return m_actionType;
56 : }
57 :
58 0 : const muse::TranslatableString& ActionIcon::title() const
59 : {
60 0 : return TConv::userName(m_actionType);
61 : }
62 :
63 0 : char16_t ActionIcon::icon() const
64 : {
65 0 : return TConv::iconCode(m_actionType);
66 : }
67 :
68 0 : engraving::PropertyValue ActionIcon::getProperty(Pid pid) const
69 : {
70 0 : switch (pid) {
71 0 : case Pid::ACTION:
72 0 : return PropertyValue(m_actionType);
73 0 : default:
74 0 : break;
75 : }
76 0 : return EngravingItem::getProperty(pid);
77 : }
78 :
79 0 : bool ActionIcon::setProperty(Pid pid, const PropertyValue& v)
80 : {
81 0 : switch (pid) {
82 0 : case Pid::ACTION:
83 0 : m_actionType = v.value<ActionIconType>();
84 0 : triggerLayout();
85 0 : break;
86 0 : default:
87 0 : return EngravingItem::setProperty(pid, v);
88 : }
89 0 : return true;
90 : }
|