@@ -1928,6 +1928,30 @@ void EditorInspectorSection::_notification(int p_what) {
19281928 Ref<Font> light_font = theme_cache.light_font ;
19291929 int light_font_size = theme_cache.light_font_size ;
19301930
1931+ // - Keying
1932+ Ref<Texture2D> key = theme_cache.icon_gui_animation_key ;
1933+ if (keying && key.is_valid ()) {
1934+ Point2 key_position;
1935+ key_position.x = rtl ? (margin_end + 2 * EDSCALE) : (get_size ().width - key->get_width () - margin_end - 2 * EDSCALE);
1936+ keying_rect = Rect2 (key_position.x - 2 * EDSCALE, 0 , key->get_width () + 4 * EDSCALE, header_height);
1937+
1938+ Color key_color (1 , 1 , 1 );
1939+ if (keying_hover) {
1940+ key_color.r *= 1.2 ;
1941+ key_color.g *= 1.2 ;
1942+ key_color.b *= 1.2 ;
1943+
1944+ Ref<StyleBox> sb_hover = theme_cache.key_hover ;
1945+ draw_style_box (sb_hover, keying_rect);
1946+ }
1947+ key_position.y = (header_height - key->get_height ()) / 2 ;
1948+
1949+ draw_texture (key, key_position, key_color);
1950+ margin_end += key->get_width () + 6 * EDSCALE;
1951+ } else {
1952+ keying_rect = Rect2 ();
1953+ }
1954+
19311955 // - Checkbox.
19321956 Ref<Texture2D> checkbox = _get_checkbox ();
19331957 if (checkbox.is_valid ()) {
@@ -1936,8 +1960,8 @@ void EditorInspectorSection::_notification(int p_what) {
19361960 Point2 checkbox_position;
19371961 Point2 label_position;
19381962 if (rtl) {
1939- label_position.x = margin_start ;
1940- checkbox_position.x = margin_start + label_size.width + 2 * EDSCALE;
1963+ label_position.x = margin_end ;
1964+ checkbox_position.x = margin_end + label_size.width + 2 * EDSCALE;
19411965 } else {
19421966 label_position.x = get_size ().width - (margin_end + label_size.width );
19431967 checkbox_position.x = label_position.x - checkbox->get_width () - 2 * EDSCALE;
@@ -1961,6 +1985,8 @@ void EditorInspectorSection::_notification(int p_what) {
19611985 draw_texture (checkbox, checkbox_position, checkbox_color);
19621986 draw_string (light_font, label_position, checkbox_text, HORIZONTAL_ALIGNMENT_LEFT, -1 .0f , light_font_size, check_font_color, TextServer::JUSTIFICATION_NONE);
19631987 margin_end += label_size.width + checkbox->get_width () + 6 * EDSCALE;
1988+ } else {
1989+ check_rect = Rect2 ();
19641990 }
19651991
19661992 int available = get_size ().width - (margin_start + margin_end);
@@ -2037,6 +2063,9 @@ void EditorInspectorSection::_notification(int p_what) {
20372063 if (dropping_for_unfold) {
20382064 dropping_unfold_timer->stop ();
20392065 }
2066+
2067+ check_hover = false ;
2068+ keying_hover = false ;
20402069 queue_redraw ();
20412070 } break ;
20422071 }
@@ -2141,11 +2170,19 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
21412170
21422171 Ref<InputEventMouse> me = p_event;
21432172 if (me.is_valid ()) {
2144- bool new_check_hover = check_rect.has_point (me->get_position ());
2173+ Vector2 mpos = me->get_position ();
2174+
2175+ bool new_check_hover = check_rect.has_point (mpos);
21452176 if (new_check_hover != check_hover) {
21462177 check_hover = new_check_hover;
21472178 queue_redraw ();
21482179 }
2180+
2181+ bool new_keying_hover = keying_rect.has_point (mpos);
2182+ if (new_keying_hover != keying_hover) {
2183+ keying_hover = new_keying_hover;
2184+ queue_redraw ();
2185+ }
21492186 }
21502187
21512188 Ref<InputEventKey> k = p_event;
@@ -2164,24 +2201,28 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
21642201
21652202 Ref<InputEventMouseButton> mb = p_event;
21662203 if (mb.is_valid () && mb->is_pressed () && mb->get_button_index () == MouseButton::LEFT) {
2204+ Vector2 pos = mb->get_position ();
2205+
21672206 if (object->editor_is_section_unfolded (section)) {
21682207 int header_height = _get_header_height ();
21692208
2170- if (mb-> get_position () .y >= header_height) {
2209+ if (pos .y >= header_height) {
21712210 return ;
21722211 }
21732212 }
21742213
21752214 accept_event ();
21762215
2177- if (checkable && check_rect.has_point (mb-> get_position () )) {
2216+ if (checkable && check_rect.has_point (pos )) {
21782217 checked = !checked;
21792218 emit_signal (SNAME (" section_toggled_by_user" ), related_enable_property, checked);
21802219 if (checked) {
21812220 unfold ();
21822221 } else if (!checkbox_only) {
2183- fold ();
2222+ vbox-> hide ();
21842223 }
2224+ } else if (keying && keying_rect.has_point (pos)) {
2225+ emit_signal (SNAME (" property_keyed" ), related_enable_property, false );
21852226 } else if (foldable) {
21862227 bool should_unfold = has_children_to_show && !(checkable && !checked && !checkbox_only) && !object->editor_is_section_unfolded (section);
21872228 if (should_unfold) {
@@ -2221,23 +2262,22 @@ void EditorInspectorSection::_accessibility_action_expand(const Variant &p_data)
22212262}
22222263
22232264void EditorInspectorSection::unfold () {
2224- if (!foldable && checkbox_only) {
2265+ if (( !foldable && !checkable) || (! checkbox_only && checkable && !checked) ) {
22252266 return ;
22262267 }
22272268
22282269 _test_unfold ();
22292270
2230- object->editor_set_section_unfold (section, true );
2271+ if (foldable) {
2272+ object->editor_set_section_unfold (section, true );
2273+ }
2274+
22312275 vbox->show ();
22322276 queue_redraw ();
22332277}
22342278
22352279void EditorInspectorSection::fold () {
2236- if (!foldable && checkbox_only) {
2237- return ;
2238- }
2239-
2240- if (!vbox_added) {
2280+ if (!foldable || !vbox_added) {
22412281 return ;
22422282 }
22432283
@@ -2251,21 +2291,32 @@ void EditorInspectorSection::set_bg_color(const Color &p_bg_color) {
22512291 queue_redraw ();
22522292}
22532293
2294+ void EditorInspectorSection::set_keying (bool p_keying) {
2295+ if (keying == (checkable && p_keying)) {
2296+ return ;
2297+ }
2298+
2299+ keying = checkable && p_keying;
2300+ if (checkable) {
2301+ queue_redraw ();
2302+ }
2303+ }
2304+
22542305void EditorInspectorSection::reset_timer () {
22552306 if (dropping_for_unfold && !dropping_unfold_timer->is_stopped ()) {
22562307 dropping_unfold_timer->start ();
22572308 }
22582309}
22592310
2260- void EditorInspectorSection::set_checkable (const String &p_related_check_property, bool p_checkbox_only) {
2311+ void EditorInspectorSection::set_checkable (const String &p_related_check_property, bool p_checkbox_only, bool p_checked ) {
22612312 if (checkable == !p_related_check_property.is_empty ()) {
22622313 return ;
22632314 }
22642315
22652316 checkbox_only = p_checkbox_only;
22662317 checkable = !p_related_check_property.is_empty ();
2318+ checked = p_checked;
22672319 related_enable_property = p_related_check_property;
2268- queue_redraw ();
22692320
22702321 if (InspectorDock::get_singleton ()) {
22712322 if (checkable) {
@@ -2274,15 +2325,27 @@ void EditorInspectorSection::set_checkable(const String &p_related_check_propert
22742325 InspectorDock::get_inspector_singleton ()->disconnect (" property_edited" , callable_mp (this , &EditorInspectorSection::_property_edited));
22752326 }
22762327 }
2328+
2329+ if (!checkbox_only && checkable && !checked) {
2330+ vbox->hide ();
2331+ }
2332+
2333+ queue_redraw ();
22772334}
22782335
22792336void EditorInspectorSection::set_checked (bool p_checked) {
2337+ if (checked == p_checked) {
2338+ return ;
2339+ }
2340+
22802341 checked = p_checked;
2281- if (!checkbox_only && !checked) {
2282- fold ();
2283- } else {
2342+ if (!checkbox_only && checkable && !checked) {
2343+ vbox-> hide ();
2344+ } else if (!checkbox_only) {
22842345 unfold ();
22852346 }
2347+
2348+ queue_redraw ();
22862349}
22872350
22882351bool EditorInspectorSection::has_revertable_properties () const {
@@ -2303,12 +2366,20 @@ void EditorInspectorSection::property_can_revert_changed(const String &p_path, b
23032366
23042367void EditorInspectorSection::_property_edited (const String &p_property) {
23052368 if (!related_enable_property.is_empty () && p_property == related_enable_property) {
2306- bool valid = false ;
2307- Variant value_checked = object->get (related_enable_property, &valid);
2369+ update_property ();
2370+ }
2371+ }
23082372
2309- if (valid) {
2310- set_checked (value_checked.operator bool ());
2311- }
2373+ void EditorInspectorSection::update_property () {
2374+ if (!checkable) {
2375+ return ;
2376+ }
2377+
2378+ bool valid = false ;
2379+ Variant value_checked = object->get (related_enable_property, &valid);
2380+
2381+ if (valid) {
2382+ set_checked (value_checked.operator bool ());
23122383 }
23132384}
23142385
@@ -2319,6 +2390,7 @@ void EditorInspectorSection::_bind_methods() {
23192390 ClassDB::bind_method (D_METHOD (" fold" ), &EditorInspectorSection::fold);
23202391
23212392 ADD_SIGNAL (MethodInfo (" section_toggled_by_user" , PropertyInfo (Variant::STRING_NAME, " property" ), PropertyInfo (Variant::BOOL, " value" )));
2393+ ADD_SIGNAL (MethodInfo (" property_keyed" , PropertyInfo (Variant::STRING_NAME, " property" )));
23222394}
23232395
23242396EditorInspectorSection::EditorInspectorSection () {
@@ -3362,8 +3434,10 @@ void EditorInspector::initialize_section_theme(EditorInspectorSection::ThemeCach
33623434 p_cache.arrow_collapsed_mirrored = p_control->get_theme_icon (SNAME (" arrow_collapsed_mirrored" ), SNAME (" Tree" ));
33633435 p_cache.icon_gui_checked = p_control->get_editor_theme_icon (SNAME (" GuiChecked" ));
33643436 p_cache.icon_gui_unchecked = p_control->get_editor_theme_icon (SNAME (" GuiUnchecked" ));
3437+ p_cache.icon_gui_animation_key = p_control->get_editor_theme_icon (SNAME (" Key" ));
33653438
33663439 p_cache.indent_box = p_control->get_theme_stylebox (SNAME (" indent_box" ), SNAME (" EditorInspectorSection" ));
3440+ p_cache.key_hover = p_control->get_theme_stylebox (SceneStringName (hover), " Button" );
33673441}
33683442
33693443void EditorInspector::initialize_category_theme (EditorInspectorCategory::ThemeCache &p_cache, Control *p_control) {
@@ -3994,6 +4068,7 @@ void EditorInspector::update_tree() {
39944068 section->set_tooltip_text (tooltip);
39954069
39964070 section->connect (" section_toggled_by_user" , callable_mp (this , &EditorInspector::_section_toggled_by_user));
4071+ section->connect (" property_keyed" , callable_mp (this , &EditorInspector::_property_keyed));
39974072
39984073 // Add editors at the start of a group.
39994074 for (Ref<EditorInspectorPlugin> &ped : valid_plugins) {
@@ -4207,8 +4282,8 @@ void EditorInspector::update_tree() {
42074282 Variant value_checked = object->get (p.name , &valid);
42084283
42094284 if (valid) {
4210- last_created_section->set_checkable (p.name , p.hint_string == " checkbox_only" );
4211- last_created_section->set_checked (value_checked. operator bool () );
4285+ last_created_section->set_checkable (p.name , p.hint_string == " checkbox_only" , value_checked. operator bool () );
4286+ last_created_section->set_keying (keying );
42124287
42134288 if (p.name .begins_with (group_base)) {
42144289 group_togglable_property = last_created_section;
@@ -4415,13 +4490,15 @@ void EditorInspector::update_tree() {
44154490 Variant value_checked = object->get (corresponding_section->related_enable_property , &valid);
44164491 if (valid) {
44174492 section->section = corresponding_section->section ;
4418- section->set_checkable (corresponding_section->related_enable_property , corresponding_section->checkbox_only );
4419- section->set_checked (value_checked. operator bool () );
4493+ section->set_checkable (corresponding_section->related_enable_property , corresponding_section->checkbox_only , value_checked. operator bool () );
4494+ section->set_keying (keying );
44204495 if (use_doc_hints) {
44214496 section->set_tooltip_text (corresponding_section->get_tooltip_text ());
44224497 }
44234498
44244499 section->connect (" section_toggled_by_user" , callable_mp (this , &EditorInspector::_section_toggled_by_user));
4500+ section->connect (" property_keyed" , callable_mp (this , &EditorInspector::_property_keyed));
4501+ sections.push_back (section);
44254502 }
44264503 }
44274504 }
@@ -4452,13 +4529,15 @@ void EditorInspector::update_tree() {
44524529 Variant value_checked = object->get (corresponding_section->related_enable_property , &valid);
44534530 if (valid) {
44544531 section->section = corresponding_section->section ;
4455- section->set_checkable (corresponding_section->related_enable_property , corresponding_section->checkbox_only );
4456- section->set_checked (value_checked. operator bool () );
4532+ section->set_checkable (corresponding_section->related_enable_property , corresponding_section->checkbox_only , value_checked. operator bool () );
4533+ section->set_keying (keying );
44574534 if (use_doc_hints) {
44584535 section->set_tooltip_text (corresponding_section->get_tooltip_text ());
44594536 }
44604537
44614538 section->connect (" section_toggled_by_user" , callable_mp (this , &EditorInspector::_section_toggled_by_user));
4539+ section->connect (" property_keyed" , callable_mp (this , &EditorInspector::_property_keyed));
4540+ sections.push_back (section);
44624541 }
44634542 }
44644543 }
@@ -4554,6 +4633,12 @@ void EditorInspector::update_property(const String &p_prop) {
45544633 E->update_editor_property_status ();
45554634 E->update_cache ();
45564635 }
4636+
4637+ for (EditorInspectorSection *S : sections) {
4638+ if (S->is_checkable ()) {
4639+ S->_property_edited (p_prop);
4640+ }
4641+ }
45574642}
45584643
45594644void EditorInspector::_clear (bool p_hide_plugins) {
@@ -4645,6 +4730,10 @@ void EditorInspector::_keying_changed() {
46454730 }
46464731 }
46474732 }
4733+
4734+ for (EditorInspectorSection *S : sections) {
4735+ S->set_keying (keying);
4736+ }
46484737}
46494738
46504739void EditorInspector::set_read_only (bool p_read_only) {
@@ -5381,6 +5470,11 @@ void EditorInspector::_notification(int p_what) {
53815470 }
53825471 }
53835472 }
5473+
5474+ for (EditorInspectorSection *S : sections) {
5475+ S->update_property ();
5476+ }
5477+
53845478 refresh_countdown = float (EDITOR_GET (" docks/property_editor/auto_refresh_interval" ));
53855479 }
53865480 }
@@ -5404,6 +5498,10 @@ void EditorInspector::_notification(int p_what) {
54045498 }
54055499 pending.remove (pending.begin ());
54065500 }
5501+
5502+ for (EditorInspectorSection *S : sections) {
5503+ S->update_property ();
5504+ }
54075505 }
54085506
54095507 changing--;
0 commit comments