Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ToolButton in favor of Button #39690

Merged
merged 1 commit into from
Jun 19, 2020

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Jun 19, 2020

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. Help is welcome for doing this 🙂

This closes godotengine/godot-proposals#1081.

Process

For future reference, here's the process I followed to make this PR:

  • In Visual Studio Code, press Ctrl + Shift + H, enable regex then use the following search/replace texts:
    • Search: (^.+)([a-z0-9_]+) = memnew\(ToolButton\);
    • Replace: $1$2 = memnew(Button);\n$2->set_flat(true);
  • Replace ToolButton with Button (case-sensitive).
  • Replace #include "scene/gui/tool_button.h" with #include "scene/gui/button.h".
  • Remove the duplicate Button registration in scene/register_scene_types.cpp.
  • Add a compatibility declaration in scene/register_scene_types.cpp:
ClassDB::add_compatibility_class("ToolButton", "Button");
  • Run clang-format over all non-thirdparty .cpp and .h files.

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 godotengine/godot-proposals#1081.
@Calinou Calinou requested review from neikeq and a team as code owners June 19, 2020 18:50
@Calinou Calinou added this to the 4.0 milestone Jun 19, 2020
@akien-mga akien-mga merged commit 6d8c14f into godotengine:master Jun 19, 2020
@akien-mga
Copy link
Member

Thanks!

Comment on lines +222 to +236
// Button

theme->set_stylebox("normal", "ToolButton", make_empty_stylebox(6, 4, 6, 4));
theme->set_stylebox("pressed", "ToolButton", make_stylebox(button_pressed_png, 4, 4, 4, 4, 6, 4, 6, 4));
theme->set_stylebox("hover", "ToolButton", make_stylebox(button_normal_png, 4, 4, 4, 4, 6, 4, 6, 4));
theme->set_stylebox("disabled", "ToolButton", make_empty_stylebox(6, 4, 6, 4));
theme->set_stylebox("focus", "ToolButton", focus);
theme->set_font("font", "ToolButton", default_font);
theme->set_stylebox("normal", "Button", make_empty_stylebox(6, 4, 6, 4));
theme->set_stylebox("pressed", "Button", make_stylebox(button_pressed_png, 4, 4, 4, 4, 6, 4, 6, 4));
theme->set_stylebox("hover", "Button", make_stylebox(button_normal_png, 4, 4, 4, 4, 6, 4, 6, 4));
theme->set_stylebox("disabled", "Button", make_empty_stylebox(6, 4, 6, 4));
theme->set_stylebox("focus", "Button", focus);
theme->set_font("font", "Button", default_font);

theme->set_color("font_color", "ToolButton", control_font_color);
theme->set_color("font_color_pressed", "ToolButton", control_font_color_pressed);
theme->set_color("font_color_hover", "ToolButton", control_font_color_hover);
theme->set_color("font_color_disabled", "ToolButton", Color(0.9, 0.95, 1, 0.3));
theme->set_color("font_color", "Button", control_font_color);
theme->set_color("font_color_pressed", "Button", control_font_color_pressed);
theme->set_color("font_color_hover", "Button", control_font_color_hover);
theme->set_color("font_color_disabled", "Button", Color(0.9, 0.95, 1, 0.3));

theme->set_constant("hseparation", "ToolButton", 3);
theme->set_constant("hseparation", "Button", 3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Calinou You wondered why all Buttons now look like ToolButtons? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the ToolButton node in favor of plain Buttons
2 participants