MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / set_offset

Method set_offset

editor/scene/gradient_editor_plugin.cpp:160–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160void GradientEdit::set_offset(int p_index, float p_offset) {
161 ERR_FAIL_INDEX_MSG(p_index, gradient->get_point_count(), "Gradient point is out of bounds.");
162
163 // Use pre_grab_offset to determine things for the undo/redo.
164 if (Math::is_equal_approx(pre_grab_offset, p_offset)) {
165 return;
166 }
167
168 int new_idx = _predict_insertion_index(p_offset);
169
170 gradient->set_offset(p_index, pre_grab_offset); // Pretend the point started from its old place.
171 EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
172 undo_redo->create_action(TTR("Move Gradient Point"));
173 undo_redo->add_do_method(*gradient, "set_offset", pre_grab_index, p_offset);
174 undo_redo->add_do_method(this, "set_selected_index", new_idx);
175 undo_redo->add_undo_method(*gradient, "set_offset", new_idx, pre_grab_offset);
176 undo_redo->add_undo_method(this, "set_selected_index", pre_grab_index);
177 undo_redo->commit_action();
178 queue_redraw();
179}
180
181void GradientEdit::set_color(int p_index, const Color &p_color) {
182 ERR_FAIL_INDEX_MSG(p_index, gradient->get_point_count(), "Gradient point is out of bounds.");

Callers 9

gui_inputMethod · 0.45
Camera3DEditorMethod · 0.45
Node3DEditorViewportMethod · 0.45
EditorResourcePickerMethod · 0.45
EditorLayoutsDialogMethod · 0.45
_notificationMethod · 0.45

Calls 7

TTRFunction · 0.85
is_equal_approxFunction · 0.50
get_point_countMethod · 0.45
create_actionMethod · 0.45
add_do_methodMethod · 0.45
add_undo_methodMethod · 0.45
commit_actionMethod · 0.45

Tested by

no test coverage detected