-split view of property editor and editor settings

This commit is contained in:
Juan Linietsky 2015-12-15 23:39:36 -03:00
parent 035bb03331
commit a1142225bf
11 changed files with 251 additions and 26 deletions

View File

@ -132,8 +132,12 @@ bool Globals::_set(const StringName& p_name, const Variant& p_value) {
if (props.has(p_name)) {
if (!props[p_name].overrided)
props[p_name].variant=p_value;
if (props[p_name].order>=NO_ORDER_BASE && registering_order) {
props[p_name].order=last_order++;
}
} else {
props[p_name]=VariantContainer(p_value,last_order++);
props[p_name]=VariantContainer(p_value,last_order++ + registering_order?0:NO_ORDER_BASE);
}
}
@ -741,6 +745,10 @@ static Variant _decode_variant(const String& p_string) {
return Variant();
}
void Globals::set_registering_order(bool p_enable) {
registering_order=p_enable;
}
Error Globals::_load_settings_binary(const String p_path) {
@ -760,6 +768,8 @@ Error Globals::_load_settings_binary(const String p_path) {
ERR_FAIL_V(ERR_FILE_CORRUPT;)
}
set_registering_order(false);
uint32_t count=f->get_32();
for(int i=0;i<count;i++) {
@ -784,6 +794,9 @@ Error Globals::_load_settings_binary(const String p_path) {
set_persisting(key,true);
}
set_registering_order(true);
return OK;
}
Error Globals::_load_settings(const String p_path) {
@ -802,6 +815,8 @@ Error Globals::_load_settings(const String p_path) {
String section;
String subpath;
set_registering_order(false);
int line_count = 0;
while(!f->eof_reached()) {
@ -877,6 +892,7 @@ Error Globals::_load_settings(const String p_path) {
memdelete(f);
set_registering_order(true);
return OK;
}
@ -1388,7 +1404,7 @@ Globals::Globals() {
singleton=this;
last_order=0;
disable_platform_override=false;
registering_order=true;
Array va;

View File

@ -54,6 +54,10 @@ public:
protected:
enum {
NO_ORDER_BASE=1<<18
};
struct VariantContainer {
int order;
bool persist;
@ -64,6 +68,7 @@ protected:
VariantContainer(const Variant& p_variant, int p_order, bool p_persist=false) { variant=p_variant; order=p_order; hide_from_editor=false; persist=p_persist; overrided=false; }
};
bool registering_order;
int last_order;
Map<StringName,VariantContainer> props;
String resource_path;
@ -134,6 +139,8 @@ public:
bool is_using_datapack() const;
void set_registering_order(bool p_registering);
Globals();
~Globals();

View File

@ -476,11 +476,13 @@ Ref<Texture> VideoStreamPlaybackTheora::get_texture() {
void VideoStreamPlaybackTheora::update(float p_delta) {
if (!playing) {
if (!playing || paused) {
//printf("not playing\n");
return;
};
#ifdef THEORA_USE_THREAD_STREAMING
thread_sem->post();
#endif
@ -730,12 +732,13 @@ bool VideoStreamPlaybackTheora::is_playing() const {
void VideoStreamPlaybackTheora::set_paused(bool p_paused) {
paused=p_paused;
//pau = !p_paused;
};
bool VideoStreamPlaybackTheora::is_paused(bool p_paused) const {
return playing;
return paused;
};
void VideoStreamPlaybackTheora::set_loop(bool p_enable) {
@ -830,6 +833,7 @@ VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() {
playing = false;
frames_pending = 0;
videobuf_time = 0;
paused=false;
buffering=false;
texture = Ref<ImageTexture>( memnew(ImageTexture ));

View File

@ -69,6 +69,7 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback {
AudioMixCallback mix_callback;
void* mix_udata;
bool paused;
#ifdef THEORA_USE_THREAD_STREAMING

View File

@ -451,6 +451,7 @@ SplitContainer::SplitContainer(bool p_vertical) {
dragging=false;
collapsed=false;
dragger_visible=true;
}

View File

@ -518,7 +518,7 @@ void ProjectSettings::popup_project_settings() {
void ProjectSettings::_item_selected() {
TreeItem *ti = globals_editor->get_scene_tree()->get_selected();
TreeItem *ti = globals_editor->get_property_editor()->get_scene_tree()->get_selected();
if (!ti)
return;
if (!ti->get_parent())
@ -562,7 +562,7 @@ void ProjectSettings::_item_add() {
String name = catname+"/"+propname;
Globals::get_singleton()->set(name,value);
globals_editor->update_tree();
globals_editor->get_property_editor()->update_tree();
}
void ProjectSettings::_item_del() {
@ -574,7 +574,7 @@ void ProjectSettings::_item_del() {
String name = catname+"/"+propname;
Globals::get_singleton()->set(name,Variant());
globals_editor->update_tree();
globals_editor->get_property_editor()->update_tree();
}
@ -694,7 +694,7 @@ void ProjectSettings::_settings_prop_edited(const String& p_name) {
Globals::get_singleton()->set_persisting(p_name,true);
// globals_editor->update_property(p_name);
globals_editor->update_tree();
globals_editor->get_property_editor()->update_tree();
}
_settings_changed();
}
@ -729,7 +729,7 @@ void ProjectSettings::_copy_to_platform(int p_which) {
name = catname+"/"+propname;
Globals::get_singleton()->set(name,value);
globals_editor->update_tree();
globals_editor->get_property_editor()->update_tree();
}
@ -1233,7 +1233,7 @@ void ProjectSettings::_update_autoload() {
void ProjectSettings::_toggle_search_bar(bool p_pressed) {
globals_editor->set_use_filter(p_pressed);
globals_editor->get_property_editor()->set_use_filter(p_pressed);
if (p_pressed) {
@ -1254,7 +1254,7 @@ void ProjectSettings::_clear_search_box() {
return;
search_box->clear();
globals_editor->update_tree();
globals_editor->get_property_editor()->update_tree();
}
void ProjectSettings::_bind_methods() {
@ -1397,15 +1397,15 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
search_bar->add_child(clear_button);
clear_button->connect("pressed",this,"_clear_search_box");
globals_editor = memnew( PropertyEditor );
globals_editor = memnew( SectionedPropertyEditor );
props_base->add_child(globals_editor);
globals_editor->hide_top_label();
//globals_editor->hide_top_label();
globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
globals_editor->register_text_enter(search_box);
globals_editor->set_capitalize_paths(false);
globals_editor->get_scene_tree()->connect("cell_selected",this,"_item_selected");
globals_editor->connect("property_toggled",this,"_item_checked");
globals_editor->connect("property_edited",this,"_settings_prop_edited");
globals_editor->get_property_editor()->register_text_enter(search_box);
globals_editor->get_property_editor()->set_capitalize_paths(false);
globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected",this,"_item_selected");
globals_editor->get_property_editor()->connect("property_toggled",this,"_item_checked");
globals_editor->get_property_editor()->connect("property_edited",this,"_settings_prop_edited");
/*
Button *save = memnew( Button );

View File

@ -46,7 +46,7 @@ class ProjectSettings : public AcceptDialog {
EditorData *data;
UndoRedo *undo_redo;
PropertyEditor *globals_editor;
SectionedPropertyEditor *globals_editor;
HBoxContainer *search_bar;
ToolButton *search_button;

View File

@ -3638,3 +3638,174 @@ PropertyEditor::~PropertyEditor()
}
/////////////////////////////
class SectionedPropertyEditorFilter : public Object {
OBJ_TYPE( SectionedPropertyEditorFilter, Object );
Object *edited;
String section;
bool _set(const StringName& p_name, const Variant& p_value) {
if (!edited)
return false;
String name=p_name;
if (section!="") {
name=section+"/"+name;
}
bool valid;
edited->set(name,p_value,&valid);
return valid;
}
bool _get(const StringName& p_name,Variant &r_ret) const{
if (!edited)
return false;
String name=p_name;
if (section!="") {
name=section+"/"+name;
}
bool valid=false;
r_ret=edited->get(name,&valid);
return valid;
}
void _get_property_list(List<PropertyInfo> *p_list) const{
if (!edited)
return;
List<PropertyInfo> pinfo;
edited->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
PropertyInfo pi=E->get();
int sp = pi.name.find("/");
if (sp!=-1) {
String ss = pi.name.substr(0,sp);
if (ss==section) {
pi.name=pi.name.substr(sp+1,pi.name.length());
p_list->push_back(pi);
}
} else {
if (section=="")
p_list->push_back(pi);
}
}
}
public:
void set_section(const String& p_section) {
section=p_section;
_change_notify();
}
void set_edited(Object* p_edited) {
edited=p_edited;
_change_notify();
}
SectionedPropertyEditorFilter() {
edited=NULL;
}
};
void SectionedPropertyEditor::_bind_methods() {
ObjectTypeDB::bind_method("_section_selected",&SectionedPropertyEditor::_section_selected);
}
void SectionedPropertyEditor::_section_selected(int p_which) {
filter->set_section( sections->get_item_metadata(p_which) );
}
void SectionedPropertyEditor::edit(Object* p_object) {
List<PropertyInfo> pinfo;
if (p_object)
p_object->get_property_list(&pinfo);
sections->clear();
Set<String> existing_sections;
for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
PropertyInfo pi=E->get();
if (pi.usage&PROPERTY_USAGE_CATEGORY)
continue;
if (pi.name.find(":")!=-1 || pi.name=="script/script")
continue;
int sp = pi.name.find("/");
if (sp!=-1) {
String sname=pi.name.substr(0,sp);
if (!existing_sections.has(sname)) {
existing_sections.insert(sname);
sections->add_item(sname.capitalize());
sections->set_item_metadata(sections->get_item_count()-1,sname);
}
} else {
if (!existing_sections.has("")) {
existing_sections.insert("");
sections->add_item("Global");
sections->set_item_metadata(sections->get_item_count()-1,"");
}
}
}
//sections->sort_items_by_text();
filter->set_edited(p_object);
editor->edit(filter);
sections->select(0);
_section_selected(0);
}
PropertyEditor *SectionedPropertyEditor::get_property_editor() {
return editor;
}
SectionedPropertyEditor::SectionedPropertyEditor() {
sections = memnew( ItemList );
add_child(sections);
sections->set_custom_minimum_size(Size2(160,0));
filter = memnew( SectionedPropertyEditorFilter );
editor = memnew( PropertyEditor );
editor->get_scene_tree()->set_column_titles_visible(false);
add_child(editor);
editor->set_h_size_flags(SIZE_EXPAND_FILL);
editor->hide_top_label();
sections->connect("item_selected",this,"_section_selected");
}
SectionedPropertyEditor::~SectionedPropertyEditor() {
memdelete(filter);
}

View File

@ -39,6 +39,7 @@
#include "scene/gui/texture_frame.h"
#include "scene/gui/text_edit.h"
#include "scene/gui/check_button.h"
#include "scene/gui/split_container.h"
#include "scene_tree_editor.h"
/**
@ -247,4 +248,28 @@ public:
};
class SectionedPropertyEditorFilter;
class SectionedPropertyEditor : public HBoxContainer {
OBJ_TYPE(SectionedPropertyEditor,HBoxContainer);
ItemList *sections;
SectionedPropertyEditorFilter *filter;
PropertyEditor *editor;
static void _bind_methods();
void _section_selected(int p_which);
public:
PropertyEditor *get_property_editor();
void edit(Object* p_object);
SectionedPropertyEditor();
~SectionedPropertyEditor();
};
#endif

View File

@ -71,7 +71,7 @@ void EditorSettingsDialog::popup_edit_settings() {
return;
property_editor->edit(EditorSettings::get_singleton());
property_editor->update_tree();
property_editor->get_property_editor()->update_tree();
search_box->select_all();
search_box->grab_focus();
@ -254,7 +254,7 @@ void EditorSettingsDialog::_clear_search_box() {
return;
search_box->clear();
property_editor->update_tree();
property_editor->get_property_editor()->update_tree();
}
void EditorSettingsDialog::_notification(int p_what) {
@ -306,10 +306,10 @@ EditorSettingsDialog::EditorSettingsDialog() {
hbc->add_child(clear_button);
clear_button->connect("pressed",this,"_clear_search_box");
property_editor = memnew( PropertyEditor );
property_editor->hide_top_label();
property_editor->set_use_filter(true);
property_editor->register_text_enter(search_box);
property_editor = memnew( SectionedPropertyEditor );
//property_editor->hide_top_label();
property_editor->get_property_editor()->set_use_filter(true);
property_editor->get_property_editor()->register_text_enter(search_box);
property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(property_editor);

View File

@ -53,7 +53,7 @@ class EditorSettingsDialog : public AcceptDialog {
Tree *plugins;
LineEdit *search_box;
ToolButton *clear_button;
PropertyEditor *property_editor;
SectionedPropertyEditor *property_editor;
Timer *timer;