summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-01-08 19:11:35 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-01-08 19:12:24 -0300
commit4fd464a4c5fc83c34377450935671b7be868333c (patch)
treeb6b0b7199bbe0b2366fcb42b092ef5c757d3891f
parentde73297883712962571c69e960e893ed12ee3854 (diff)
Removed ratio anchoring (will have to fix multiple 3D views later..)
-rw-r--r--scene/gui/control.cpp117
-rw-r--r--scene/gui/control.h1
-rw-r--r--tools/editor/call_dialog.cpp11
-rw-r--r--tools/editor/call_dialog.h2
-rw-r--r--tools/editor/editor_node.cpp10
-rw-r--r--tools/editor/editor_node.h3
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp44
7 files changed, 51 insertions, 137 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 8018b845da..1f5f6e10f6 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -116,30 +116,7 @@ bool Control::_set(const StringName& p_name, const Variant& p_value) {
String name= p_name;
if (!name.begins_with("custom")) {
- if (name.begins_with("margin/")) {
- String dname = name.get_slicec('/', 1);
- if (dname == "left") {
- set_margin(MARGIN_LEFT, p_value);
- return true;
- }
- else if (dname == "top") {
- set_margin(MARGIN_TOP, p_value);
- return true;
- }
- else if (dname == "right") {
- set_margin(MARGIN_RIGHT, p_value);
- return true;
- }
- else if (dname == "bottom") {
- set_margin(MARGIN_BOTTOM, p_value);
- return true;
- }
- else {
- return false;
- }
- } else {
- return false;
- }
+ return false;
}
if (p_value.get_type()==Variant::NIL) {
@@ -235,30 +212,8 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const {
String sname=p_name;
if (!sname.begins_with("custom")) {
- if (sname.begins_with("margin/")) {
- String dname = sname.get_slicec('/', 1);
- if (dname == "left") {
- r_ret = get_margin(MARGIN_LEFT);
- return true;
- }
- else if (dname == "top") {
- r_ret = get_margin(MARGIN_TOP);
- return true;
- }
- else if (dname == "right") {
- r_ret = get_margin(MARGIN_RIGHT);
- return true;
- }
- else if (dname == "bottom") {
- r_ret = get_margin(MARGIN_BOTTOM);
- return true;
- }
- else {
- return false;
- }
- } else {
- return false;
- }
+ return false;
+
}
if (sname.begins_with("custom_icons/")) {
@@ -295,36 +250,6 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const {
}
void Control::_get_property_list( List<PropertyInfo> *p_list) const {
- {
- if (get_anchor(MARGIN_LEFT) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/left", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/left", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
-
- if (get_anchor(MARGIN_TOP) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/top", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/top", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
-
- if (get_anchor(MARGIN_RIGHT) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/right", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/right", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
-
- if (get_anchor(MARGIN_BOTTOM) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/bottom", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/bottom", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
- }
-
Ref<Theme> theme;
if (data.theme.is_valid()) {
@@ -1258,14 +1183,10 @@ void Control::_size_changed() {
margin_pos[i]=area-data.margin[i];
} break;
- case ANCHOR_RATIO: {
+ case ANCHOR_CENTER: {
- margin_pos[i]=area*data.margin[i];
+ margin_pos[i]=(area/2)-data.margin[i];
} break;
- case ANCHOR_CENTER: {
-
- margin_pos[i]=(area/2)-data.margin[i];
- } break;
}
}
@@ -1334,12 +1255,9 @@ float Control::_s2a(float p_val, AnchorType p_anchor,float p_range) const {
case ANCHOR_END: {
return p_range-p_val;
} break;
- case ANCHOR_RATIO: {
- return p_val/p_range;
+ case ANCHOR_CENTER: {
+ return (p_range/2)-p_val;
} break;
- case ANCHOR_CENTER: {
- return (p_range/2)-p_val;
- } break;
}
return 0;
@@ -1356,11 +1274,8 @@ float Control::_a2s(float p_val, AnchorType p_anchor,float p_range) const {
case ANCHOR_END: {
return Math::floor(p_range-p_val);
} break;
- case ANCHOR_RATIO: {
- return Math::floor(p_range*p_val);
- } break;
case ANCHOR_CENTER: {
- return Math::floor((p_range/2)-p_val);
+ return Math::floor((p_range/2)-p_val);
} break;
}
return 0;
@@ -2565,10 +2480,16 @@ void Control::_bind_methods() {
BIND_VMETHOD(MethodInfo("drop_data",PropertyInfo(Variant::VECTOR2,"pos"),PropertyInfo(Variant::NIL,"data")));
ADD_GROUP("Anchor","anchor_");
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_left", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_top", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_right", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_bottom", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_BOTTOM );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_left", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_top", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_right", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_bottom", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_BOTTOM );
+
+ ADD_GROUP("Margin","margin_");
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_left", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_top", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_right", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_bottom", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_BOTTOM );
ADD_GROUP("Rect","rect_");
ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_pos"),_SCS("get_pos") );
@@ -2577,6 +2498,7 @@ void Control::_bind_methods() {
ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect_rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("set_rotation_deg"),_SCS("get_rotation_deg") );
ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect_scale"), _SCS("set_scale"),_SCS("get_scale") );
+
ADD_GROUP("Hint","hint_");
ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint_tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") );
@@ -2598,7 +2520,6 @@ void Control::_bind_methods() {
BIND_CONSTANT( ANCHOR_BEGIN );
BIND_CONSTANT( ANCHOR_END );
- BIND_CONSTANT( ANCHOR_RATIO );
BIND_CONSTANT( ANCHOR_CENTER );
BIND_CONSTANT( FOCUS_NONE );
BIND_CONSTANT( FOCUS_CLICK );
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 2da004c583..fa8e5f22e3 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -54,7 +54,6 @@ public:
enum AnchorType {
ANCHOR_BEGIN,
ANCHOR_END,
- ANCHOR_RATIO,
ANCHOR_CENTER,
};
diff --git a/tools/editor/call_dialog.cpp b/tools/editor/call_dialog.cpp
index 7e8ce1a37a..054a5098f0 100644
--- a/tools/editor/call_dialog.cpp
+++ b/tools/editor/call_dialog.cpp
@@ -28,6 +28,7 @@
/*************************************************************************/
#include "call_dialog.h"
+#if 0
#include "scene/gui/label.h"
#include "object_type_db.h"
#include "print_string.h"
@@ -268,7 +269,6 @@ CallDialog::CallDialog() {
tree = memnew( Tree );
- tree->set_anchor( MARGIN_RIGHT, ANCHOR_RATIO );
tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
tree->set_begin( Point2( 20,50 ) );
tree->set_margin(MARGIN_BOTTOM, 44 );
@@ -283,7 +283,7 @@ CallDialog::CallDialog() {
property_editor->set_anchor_and_margin( MARGIN_RIGHT, ANCHOR_END, 15 );
property_editor->set_anchor_and_margin( MARGIN_TOP, ANCHOR_BEGIN, 50 );
- property_editor->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.55 );
+// property_editor->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.55 );
property_editor->set_anchor_and_margin( MARGIN_BOTTOM, ANCHOR_END, 90 );
property_editor->get_scene_tree()->set_hide_root( true );
property_editor->hide_top_label();
@@ -296,21 +296,21 @@ CallDialog::CallDialog() {
add_child(method_label);
Label *label = memnew( Label );
- label->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.53 );
+ //label->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.53 );
label->set_anchor_and_margin( MARGIN_TOP, ANCHOR_BEGIN, 25 );
label->set_text(TTR("Arguments:"));
add_child(label);
return_label = memnew( Label );
- return_label->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.53 );
+ //return_label->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.53 );
return_label->set_anchor_and_margin( MARGIN_TOP, ANCHOR_END, 85 );
return_label->set_text(TTR("Return:"));
add_child(return_label);
return_value = memnew( LineEdit );
- return_value->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.55 );
+ //return_value->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.55 );
return_value->set_anchor_and_margin( MARGIN_RIGHT, ANCHOR_END, 15 );
return_value->set_anchor_and_margin( MARGIN_TOP, ANCHOR_END, 65 );
@@ -338,3 +338,4 @@ CallDialog::~CallDialog()
{
memdelete(call_params);
}
+#endif
diff --git a/tools/editor/call_dialog.h b/tools/editor/call_dialog.h
index 928ee74567..b0ebe68d86 100644
--- a/tools/editor/call_dialog.h
+++ b/tools/editor/call_dialog.h
@@ -39,6 +39,7 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
+#if 0
class CallDialogParams;
@@ -81,3 +82,4 @@ public:
};
#endif
+#endif
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 72a8473945..6961d25d76 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -2638,12 +2638,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
_set_editing_top_editors(current);
} break;
- case OBJECT_CALL_METHOD: {
-
- editor_data.apply_changes_in_editors();;
- call_dialog->set_object(current);
- call_dialog->popup_centered_ratio();
- } break;
case RUN_PLAY: {
_menu_option_confirm(RUN_STOP,true);
_call_build();
@@ -6346,9 +6340,7 @@ EditorNode::EditorNode() {
- call_dialog = memnew( CallDialog );
- call_dialog->hide();
- gui_base->add_child( call_dialog );
+
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index 90162e0082..fcfd5ca389 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -159,7 +159,6 @@ private:
OBJECT_COPY_PARAMS,
OBJECT_PASTE_PARAMS,
OBJECT_UNIQUE_RESOURCES,
- OBJECT_CALL_METHOD,
OBJECT_REQUEST_HELP,
RUN_PLAY,
@@ -287,7 +286,7 @@ private:
CreateDialog *create_dialog;
- CallDialog *call_dialog;
+// CallDialog *call_dialog;
ConfirmationDialog *confirmation;
ConfirmationDialog *import_confirmation;
ConfirmationDialog *open_recent_confirmation;
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index ef2ea13729..2897723f29 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -2963,9 +2963,9 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
}
viewports[0]->set_area_as_parent_rect();
- viewports[0]->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_RATIO,0.5);
+ //viewports[0]->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_RATIO,0.5);
viewports[2]->set_area_as_parent_rect();
- viewports[2]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
+ //viewports[2]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false );
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), true );
@@ -2987,9 +2987,9 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
}
viewports[0]->set_area_as_parent_rect();
- viewports[0]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
+ //viewports[0]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
viewports[2]->set_area_as_parent_rect();
- viewports[2]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
+ //viewports[2]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false );
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false );
@@ -3009,13 +3009,13 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
viewports[i]->show();
}
viewports[0]->set_area_as_parent_rect();
- viewports[0]->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_RATIO,0.5);
+ //viewports[0]->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_RATIO,0.5);
viewports[2]->set_area_as_parent_rect();
- viewports[2]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
- viewports[2]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
+ //viewports[2]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
+ //viewports[2]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
viewports[3]->set_area_as_parent_rect();
- viewports[3]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
- viewports[3]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
+ //viewports[3]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
+ //viewports[3]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false );
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false );
@@ -3035,13 +3035,13 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
viewports[i]->show();
}
viewports[0]->set_area_as_parent_rect();
- viewports[0]->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_RATIO,0.5);
- viewports[0]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
+ //viewports[0]->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_RATIO,0.5);
+ //viewports[0]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
viewports[2]->set_area_as_parent_rect();
- viewports[2]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
- viewports[2]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
+ //viewports[2]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
+ //viewports[2]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
viewports[3]->set_area_as_parent_rect();
- viewports[3]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
+ //viewports[3]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false );
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false );
@@ -3058,17 +3058,17 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
viewports[i]->show();
}
viewports[0]->set_area_as_parent_rect();
- viewports[0]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
- viewports[0]->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_RATIO,0.5);
+ //viewports[0]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
+ //viewports[0]->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_RATIO,0.5);
viewports[1]->set_area_as_parent_rect();
- viewports[1]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
- viewports[1]->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_RATIO,0.5);
+ //viewports[1]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
+ //viewports[1]->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_RATIO,0.5);
viewports[2]->set_area_as_parent_rect();
- viewports[2]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
- viewports[2]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
+ //viewports[2]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
+ //viewports[2]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
viewports[3]->set_area_as_parent_rect();
- viewports[3]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
- viewports[3]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
+ //viewports[3]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
+ //viewports[3]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false );
view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false );