diff options
| author | Rémi Verschelde | 2017-07-05 10:20:44 +0200 |
|---|---|---|
| committer | GitHub | 2017-07-05 10:20:44 +0200 |
| commit | f4ff452a58b46b4ed8429eeeb32bfe766acc829a (patch) | |
| tree | 30195918f476e5604c2aeb7d6ee4546ccf89a2cb /editor/plugins/item_list_editor_plugin.cpp | |
| parent | 444354b51f8f9a3be9805d137f890302c02de0db (diff) | |
| parent | 3aff102fc3a9db4bcebdee844c8f6c02147bf371 (diff) | |
| download | godot-f4ff452a58b46b4ed8429eeeb32bfe766acc829a.tar.gz godot-f4ff452a58b46b4ed8429eeeb32bfe766acc829a.tar.zst godot-f4ff452a58b46b4ed8429eeeb32bfe766acc829a.zip | |
Merge pull request #9496 from Noshyaar/pr-itemlist
ItemList: expose methods, in-editor items editing support
Diffstat (limited to 'editor/plugins/item_list_editor_plugin.cpp')
| -rw-r--r-- | editor/plugins/item_list_editor_plugin.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index 7f56286f0..f567abc5b 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -193,6 +193,45 @@ ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() { } /////////////////////////////////////////////////////////////// + +void ItemListItemListPlugin::set_object(Object *p_object) { + + pp = p_object->cast_to<ItemList>(); +} + +bool ItemListItemListPlugin::handles(Object *p_object) const { + + return p_object->is_class("ItemList"); +} + +int ItemListItemListPlugin::get_flags() const { + + return FLAG_ICON | FLAG_ENABLE; +} + +void ItemListItemListPlugin::add_item() { + + pp->add_item(vformat(TTR("Item %d"), pp->get_item_count())); + _change_notify(); +} + +int ItemListItemListPlugin::get_item_count() const { + + return pp->get_item_count(); +} + +void ItemListItemListPlugin::erase(int p_idx) { + + pp->remove_item(p_idx); + _change_notify(); +} + +ItemListItemListPlugin::ItemListItemListPlugin() { + + pp = NULL; +} + +/////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// @@ -373,6 +412,7 @@ ItemListEditorPlugin::ItemListEditorPlugin(EditorNode *p_node) { item_list_editor->hide(); item_list_editor->add_plugin(memnew(ItemListOptionButtonPlugin)); item_list_editor->add_plugin(memnew(ItemListPopupMenuPlugin)); + item_list_editor->add_plugin(memnew(ItemListItemListPlugin)); } ItemListEditorPlugin::~ItemListEditorPlugin() { |
