2
0
Эх сурвалжийг харах

Draw an indicator to denote overbright colors in ColorPicker

This makes it faster to distinguish overbright colors from
"standard" colors.
Hugo Locurcio 6 жил өмнө
parent
commit
70c4e96623

+ 2 - 0
editor/editor_themes.cpp

@@ -203,6 +203,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme =
 	exceptions.push_back("StatusSuccess");
 	exceptions.push_back("StatusWarning");
 	exceptions.push_back("NodeWarning");
+	exceptions.push_back("OverbrightIndicator");
 
 	ImageLoaderSVG::set_convert_colors(&dark_icon_color_dictionary);
 
@@ -1104,6 +1105,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
 	theme->set_icon("screen_picker", "ColorPicker", theme->get_icon("ColorPick", "EditorIcons"));
 	theme->set_icon("add_preset", "ColorPicker", theme->get_icon("Add", "EditorIcons"));
 	theme->set_icon("preset_bg", "ColorPicker", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));
+	theme->set_icon("overbright_indicator", "ColorPicker", theme->get_icon("OverbrightIndicator", "EditorIcons"));
 
 	theme->set_icon("bg", "ColorPickerButton", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));
 

+ 1 - 0
editor/icons/icon_overbright_indicator.svg

@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m0 0v10l10-10z" fill="#fff"/><path d="m0 12 12-12h-2l-10 10z" fill="#000003"/></svg>

+ 15 - 3
scene/gui/color_picker.cpp

@@ -396,11 +396,18 @@ void ColorPicker::_update_text_value() {
 }
 
 void ColorPicker::_sample_draw() {
-	Rect2 r = Rect2(Point2(), Size2(uv_edit->get_size().width, sample->get_size().height * 0.95));
+	const Rect2 r = Rect2(Point2(), Size2(uv_edit->get_size().width, sample->get_size().height * 0.95));
+
 	if (color.a < 1.0) {
 		sample->draw_texture_rect(get_icon("preset_bg", "ColorPicker"), r, true);
 	}
+
 	sample->draw_rect(r, color);
+
+	if (color.r > 1 || color.g > 1 || color.b > 1) {
+		// Draw an indicator to denote that the color is "overbright" and can't be displayed accurately in the preview
+		sample->draw_texture(get_icon("overbright_indicator", "ColorPicker"), Point2());
+	}
 }
 
 void ColorPicker::_hsv_draw(int p_which, Control *c) {
@@ -894,10 +901,15 @@ void ColorPickerButton::_notification(int p_what) {
 	switch (p_what) {
 		case NOTIFICATION_DRAW: {
 
-			Ref<StyleBox> normal = get_stylebox("normal");
-			Rect2 r = Rect2(normal->get_offset(), get_size() - normal->get_minimum_size());
+			const Ref<StyleBox> normal = get_stylebox("normal");
+			const Rect2 r = Rect2(normal->get_offset(), get_size() - normal->get_minimum_size());
 			draw_texture_rect(Control::get_icon("bg", "ColorPickerButton"), r, true);
 			draw_rect(r, color);
+
+			if (color.r > 1 || color.g > 1 || color.b > 1) {
+				// Draw an indicator to denote that the color is "overbright" and can't be displayed accurately in the preview
+				draw_texture(Control::get_icon("overbright_indicator", "ColorPicker"), normal->get_offset());
+			}
 		} break;
 		case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
 

+ 2 - 1
scene/resources/default_theme/default_theme.cpp

@@ -763,7 +763,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
 	theme->set_color("folder_icon_modulate", "FileDialog", Color(1, 1, 1));
 	theme->set_color("files_disabled", "FileDialog", Color(0, 0, 0, 0.7));
 
-	// colorPicker
+	// ColorPicker
 
 	theme->set_constant("margin", "ColorPicker", 4 * scale);
 	theme->set_constant("sv_width", "ColorPicker", 256 * scale);
@@ -776,6 +776,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
 	theme->set_icon("color_hue", "ColorPicker", make_icon(color_picker_hue_png));
 	theme->set_icon("color_sample", "ColorPicker", make_icon(color_picker_sample_png));
 	theme->set_icon("preset_bg", "ColorPicker", make_icon(mini_checkerboard_png));
+	theme->set_icon("overbright_indicator", "ColorPicker", make_icon(overbright_indicator_png));
 
 	theme->set_icon("bg", "ColorPickerButton", make_icon(mini_checkerboard_png));
 

BIN
scene/resources/default_theme/overbright_indicator.png


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
scene/resources/default_theme/theme_data.h


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно