BCESolve
bceslider.hpp
1// This file is part of the BCESolve library for games of incomplete
2// information
3// Copyright (C) 2022 Benjamin A. Brooks
4//
5// BCESolve free software: you can redistribute it and/or modify it
6// under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// BCESolve is distributed in the hope that it will be useful, but
11// WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see
17// <http://www.gnu.org/licenses/>.
18//
19// Benjamin A. Brooks
20// ben@benjaminbrooks.net
21// Chicago, IL
22
23#ifndef BCESLIDER_HPP
24#define BCESLIDER_HPP
25
26#include <QtWidgets>
27#include "bceenumeration.hpp"
28
30
36class BCESlider : public QScrollBar
37{
38 Q_OBJECT;
39
40private:
41
43 BCESliderType sliderType;
45 int player;
46
47public:
48
50 BCESlider(BCESliderType _type,int _player):
51 sliderType(_type),player(_player),QScrollBar()
52 {
53 connect(this,SIGNAL(valueChanged(int)),
54 this,SLOT(changeValue(int)));
55 }
56
57signals:
59 void valueChanged(int newValue,BCESliderType type,int player);
60
61public slots:
63 void changeValue(int newValue)
64 { emit(valueChanged(newValue,sliderType,player)); }
65
67 void changeSliderPosition(int newValEmitted,
68 BCESliderType typeEmitted,
69 int playerEmitted) {
70 if (sliderType == typeEmitted && player == playerEmitted)
71 setSliderPosition(newValEmitted);
72 }
73
74};
75
76#endif
QScrollBar with added signal and slots.
Definition: bceslider.hpp:37
int player
Player associated with the BCEScrollBar.
Definition: bceslider.hpp:45
void valueChanged(int newValue, BCESliderType type, int player)
Signals that the user has moved the BCESlider.
BCESliderType sliderType
Type of BCEScrollBar.
Definition: bceslider.hpp:38
void changeSliderPosition(int newValEmitted, BCESliderType typeEmitted, int playerEmitted)
Changes position of the slider.
Definition: bceslider.hpp:67
BCESlider(BCESliderType _type, int _player)
Constructor.
Definition: bceslider.hpp:50
void changeValue(int newValue)
Changes value of the slider.
Definition: bceslider.hpp:63