Browse Source

Improved color temperature in script editor

Daniel J. Ramirez 8 years ago
parent
commit
215b110cd3
3 changed files with 23 additions and 5 deletions
  1. 4 4
      editor/plugins/script_editor_plugin.cpp
  2. 15 1
      scene/gui/item_list.cpp
  3. 4 0
      scene/gui/item_list.h

+ 4 - 4
editor/plugins/script_editor_plugin.cpp

@@ -1417,7 +1417,7 @@ void ScriptEditor::_update_script_colors() {
 			int non_zero_hist_size = (hist_size == 0) ? 1 : hist_size;
 			float v = Math::ease((edit_pass - pass) / float(non_zero_hist_size), 0.4);
 
-			script_list->set_item_custom_bg_color(i, hot_color.linear_interpolate(cold_color, v));
+			script_list->set_item_custom_fg_color(i, hot_color.linear_interpolate(cold_color, v));
 		}
 	}
 }
@@ -2506,9 +2506,9 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
 	EDITOR_DEF("text_editor/open_scripts/script_temperature_enabled", true);
 	EDITOR_DEF("text_editor/open_scripts/highlight_current_script", true);
 	EDITOR_DEF("text_editor/open_scripts/script_temperature_history_size", 15);
-	EDITOR_DEF("text_editor/open_scripts/script_temperature_hot_color", Color(1, 0, 0, 0.3));
-	EDITOR_DEF("text_editor/open_scripts/script_temperature_cold_color", Color(0, 0, 1, 0.3));
-	EDITOR_DEF("text_editor/open_scripts/current_script_background_color", Color(0.81, 0.81, 0.14, 0.63));
+	EDITOR_DEF("text_editor/open_scripts/script_temperature_hot_color", Color::html("ed5e5e"));
+	EDITOR_DEF("text_editor/open_scripts/script_temperature_cold_color", Color(1, 1, 1, 0.3));
+	EDITOR_DEF("text_editor/open_scripts/current_script_background_color", Color(1, 1, 1, 0.5));
 	EDITOR_DEF("text_editor/open_scripts/group_help_pages", true);
 	EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/open_scripts/sort_scripts_by", PROPERTY_HINT_ENUM, "Name,Path"));
 	EDITOR_DEF("text_editor/open_scripts/sort_scripts_by", 0);

+ 15 - 1
scene/gui/item_list.cpp

@@ -151,6 +151,20 @@ Color ItemList::get_item_custom_bg_color(int p_idx) const {
 	return items[p_idx].custom_bg;
 }
 
+void ItemList::set_item_custom_fg_color(int p_idx, const Color &p_custom_fg_color) {
+
+	ERR_FAIL_INDEX(p_idx, items.size());
+
+	items[p_idx].custom_fg = p_custom_fg_color;
+}
+
+Color ItemList::get_item_custom_fg_color(int p_idx) const {
+
+	ERR_FAIL_INDEX_V(p_idx, items.size(), Color());
+
+	return items[p_idx].custom_fg;
+}
+
 void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon) {
 
 	ERR_FAIL_INDEX(p_idx, items.size());
@@ -1021,7 +1035,7 @@ void ItemList::_notification(int p_what) {
 				else
 					max_len = size.x;
 
-				Color modulate = items[i].selected ? font_color_selected : font_color;
+				Color modulate = items[i].selected ? font_color_selected : (items[i].custom_fg != Color() ? items[i].custom_fg : font_color);
 				if (items[i].disabled)
 					modulate.a *= 0.5;
 

+ 4 - 0
scene/gui/item_list.h

@@ -61,6 +61,7 @@ private:
 		bool tooltip_enabled;
 		Variant metadata;
 		String tooltip;
+		Color custom_fg;
 		Color custom_bg;
 
 		Rect2 rect_cache;
@@ -150,6 +151,9 @@ public:
 	void set_item_custom_bg_color(int p_idx, const Color &p_custom_bg_color);
 	Color get_item_custom_bg_color(int p_idx) const;
 
+	void set_item_custom_fg_color(int p_idx, const Color &p_custom_fg_color);
+	Color get_item_custom_fg_color(int p_idx) const;
+
 	void select(int p_idx, bool p_single = true);
 	void unselect(int p_idx);
 	bool is_selected(int p_idx) const;