summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_track_editor.cpp11
-rw-r--r--editor/animation_track_editor.h2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp29
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h3
-rw-r--r--editor/script_editor_debugger.cpp13
-rw-r--r--editor/script_editor_debugger.h4
6 files changed, 37 insertions, 25 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 33f833afa4..40aa9a28b2 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -2026,7 +2026,7 @@ void AnimationTrackEdit::_notification(int p_what) {
float offset = animation->track_get_key_time(track, i) - timeline->get_value();
if (editor->is_key_selected(track, i) && editor->is_moving_selection()) {
- offset = editor->snap_time(offset + editor->get_moving_selection_offset());
+ offset = editor->snap_time(offset + editor->get_moving_selection_offset(), true);
}
offset = offset * scale + limit;
if (i < animation->track_get_key_count(track) - 1) {
@@ -5703,7 +5703,7 @@ void AnimationTrackEditor::_selection_changed() {
}
}
-float AnimationTrackEditor::snap_time(float p_value) {
+float AnimationTrackEditor::snap_time(float p_value, bool p_relative) {
if (is_snap_enabled()) {
@@ -5713,7 +5713,12 @@ float AnimationTrackEditor::snap_time(float p_value) {
else
snap_increment = step->get_value();
- p_value = Math::stepify(p_value, snap_increment);
+ if (p_relative) {
+ double rel = Math::fmod(timeline->get_value(), snap_increment);
+ p_value = Math::stepify(p_value + rel, snap_increment) - rel;
+ } else {
+ p_value = Math::stepify(p_value, snap_increment);
+ }
}
return p_value;
diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h
index fd28d8f4d1..ef6a769196 100644
--- a/editor/animation_track_editor.h
+++ b/editor/animation_track_editor.h
@@ -521,7 +521,7 @@ public:
bool is_moving_selection() const;
bool is_snap_enabled() const;
float get_moving_selection_offset() const;
- float snap_time(float p_value);
+ float snap_time(float p_value, bool p_relative = false);
bool is_grouping_tracks();
MenuButton *get_edit_menu();
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 7170ce30cc..fcbd68a60f 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -3671,7 +3671,7 @@ void CanvasItemEditor::_notification(int p_what) {
int nb_having_pivot = 0;
// Update the viewport if the canvas_item changes
- List<CanvasItem *> selection = _get_edited_canvas_items();
+ List<CanvasItem *> selection = _get_edited_canvas_items(true);
for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get();
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
@@ -3971,9 +3971,9 @@ void CanvasItemEditor::_update_scrollbars() {
updating_scroll = true;
// Move the zoom buttons
- Point2 zoom_hb_begin = Point2(5, 5);
- zoom_hb_begin += (show_rulers) ? Point2(RULER_WIDTH, RULER_WIDTH) : Point2();
- zoom_hb->set_begin(zoom_hb_begin);
+ Point2 controls_vb_begin = Point2(5, 5);
+ controls_vb_begin += (show_rulers) ? Point2(RULER_WIDTH, RULER_WIDTH) : Point2();
+ controls_vb->set_begin(controls_vb_begin);
// Move and resize the scrollbars
Size2 size = viewport->get_size();
@@ -5308,6 +5308,14 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
scene_tree->set_anchors_and_margins_preset(Control::PRESET_WIDE);
scene_tree->add_child(p_editor->get_scene_root());
+ controls_vb = memnew(VBoxContainer);
+ controls_vb->set_begin(Point2(5, 5));
+
+ zoom_hb = memnew(HBoxContainer);
+ // Bring the zoom percentage closer to the zoom buttons
+ zoom_hb->add_constant_override("separation", Math::round(-8 * EDSCALE));
+ controls_vb->add_child(zoom_hb);
+
viewport = memnew(CanvasItemEditorViewport(p_editor, this));
viewport_scrollable->add_child(viewport);
viewport->set_mouse_filter(MOUSE_FILTER_PASS);
@@ -5351,11 +5359,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
v_scroll->connect("value_changed", this, "_update_scroll");
v_scroll->hide();
- zoom_hb = memnew(HBoxContainer);
- viewport->add_child(zoom_hb);
- zoom_hb->set_begin(Point2(5, 5));
- // Bring the zoom percentage closer to the zoom buttons
- zoom_hb->add_constant_override("separation", Math::round(-8 * EDSCALE));
+ viewport->add_child(controls_vb);
zoom_minus = memnew(ToolButton);
zoom_hb->add_child(zoom_minus);
@@ -5742,8 +5746,6 @@ void CanvasItemEditorViewport::_on_change_type_closed() {
}
void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const {
- label->set_position(get_global_position() + Point2(14, 14) * EDSCALE);
- label_desc->set_position(label->get_position() + Point2(0, label->get_size().height));
bool add_preview = false;
for (int i = 0; i < files.size(); i++) {
String path = files[i];
@@ -6165,7 +6167,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
label->add_color_override("font_color_shadow", Color(0, 0, 0, 1));
label->add_constant_override("shadow_as_outline", 1 * EDSCALE);
label->hide();
- editor->get_gui_base()->add_child(label);
+ canvas_item_editor->get_controls_container()->add_child(label);
label_desc = memnew(Label);
label_desc->set_text(TTR("Drag & drop + Shift : Add node as sibling\nDrag & drop + Alt : Change node type"));
@@ -6174,7 +6176,8 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
label_desc->add_constant_override("shadow_as_outline", 1 * EDSCALE);
label_desc->add_constant_override("line_spacing", 0);
label_desc->hide();
- editor->get_gui_base()->add_child(label_desc);
+ canvas_item_editor->get_controls_container()->add_child(label_desc);
+
VS::get_singleton()->canvas_set_disable_scale(true);
}
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 3fdf00d611..3ba66c00f9 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -530,6 +530,7 @@ private:
void _button_toggle_anchor_mode(bool p_status);
+ VBoxContainer *controls_vb;
HBoxContainer *zoom_hb;
void _zoom_on_position(float p_zoom, Point2 p_position = Point2());
void _update_zoom_label();
@@ -627,6 +628,8 @@ public:
Control *get_viewport_control() { return viewport; }
+ Control *get_controls_container() { return controls_vb; }
+
void update_viewport();
Tool get_current_tool() { return tool; }
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index afbd8832f2..a7f338051a 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -492,7 +492,7 @@ void ScriptEditorDebugger::_video_mem_request() {
Size2 ScriptEditorDebugger::get_minimum_size() const {
- Size2 ms = Control::get_minimum_size();
+ Size2 ms = MarginContainer::get_minimum_size();
ms.y = MAX(ms.y, 250 * EDSCALE);
return ms;
}
@@ -1426,11 +1426,12 @@ void ScriptEditorDebugger::_notification(int p_what) {
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ add_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
+ add_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT));
+
tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles"));
tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles"));
tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles"));
- tabs->set_margin(MARGIN_LEFT, -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
- tabs->set_margin(MARGIN_RIGHT, EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT));
copy->set_icon(get_icon("ActionCopy", "EditorIcons"));
step->set_icon(get_icon("DebugStep", "EditorIcons"));
@@ -2242,6 +2243,9 @@ void ScriptEditorDebugger::_bind_methods() {
ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
+ add_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
+ add_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT));
+
ppeer = Ref<PacketPeerStream>(memnew(PacketPeerStream));
ppeer->set_input_buffer_max_size(1024 * 1024 * 8); //8mb should be enough
editor = p_editor;
@@ -2253,9 +2257,6 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles"));
tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles"));
- tabs->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- tabs->set_margin(MARGIN_LEFT, -editor->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
- tabs->set_margin(MARGIN_RIGHT, editor->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT));
add_child(tabs);
{ //debugger
diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h
index 14b024d066..c885614dab 100644
--- a/editor/script_editor_debugger.h
+++ b/editor/script_editor_debugger.h
@@ -55,9 +55,9 @@ class EditorNetworkProfiler;
class ScriptEditorDebuggerInspectedObject;
-class ScriptEditorDebugger : public Control {
+class ScriptEditorDebugger : public MarginContainer {
- GDCLASS(ScriptEditorDebugger, Control);
+ GDCLASS(ScriptEditorDebugger, MarginContainer);
public:
enum CameraOverride {