mirror of https://github.com/godotengine/godot
Merge pull request #111226 from PhairZ/copy-color
Add a copy button to the color picker dialog.
This commit is contained in:
commit
10aa2e3013
|
|
@ -179,6 +179,9 @@
|
|||
<theme_item name="bar_arrow" data_type="icon" type="Texture2D">
|
||||
The texture for the arrow grabber.
|
||||
</theme_item>
|
||||
<theme_item name="color_copy" data_type="icon" type="Texture2D">
|
||||
The icon for the button that copies the color in text format to the clipboard.
|
||||
</theme_item>
|
||||
<theme_item name="color_hue" data_type="icon" type="Texture2D">
|
||||
Custom texture for the hue selection slider on the right.
|
||||
</theme_item>
|
||||
|
|
|
|||
|
|
@ -1523,6 +1523,7 @@ void ThemeClassic::populate_standard_styles(const Ref<EditorTheme> &p_theme, Edi
|
|||
p_theme->set_icon("picker_cursor", "ColorPicker", p_theme->get_icon(SNAME("PickerCursor"), EditorStringName(EditorIcons)));
|
||||
p_theme->set_icon("picker_cursor_bg", "ColorPicker", p_theme->get_icon(SNAME("PickerCursorBg"), EditorStringName(EditorIcons)));
|
||||
p_theme->set_icon("color_script", "ColorPicker", p_theme->get_icon(SNAME("Script"), EditorStringName(EditorIcons)));
|
||||
p_theme->set_icon("color_copy", "ColorPicker", p_theme->get_icon(SNAME("ActionCopy"), EditorStringName(EditorIcons)));
|
||||
|
||||
// ColorPickerButton.
|
||||
p_theme->set_icon("bg", "ColorPickerButton", p_theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));
|
||||
|
|
|
|||
|
|
@ -1563,6 +1563,7 @@ void ThemeModern::populate_standard_styles(const Ref<EditorTheme> &p_theme, Edit
|
|||
p_theme->set_icon("picker_cursor", "ColorPicker", p_theme->get_icon(SNAME("PickerCursor"), EditorStringName(EditorIcons)));
|
||||
p_theme->set_icon("picker_cursor_bg", "ColorPicker", p_theme->get_icon(SNAME("PickerCursorBg"), EditorStringName(EditorIcons)));
|
||||
p_theme->set_icon("color_script", "ColorPicker", p_theme->get_icon(SNAME("Script"), EditorStringName(EditorIcons)));
|
||||
p_theme->set_icon("color_copy", "ColorPicker", p_theme->get_icon(SNAME("ActionCopy"), EditorStringName(EditorIcons)));
|
||||
|
||||
// ColorPickerButton.
|
||||
p_theme->set_icon("bg", "ColorPickerButton", p_theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));
|
||||
|
|
|
|||
|
|
@ -171,6 +171,8 @@ void ColorPicker::_notification(int p_what) {
|
|||
hex_label->set_custom_minimum_size(Size2(38 * theme_cache.base_scale, 0));
|
||||
// Adjust for the width of the "script" icon.
|
||||
text_type->set_custom_minimum_size(Size2(28 * theme_cache.base_scale, 0));
|
||||
text_copy->set_button_icon(theme_cache.color_copy);
|
||||
text_copy->set_custom_minimum_size(Size2(28 * theme_cache.base_scale, 0));
|
||||
|
||||
_update_controls();
|
||||
// HACK: Deferring updating presets to ensure their size is correct when creating ColorPicker at runtime.
|
||||
|
|
@ -843,6 +845,10 @@ void ColorPicker::_text_type_toggled() {
|
|||
}
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
void ColorPicker::_text_copy_pressed() {
|
||||
DisplayServer::get_singleton()->clipboard_set(c_text->get_text());
|
||||
}
|
||||
|
||||
Color ColorPicker::get_pick_color() const {
|
||||
return color;
|
||||
}
|
||||
|
|
@ -2057,6 +2063,7 @@ void ColorPicker::_bind_methods() {
|
|||
BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, ColorPicker, color_hue);
|
||||
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, ColorPicker, color_script);
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, ColorPicker, color_copy);
|
||||
|
||||
BIND_THEME_ITEM_EXT(Theme::DATA_TYPE_STYLEBOX, ColorPicker, mode_button_normal, "tab_unselected", "TabContainer");
|
||||
BIND_THEME_ITEM_EXT(Theme::DATA_TYPE_STYLEBOX, ColorPicker, mode_button_pressed, "tab_selected", "TabContainer");
|
||||
|
|
@ -2224,6 +2231,13 @@ ColorPicker::ColorPicker() {
|
|||
c_text->connect(SceneStringName(text_changed), callable_mp(this, &ColorPicker::_text_changed));
|
||||
c_text->connect(SceneStringName(focus_exited), callable_mp(this, &ColorPicker::_html_focus_exit));
|
||||
|
||||
text_copy = memnew(Button);
|
||||
hex_hbc->add_child(text_copy);
|
||||
text_copy->set_icon_alignment(HORIZONTAL_ALIGNMENT_CENTER);
|
||||
text_copy->set_tooltip_text(ETR("Copy the color value."));
|
||||
text_type->set_accessibility_name(ETR("Copy Color"));
|
||||
text_copy->connect(SceneStringName(pressed), callable_mp(this, &ColorPicker::_text_copy_pressed));
|
||||
|
||||
_update_controls();
|
||||
updating = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@ private:
|
|||
|
||||
Button *text_type = nullptr;
|
||||
LineEdit *c_text = nullptr;
|
||||
Button *text_copy = nullptr;
|
||||
|
||||
HSlider *alpha_slider = nullptr;
|
||||
SpinBox *alpha_value = nullptr;
|
||||
|
|
@ -340,6 +341,7 @@ private:
|
|||
Ref<Texture2D> color_hue;
|
||||
|
||||
Ref<Texture2D> color_script;
|
||||
Ref<Texture2D> color_copy;
|
||||
|
||||
/* Mode buttons */
|
||||
Ref<StyleBox> mode_button_normal;
|
||||
|
|
@ -367,6 +369,7 @@ private:
|
|||
#ifdef TOOLS_ENABLED
|
||||
void _text_type_toggled();
|
||||
#endif // TOOLS_ENABLED
|
||||
void _text_copy_pressed();
|
||||
void _sample_input(const Ref<InputEvent> &p_event);
|
||||
void _sample_draw();
|
||||
void _slider_draw(int p_which);
|
||||
|
|
|
|||
|
|
@ -1100,6 +1100,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
|
|||
theme->set_icon("picker_cursor", "ColorPicker", icons["color_picker_cursor"]);
|
||||
theme->set_icon("picker_cursor_bg", "ColorPicker", icons["color_picker_cursor_bg"]);
|
||||
theme->set_icon("color_script", "ColorPicker", icons["script"]);
|
||||
theme->set_icon("color_copy", "ColorPicker", icons["action_copy"]);
|
||||
|
||||
{
|
||||
const int precision = 7;
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#e0e0e0" d="M2 1a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1h1V3h9V2a1 1 0 0 0-1-1zm3 3a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1zm1 2h7v7H6z"/></svg>
|
||||
|
After Width: | Height: | Size: 232 B |
Loading…
Reference in New Issue