Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Various ColorPicker shapes #46340

Merged
merged 1 commit into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/classes/ColorPicker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
If [code]true[/code], allows editing the color with Hue/Saturation/Value sliders.
[b]Note:[/b] Cannot be enabled if raw mode is on.
</member>
<member name="picker_shape" type="int" setter="set_picker_shape" getter="get_picker_shape" default="0">
The shape of the color space view. See [enum PickerShapeType].
</member>
<member name="presets_enabled" type="bool" setter="set_presets_enabled" getter="are_presets_enabled" default="true">
If [code]true[/code], the "add preset" button is enabled.
</member>
Expand Down Expand Up @@ -86,6 +89,15 @@
</signal>
</signals>
<constants>
<constant name="SHAPE_HSV_RECTANGLE" value="0" enum="PickerShapeType">
HSV Color Model rectangle color space.
</constant>
<constant name="SHAPE_HSV_WHEEL" value="1" enum="PickerShapeType">
HSV Color Model rectangle color space with a wheel.
</constant>
<constant name="SHAPE_VHS_CIRCLE" value="2" enum="PickerShapeType">
HSV Color Model circle color space. Use Saturation as a radius.
</constant>
</constants>
<theme_items>
<theme_item name="add_preset" type="Texture2D">
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5892,6 +5892,8 @@ EditorNode::EditorNode() {
EDITOR_DEF("interface/inspector/resources_to_open_in_new_inspector", "Script,MeshLibrary,TileSet");
EDITOR_DEF("interface/inspector/default_color_picker_mode", 0);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_color_picker_mode", PROPERTY_HINT_ENUM, "RGB,HSV,RAW", PROPERTY_USAGE_DEFAULT));
EDITOR_DEF("interface/inspector/default_color_picker_shape", (int32_t)ColorPicker::SHAPE_VHS_CIRCLE);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_color_picker_shape", PROPERTY_HINT_ENUM, "HSV Rectangle,HSV Rectangle Wheel,VHS Circle", PROPERTY_USAGE_DEFAULT));
EDITOR_DEF("run/auto_save/save_before_running", true);

theme_base = memnew(Control);
Expand Down
3 changes: 3 additions & 0 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2190,6 +2190,9 @@ void EditorPropertyColor::_picker_created() {
} else if (default_color_mode == 2) {
picker->get_picker()->set_raw_mode(true);
}

int picker_shape = EDITOR_GET("interface/inspector/default_color_picker_shape");
picker->get_picker()->set_picker_shape((ColorPicker::PickerShapeType)picker_shape);
}

void EditorPropertyColor::_picker_opening() {
Expand Down
1 change: 1 addition & 0 deletions editor/editor_themes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
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("bar_arrow", "ColorPicker", theme->get_icon("ColorPickerBarArrow", "EditorIcons"));
theme->set_icon("picker_cursor", "ColorPicker", theme->get_icon("PickerCursor", "EditorIcons"));

theme->set_icon("bg", "ColorPickerButton", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));

Expand Down
1 change: 1 addition & 0 deletions editor/icons/PickerCursor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions editor/plugins/script_text_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,9 @@ void ScriptTextEditor::_enable_code_editor() {
color_picker->set_raw_mode(true);
}

int picker_shape = EDITOR_GET("interface/inspector/default_color_picker_shape");
groud marked this conversation as resolved.
Show resolved Hide resolved
color_picker->set_picker_shape((ColorPicker::PickerShapeType)picker_shape);

quick_open = memnew(ScriptEditorQuickOpen);
quick_open->connect("goto_line", callable_mp(this, &ScriptTextEditor::_goto_line));
add_child(quick_open);
Expand Down
3 changes: 3 additions & 0 deletions editor/property_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,9 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (default_color_mode == 2) {
color_picker->set_raw_mode(true);
}

int picker_shape = EDITOR_GET("interface/inspector/default_color_picker_shape");
color_picker->set_picker_shape((ColorPicker::PickerShapeType)picker_shape);
}

color_picker->show();
Expand Down
Loading