2022-04-11 13:42:49 +02:00
|
|
|
/*
|
|
|
|
Copyright (c) 2019-2022 Péter Magyar
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mdi_ed.h"
|
|
|
|
|
2022-04-13 20:39:17 +02:00
|
|
|
#include "./uv_editor/mdr_ed_uv_previewer.h"
|
|
|
|
#include "./uv_editor/mdr_uv_rect_editor_popup.h"
|
2022-04-13 02:08:30 +02:00
|
|
|
#include "core/os/keyboard.h"
|
|
|
|
#include "mdi_ed_plugin.h"
|
2022-04-13 20:39:17 +02:00
|
|
|
#include "scene/gui/box_container.h"
|
|
|
|
#include "scene/gui/button.h"
|
|
|
|
#include "scene/gui/label.h"
|
|
|
|
#include "scene/gui/scroll_container.h"
|
|
|
|
#include "scene/gui/separator.h"
|
2022-04-13 02:08:30 +02:00
|
|
|
|
2022-04-11 13:42:49 +02:00
|
|
|
void MDIEd::_enter_tree() {
|
|
|
|
/*
|
|
|
|
uv_preview = get_node(uv_preview_path)
|
|
|
|
uv_editor = get_node(uv_editor_path)
|
|
|
|
|
|
|
|
if _plugin && uv_editor:
|
|
|
|
uv_editor.set_plugin(_plugin)
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
void MDIEd::set_plugin(EditorPlugin *plugin) {
|
|
|
|
/*
|
|
|
|
_plugin = plugin
|
|
|
|
|
|
|
|
if uv_editor:
|
|
|
|
uv_editor.set_plugin(plugin)
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
void MDIEd::set_mesh_data_resource(Ref<MeshDataResource> a) {
|
|
|
|
/*
|
|
|
|
if uv_preview:
|
|
|
|
uv_preview.set_mesh_data_resource(a)
|
|
|
|
|
|
|
|
if uv_editor:
|
|
|
|
uv_editor.set_mesh_data_resource(a)
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
void MDIEd::set_mesh_data_instance(MeshDataInstance *a) {
|
|
|
|
/*
|
|
|
|
if uv_preview:
|
|
|
|
uv_preview.set_mesh_data_instance(a)
|
|
|
|
|
|
|
|
if uv_editor:
|
|
|
|
uv_editor.set_mesh_data_instance(a)
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
void MDIEd::_unhandled_key_input(Ref<InputEventKey> event) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (event->is_echo()) {
|
|
|
|
return;
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
|
2022-04-13 02:08:30 +02:00
|
|
|
if (event->get_alt() || event->get_shift() || event->get_control() || event->get_metakey() || event->get_command()) {
|
|
|
|
return;
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
|
2022-04-13 02:08:30 +02:00
|
|
|
uint32_t scancode = event->get_scancode();
|
2022-04-11 13:42:49 +02:00
|
|
|
|
2022-04-13 02:08:30 +02:00
|
|
|
if (scancode == KEY_G) {
|
|
|
|
set_edit_mode_translate();
|
|
|
|
} else if (scancode == KEY_H) {
|
|
|
|
set_edit_mode_rotate();
|
|
|
|
} else if (scancode == KEY_J) {
|
|
|
|
set_edit_mode_scale();
|
|
|
|
} else if (scancode == KEY_V) {
|
|
|
|
set_axis_x(!get_axis_x());
|
|
|
|
} else if (scancode == KEY_B) {
|
|
|
|
set_axis_y(!get_axis_y());
|
|
|
|
} else if (scancode == KEY_N) {
|
|
|
|
set_axis_z(!get_axis_z());
|
|
|
|
} else if (scancode == KEY_K) {
|
|
|
|
set_selection_mode_vertex();
|
|
|
|
} else if (scancode == KEY_L) {
|
|
|
|
set_selection_mode_edge();
|
|
|
|
} else if (scancode == KEY_SEMICOLON) {
|
|
|
|
set_selection_mode_face();
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Edit modes
|
|
|
|
void MDIEd::set_edit_mode_translate() {
|
|
|
|
/*
|
|
|
|
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer/Translate.pressed = true
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
void MDIEd::set_edit_mode_rotate() {
|
|
|
|
/*
|
|
|
|
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer/Rotate.pressed = true
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
void MDIEd::set_edit_mode_scale() {
|
|
|
|
/*
|
|
|
|
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer/Scale.pressed = true
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void MDIEd::on_edit_mode_translate_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
if (_plugin) {
|
|
|
|
_plugin->set_translate();
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::on_edit_mode_rotate_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
if (_plugin) {
|
|
|
|
_plugin->set_rotate();
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::on_edit_mode_scale_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
if (_plugin) {
|
|
|
|
_plugin->set_scale();
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//axis locks
|
|
|
|
bool MDIEd::get_axis_x() {
|
|
|
|
/*
|
|
|
|
return $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisX.pressed
|
|
|
|
*/
|
2022-04-13 14:59:40 +02:00
|
|
|
return false;
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
bool MDIEd::get_axis_y() {
|
|
|
|
/*
|
|
|
|
return $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisY.pressed
|
|
|
|
*/
|
2022-04-13 14:59:40 +02:00
|
|
|
return false;
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
bool MDIEd::get_axis_z() {
|
|
|
|
/*
|
|
|
|
return $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisZ.pressed
|
|
|
|
*/
|
2022-04-13 14:59:40 +02:00
|
|
|
return false;
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::set_axis_x(bool on) {
|
|
|
|
/*
|
|
|
|
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisX.pressed = on
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
void MDIEd::set_axis_y(bool on) {
|
|
|
|
/*
|
|
|
|
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisY.pressed = on
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
void MDIEd::set_axis_z(bool on) {
|
|
|
|
/*
|
|
|
|
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisZ.pressed = on
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void MDIEd::on_axis_x_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
if (_plugin) {
|
|
|
|
_plugin->set_axis_x(on);
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::on_axis_y_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
if (_plugin) {
|
|
|
|
_plugin->set_axis_y(on);
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::on_axis_z_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
if (_plugin) {
|
|
|
|
_plugin->set_axis_z(on);
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//selection modes
|
|
|
|
void MDIEd::on_selection_mode_vertex_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
if (_plugin) {
|
|
|
|
_plugin->set_selection_mode_vertex();
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::on_selection_mode_edge_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
if (_plugin) {
|
|
|
|
_plugin->set_selection_mode_edge();
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::on_selection_mode_face_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
if (_plugin) {
|
|
|
|
_plugin->set_selection_mode_face();
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MDIEd::set_selection_mode_vertex() {
|
|
|
|
/*
|
|
|
|
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer3/Vertex.pressed = true
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
void MDIEd::set_selection_mode_edge() {
|
|
|
|
/*
|
|
|
|
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer3/Edge.pressed = true
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
void MDIEd::set_selection_mode_face() {
|
|
|
|
/*
|
|
|
|
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer3/Face.pressed = true
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void MDIEd::_on_Extrude_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->extrude();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_AddBox_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->add_box();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_UnwrapButton_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->uv_unwrap();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_add_triangle_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->add_triangle();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_add_quad_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->add_quad();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_split_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->split();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_connect_to_first_selected_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->connect_to_first_selected();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_connect_to_avg_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->connect_to_avg();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_connect_to_last_selected_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->connect_to_last_selected();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_disconnect_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->disconnect_action();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_add_triangle_at_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->add_triangle_at();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_add_auad_at_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->add_quad_at();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_oncreate_face_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->create_face();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_delete_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->delete_selected();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_GenNormals_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->generate_normals();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_RemDoubles_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->remove_doubles();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_MergeOptimize_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->merge_optimize();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_GenTangents_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->generate_tangents();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_mark_seam_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->mark_seam();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_unmark_seam_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->unmark_seam();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_apply_seams_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->apply_seam();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_uv_edit_pressed() {
|
|
|
|
/*
|
|
|
|
$Popups/UVEditorPopup.popup_centered()
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void MDIEd::on_pivot_average_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
_plugin->set_pivot_averaged();
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::on_pivot_mdi_origin_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
_plugin->set_pivot_mdi_origin();
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::on_pivot_world_origin_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
if (on) {
|
|
|
|
_plugin->set_pivot_world_origin();
|
|
|
|
}
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::on_visual_indicator_outline_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->visual_indicator_outline_set(on);
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::on_visual_indicator_seam_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->visual_indicator_seam_set(on);
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::on_visual_indicator_handle_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->visual_indicator_handle_set(on);
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_select_all_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->select_all();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MDIEd::onhandle_selection_type_front_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->handle_selection_type_front();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::onhandle_selection_type_back_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->handle_selection_type_back();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::onhandle_selection_type_all_toggled(bool on) {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->handle_selection_type_all();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MDIEd::_on_clean_mesh_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->clean_mesh();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
void MDIEd::_on_flip_face_pressed() {
|
2022-04-13 02:08:30 +02:00
|
|
|
_plugin->flip_selected_faces();
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MDIEd::MDIEd() {
|
2022-04-13 20:39:17 +02:00
|
|
|
uv_preview = nullptr;
|
|
|
|
|
|
|
|
//Main
|
|
|
|
VBoxContainer *main_cont = memnew(VBoxContainer);
|
|
|
|
add_child(main_cont);
|
|
|
|
|
|
|
|
// -- Actions
|
|
|
|
VBoxContainer *main_actions_container = memnew(VBoxContainer);
|
|
|
|
main_cont->add_child(main_actions_container);
|
|
|
|
|
|
|
|
HBoxContainer *actions_inner_container = memnew(HBoxContainer);
|
|
|
|
actions_inner_container->set_alignment(BoxContainer::ALIGN_CENTER);
|
|
|
|
main_actions_container->add_child(actions_inner_container);
|
|
|
|
|
|
|
|
VBoxContainer *left_actions_container = memnew(VBoxContainer);
|
|
|
|
actions_inner_container->add_child(left_actions_container);
|
|
|
|
|
|
|
|
VBoxContainer *right_actions_container = memnew(VBoxContainer);
|
|
|
|
actions_inner_container->add_child(right_actions_container);
|
|
|
|
|
|
|
|
// -- Actions -- Edit Mode
|
|
|
|
Label *action_label = memnew(Label);
|
|
|
|
action_label->set_text("E");
|
|
|
|
action_label->set_align(Label::ALIGN_CENTER);
|
|
|
|
action_label->set_valign(Label::VALIGN_CENTER);
|
|
|
|
action_label->set_tooltip("Edit Mode");
|
|
|
|
action_label->set_mouse_filter(Control::MOUSE_FILTER_STOP);
|
|
|
|
action_label->set_v_size_flags(SIZE_EXPAND_FILL | SIZE_SHRINK_CENTER);
|
|
|
|
left_actions_container->add_child(action_label);
|
|
|
|
|
|
|
|
Ref<ButtonGroup> action_button_group;
|
|
|
|
action_button_group.instance();
|
|
|
|
|
|
|
|
HBoxContainer *action_buttons_container = memnew(HBoxContainer);
|
|
|
|
right_actions_container->add_child(action_buttons_container);
|
|
|
|
|
|
|
|
Button *action_button = memnew(Button);
|
|
|
|
action_button->set_text("T");
|
|
|
|
action_button->set_toggle_mode(true);
|
|
|
|
action_button->set_pressed(true);
|
|
|
|
action_button->set_button_group(action_button_group);
|
|
|
|
action_button->set_custom_minimum_size(Size2(25, 20));
|
|
|
|
action_button->set_tooltip("Translate");
|
|
|
|
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
action_button->connect("toggled", this, "on_edit_mode_translate_toggled");
|
|
|
|
action_buttons_container->add_child(action_button);
|
|
|
|
|
|
|
|
action_button = memnew(Button);
|
|
|
|
action_button->set_text("R");
|
|
|
|
action_button->set_toggle_mode(true);
|
|
|
|
action_button->set_pressed(false);
|
|
|
|
action_button->set_button_group(action_button_group);
|
|
|
|
action_button->set_custom_minimum_size(Size2(25, 20));
|
|
|
|
action_button->set_tooltip("Rotate");
|
|
|
|
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
action_button->connect("toggled", this, "on_edit_mode_rotate_toggled");
|
|
|
|
action_buttons_container->add_child(action_button);
|
|
|
|
|
|
|
|
action_button = memnew(Button);
|
|
|
|
action_button->set_text("S");
|
|
|
|
action_button->set_toggle_mode(true);
|
|
|
|
action_button->set_pressed(false);
|
|
|
|
action_button->set_button_group(action_button_group);
|
|
|
|
action_button->set_custom_minimum_size(Size2(25, 20));
|
|
|
|
action_button->set_tooltip("Scale");
|
|
|
|
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
action_button->connect("toggled", this, "on_edit_mode_scale_toggled");
|
|
|
|
action_buttons_container->add_child(action_button);
|
|
|
|
|
|
|
|
// -- Actions -- Active Axis
|
|
|
|
action_label = memnew(Label);
|
|
|
|
action_label->set_text("A");
|
|
|
|
action_label->set_align(Label::ALIGN_CENTER);
|
|
|
|
action_label->set_valign(Label::VALIGN_CENTER);
|
|
|
|
action_label->set_tooltip("Active Axis");
|
|
|
|
action_label->set_mouse_filter(Control::MOUSE_FILTER_STOP);
|
|
|
|
action_label->set_v_size_flags(SIZE_EXPAND_FILL | SIZE_SHRINK_CENTER);
|
|
|
|
left_actions_container->add_child(action_label);
|
|
|
|
|
|
|
|
action_buttons_container = memnew(HBoxContainer);
|
|
|
|
right_actions_container->add_child(action_buttons_container);
|
|
|
|
|
|
|
|
action_button = memnew(Button);
|
|
|
|
action_button->set_text("X");
|
|
|
|
action_button->set_toggle_mode(true);
|
|
|
|
action_button->set_pressed(true);
|
|
|
|
action_button->set_custom_minimum_size(Size2(25, 20));
|
|
|
|
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
action_button->connect("toggled", this, "on_axis_x_toggled");
|
|
|
|
action_buttons_container->add_child(action_button);
|
|
|
|
|
|
|
|
action_button = memnew(Button);
|
|
|
|
action_button->set_text("Y");
|
|
|
|
action_button->set_toggle_mode(true);
|
|
|
|
action_button->set_pressed(true);
|
|
|
|
action_button->set_custom_minimum_size(Size2(25, 20));
|
|
|
|
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
action_button->connect("toggled", this, "on_axis_y_toggled");
|
|
|
|
action_buttons_container->add_child(action_button);
|
|
|
|
|
|
|
|
action_button = memnew(Button);
|
|
|
|
action_button->set_text("Z");
|
|
|
|
action_button->set_toggle_mode(true);
|
|
|
|
action_button->set_pressed(true);
|
|
|
|
action_button->set_custom_minimum_size(Size2(25, 20));
|
|
|
|
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
action_button->connect("toggled", this, "on_axis_z_toggled");
|
|
|
|
action_buttons_container->add_child(action_button);
|
|
|
|
|
|
|
|
// -- Actions -- Selection Mode
|
|
|
|
action_label = memnew(Label);
|
|
|
|
action_label->set_text("S");
|
|
|
|
action_label->set_align(Label::ALIGN_CENTER);
|
|
|
|
action_label->set_valign(Label::VALIGN_CENTER);
|
|
|
|
action_label->set_tooltip("Selection Mode");
|
|
|
|
action_label->set_mouse_filter(Control::MOUSE_FILTER_STOP);
|
|
|
|
action_label->set_v_size_flags(SIZE_EXPAND_FILL | SIZE_SHRINK_CENTER);
|
|
|
|
left_actions_container->add_child(action_label);
|
|
|
|
|
|
|
|
action_button_group.instance();
|
|
|
|
|
|
|
|
action_buttons_container = memnew(HBoxContainer);
|
|
|
|
right_actions_container->add_child(action_buttons_container);
|
|
|
|
|
|
|
|
action_button = memnew(Button);
|
|
|
|
action_button->set_text("V");
|
|
|
|
action_button->set_toggle_mode(true);
|
|
|
|
action_button->set_pressed(true);
|
|
|
|
action_button->set_button_group(action_button_group);
|
|
|
|
action_button->set_custom_minimum_size(Size2(25, 20));
|
|
|
|
action_button->set_tooltip("Vertex");
|
|
|
|
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
action_button->connect("toggled", this, "on_selection_mode_vertex_toggled");
|
|
|
|
action_buttons_container->add_child(action_button);
|
|
|
|
|
|
|
|
action_button = memnew(Button);
|
|
|
|
action_button->set_text("E");
|
|
|
|
action_button->set_toggle_mode(true);
|
|
|
|
action_button->set_pressed(false);
|
|
|
|
action_button->set_button_group(action_button_group);
|
|
|
|
action_button->set_custom_minimum_size(Size2(25, 20));
|
|
|
|
action_button->set_tooltip("Edge");
|
|
|
|
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
action_button->connect("toggled", this, "on_selection_mode_edge_toggled");
|
|
|
|
action_buttons_container->add_child(action_button);
|
|
|
|
|
|
|
|
action_button = memnew(Button);
|
|
|
|
action_button->set_text("F");
|
|
|
|
action_button->set_toggle_mode(true);
|
|
|
|
action_button->set_pressed(false);
|
|
|
|
action_button->set_button_group(action_button_group);
|
|
|
|
action_button->set_custom_minimum_size(Size2(25, 20));
|
|
|
|
action_button->set_tooltip("Face");
|
|
|
|
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
action_button->connect("toggled", this, "on_selection_mode_face_toggled");
|
|
|
|
action_buttons_container->add_child(action_button);
|
|
|
|
|
|
|
|
// -- Main separator
|
|
|
|
main_cont->add_child(memnew(HSeparator));
|
|
|
|
|
|
|
|
// -- Main ScrollContainer
|
|
|
|
ScrollContainer *main_scroll_container = memnew(ScrollContainer);
|
|
|
|
main_cont->add_child(main_scroll_container);
|
|
|
|
|
|
|
|
//Popups
|
|
|
|
Control *popups_node = memnew(Control);
|
|
|
|
popups_node->set_mouse_filter(MOUSE_FILTER_IGNORE);
|
|
|
|
add_child(popups_node);
|
|
|
|
|
|
|
|
uv_editor = memnew(MDRUVRectEditorPopup);
|
|
|
|
uv_editor->set_title("UV Editor");
|
|
|
|
uv_editor->set_resizable(true);
|
|
|
|
uv_editor->hide();
|
|
|
|
popups_node->add_child(uv_editor);
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MDIEd::~MDIEd() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void MDIEd::_bind_methods() {
|
2022-04-13 20:39:17 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("on_edit_mode_translate_toggled"), &MDIEd::on_edit_mode_translate_toggled);
|
|
|
|
ClassDB::bind_method(D_METHOD("on_edit_mode_rotate_toggled"), &MDIEd::on_edit_mode_rotate_toggled);
|
|
|
|
ClassDB::bind_method(D_METHOD("on_edit_mode_scale_toggled"), &MDIEd::on_edit_mode_scale_toggled);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("on_axis_x_toggled"), &MDIEd::on_axis_x_toggled);
|
|
|
|
ClassDB::bind_method(D_METHOD("on_axis_y_toggled"), &MDIEd::on_axis_y_toggled);
|
|
|
|
ClassDB::bind_method(D_METHOD("on_axis_z_toggled"), &MDIEd::on_axis_z_toggled);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("on_selection_mode_vertex_toggled"), &MDIEd::on_selection_mode_vertex_toggled);
|
|
|
|
ClassDB::bind_method(D_METHOD("on_selection_mode_edge_toggled"), &MDIEd::on_selection_mode_edge_toggled);
|
|
|
|
ClassDB::bind_method(D_METHOD("on_selection_mode_face_toggled"), &MDIEd::on_selection_mode_face_toggled);
|
2022-04-11 13:42:49 +02:00
|
|
|
}
|