summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2020-06-19 20:49:04 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2020-06-19 20:49:49 +0200
commit31b7f02a29cdf4f1c30cfc37962f43f67380b9ad (patch)
tree1c0de1bac35046915575687e8d8993643d372474 /scene/gui
parentcb9d02a8d1b5bb71abcec6be0e75002c5ea656c4 (diff)
Remove ToolButton in favor of Button
ToolButton has no redeeming differences with Button; it's just a Button with the Flat property enabled by default. Removing it avoids some confusion when creating GUIs. Existing ToolButtons will be converted to Buttons, but the Flat property won't be enabled automatically. This closes https://github.com/godotengine/godot-proposals/issues/1081.
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/color_picker.cpp3
-rw-r--r--scene/gui/color_picker.h3
-rw-r--r--scene/gui/file_dialog.cpp15
-rw-r--r--scene/gui/file_dialog.h7
-rw-r--r--scene/gui/graph_edit.cpp13
-rw-r--r--scene/gui/graph_edit.h10
-rw-r--r--scene/gui/tool_button.cpp35
-rw-r--r--scene/gui/tool_button.h43
8 files changed, 29 insertions, 100 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 84170a65d1..fafbb298b7 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -758,7 +758,8 @@ ColorPicker::ColorPicker() :
sample->set_h_size_flags(SIZE_EXPAND_FILL);
sample->connect("draw", callable_mp(this, &ColorPicker::_sample_draw));
- btn_pick = memnew(ToolButton);
+ btn_pick = memnew(Button);
+ btn_pick->set_flat(true);
hb_smpl->add_child(btn_pick);
btn_pick->set_toggle_mode(true);
btn_pick->set_tooltip(TTR("Pick a color from the editor window."));
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index 31ae92f4e4..b2e8263e7f 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -41,7 +41,6 @@
#include "scene/gui/slider.h"
#include "scene/gui/spin_box.h"
#include "scene/gui/texture_rect.h"
-#include "scene/gui/tool_button.h"
class ColorPicker : public BoxContainer {
GDCLASS(ColorPicker, BoxContainer);
@@ -57,7 +56,7 @@ private:
HSeparator *preset_separator;
Button *bt_add_preset;
List<Color> presets;
- ToolButton *btn_pick;
+ Button *btn_pick;
CheckButton *btn_hsv;
CheckButton *btn_raw;
HSlider *scroll[4];
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 630f3c8ff6..41ca6458af 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -45,9 +45,9 @@ VBoxContainer *FileDialog::get_vbox() {
}
void FileDialog::_theme_changed() {
- Color font_color = vbox->get_theme_color("font_color", "ToolButton");
- Color font_color_hover = vbox->get_theme_color("font_color_hover", "ToolButton");
- Color font_color_pressed = vbox->get_theme_color("font_color_pressed", "ToolButton");
+ Color font_color = vbox->get_theme_color("font_color", "Button");
+ Color font_color_hover = vbox->get_theme_color("font_color_hover", "Button");
+ Color font_color_pressed = vbox->get_theme_color("font_color_pressed", "Button");
dir_up->add_theme_color_override("icon_color_normal", font_color);
dir_up->add_theme_color_override("icon_color_hover", font_color_hover);
@@ -859,7 +859,8 @@ FileDialog::FileDialog() {
HBoxContainer *hbc = memnew(HBoxContainer);
- dir_up = memnew(ToolButton);
+ dir_up = memnew(Button);
+ dir_up->set_flat(true);
dir_up->set_tooltip(RTR("Go to parent folder."));
hbc->add_child(dir_up);
dir_up->connect("pressed", callable_mp(this, &FileDialog::_go_up));
@@ -877,12 +878,14 @@ FileDialog::FileDialog() {
hbc->add_child(dir);
dir->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- refresh = memnew(ToolButton);
+ refresh = memnew(Button);
+ refresh->set_flat(true);
refresh->set_tooltip(RTR("Refresh files."));
refresh->connect("pressed", callable_mp(this, &FileDialog::update_file_list));
hbc->add_child(refresh);
- show_hidden = memnew(ToolButton);
+ show_hidden = memnew(Button);
+ show_hidden->set_flat(true);
show_hidden->set_toggle_mode(true);
show_hidden->set_pressed(is_showing_hidden_files());
show_hidden->set_tooltip(RTR("Toggle the visibility of hidden files."));
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 8bc536d576..44050a2376 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -36,7 +36,6 @@
#include "scene/gui/dialogs.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/option_button.h"
-#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
class FileDialog : public ConfirmationDialog {
@@ -87,10 +86,10 @@ private:
DirAccess *dir_access;
ConfirmationDialog *confirm_save;
- ToolButton *dir_up;
+ Button *dir_up;
- ToolButton *refresh;
- ToolButton *show_hidden;
+ Button *refresh;
+ Button *show_hidden;
Vector<String> filters;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 5080ba74e2..2b0e084db4 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -33,6 +33,7 @@
#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "scene/gui/box_container.h"
+#include "scene/gui/button.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
@@ -1310,25 +1311,29 @@ GraphEdit::GraphEdit() {
top_layer->add_child(zoom_hb);
zoom_hb->set_position(Vector2(10, 10));
- zoom_minus = memnew(ToolButton);
+ zoom_minus = memnew(Button);
+ zoom_minus->set_flat(true);
zoom_hb->add_child(zoom_minus);
zoom_minus->set_tooltip(RTR("Zoom Out"));
zoom_minus->connect("pressed", callable_mp(this, &GraphEdit::_zoom_minus));
zoom_minus->set_focus_mode(FOCUS_NONE);
- zoom_reset = memnew(ToolButton);
+ zoom_reset = memnew(Button);
+ zoom_reset->set_flat(true);
zoom_hb->add_child(zoom_reset);
zoom_reset->set_tooltip(RTR("Zoom Reset"));
zoom_reset->connect("pressed", callable_mp(this, &GraphEdit::_zoom_reset));
zoom_reset->set_focus_mode(FOCUS_NONE);
- zoom_plus = memnew(ToolButton);
+ zoom_plus = memnew(Button);
+ zoom_plus->set_flat(true);
zoom_hb->add_child(zoom_plus);
zoom_plus->set_tooltip(RTR("Zoom In"));
zoom_plus->connect("pressed", callable_mp(this, &GraphEdit::_zoom_plus));
zoom_plus->set_focus_mode(FOCUS_NONE);
- snap_button = memnew(ToolButton);
+ snap_button = memnew(Button);
+ snap_button->set_flat(true);
snap_button->set_toggle_mode(true);
snap_button->set_tooltip(RTR("Enable snap and show grid."));
snap_button->connect("pressed", callable_mp(this, &GraphEdit::_snap_toggled));
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index c632490855..a627a8eec8 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -32,12 +32,12 @@
#define GRAPH_EDIT_H
#include "scene/gui/box_container.h"
+#include "scene/gui/button.h"
#include "scene/gui/graph_node.h"
#include "scene/gui/scroll_bar.h"
#include "scene/gui/slider.h"
#include "scene/gui/spin_box.h"
#include "scene/gui/texture_rect.h"
-#include "scene/gui/tool_button.h"
class GraphEdit;
@@ -65,11 +65,11 @@ public:
};
private:
- ToolButton *zoom_minus;
- ToolButton *zoom_reset;
- ToolButton *zoom_plus;
+ Button *zoom_minus;
+ Button *zoom_reset;
+ Button *zoom_plus;
- ToolButton *snap_button;
+ Button *snap_button;
SpinBox *snap_amount;
void _zoom_minus();
diff --git a/scene/gui/tool_button.cpp b/scene/gui/tool_button.cpp
deleted file mode 100644
index c9f87f0015..0000000000
--- a/scene/gui/tool_button.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*************************************************************************/
-/* tool_button.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "tool_button.h"
-
-ToolButton::ToolButton() {
- set_flat(true);
-}
diff --git a/scene/gui/tool_button.h b/scene/gui/tool_button.h
deleted file mode 100644
index 9848b21381..0000000000
--- a/scene/gui/tool_button.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*************************************************************************/
-/* tool_button.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef TOOL_BUTTON_H
-#define TOOL_BUTTON_H
-
-#include "scene/gui/button.h"
-
-class ToolButton : public Button {
- GDCLASS(ToolButton, Button);
-
-public:
- ToolButton();
-};
-
-#endif // TOOL_BUTTON_H