Merge pull request #95906 from larspet/change-2d-zoom
Add a zoom speed setting to the 2D editor
This commit is contained in:
commit
3db976bdb7
|
@ -258,11 +258,14 @@
|
|||
The color to use when drawing smart snapping lines in the 2D editor. The smart snapping lines will automatically display when moving 2D nodes if smart snapping is enabled in the Snapping Options menu at the top of the 2D editor viewport.
|
||||
</member>
|
||||
<member name="editors/2d/use_integer_zoom_by_default" type="bool" setter="" getter="">
|
||||
If [code]true[/code], the 2D editor will snap to integer zoom values while not holding the [kbd]Alt[/kbd] key and powers of two while holding it. If [code]false[/code], this behavior is swapped.
|
||||
If [code]true[/code], the 2D editor will snap to integer zoom values when not holding the [kbd]Alt[/kbd] key. If [code]false[/code], this behavior is swapped.
|
||||
</member>
|
||||
<member name="editors/2d/viewport_border_color" type="Color" setter="" getter="">
|
||||
The color of the viewport border in the 2D editor. This border represents the viewport's size at the base resolution defined in the Project Settings. Objects placed outside this border will not be visible unless a [Camera2D] node is used, or unless the window is resized and the stretch mode is set to [code]disabled[/code].
|
||||
</member>
|
||||
<member name="editors/2d/zoom_speed_factor" type="float" setter="" getter="">
|
||||
The factor to use when zooming in or out in the 2D editor. For example, [code]1.1[/code] will zoom in by 10% with every step. If set to [code]2.0[/code], zooming will only cycle through powers of two.
|
||||
</member>
|
||||
<member name="editors/3d/default_fov" type="float" setter="" getter="">
|
||||
The default camera vertical field of view to use in the 3D editor (in degrees). The camera field of view can be adjusted on a per-scene basis using the [b]View[/b] menu at the top of the 3D editor. If a scene had its camera field of view adjusted using the [b]View[/b] menu, this setting is ignored in the scene in question. This setting is also ignored while a [Camera3D] node is being previewed in the editor.
|
||||
[b]Note:[/b] The editor camera always uses the [b]Keep Height[/b] aspect mode.
|
||||
|
|
|
@ -767,6 +767,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/2d/bone_outline_size", 2.0, "0.01,8,0.01,or_greater")
|
||||
_initial_set("editors/2d/viewport_border_color", Color(0.4, 0.4, 1.0, 0.4));
|
||||
_initial_set("editors/2d/use_integer_zoom_by_default", false);
|
||||
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/2d/zoom_speed_factor", 1.1, "1.01,2,0.01")
|
||||
|
||||
// Panning
|
||||
// Enum should be in sync with ControlScheme in ViewPanner.
|
||||
|
|
|
@ -141,22 +141,15 @@ void EditorZoomWidget::set_zoom_by_increments(int p_increment_count, bool p_inte
|
|||
}
|
||||
}
|
||||
} else {
|
||||
// Base increment factor defined as the twelveth root of two.
|
||||
// This allows for a smooth geometric evolution of the zoom, with the advantage of
|
||||
// visiting all integer power of two scale factors.
|
||||
// Note: this is analogous to the 'semitone' interval in the music world
|
||||
// In order to avoid numerical imprecisions, we compute and edit a zoom index
|
||||
// with the following relation: zoom = 2 ^ (index / 12)
|
||||
|
||||
if (zoom < CMP_EPSILON || p_increment_count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// zoom = 2**(index/12) => log2(zoom) = index/12
|
||||
float closest_zoom_index = Math::round(Math::log(zoom_noscale) * 12.f / Math::log(2.f));
|
||||
|
||||
float new_zoom_index = closest_zoom_index + p_increment_count;
|
||||
float new_zoom = Math::pow(2.f, new_zoom_index / 12.f);
|
||||
// Zoom is calculated as pow(zoom_factor, zoom_step).
|
||||
// This ensures the zoom will always equal 100% when zoom_step is 0.
|
||||
float zoom_factor = EDITOR_GET("editors/2d/zoom_speed_factor");
|
||||
float current_zoom_step = Math::round(Math::log(zoom_noscale) / Math::log(zoom_factor));
|
||||
float new_zoom = Math::pow(zoom_factor, current_zoom_step + p_increment_count);
|
||||
|
||||
// Restore Editor scale transformation.
|
||||
new_zoom *= MAX(1, EDSCALE);
|
||||
|
|
Loading…
Reference in New Issue