File: alignSelect.cpp

package info (click to toggle)
musescore3 3.2.3%2Bdfsg2-11
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 210,672 kB
  • sloc: cpp: 291,093; xml: 200,238; sh: 3,779; ansic: 1,447; python: 393; makefile: 240; perl: 82; pascal: 79
file content (115 lines) | stat: -rw-r--r-- 3,538 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//=============================================================================
//  MuseScore
//  Music Composition & Notation
//
//  Copyright (C) 2017 Werner Schweer and others
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License version 2
//  as published by the Free Software Foundation and appearing in
//  the file LICENSE.GPL
//=============================================================================

#include "alignSelect.h"
#include "libmscore/types.h"
#include "icons.h"

namespace Ms {

//---------------------------------------------------------
//   AlignSelect
//---------------------------------------------------------

AlignSelect::AlignSelect(QWidget* parent)
   : QWidget(parent)
      {
      setupUi(this);

      g1 = new QButtonGroup(this);
      g1->addButton(alignLeft);
      g1->addButton(alignHCenter);
      g1->addButton(alignRight);

      g2 = new QButtonGroup(this);
      g2->addButton(alignTop);
      g2->addButton(alignVCenter);
      g2->addButton(alignBaseline);
      g2->addButton(alignBottom);

      alignLeft->setIcon(*icons[int(Icons::textLeft_ICON)]);
      alignRight->setIcon(*icons[int(Icons::textRight_ICON)]);
      alignHCenter->setIcon(*icons[int(Icons::textCenter_ICON)]);
      alignVCenter->setIcon(*icons[int(Icons::textVCenter_ICON)]);
      alignTop->setIcon(*icons[int(Icons::textTop_ICON)]);
      alignBaseline->setIcon(*icons[int(Icons::textBaseline_ICON)]);
      alignBottom->setIcon(*icons[int(Icons::textBottom_ICON)]);

      connect(g1, SIGNAL(buttonToggled(int,bool)), SLOT(_alignChanged()));
      connect(g2, SIGNAL(buttonToggled(int,bool)), SLOT(_alignChanged()));
      }

//---------------------------------------------------------
//   _alignChanged
//---------------------------------------------------------

void AlignSelect::_alignChanged()
      {
      emit alignChanged(align());
      }

//---------------------------------------------------------
//   align
//---------------------------------------------------------

Align AlignSelect::align() const
      {
      Align a = Align::LEFT;
      if (alignHCenter->isChecked())
            a = a | Align::HCENTER;
      else if (alignRight->isChecked())
            a = a | Align::RIGHT;
      if (alignVCenter->isChecked())
            a = a | Align::VCENTER;
      else if (alignBottom->isChecked())
            a = a | Align::BOTTOM;
      else if (alignBaseline->isChecked())
            a = a | Align::BASELINE;
      return a;
      }

//---------------------------------------------------------
//   blockAlign
//---------------------------------------------------------

void AlignSelect::blockAlign(bool val)
      {
      g1->blockSignals(val);
      g2->blockSignals(val);
      }

//---------------------------------------------------------
//   setElement
//---------------------------------------------------------

void AlignSelect::setAlign(Align a)
      {
      blockAlign(true);
      if (a & Align::HCENTER)
            alignHCenter->setChecked(true);
      else if (a & Align::RIGHT)
            alignRight->setChecked(true);
      else
            alignLeft->setChecked(true);
      if (a & Align::VCENTER)
            alignVCenter->setChecked(true);
      else if (a & Align::BOTTOM)
            alignBottom->setChecked(true);
      else if (a & Align::BASELINE)
            alignBaseline->setChecked(true);
      else
            alignTop->setChecked(true);
      blockAlign(false);
      }

}