2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-06 14:48:05 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-21 12:25:28 +00:00
|
|
|
// SwitchComponent.h
|
2020-06-06 14:48:05 +00:00
|
|
|
//
|
2020-12-15 17:49:43 +00:00
|
|
|
// Basic on/off switch used in menus.
|
2020-06-06 14:48:05 +00:00
|
|
|
//
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_CORE_COMPONENTS_SWITCH_COMPONENT_H
|
|
|
|
#define ES_CORE_COMPONENTS_SWITCH_COMPONENT_H
|
2013-06-19 01:12:30 +00:00
|
|
|
|
2014-06-20 01:30:09 +00:00
|
|
|
#include "components/ImageComponent.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "GuiComponent.h"
|
2013-06-19 01:12:30 +00:00
|
|
|
|
2020-06-06 14:48:05 +00:00
|
|
|
// A simple "on/off" switch.
|
2013-06-19 01:12:30 +00:00
|
|
|
class SwitchComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2020-06-21 12:25:28 +00:00
|
|
|
SwitchComponent(Window* window, bool state = false);
|
2013-06-19 01:12:30 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
bool input(InputConfig* config, Input input) override;
|
|
|
|
void render(const Transform4x4f& parentTrans) override;
|
|
|
|
void onSizeChanged() override;
|
2013-06-19 01:12:30 +00:00
|
|
|
|
2020-12-17 19:49:20 +00:00
|
|
|
void setResize(float width, float height) override;
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
bool getState() const;
|
|
|
|
void setState(bool state);
|
2020-06-25 17:52:38 +00:00
|
|
|
std::string getValue() const override;
|
2020-06-21 12:25:28 +00:00
|
|
|
void setValue(const std::string& statestring) override;
|
2013-06-19 01:12:30 +00:00
|
|
|
|
2020-07-15 15:44:27 +00:00
|
|
|
void setOriginalColor(unsigned int color) override { mColorOriginalValue = color; };
|
|
|
|
void setChangedColor(unsigned int color) override { mColorChangedValue = color; };
|
2020-12-15 17:49:43 +00:00
|
|
|
void setCallback(const std::function<void()>& callbackFunc) { mToggleCallback = callbackFunc; };
|
2020-07-15 15:44:27 +00:00
|
|
|
|
2020-12-15 17:49:43 +00:00
|
|
|
unsigned char getOpacity() const override;
|
2020-08-05 17:31:59 +00:00
|
|
|
void setOpacity(unsigned char opacity) override;
|
|
|
|
// Multiply all pixels in the image by this color when rendering.
|
|
|
|
void setColorShift(unsigned int color) override;
|
|
|
|
|
2020-11-08 12:03:45 +00:00
|
|
|
unsigned int getColorShift() const override;
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
2014-01-25 23:34:29 +00:00
|
|
|
|
2013-06-19 01:12:30 +00:00
|
|
|
private:
|
2020-06-21 12:25:28 +00:00
|
|
|
void onStateChanged();
|
2014-03-08 01:35:16 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
ImageComponent mImage;
|
|
|
|
bool mState;
|
2020-07-15 15:44:27 +00:00
|
|
|
bool mOriginalValue;
|
|
|
|
unsigned int mColorOriginalValue;
|
|
|
|
unsigned int mColorChangedValue;
|
2020-12-15 17:49:43 +00:00
|
|
|
std::function<void()> mToggleCallback;
|
2013-06-19 01:12:30 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_CORE_COMPONENTS_SWITCH_COMPONENT_H
|