Files
Aerofoil/PortabilityLayer/PLButtonWidget.h

53 lines
1.4 KiB
C
Raw Permalink Normal View History

#pragma once
#include "PascalStr.h"
#include "PLWidgets.h"
namespace PortabilityLayer
{
2021-03-29 21:41:11 -04:00
class ButtonWidget final : public WidgetSpec<ButtonWidget, WidgetTypes::kButton>
{
public:
2020-05-18 02:03:17 -04:00
enum ButtonStyle
{
kButtonStyle_Button,
kButtonStyle_CheckBox,
kButtonStyle_Radio,
};
struct AdditionalData
{
AdditionalData();
2020-05-18 02:03:17 -04:00
ButtonStyle m_buttonStyle;
};
2020-05-18 02:03:17 -04:00
explicit ButtonWidget(const WidgetBasicState &state);
bool Init(const WidgetBasicState &state, const void *additionalData) override;
2020-01-04 01:19:01 -05:00
void DrawControl(DrawSurface *surface) override;
2020-05-18 02:03:17 -04:00
void SetString(const PLPasStr &str) override;
PLPasStr GetString() const override;
2021-03-29 21:41:11 -04:00
WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) GP_ASYNCIFY_PARANOID_OVERRIDE;
2020-03-01 17:01:35 -05:00
void OnEnabledChanged() override;
2020-05-18 02:03:17 -04:00
void OnStateChanged() override;
2021-03-29 21:41:11 -04:00
int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) GP_ASYNCIFY_PARANOID_OVERRIDE;
2020-05-17 23:02:08 -04:00
void SetHighlightStyle(int16_t style, bool enabled) override;
static void DrawDefaultButtonChrome(const Rect &rect, DrawSurface *surface);
private:
2020-03-14 05:04:51 -04:00
void DrawControlInternal(DrawSurface *surface, bool inverted);
2020-05-18 02:03:17 -04:00
void DrawAsButton(DrawSurface *surface, bool inverted);
void DrawAsRadio(DrawSurface *surface, bool inverted);
void DrawAsCheck(DrawSurface *surface, bool inverted);
PascalStr<255> m_text;
2020-05-18 02:03:17 -04:00
ButtonStyle m_buttonStyle;
2020-05-17 23:02:08 -04:00
bool m_haveHighlightOverride;
};
}