summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-07-05 10:20:44 +0200
committerGitHub <noreply@github.com>2017-07-05 10:20:44 +0200
commitf4ff452a58b46b4ed8429eeeb32bfe766acc829a (patch)
tree30195918f476e5604c2aeb7d6ee4546ccf89a2cb /editor
parent444354b51f8f9a3be9805d137f890302c02de0db (diff)
parent3aff102fc3a9db4bcebdee844c8f6c02147bf371 (diff)
Merge pull request #9496 from Noshyaar/pr-itemlist
ItemList: expose methods, in-editor items editing support
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/item_list_editor_plugin.cpp40
-rw-r--r--editor/plugins/item_list_editor_plugin.h29
2 files changed, 69 insertions, 0 deletions
diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp
index 7f56286f08..f567abc5b1 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() {
diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h
index 042e88839f..4fed8e49f5 100644
--- a/editor/plugins/item_list_editor_plugin.h
+++ b/editor/plugins/item_list_editor_plugin.h
@@ -167,6 +167,35 @@ public:
///////////////////////////////////////////////////////////////
+class ItemListItemListPlugin : public ItemListPlugin {
+
+ GDCLASS(ItemListItemListPlugin, ItemListPlugin);
+
+ ItemList *pp;
+
+public:
+ virtual void set_object(Object *p_object);
+ virtual bool handles(Object *p_object) const;
+ virtual int get_flags() const;
+
+ virtual void set_item_text(int p_idx, const String &p_text) { pp->set_item_text(p_idx, p_text); }
+ virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); }
+
+ virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { pp->set_item_icon(p_idx, p_tex); }
+ virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
+
+ virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx, !p_enabled); }
+ virtual bool is_item_enabled(int p_idx) const { return !pp->is_item_disabled(p_idx); }
+
+ virtual void add_item();
+ virtual int get_item_count() const;
+ virtual void erase(int p_idx);
+
+ ItemListItemListPlugin();
+};
+
+///////////////////////////////////////////////////////////////
+
class ItemListEditor : public HBoxContainer {
GDCLASS(ItemListEditor, HBoxContainer);