aseprite/src/ui/button.h
David Capello 89fcd44394 Select the initial ColorButton color when we go back to the button
If start dragging from the ColorButton, we go outside the button, and
then we go back to the same button, we should select the original
color when the whole drag-and-drop process started.

We have also improved the look of the button in that case: the
original color is displayed (instead of the inverted color, which is
when the button is selected, in this way is less confusing).
2021-05-20 15:42:09 -03:00

92 lines
1.8 KiB
C++

// Aseprite UI Library
// Copyright (C) 2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef UI_BUTTON_H_INCLUDED
#define UI_BUTTON_H_INCLUDED
#pragma once
#include "obs/signal.h"
#include "ui/widget.h"
#include <vector>
namespace os {
class Surface;
}
namespace ui {
class Event;
// Generic button
class ButtonBase : public Widget {
public:
ButtonBase(const std::string& text,
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);
virtual void onStartDrag();
virtual void onSelectWhenDragging();
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:
CheckBox(const std::string& text,
const WidgetType drawType = kCheckWidget);
};
// Radio buttons
class RadioButton : public ButtonBase {
public:
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
#endif