2013-08-09 00:01:20 +00:00
|
|
|
// Aseprite UI Library
|
2018-10-11 15:01:21 +00:00
|
|
|
// Copyright (C) 2001-2018 David Capello
|
2010-09-27 22:18:17 +00:00
|
|
|
//
|
2014-03-29 23:08:05 +00:00
|
|
|
// This file is released under the terms of the MIT license.
|
|
|
|
// Read LICENSE.txt for more information.
|
2010-09-27 22:18:17 +00:00
|
|
|
|
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
|
|
|
|
2016-09-13 18:02:00 +00:00
|
|
|
#include "obs/signal.h"
|
2012-06-18 01:49:58 +00:00
|
|
|
#include "ui/widget.h"
|
2011-03-27 23:42:16 +00:00
|
|
|
|
2010-08-23 20:41:19 +00:00
|
|
|
#include <vector>
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2018-08-09 15:58:43 +00:00
|
|
|
namespace os {
|
2014-06-22 21:53:14 +00:00
|
|
|
class Surface;
|
|
|
|
}
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2012-06-18 01:02:54 +00:00
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
class Event;
|
|
|
|
|
|
|
|
// Generic button
|
2014-06-22 21:53:14 +00:00
|
|
|
class ButtonBase : public Widget {
|
2012-06-18 01:02:54 +00:00
|
|
|
public:
|
2014-04-20 22:53:27 +00:00
|
|
|
ButtonBase(const std::string& text,
|
2018-10-11 15:01:21 +00:00
|
|
|
const WidgetType type,
|
|
|
|
const WidgetType behaviorType,
|
|
|
|
const WidgetType drawType);
|
2012-06-18 01:02:54 +00:00
|
|
|
virtual ~ButtonBase();
|
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-04 17:39:04 +00:00
|
|
|
WidgetType behaviorType() const;
|
2012-06-18 01:02:54 +00:00
|
|
|
// Signals
|
2016-09-13 18:02:00 +00:00
|
|
|
obs::signal<void(Event&)> Click;
|
2012-06-18 01:02:54 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Events
|
2014-08-15 02:07:47 +00:00
|
|
|
bool onProcessMessage(Message* msg) override;
|
2012-06-18 01:02:54 +00:00
|
|
|
|
|
|
|
// New events
|
|
|
|
virtual void onClick(Event& ev);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void generateButtonSelectSignal();
|
|
|
|
|
|
|
|
bool m_pressedStatus;
|
2013-04-04 01:07:24 +00:00
|
|
|
WidgetType m_behaviorType;
|
2012-06-18 01:02:54 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_handleSelect;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Pushable button to execute commands
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-04 17:39:04 +00:00
|
|
|
class Button : public ButtonBase {
|
2012-06-18 01:02:54 +00:00
|
|
|
public:
|
2014-04-20 22:53:27 +00:00
|
|
|
Button(const std::string& text);
|
2012-06-18 01:02:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Check boxes
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-04 17:39:04 +00:00
|
|
|
class CheckBox : public ButtonBase {
|
2012-06-18 01:02:54 +00:00
|
|
|
public:
|
2018-10-11 15:01:21 +00:00
|
|
|
CheckBox(const std::string& text,
|
|
|
|
const WidgetType drawType = kCheckWidget);
|
2012-06-18 01:02:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Radio buttons
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-04 17:39:04 +00:00
|
|
|
class RadioButton : public ButtonBase {
|
2012-06-18 01:02:54 +00:00
|
|
|
public:
|
2018-10-11 15:01:21 +00:00
|
|
|
RadioButton(const std::string& text,
|
|
|
|
const int radioGroup = 0,
|
|
|
|
const WidgetType drawType = kRadioWidget);
|
2012-06-18 01:02:54 +00:00
|
|
|
|
|
|
|
int getRadioGroup() const;
|
|
|
|
void setRadioGroup(int radioGroup);
|
|
|
|
|
|
|
|
void deselectRadioGroup();
|
|
|
|
|
|
|
|
protected:
|
2016-09-08 18:53:10 +00:00
|
|
|
void onSelect(bool selected) override;
|
2012-06-18 01:02:54 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int m_radioGroup;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ui
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2009-08-17 21:38:00 +00:00
|
|
|
#endif
|