Fixed smaller issues and added all of mat maker's widgets to the build.

This commit is contained in:
Relintai 2022-06-14 17:16:26 +02:00
parent 35fadcb6bb
commit f180658682
5 changed files with 21 additions and 7 deletions

View File

@ -41,11 +41,15 @@ sources = [
"editor/widgets/gradient_editor/gradient_editor.cpp", "editor/widgets/gradient_editor/gradient_editor.cpp",
"editor/widgets/gradient_editor/gradient_popup.cpp", "editor/widgets/gradient_editor/gradient_popup.cpp",
#"editor/widgets//.cpp", "editor/widgets/image_picker_button/image_picker_button.cpp",
#"editor/widgets//.cpp",
#"editor/widgets//.cpp", "editor/widgets/mm_dnd_color_picker_button/mm_dnd_color_picker_button.cpp",
#"editor/widgets//.cpp",
#"editor/widgets//.cpp", "editor/widgets/polygon_edit/polygon_control_point.cpp",
"editor/widgets/polygon_edit/polygon_dialog.cpp",
"editor/widgets/polygon_edit/polygon_edit.cpp",
"editor/widgets/polygon_edit/polygon_editor.cpp",
"editor/widgets/polygon_edit/polygon_view.cpp",
] ]

View File

@ -5,6 +5,8 @@
#include "core/io/resource_loader.h" #include "core/io/resource_loader.h"
#include "scene/resources/texture.h" #include "scene/resources/texture.h"
#include "scene/resources/bit_map.h"
String ImagePickerButton::get_image_path() { String ImagePickerButton::get_image_path() {
return image_path; return image_path;
} }

View File

@ -1,6 +1,8 @@
#include "polygon_control_point.h" #include "polygon_control_point.h"
#include "polygon_editor.h"
bool PolygonControlPoint::get_moving() const { bool PolygonControlPoint::get_moving() const {
return moving; return moving;
} }
@ -17,7 +19,7 @@ void PolygonControlPoint::_draw() {
} }
void PolygonControlPoint::initialize(const Vector2 &p) { void PolygonControlPoint::initialize(const Vector2 &p) {
set_rect_position(get_parent().transform_point(p) - OFFSET); set_position(polygon_editor->transform_point(p) - OFFSET);
} }
void PolygonControlPoint::_on_ControlPoint_gui_input(const Ref<InputEvent> &event) { void PolygonControlPoint::_on_ControlPoint_gui_input(const Ref<InputEvent> &event) {
@ -30,7 +32,7 @@ void PolygonControlPoint::_on_ControlPoint_gui_input(const Ref<InputEvent> &even
moving = true; moving = true;
} else { } else {
moving = false; moving = false;
get_parent().update_controls(); polygon_editor->update_controls();
} }
} else if (iemb->get_button_index() == BUTTON_RIGHT && event->is_pressed()) { } else if (iemb->get_button_index() == BUTTON_RIGHT && event->is_pressed()) {
emit_signal("removed", get_index()); emit_signal("removed", get_index());
@ -44,6 +46,7 @@ void PolygonControlPoint::_on_ControlPoint_gui_input(const Ref<InputEvent> &even
} }
PolygonControlPoint::PolygonControlPoint() { PolygonControlPoint::PolygonControlPoint() {
polygon_editor = nullptr;
moving = false; moving = false;
set_custom_minimum_size(Vector2(7, 7)); set_custom_minimum_size(Vector2(7, 7));

View File

@ -5,6 +5,8 @@
#include "core/os/input_event.h" #include "core/os/input_event.h"
class PolygonEditor;
class PolygonControlPoint : public Control { class PolygonControlPoint : public Control {
GDCLASS(PolygonControlPoint, Control); GDCLASS(PolygonControlPoint, Control);
@ -20,6 +22,8 @@ public:
PolygonControlPoint(); PolygonControlPoint();
~PolygonControlPoint(); ~PolygonControlPoint();
PolygonEditor *polygon_editor;
const Vector2 OFFSET = Vector2(3, 3); const Vector2 OFFSET = Vector2(3, 3);
protected: protected:

View File

@ -26,6 +26,7 @@ void PolygonEditor::update_controls() {
Vector2 p = points[i]; Vector2 p = points[i];
PolygonControlPoint *control_point = memnew(PolygonControlPoint); PolygonControlPoint *control_point = memnew(PolygonControlPoint);
control_point->polygon_editor = this;
add_child(control_point); add_child(control_point);
control_point->initialize(p); control_point->initialize(p);