1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-15 13:51:40 +00:00

Add inline ColorPicker to Script text editor.

Adds an option to the script editor context menu that lets you open
a ColorPicker in order to easily edit `Color()` constructors.
To do this, right click on the word `Color` and select `Pick Color`.

A side effect of this change is that the script editor now has its own
context menu instead of re-using the one from TextEdit.
It's now possible to indent left/right and to toggle comments via this menu.
I also felt free to make it more context-sensitive than before:
Now "Cut" and "Copy" will only be shown if text has actually been selected.

I also added default shortcuts for indent left/right. (alt + left/right)

Closes #6232
This commit is contained in:
Andreas Haas
2016-09-29 09:12:45 +02:00
parent 5e7db2a5b4
commit f81d009525
4 changed files with 132 additions and 6 deletions

View File

@@ -30,6 +30,7 @@
#define SCRIPT_TEXT_EDITOR_H
#include "script_editor_plugin.h"
#include "scene/gui/color_picker.h"
class ScriptTextEditor : public ScriptEditorBase {
@@ -47,10 +48,16 @@ class ScriptTextEditor : public ScriptEditorBase {
MenuButton *edit_menu;
MenuButton *search_menu;
PopupMenu *context_menu;
GotoLineDialog *goto_line_dialog;
ScriptEditorQuickOpen *quick_open;
PopupPanel *color_panel;
ColorPicker *color_picker;
int color_line;
String color_args;
enum {
EDIT_UNDO,
EDIT_REDO,
@@ -67,6 +74,7 @@ class ScriptTextEditor : public ScriptEditorBase {
EDIT_INDENT_RIGHT,
EDIT_INDENT_LEFT,
EDIT_CLONE_DOWN,
EDIT_PICK_COLOR,
SEARCH_FIND,
SEARCH_FIND_NEXT,
SEARCH_FIND_PREV,
@@ -96,6 +104,9 @@ protected:
static void _bind_methods();
void _edit_option(int p_op);
void _make_context_menu(bool p_selection, bool p_color);
void _text_edit_input_event(const InputEvent& ev);
void _color_changed(const Color& p_color);
void _goto_line(int p_line) { goto_line(p_line); }
void _lookup_symbol(const String& p_symbol,int p_row, int p_column);