libgui/include/gui/GuiSelectBox.h

141 lines
4.0 KiB
C
Raw Normal View History

2018-06-21 20:44:58 +02:00
/****************************************************************************
* Copyright (C) 2016 Maschell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef GUI_SELECTBOX_H_
#define GUI_SELECTBOX_H_
#include <gui/Gui.h>
#include <gui/GuiImage.h>
#include <gui/GuiImageData.h>
//!A simple CheckBox
class GuiSelectBox : public GuiFrame, public sigslot::has_slots<> {
public:
//!Constructor
//!\param checked Checked
2020-08-13 12:38:07 +02:00
GuiSelectBox(GuiImage *background, std::string caption, float width = 0.0f, float height = 0.0f, GuiFrame *parent = 0);
2018-06-21 20:44:58 +02:00
//!Destructor
virtual ~GuiSelectBox();
sigslot::signal2<GuiSelectBox *, std::string> valueChanged;
sigslot::signal2<GuiSelectBox *, bool> showhide;
2020-08-13 12:38:07 +02:00
void setImageTopBackground(GuiImage *img) {
2018-06-21 20:44:58 +02:00
topBackgroundImg = img;
topValueButton.setImage(img);
}
2020-08-13 12:38:07 +02:00
void setImageTopHighlighted(GuiImage *img) {
2018-06-21 20:44:58 +02:00
topHighlightedImg = img;
topValueButton.setIconOver(img);
}
2020-08-13 12:38:07 +02:00
void setImageValueBackground(GuiImageData *img) {
2018-06-21 20:44:58 +02:00
valueImageData = img;
}
2020-08-13 12:38:07 +02:00
void setImageValueHighlighted(GuiImageData *img) {
2018-06-21 20:44:58 +02:00
valueHighlightedImageData = img;
}
2020-08-13 12:38:07 +02:00
void setImageValueSelected(GuiImageData *img) {
2018-06-21 20:44:58 +02:00
valueSelectedImageData = img;
}
2020-08-13 12:38:07 +02:00
void setSoundClick(GuiSound *snd) {
2018-06-21 20:44:58 +02:00
buttonClickSound = snd;
topValueButton.setSoundClick(snd);
}
void OnTopValueClicked(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
2020-08-13 12:38:07 +02:00
void Init(std::map<std::string, std::string> values, int32_t valueID);
2018-06-21 20:44:58 +02:00
void setState(int32_t s, int32_t c = -1);
virtual void setSize(float width, float height);
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
virtual float getTopValueHeight();
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
virtual float getTopValueWidth();
virtual float getHeight();
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
virtual float getWidth();
protected:
void DeleteValueData();
2020-08-13 12:38:07 +02:00
void update(GuiController *c);
2018-06-21 20:44:58 +02:00
void OnValueClicked(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
void OnDPADClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
void OnValueOpenEffectFinish(GuiElement *element);
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
void OnValueCloseEffectFinish(GuiElement *element);
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
void ShowHideValues(bool showhide);
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
void SelectValue(uint32_t value);
uint32_t selected;
bool bChanged;
bool bSelectedChanged;
bool showValues;
bool opened;
std::string captionText;
GuiFrame valuesFrame;
2020-08-13 12:38:07 +02:00
GuiImage *topBackgroundImg = NULL;
GuiImage *topHighlightedImg = NULL;
2018-06-21 20:44:58 +02:00
GuiButton topValueButton;
2020-08-13 12:38:07 +02:00
GuiImageData *valueImageData = NULL;
GuiImageData *valueSelectedImageData = NULL;
GuiImageData *valueHighlightedImageData = NULL;
2018-06-21 20:44:58 +02:00
GuiText topValueText;
GuiTrigger touchTrigger;
GuiTrigger wpadTouchTrigger;
GuiTrigger buttonATrigger;
GuiTrigger buttonBTrigger;
GuiTrigger buttonLeftTrigger;
GuiTrigger buttonRightTrigger;
GuiTrigger buttonUpTrigger;
GuiTrigger buttonDownTrigger;
GuiButton DPADButtons;
2020-08-13 12:38:07 +02:00
GuiSound *buttonClickSound;
2018-06-21 20:44:58 +02:00
typedef struct {
GuiImage *valueButtonImg;
GuiImage *valueButtonCheckedImg;
GuiImage *valueButtonHighlightedImg;
GuiButton *valueButton;
GuiText *valueButtonText;
} SelectBoxValueButton;
2020-08-13 12:38:07 +02:00
std::map<GuiButton *, std::string> buttonToValue;
2018-06-21 20:44:58 +02:00
std::vector<SelectBoxValueButton> valueButtons;
};
#endif