Remove ui::Event& args from ui::Button::Click signal

This is to simplify code and to match ui::MenuItem::Click and
ui::Button::Click signals (so then we can write some generic code
using Button::Click or MenuItem::Click).
This commit is contained in:
David Capello 2023-01-12 11:00:16 -03:00
parent 9678cc4ac3
commit 39d1fb56d4
26 changed files with 74 additions and 78 deletions

View File

@ -244,7 +244,7 @@ public:
factor()->Change.connect([this]{ onIndexParamChange(); });
advancedCheck()->Click.connect(
[this](ui::Event&){
[this](){
advanced()->setVisible(advancedCheck()->isSelected());
expandWindow(sizeHint());
});

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2021 Igara Studio S.A.
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -49,7 +49,7 @@ public:
rgbmapAlgorithmPlaceholder()->addChild(&m_algoSelector);
advancedCheck()->Click.connect(
[this](ui::Event&){
[this](){
advanced()->setVisible(advancedCheck()->isSelected());
expandWindow(sizeHint());
});

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -327,7 +327,7 @@ public:
if (m_pref.general.dataRecovery())
enableDataRecovery()->setSelected(true);
enableDataRecovery()->Click.connect(
[this](Event&){
[this](){
const bool state = enableDataRecovery()->isSelected();
keepEditedSpriteData()->setEnabled(state);
keepEditedSpriteData()->setSelected(state);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -201,7 +201,7 @@ void SpritePropertiesCommand::onExecute(Context* context)
window.colorProfile()->Change.connect(updateButtons);
window.assignColorProfile()->Click.connect(
[&](Event&){
[&](){
selectedColorProfile = window.colorProfile()->getSelectedItemIndex();
ContextWriter writer(context);
@ -214,7 +214,7 @@ void SpritePropertiesCommand::onExecute(Context* context)
updateButtons();
});
window.convertColorProfile()->Click.connect(
[&](Event&){
[&](){
selectedColorProfile = window.colorProfile()->getSelectedItemIndex();
ContextWriter writer(context);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2020-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -150,17 +150,17 @@ void FilterWindow::setNewTarget(Target target)
m_targetButton.setTarget(target);
}
void FilterWindow::onOk(Event& ev)
void FilterWindow::onOk()
{
m_okButton.closeWindow();
}
void FilterWindow::onCancel(Event& ev)
void FilterWindow::onCancel()
{
m_cancelButton.closeWindow();
}
void FilterWindow::onShowPreview(Event& ev)
void FilterWindow::onShowPreview()
{
restartPreview();

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2022 Igara Studio S.A.
// Copyright (C) 2022-2023 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -52,9 +52,9 @@ namespace app {
// Returns the container where derived classes should put controls.
ui::Widget* getContainer() { return &m_container; }
void onOk(ui::Event& ev);
void onCancel(ui::Event& ev);
void onShowPreview(ui::Event& ev);
void onOk();
void onCancel();
void onShowPreview();
void onTargetButtonChange();
void onTiledChange();

View File

@ -558,7 +558,7 @@ int Dialog_button_base(lua_State* L, T** outputWidget = nullptr)
auto dlg = get_obj<Dialog>(L, 1);
Dialog_connect_signal(
L, 1, widget->Click,
[dlg, widget](lua_State* L, Event&){
[dlg, widget](lua_State* L){
if (widget->type() == ui::kButtonWidget)
dlg->lastButton = widget;
});

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2021 Igara Studio S.A.
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2018 David Capello
//
// This program is distributed under the terms of
@ -167,7 +167,7 @@ bool ask_access(lua_State* L,
});
dlg.full()->Click.connect(
[&dlg, &allowButtonText](ui::Event&){
[&dlg, &allowButtonText](){
if (dlg.full()->isSelected()) {
dlg.dontShow()->setSelected(true);
dlg.dontShow()->setEnabled(false);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2021 Igara Studio S.A.
// Copyright (C) 2021-2023 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -22,8 +22,7 @@ AsepriteUpdate::AsepriteUpdate(std::string version)
, m_timer(500, this)
{
okButton()->setEnabled(false);
okButton()->Click.connect([this](ui::Event&) {
});
okButton()->Click.connect([this]() { });
m_timer.Tick.connect([this] { this->onTimerTick(); });
log(base::string_printf("Downloading Aseprite %s...", version.c_str()));
@ -213,4 +212,4 @@ void AsepriteUpdate::log(std::string text)
layout();
}
}
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020-2022 Igara Studio S.A.
// Copyright (C) 2020-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -295,9 +295,9 @@ void ColorButton::onPaint(PaintEvent& ev)
g->drawUIText(text(), textcolor, gfx::ColorNone, textrc.origin(), 0);
}
void ColorButton::onClick(Event& ev)
void ColorButton::onClick()
{
ButtonBase::onClick(ev);
ButtonBase::onClick();
// If the popup window was not created or shown yet..
if (!m_window || !m_window->isVisible()) {

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2021 Igara Studio S.A.
// Copyright (C) 2021-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -57,7 +57,7 @@ namespace app {
bool onProcessMessage(ui::Message* msg) override;
void onSizeHint(ui::SizeHintEvent& ev) override;
void onPaint(ui::PaintEvent& ev) override;
void onClick(ui::Event& ev) override;
void onClick() override;
void onStartDrag() override;
void onSelectWhenDragging() override;
void onLoadLayout(ui::LoadLayoutEvent& ev) override;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020-2022 Igara Studio S.A.
// Copyright (C) 2020-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -66,7 +66,7 @@ public:
}
private:
void onClick(Event& ev) override {
void onClick() override {
m_colorPopup->setColorWithSignal(m_color, ChangeType);
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -366,8 +366,8 @@ protected:
setStyle(SkinTheme::get(this)->styles.miniCheckBox());
}
void onClick(Event& ev) override {
CheckBox::onClick(ev);
void onClick() override {
CheckBox::onClick();
Tool* tool = App::instance()->activeTool();
Preferences::instance().tool(tool).contiguous(isSelected());
@ -904,7 +904,7 @@ private:
buttonset.setSelectedItem(int(pos));
visible.Click.connect(
[&visible](Event&){
[&visible](){
Preferences::instance().selection.pivotVisibility(
visible.isSelected());
});
@ -1249,8 +1249,8 @@ protected:
setStyle(SkinTheme::get(this)->styles.miniCheckBox());
}
void onClick(Event& ev) override {
CheckBox::onClick(ev);
void onClick() override {
CheckBox::onClick();
Tool* tool = App::instance()->activeTool();
Preferences::instance().tool(tool).freehandAlgorithm(
@ -1386,8 +1386,8 @@ protected:
setStyle(SkinTheme::get(this)->styles.miniCheckBox());
}
void onClick(Event& ev) override {
CheckBox::onClick(ev);
void onClick() override {
CheckBox::onClick();
auto atm = App::instance()->activeToolManager();
if (atm->quickTool() &&

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2022 Igara Studio S.A.
// Copyright (C) 2022-2023 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -44,13 +44,13 @@ DropDownButton::DropDownButton(const char* text)
initTheme();
}
void DropDownButton::onButtonClick(Event& ev)
void DropDownButton::onButtonClick()
{
// Fire "Click" signal.
Click();
}
void DropDownButton::onDropDownButtonClick(Event& ev)
void DropDownButton::onDropDownButtonClick()
{
DropDownClick();
}

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2023 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This program is distributed under the terms of
@ -29,8 +30,8 @@ namespace app {
obs::signal<void()> DropDownClick;
protected:
void onButtonClick(ui::Event& ev);
void onDropDownButtonClick(ui::Event& ev);
void onButtonClick();
void onDropDownButtonClick();
private:
ui::Button* m_button;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2021 Igara Studio S.A.
// Copyright (C) 2021-2023 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -32,7 +32,7 @@ EnterLicense::EnterLicense() : m_timer(500, this), m_activationInProgress(false)
});
okButton()->setEnabled(false);
okButton()->Click.connect([this](ui::Event&) {
okButton()->Click.connect([this]() {
startActivation();
});
@ -108,4 +108,4 @@ void EnterLicense::showSuccess()
m_activationInProgress = false;
}
}
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020-2022 Igara Studio S.A.
// Copyright (C) 2020-2023 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -70,7 +70,7 @@ void Notifications::onPaint(PaintEvent& ev)
g, m_flagStyle, clientBounds(), info);
}
void Notifications::onClick(ui::Event& ev)
void Notifications::onClick()
{
m_red = false;
invalidate();

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2020-2023 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -29,7 +29,7 @@ namespace app {
protected:
void onSizeHint(ui::SizeHintEvent& ev) override;
void onPaint(ui::PaintEvent& ev) override;
void onClick(ui::Event& ev) override;
void onClick() override;
private:
ui::Style* m_flagStyle;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020-2022 Igara Studio S.A.
// Copyright (C) 2020-2023 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -74,8 +74,8 @@ class PalettesListItem : public ResourceListItem {
setBgColor(theme->colors.listitemNormalFace());
}
void onClick(Event& ev) override {
IconButton::onClick(ev);
void onClick() override {
IconButton::onClick();
std::string::size_type j, i = m_comment.find("http");
if (i != std::string::npos) {

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -114,11 +114,11 @@ private:
setupIcons();
}
void onClick(Event& ev) override {
void onClick() override {
m_isPlaying = !m_isPlaying;
setupIcons();
Button::onClick(ev);
Button::onClick();
}
void onSetDecorativeWidgetBounds() override {

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2019-2023 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -33,7 +33,7 @@ TaskWidget::TaskWidget(const Type type,
addChild(&m_cancelButton);
m_cancelButton.Click.connect(
[this](Event&){
[this](){
m_task.cancel();
m_cancelButton.setEnabled(false);
m_progressBar.setEnabled(false);

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2019-2021 Igara Studio S.A.
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
@ -50,10 +50,10 @@ WidgetType ButtonBase::behaviorType() const
return m_behaviorType;
}
void ButtonBase::onClick(Event& ev)
void ButtonBase::onClick()
{
// Fire Click() signal
Click(ev);
Click();
}
bool ButtonBase::onProcessMessage(Message* msg)
@ -147,8 +147,7 @@ bool ButtonBase::onProcessMessage(Message* msg)
case kCheckWidget: {
// Fire onClick() event
Event ev(this);
onClick(ev);
onClick();
return true;
}
@ -212,8 +211,7 @@ bool ButtonBase::onProcessMessage(Message* msg)
case kCheckWidget:
{
// Fire onClick() event
Event ev(this);
onClick(ev);
onClick();
invalidate();
}
@ -225,8 +223,7 @@ bool ButtonBase::onProcessMessage(Message* msg)
setSelected(true);
// Fire onClick() event
Event ev(this);
onClick(ev);
onClick();
}
break;
}
@ -260,8 +257,7 @@ void ButtonBase::generateButtonSelectSignal()
setSelected(false);
// Fire onClick() event
Event ev(this);
onClick(ev);
onClick();
}
void ButtonBase::onStartDrag()

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2021 Igara Studio S.A.
// Copyright (C) 2021-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
@ -33,14 +33,14 @@ namespace ui {
WidgetType behaviorType() const;
// Signals
obs::signal<void(Event&)> Click;
obs::signal<void()> Click;
protected:
// Events
bool onProcessMessage(Message* msg) override;
// New events
virtual void onClick(Event& ev);
virtual void onClick();
virtual void onStartDrag();
virtual void onSelectWhenDragging();

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
@ -632,7 +632,7 @@ void ComboBoxListBox::onChange()
}
// When the mouse is clicked we switch the visibility-status of the list-box
void ComboBox::onButtonClick(Event& ev)
void ComboBox::onButtonClick()
{
switchListBox();
}

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2019-2021 Igara Studio S.A.
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
@ -115,7 +115,7 @@ namespace ui {
private:
void updateListBoxPos();
void onButtonClick(Event& ev);
void onButtonClick();
void filterMessages();
void removeMessageFilters();
void putSelectedItemAsCustomWidget();

View File

@ -70,8 +70,8 @@ public:
protected:
void onClick(Event& ev) override {
ButtonBase::onClick(ev);
void onClick() override {
ButtonBase::onClick();
closeWindow();
}