aseprite/src/ui/button.h

89 lines
1.7 KiB
C
Raw Normal View History

// Aseprite UI Library
2018-10-11 15:01:21 +00:00
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
2012-06-18 01:49:58 +00:00
#ifndef UI_BUTTON_H_INCLUDED
#define UI_BUTTON_H_INCLUDED
2014-03-29 22:40:17 +00:00
#pragma once
2007-09-18 23:57:02 +00:00
#include "obs/signal.h"
2012-06-18 01:49:58 +00:00
#include "ui/widget.h"
#include <vector>
2007-09-18 23:57:02 +00:00
2018-08-09 15:58:43 +00:00
namespace os {
class Surface;
}
2007-09-18 23:57:02 +00:00
namespace ui {
class Event;
// Generic button
class ButtonBase : public Widget {
public:
ButtonBase(const std::string& text,
2018-10-11 15:01:21 +00:00
const WidgetType type,
const WidgetType behaviorType,
const WidgetType drawType);
virtual ~ButtonBase();
WidgetType behaviorType() const;
// Signals
obs::signal<void(Event&)> Click;
protected:
// Events
bool onProcessMessage(Message* msg) override;
// New events
virtual void onClick(Event& ev);
private:
void generateButtonSelectSignal();
bool m_pressedStatus;
WidgetType m_behaviorType;
protected:
bool m_handleSelect;
};
// Pushable button to execute commands
class Button : public ButtonBase {
public:
Button(const std::string& text);
};
// Check boxes
class CheckBox : public ButtonBase {
public:
2018-10-11 15:01:21 +00:00
CheckBox(const std::string& text,
const WidgetType drawType = kCheckWidget);
};
// Radio buttons
class RadioButton : public ButtonBase {
public:
2018-10-11 15:01:21 +00:00
RadioButton(const std::string& text,
const int radioGroup = 0,
const WidgetType drawType = kRadioWidget);
int getRadioGroup() const;
void setRadioGroup(int radioGroup);
void deselectRadioGroup();
protected:
void onSelect(bool selected) override;
private:
int m_radioGroup;
};
} // namespace ui
2007-09-18 23:57:02 +00:00
2009-08-17 21:38:00 +00:00
#endif