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

Auto resize custom class category icon in inspector. #71817

Closed
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
8 changes: 5 additions & 3 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,14 +1124,16 @@ void EditorInspectorCategory::_notification(int p_what) {

int w = font->get_string_size(label, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width;
if (icon.is_valid()) {
w += hs + icon->get_width();
w += (hs + 16 * EDSCALE);
}

int ofs = (get_size().width - w) / 2;

if (icon.is_valid()) {
draw_texture(icon, Point2(ofs, (get_size().height - icon->get_height()) / 2).floor());
ofs += hs + icon->get_width();
auto rect_size = Size2(16 * EDSCALE, 16 * EDSCALE);
auto rect_pos = Point2(ofs, (get_size().height - rect_size.height) / 2).floor();
draw_texture_rect(icon, Rect2(rect_pos, rect_size), false);
ofs += hs + rect_size.width;
}

Color color = get_theme_color(SNAME("font_color"), SNAME("Tree"));
Expand Down