diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-02-15 21:16:33 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-02-15 21:16:33 -0300 |
commit | 8c1731b67995add31361ae526b0e6af76346181e (patch) | |
tree | f96080fdbb6e0f0f3fcc12bf10fc92928f0310cb /scene | |
parent | 9afdb3e0ad5bfbdafe307212f5d4ebcc7c3ac852 (diff) |
-project settings are saved when changed
-load() was in the GDScript docs but missing in the scripting-different music for platformer 2D and 3D
-fix how documentation is generated, built in doc browser should be always up to date
-copypaste, scrolling, etc in builtin doc
-built-in scripts get saved now (though debugger may not always work on them)
-Theme can be set to controls as a property
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/control.cpp | 1 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 110 | ||||
-rw-r--r-- | scene/gui/rich_text_label.h | 1 | ||||
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 1 |
4 files changed, 110 insertions, 3 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 9b0c05b6a6..1bb34c1a67 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2796,6 +2796,7 @@ void Control::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"size_flags/horizontal", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_h_size_flags"),_SCS("get_h_size_flags") ); ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"size_flags/vertical", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_v_size_flags"),_SCS("get_v_size_flags") ); ADD_PROPERTY( PropertyInfo(Variant::INT,"size_flags/stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"),_SCS("get_stretch_ratio") ); + ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"theme/theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), _SCS("set_theme"),_SCS("get_theme") ); BIND_CONSTANT( ANCHOR_BEGIN ); BIND_CONSTANT( ANCHOR_END ); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 95c3affdf5..5ac278a38e 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -27,9 +27,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "rich_text_label.h" -#include "scene/scene_string_names.h"e" - - +#include "scene/scene_string_names.h" +#include "os/keyboard.h" +#include "os/os.h" RichTextLabel::Item *RichTextLabel::_get_next_item(Item* p_item) { if (p_item->subitems.size()) { @@ -455,11 +455,18 @@ void RichTextLabel::_notification(int p_what) { _validate_line_caches(); _update_scroll(); + RID ci=get_canvas_item(); Size2 size = get_size(); VisualServer::get_singleton()->canvas_item_set_clip(ci,true); + if (has_focus()) { + VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,true); + draw_style_box(get_stylebox("focus"),Rect2(Point2(),size)); + VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,false); + } + int ofs = vscroll->get_val(); //todo, change to binary search @@ -608,6 +615,60 @@ void RichTextLabel::_input_event(InputEvent p_event) { vscroll->set_val( vscroll->get_val()+vscroll->get_page()/8 ); } } break; + case InputEvent::KEY: { + + const InputEventKey &k=p_event.key; + if (k.pressed) { + bool handled=true; + switch(k.scancode) { + case KEY_PAGEUP: { + + if (vscroll->is_visible()) + vscroll->set_val( vscroll->get_val() - vscroll->get_page() ); + } break; + case KEY_PAGEDOWN: { + + if (vscroll->is_visible()) + vscroll->set_val( vscroll->get_val() + vscroll->get_page() ); + } break; + case KEY_UP: { + + if (vscroll->is_visible()) + vscroll->set_val( vscroll->get_val() - get_font("default_font")->get_height() ); + } break; + case KEY_DOWN: { + + if (vscroll->is_visible()) + vscroll->set_val( vscroll->get_val() + get_font("default_font")->get_height() ); + } break; + case KEY_HOME: { + + if (vscroll->is_visible()) + vscroll->set_val( 0 ); + } break; + case KEY_END: { + + if (vscroll->is_visible()) + vscroll->set_val( vscroll->get_max() ); + } break; + case KEY_INSERT: + case KEY_C: { + + if (k.mod.command) { + selection_copy(); + } else { + handled=false; + } + + } break; + default: handled=false; + } + + if (handled) + accept_event(); + } + + } break; case InputEvent::MOUSE_MOTION: { if (first_invalid_line<lines.size()) @@ -1300,6 +1361,9 @@ void RichTextLabel::set_selection_enabled(bool p_enabled) { selection.active=false; update(); } + set_focus_mode(FOCUS_NONE); + } else { + set_focus_mode(FOCUS_ALL); } } @@ -1368,6 +1432,46 @@ bool RichTextLabel::search(const String& p_string,bool p_from_selection) { } +void RichTextLabel::selection_copy() { + + if (!selection.enabled) + return; + + String text; + + RichTextLabel::Item *item=selection.from; + + while(item) { + + if (item->type==ITEM_TEXT) { + + String itext = static_cast<ItemText*>(item)->text; + if (item==selection.from && item==selection.to) { + text+=itext.substr(selection.from_char,selection.to_char-selection.from_char+1); + } else if (item==selection.from) { + text+=itext.substr(selection.from_char,itext.size()); + } else if (item==selection.to) { + text+=itext.substr(0,selection.to_char+1); + } else { + text+=itext; + } + + } else if (item->type==ITEM_NEWLINE) { + text+="\n"; + } + if (item==selection.to) + break; + + item=_get_next_item(item); + } + + if (text!="") { + OS::get_singleton()->set_clipboard(text); + print_line("COPY: "+text); + } + +} + bool RichTextLabel::is_selection_enabled() const { return selection.enabled; diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 871084a56f..228d607049 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -289,6 +289,7 @@ public: void set_selection_enabled(bool p_enabled); bool is_selection_enabled() const; + void selection_copy(); Error parse_bbcode(const String& p_bbcode); Error append_bbcode(const String& p_bbcode); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 6ec587637d..3c992a93b9 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -533,6 +533,7 @@ void make_default_theme() { t->set_color("font_color_selected","RichTextLabel", font_color_selection ); t->set_color("selection_color","RichTextLabel", Color(0.1,0.1,1,0.8) ); t->set_constant("line_separation","RichTextLabel", 1 ); + t->set_stylebox("focus","RichTextLabel", focus ); t->set_constant("separation","HBoxContainer",4); |