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 "iengravingconfiguration.h" // IWYU pragma: keep
26 :
27 : #include "mscore.h"
28 : #include "property.h"
29 : #include "types/typesconv.h"
30 :
31 : using namespace mu;
32 : using namespace muse::draw;
33 : using namespace mu::engraving;
34 :
35 0 : ActionIcon::ActionIcon(DummyParentOr<EngravingItem> parent)
36 0 : : EngravingItem(ElementType::ACTION_ICON, parent)
37 : {
38 0 : m_iconFont = Font(configuration()->iconsFontFamily(), Font::Type::Icon);
39 0 : m_iconFont.setPointSizeF(UI_ICONS_DEFAULT_FONT_SIZE);
40 0 : }
41 :
42 0 : ActionIcon* ActionIcon::clone() const
43 : {
44 0 : return new ActionIcon(*this);
45 : }
46 :
47 0 : void ActionIcon::setActionType(ActionIconType val)
48 : {
49 0 : m_actionType = val;
50 0 : }
51 :
52 0 : ActionIconType ActionIcon::actionType() const
53 : {
54 0 : return m_actionType;
55 : }
56 :
57 0 : const muse::TranslatableString& ActionIcon::title() const
58 : {
59 0 : return TConv::userName(m_actionType);
60 : }
61 :
62 0 : char16_t ActionIcon::icon() const
63 : {
64 0 : return TConv::iconCode(m_actionType);
65 : }
66 :
67 0 : engraving::PropertyValue ActionIcon::getProperty(Pid pid) const
68 : {
69 0 : switch (pid) {
70 0 : case Pid::ACTION:
71 0 : return PropertyValue(m_actionType);
72 0 : default:
73 0 : break;
74 : }
75 0 : return EngravingItem::getProperty(pid);
76 : }
77 :
78 0 : bool ActionIcon::setProperty(Pid pid, const PropertyValue& v)
79 : {
80 0 : switch (pid) {
81 0 : case Pid::ACTION:
82 0 : m_actionType = v.value<ActionIconType>();
83 0 : triggerLayout();
84 0 : break;
85 0 : default:
86 0 : return EngravingItem::setProperty(pid, v);
87 : }
88 0 : return true;
89 : }
|