summaryrefslogtreecommitdiffstats
path: root/editor/plugins/canvas_item_editor_plugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins/canvas_item_editor_plugin.cpp')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp179
1 files changed, 105 insertions, 74 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 832d0c204d..703cd7ef81 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -37,6 +37,7 @@
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
+#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/gui/editor_run_bar.h"
#include "editor/gui/editor_toaster.h"
@@ -1033,6 +1034,22 @@ void CanvasItemEditor::_on_grid_menu_id_pressed(int p_id) {
viewport->queue_redraw();
}
+void CanvasItemEditor::_switch_theme_preview(int p_mode) {
+ view_menu->get_popup()->hide();
+
+ if (theme_preview == p_mode) {
+ return;
+ }
+ theme_preview = (ThemePreviewMode)p_mode;
+ EditorSettings::get_singleton()->set_project_metadata("2d_editor", "theme_preview", theme_preview);
+
+ for (int i = 0; i < THEME_PREVIEW_MAX; i++) {
+ theme_menu->set_item_checked(i, i == theme_preview);
+ }
+
+ EditorNode::get_singleton()->update_preview_themes(theme_preview);
+}
+
bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_event) {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
Ref<InputEventMouseButton> b = p_event;
@@ -2293,17 +2310,17 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
if (b.is_valid() && b->is_pressed() && b->get_button_index() == MouseButton::RIGHT) {
add_node_menu->clear();
- add_node_menu->add_icon_item(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), TTR("Add Node Here..."), ADD_NODE);
- add_node_menu->add_icon_item(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Instantiate Scene Here..."), ADD_INSTANCE);
+ add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("Add")), TTR("Add Node Here..."), ADD_NODE);
+ add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("Instance")), TTR("Instantiate Scene Here..."), ADD_INSTANCE);
for (Node *node : SceneTreeDock::get_singleton()->get_node_clipboard()) {
if (Object::cast_to<CanvasItem>(node)) {
- add_node_menu->add_icon_item(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons")), TTR("Paste Node(s) Here"), ADD_PASTE);
+ add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("ActionPaste")), TTR("Paste Node(s) Here"), ADD_PASTE);
break;
}
}
for (Node *node : EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()) {
if (Object::cast_to<CanvasItem>(node)) {
- add_node_menu->add_icon_item(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons")), TTR("Move Node(s) Here"), ADD_MOVE);
+ add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("ToolMove")), TTR("Move Node(s) Here"), ADD_MOVE);
break;
}
}
@@ -2678,7 +2695,7 @@ Control::CursorShape CanvasItemEditor::get_cursor_shape(const Point2 &p_pos) con
}
void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Side p_side) {
- Color color = get_theme_color(SNAME("font_color"), SNAME("Editor"));
+ Color color = get_theme_color(SNAME("font_color"), EditorStringName(Editor));
color.a = 0.8;
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
@@ -2717,7 +2734,7 @@ void CanvasItemEditor::_draw_percentage_at_position(real_t p_value, Point2 p_pos
void CanvasItemEditor::_draw_focus() {
// Draw the focus around the base viewport
if (viewport->has_focus()) {
- get_theme_stylebox(SNAME("FocusViewport"), SNAME("EditorStyles"))->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size()));
+ get_theme_stylebox(SNAME("FocusViewport"), EditorStringName(EditorStyles))->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size()));
}
}
@@ -2747,13 +2764,13 @@ void CanvasItemEditor::_draw_guides() {
}
// Dragged guide.
- Color text_color = get_theme_color(SNAME("font_color"), SNAME("Editor"));
+ Color text_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor));
Color outline_color = text_color.inverted();
const float outline_size = 2;
if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_V_GUIDE) {
String str = TS->format_number(vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).x)));
- Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
- int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
+ Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts));
+ int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts));
Size2 text_size = font->get_string_size(str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size);
viewport->draw_string_outline(font, Point2(dragged_guide_pos.x + 10, RULER_WIDTH + text_size.y / 2 + 10), str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, outline_size, outline_color);
viewport->draw_string(font, Point2(dragged_guide_pos.x + 10, RULER_WIDTH + text_size.y / 2 + 10), str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, text_color);
@@ -2761,8 +2778,8 @@ void CanvasItemEditor::_draw_guides() {
}
if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_H_GUIDE) {
String str = TS->format_number(vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).y)));
- Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
- int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
+ Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts));
+ int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts));
Size2 text_size = font->get_string_size(str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size);
viewport->draw_string_outline(font, Point2(RULER_WIDTH + 10, dragged_guide_pos.y + text_size.y / 2 + 10), str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, outline_size, outline_color);
viewport->draw_string(font, Point2(RULER_WIDTH + 10, dragged_guide_pos.y + text_size.y / 2 + 10), str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, text_color);
@@ -2785,12 +2802,12 @@ void CanvasItemEditor::_draw_smart_snapping() {
}
void CanvasItemEditor::_draw_rulers() {
- Color bg_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor"));
- Color graduation_color = get_theme_color(SNAME("font_color"), SNAME("Editor")).lerp(bg_color, 0.5);
- Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor"));
+ Color bg_color = get_theme_color(SNAME("dark_color_2"), EditorStringName(Editor));
+ Color graduation_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor)).lerp(bg_color, 0.5);
+ Color font_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor));
font_color.a = 0.8;
- Ref<Font> font = get_theme_font(SNAME("rulers"), SNAME("EditorFonts"));
- int font_size = get_theme_font_size(SNAME("rulers_size"), SNAME("EditorFonts"));
+ Ref<Font> font = get_theme_font(SNAME("rulers"), EditorStringName(EditorFonts));
+ int font_size = get_theme_font_size(SNAME("rulers_size"), EditorStringName(EditorFonts));
// The rule transform
Transform2D ruler_transform;
@@ -2951,7 +2968,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
}
if (ruler_tool_active) {
- Color ruler_primary_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
+ Color ruler_primary_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor));
Color ruler_secondary_color = ruler_primary_color;
ruler_secondary_color.a = 0.5;
@@ -2963,9 +2980,9 @@ void CanvasItemEditor::_draw_ruler_tool() {
const real_t horizontal_angle_rad = length_vector.angle();
const real_t vertical_angle_rad = Math_PI / 2.0 - horizontal_angle_rad;
- Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
- int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"));
- Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor"));
+ Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts));
+ int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts));
+ Color font_color = get_theme_color(SNAME("font_color"), EditorStringName(Editor));
Color font_secondary_color = font_color;
font_secondary_color.set_v(font_secondary_color.get_v() > 0.5 ? 0.7 : 0.3);
Color outline_color = font_color.inverted();
@@ -3018,8 +3035,8 @@ void CanvasItemEditor::_draw_ruler_tool() {
if (begin.is_equal_approx(end)) {
viewport->draw_string_outline(font, text_pos, (String)ruler_tool_origin, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, outline_size, outline_color);
viewport->draw_string(font, text_pos, (String)ruler_tool_origin, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color);
- Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons"));
- viewport->draw_texture(get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
+ Ref<Texture2D> position_icon = get_editor_theme_icon(SNAME("EditorPosition"));
+ viewport->draw_texture(get_editor_theme_icon(SNAME("EditorPosition")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
return;
}
@@ -3090,8 +3107,8 @@ void CanvasItemEditor::_draw_ruler_tool() {
}
} else {
if (grid_snap_active) {
- Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons"));
- viewport->draw_texture(get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
+ Ref<Texture2D> position_icon = get_editor_theme_icon(SNAME("EditorPosition"));
+ viewport->draw_texture(get_editor_theme_icon(SNAME("EditorPosition")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
}
}
}
@@ -3308,9 +3325,9 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
}
void CanvasItemEditor::_draw_selection() {
- Ref<Texture2D> pivot_icon = get_theme_icon(SNAME("EditorPivot"), SNAME("EditorIcons"));
- Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons"));
- Ref<Texture2D> previous_position_icon = get_theme_icon(SNAME("EditorPositionPrevious"), SNAME("EditorIcons"));
+ Ref<Texture2D> pivot_icon = get_editor_theme_icon(SNAME("EditorPivot"));
+ Ref<Texture2D> position_icon = get_editor_theme_icon(SNAME("EditorPosition"));
+ Ref<Texture2D> previous_position_icon = get_editor_theme_icon(SNAME("EditorPositionPrevious"));
RID vp_ci = viewport->get_canvas_item();
@@ -3437,16 +3454,16 @@ void CanvasItemEditor::_draw_selection() {
Vector2((move_factor.x + 10) * EDSCALE, 0)
};
- viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_x_color"), SNAME("Editor")));
- viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")), Math::round(EDSCALE));
+ viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)));
+ viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)), Math::round(EDSCALE));
points.clear();
points.push_back(Vector2(5 * EDSCALE, move_factor.y * EDSCALE));
points.push_back(Vector2(-5 * EDSCALE, move_factor.y * EDSCALE));
points.push_back(Vector2(0, (move_factor.y + 10) * EDSCALE));
- viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_y_color"), SNAME("Editor")));
- viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")), Math::round(EDSCALE));
+ viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)));
+ viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)), Math::round(EDSCALE));
viewport->draw_set_transform_matrix(viewport->get_transform());
}
@@ -3476,12 +3493,12 @@ void CanvasItemEditor::_draw_selection() {
viewport->draw_set_transform_matrix(simple_xform);
Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
- viewport->draw_rect(x_handle_rect, get_theme_color(SNAME("axis_x_color"), SNAME("Editor")));
- viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")), Math::round(EDSCALE));
+ viewport->draw_rect(x_handle_rect, get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)));
+ viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)), Math::round(EDSCALE));
Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
- viewport->draw_rect(y_handle_rect, get_theme_color(SNAME("axis_y_color"), SNAME("Editor")));
- viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")), Math::round(EDSCALE));
+ viewport->draw_rect(y_handle_rect, get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)));
+ viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)), Math::round(EDSCALE));
viewport->draw_set_transform_matrix(viewport->get_transform());
}
@@ -3496,11 +3513,11 @@ void CanvasItemEditor::_draw_selection() {
viewport->draw_rect(
Rect2(bsfrom, bsto - bsfrom),
- get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor")));
+ get_theme_color(SNAME("box_selection_fill_color"), EditorStringName(Editor)));
viewport->draw_rect(
Rect2(bsfrom, bsto - bsfrom),
- get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")),
+ get_theme_color(SNAME("box_selection_stroke_color"), EditorStringName(Editor)),
false,
Math::round(EDSCALE));
}
@@ -3510,7 +3527,7 @@ void CanvasItemEditor::_draw_selection() {
viewport->draw_line(
transform.xform(drag_rotation_center),
transform.xform(drag_to),
- get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.6),
+ get_theme_color(SNAME("accent_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.6),
Math::round(2 * EDSCALE));
}
}
@@ -3558,8 +3575,8 @@ void CanvasItemEditor::_draw_straight_line(Point2 p_from, Point2 p_to, Color p_c
void CanvasItemEditor::_draw_axis() {
if (show_origin) {
- _draw_straight_line(Point2(), Point2(1, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")) * Color(1, 1, 1, 0.75));
- _draw_straight_line(Point2(), Point2(0, 1), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")) * Color(1, 1, 1, 0.75));
+ _draw_straight_line(Point2(), Point2(1, 0), get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.75));
+ _draw_straight_line(Point2(), Point2(0, 1), get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)) * Color(1, 1, 1, 0.75));
}
if (show_viewport) {
@@ -3613,7 +3630,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
Transform2D xform = transform * canvas_xform * parent_xform;
// Draw the node's position
- Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPositionUnselected"), SNAME("EditorIcons"));
+ Ref<Texture2D> position_icon = get_editor_theme_icon(SNAME("EditorPositionUnselected"));
Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
viewport->draw_set_transform_matrix(simple_xform);
@@ -3744,13 +3761,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p
if (ci) {
real_t offset = 0;
- Ref<Texture2D> lock = get_theme_icon(SNAME("LockViewport"), SNAME("EditorIcons"));
+ Ref<Texture2D> lock = get_editor_theme_icon(SNAME("LockViewport"));
if (p_node->has_meta("_edit_lock_") && show_edit_locks) {
lock->draw(viewport_ci, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
offset += lock->get_size().x;
}
- Ref<Texture2D> group = get_theme_icon(SNAME("GroupViewport"), SNAME("EditorIcons"));
+ Ref<Texture2D> group = get_editor_theme_icon(SNAME("GroupViewport"));
if (ci->has_meta("_edit_group_") && show_edit_locks) {
group->draw(viewport_ci, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
//offset += group->get_size().x;
@@ -3837,41 +3854,41 @@ void CanvasItemEditor::set_current_tool(Tool p_tool) {
}
void CanvasItemEditor::_update_editor_settings() {
- button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons")));
- select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons")));
- select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons")));
- list_select_button->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons")));
- move_button->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons")));
- scale_button->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons")));
- rotate_button->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons")));
- smart_snap_button->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons")));
- grid_snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
- snap_config_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
- skeleton_menu->set_icon(get_theme_icon(SNAME("Bone"), SNAME("EditorIcons")));
- override_camera_button->set_icon(get_theme_icon(SNAME("Camera2D"), SNAME("EditorIcons")));
- pan_button->set_icon(get_theme_icon(SNAME("ToolPan"), SNAME("EditorIcons")));
- ruler_button->set_icon(get_theme_icon(SNAME("Ruler"), SNAME("EditorIcons")));
- pivot_button->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons")));
- select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons"));
- anchor_handle = get_theme_icon(SNAME("EditorControlAnchor"), SNAME("EditorIcons"));
- lock_button->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons")));
- unlock_button->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons")));
- group_button->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons")));
- ungroup_button->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons")));
- key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons")));
- key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons")));
- key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons")));
- key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons")));
- key_auto_insert_button->set_icon(get_theme_icon(SNAME("AutoKey"), SNAME("EditorIcons")));
+ button_center_view->set_icon(get_editor_theme_icon(SNAME("CenterView")));
+ select_button->set_icon(get_editor_theme_icon(SNAME("ToolSelect")));
+ select_sb->set_texture(get_editor_theme_icon(SNAME("EditorRect2D")));
+ list_select_button->set_icon(get_editor_theme_icon(SNAME("ListSelect")));
+ move_button->set_icon(get_editor_theme_icon(SNAME("ToolMove")));
+ scale_button->set_icon(get_editor_theme_icon(SNAME("ToolScale")));
+ rotate_button->set_icon(get_editor_theme_icon(SNAME("ToolRotate")));
+ smart_snap_button->set_icon(get_editor_theme_icon(SNAME("Snap")));
+ grid_snap_button->set_icon(get_editor_theme_icon(SNAME("SnapGrid")));
+ snap_config_menu->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl")));
+ skeleton_menu->set_icon(get_editor_theme_icon(SNAME("Bone")));
+ override_camera_button->set_icon(get_editor_theme_icon(SNAME("Camera2D")));
+ pan_button->set_icon(get_editor_theme_icon(SNAME("ToolPan")));
+ ruler_button->set_icon(get_editor_theme_icon(SNAME("Ruler")));
+ pivot_button->set_icon(get_editor_theme_icon(SNAME("EditPivot")));
+ select_handle = get_editor_theme_icon(SNAME("EditorHandle"));
+ anchor_handle = get_editor_theme_icon(SNAME("EditorControlAnchor"));
+ lock_button->set_icon(get_editor_theme_icon(SNAME("Lock")));
+ unlock_button->set_icon(get_editor_theme_icon(SNAME("Unlock")));
+ group_button->set_icon(get_editor_theme_icon(SNAME("Group")));
+ ungroup_button->set_icon(get_editor_theme_icon(SNAME("Ungroup")));
+ key_loc_button->set_icon(get_editor_theme_icon(SNAME("KeyPosition")));
+ key_rot_button->set_icon(get_editor_theme_icon(SNAME("KeyRotation")));
+ key_scale_button->set_icon(get_editor_theme_icon(SNAME("KeyScale")));
+ key_insert_button->set_icon(get_editor_theme_icon(SNAME("Key")));
+ key_auto_insert_button->set_icon(get_editor_theme_icon(SNAME("AutoKey")));
// Use a different color for the active autokey icon to make them easier
// to distinguish from the other key icons at the top. On a light theme,
// the icon will be dark, so we need to lighten it before blending it
// with the red color.
const Color key_auto_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25);
key_auto_insert_button->add_theme_color_override("icon_pressed_color", key_auto_color.lerp(Color(1, 0, 0), 0.55));
- animation_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
+ animation_menu->set_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl")));
- context_menu_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("ContextualToolbar"), SNAME("EditorStyles")));
+ context_menu_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("ContextualToolbar"), EditorStringName(EditorStyles)));
panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/2d_editor_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning")));
panner->set_scroll_speed(EDITOR_GET("editors/panning/2d_editor_pan_speed"));
@@ -3962,7 +3979,7 @@ void CanvasItemEditor::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_TREE: {
- select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons")));
+ select_sb->set_texture(get_editor_theme_icon(SNAME("EditorRect2D")));
select_sb->set_texture_margin_all(4);
select_sb->set_content_margin_all(4);
@@ -5321,6 +5338,20 @@ CanvasItemEditor::CanvasItemEditor() {
p->add_separator();
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/preview_canvas_scale", TTR("Preview Canvas Scale")), PREVIEW_CANVAS_SCALE);
+ theme_menu = memnew(PopupMenu);
+ theme_menu->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_switch_theme_preview));
+ theme_menu->set_name("ThemeMenu");
+ theme_menu->add_radio_check_item(TTR("Project theme"), THEME_PREVIEW_PROJECT);
+ theme_menu->add_radio_check_item(TTR("Editor theme"), THEME_PREVIEW_EDITOR);
+ theme_menu->add_radio_check_item(TTR("Default theme"), THEME_PREVIEW_DEFAULT);
+ p->add_child(theme_menu);
+ p->add_submenu_item(TTR("Preview Theme"), "ThemeMenu");
+
+ theme_preview = (ThemePreviewMode)(int)EditorSettings::get_singleton()->get_project_metadata("2d_editor", "theme_preview", THEME_PREVIEW_PROJECT);
+ for (int i = 0; i < THEME_PREVIEW_MAX; i++) {
+ theme_menu->set_item_checked(i, i == theme_preview);
+ }
+
main_menu_hbox->add_child(memnew(VSeparator));
// Contextual toolbars.
@@ -5870,10 +5901,10 @@ void CanvasItemEditorViewport::_update_theme() {
for (int i = 0; i < btn_list.size(); i++) {
CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]);
- check->set_icon(get_theme_icon(check->get_text(), SNAME("EditorIcons")));
+ check->set_icon(get_editor_theme_icon(check->get_text()));
}
- label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
}
void CanvasItemEditorViewport::_notification(int p_what) {