Skip to content

Commit

Permalink
ColorPicker: ignore TextureRect expand mode during legacy picking
Browse files Browse the repository at this point in the history
The color picker has a "legacy" fallback mode when
`FEATURE_SCREEN_CAPTURE` is not supported by the current
`DisplayServer`. It works by "freezing" the current view by making a
huge `Popup` with a `TextureRect` inside covering the screen.

Before this patch, said `TextureRect` could get cut off if its buffer
was nominally bigger than the parent popup, such as when the
`canvas_items` content scale mode is active.

This is because the default TextureRect scaling logic only allows
expanding the texture up. `EXPAND_IGNORE_SIZE` fixes that by allowing
the texture to logically "shrink", filling the whole screen
independently of the actual buffer size.

Special thanks to Federico Fausto Santoro for helping with the diagnosis
:D

Co-Authored-By: Federico Fausto Santoro <[email protected]>
  • Loading branch information
Riteo and fedyfausto committed Sep 20, 2024
1 parent 0a4aedb commit ef48c4d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions scene/gui/color_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ void ColorPicker::_pick_button_pressed_legacy() {

picker_texture_rect = memnew(TextureRect);
picker_texture_rect->set_anchors_preset(Control::PRESET_FULL_RECT);
picker_texture_rect->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE);
picker_window->add_child(picker_texture_rect);
picker_texture_rect->set_default_cursor_shape(CURSOR_POINTING_HAND);
picker_texture_rect->connect(SceneStringName(gui_input), callable_mp(this, &ColorPicker::_picker_texture_input));
Expand Down

0 comments on commit ef48c4d

Please sign in to comment.