summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-01-25 19:58:41 +0100
committerGitHub <noreply@github.com>2017-01-25 19:58:41 +0100
commit4b9ec15124c8784d11980a467318c585bbc0e0e2 (patch)
tree68f3980116c41fbb7294c22730fadc6f3b2791d2 /tools
parent1005a56e5a27fb7f491d280d5aff6fe88691365c (diff)
parent92363a2afee8b31a4ba4e1fd059dffabfeec0e95 (diff)
Merge pull request #7542 from volzhs/modulate-transparency
Show transparency and accurate color for modulate
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/icons/2x/icon_transparent.pngbin0 -> 177 bytes
-rw-r--r--tools/editor/icons/icon_transparent.pngbin0 -> 158 bytes
-rw-r--r--tools/editor/property_editor.cpp24
-rw-r--r--tools/editor/property_editor.h1
4 files changed, 23 insertions, 2 deletions
diff --git a/tools/editor/icons/2x/icon_transparent.png b/tools/editor/icons/2x/icon_transparent.png
new file mode 100644
index 0000000000..627607039b
--- /dev/null
+++ b/tools/editor/icons/2x/icon_transparent.png
Binary files differ
diff --git a/tools/editor/icons/icon_transparent.png b/tools/editor/icons/icon_transparent.png
new file mode 100644
index 0000000000..07e9b52b5c
--- /dev/null
+++ b/tools/editor/icons/icon_transparent.png
Binary files differ
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index ab850ba1a7..e5dce0524f 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -2431,7 +2431,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
} break;
case Variant::COLOR: {
- p_item->set_custom_bg_color(1,obj->get(p_name));
+ tree->update();
//p_item->set_text(1,obj->get(p_name));
} break;
@@ -3708,7 +3708,7 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
item->set_editable( 1, !read_only );
//item->set_text(1,obj->get(p.name));
- item->set_custom_bg_color(1,obj->get(p.name));
+ item->set_custom_draw(1,this,"_draw_transparency");
if (show_type_icons)
item->set_icon( 0,get_icon("Color","EditorIcons") );
@@ -3856,6 +3856,25 @@ void PropertyEditor::update_tree() {
}
}
+void PropertyEditor::_draw_transparency(Object *t, const Rect2& p_rect) {
+
+ TreeItem *ti=t->cast_to<TreeItem>();
+ if (!ti)
+ return;
+
+ Color color=obj->get(ti->get_metadata(1));
+ Ref<Texture> arrow=tree->get_icon("select_arrow");
+
+ // make a little space between consecutive color fields
+ Rect2 area=p_rect;
+ area.pos.y+=1;
+ area.size.height-=2;
+ area.size.width-=arrow->get_size().width+5;
+ tree->draw_texture_rect(get_icon("Transparent", "EditorIcons"), area, true);
+ tree->draw_rect(area, color);
+
+}
+
void PropertyEditor::_item_selected() {
@@ -4366,6 +4385,7 @@ void PropertyEditor::_bind_methods() {
ClassDB::bind_method( "update_tree",&PropertyEditor::update_tree);
ClassDB::bind_method( "_resource_preview_done",&PropertyEditor::_resource_preview_done);
ClassDB::bind_method( "refresh",&PropertyEditor::refresh);
+ ClassDB::bind_method( "_draw_transparency",&PropertyEditor::_draw_transparency);
ClassDB::bind_method(_MD("get_drag_data_fw"), &PropertyEditor::get_drag_data_fw);
ClassDB::bind_method(_MD("can_drop_data_fw"), &PropertyEditor::can_drop_data_fw);
diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h
index 900d06497f..3f8d071a01 100644
--- a/tools/editor/property_editor.h
+++ b/tools/editor/property_editor.h
@@ -245,6 +245,7 @@ friend class ProjectExportDialog;
void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
void _resource_preview_done(const String& p_path,const Ref<Texture>& p_preview,Variant p_ud);
+ void _draw_transparency(Object *t, const Rect2& p_rect);
UndoRedo *undo_redo;
protected: