diff options
| author | volzhs | 2017-04-28 01:51:23 +0900 |
|---|---|---|
| committer | volzhs | 2017-04-28 02:09:18 +0900 |
| commit | e592860145ff511d4249c46d98fc4845d943bad8 (patch) | |
| tree | d6fe9616702fa6a3fabb7a26b8f94ca17d62c310 | |
| parent | 6cde867b2ffdcf3b25e927349967a95f15298df6 (diff) | |
| download | godot-e592860145ff511d4249c46d98fc4845d943bad8.tar.gz godot-e592860145ff511d4249c46d98fc4845d943bad8.tar.zst godot-e592860145ff511d4249c46d98fc4845d943bad8.zip | |
Show transparency and accurate color for property
Diffstat (limited to '')
| -rw-r--r-- | editor/icons/2x/icon_transparent.png | bin | 0 -> 177 bytes | |||
| -rw-r--r-- | editor/icons/icon_transparent.png | bin | 0 -> 158 bytes | |||
| -rw-r--r-- | editor/property_editor.cpp | 23 | ||||
| -rw-r--r-- | editor/property_editor.h | 1 |
4 files changed, 22 insertions, 2 deletions
diff --git a/editor/icons/2x/icon_transparent.png b/editor/icons/2x/icon_transparent.png Binary files differnew file mode 100644 index 000000000..627607039 --- /dev/null +++ b/editor/icons/2x/icon_transparent.png diff --git a/editor/icons/icon_transparent.png b/editor/icons/icon_transparent.png Binary files differnew file mode 100644 index 000000000..07e9b52b5 --- /dev/null +++ b/editor/icons/icon_transparent.png diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index c4aa2d921..5c13fea95 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -2028,7 +2028,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; @@ -3168,7 +3168,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")); @@ -3309,6 +3309,24 @@ 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() { TreeItem *item = tree->get_selected(); @@ -3790,6 +3808,7 @@ void PropertyEditor::_bind_methods() { ObjectTypeDB::bind_method("update_tree", &PropertyEditor::update_tree); ObjectTypeDB::bind_method("_resource_preview_done", &PropertyEditor::_resource_preview_done); ObjectTypeDB::bind_method("refresh", &PropertyEditor::refresh); + ObjectTypeDB::bind_method("_draw_transparency", &PropertyEditor::_draw_transparency); ObjectTypeDB::bind_method(_MD("get_drag_data_fw"), &PropertyEditor::get_drag_data_fw); ObjectTypeDB::bind_method(_MD("can_drop_data_fw"), &PropertyEditor::can_drop_data_fw); diff --git a/editor/property_editor.h b/editor/property_editor.h index 18c6e4b89..bbfac4187 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -234,6 +234,7 @@ class PropertyEditor : public Control { 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; |
