Last active
July 21, 2020 21:55
-
-
Save HungryProton/ed9221f1f2afdea013b5b1ce857dc19c to your computer and use it in GitHub Desktop.
UI scaling to make the interface appear larger on high dpi monitors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static func get_scaled_theme(theme: Theme) -> Theme: | |
var scale = get_editor_scale() | |
var res: Theme = theme.duplicate(true) | |
res.default_font.size *= scale | |
for font_name in res.get_font_list("EditorFonts"): | |
var font = res.get_font(font_name, "EditorFonts") | |
font.size *= scale | |
for stylebox_type in res.get_stylebox_types(): | |
for font_name in res.get_font_list(stylebox_type): | |
var font = res.get_font(font_name, stylebox_type) | |
font.size *= scale | |
for const_name in res.get_constant_list(stylebox_type): | |
var c = res.get_constant(const_name, stylebox_type) | |
res.set_constant(const_name, stylebox_type, c * scale) | |
for box_name in res.get_stylebox_list(stylebox_type): | |
var box = res.get_stylebox(box_name, stylebox_type) | |
box.content_margin_bottom *= scale | |
box.content_margin_left *= scale | |
box.content_margin_right *= scale | |
box.content_margin_top *= scale | |
if box is StyleBoxFlat: | |
box.corner_radius_bottom_left *= scale | |
box.corner_radius_bottom_right *= scale | |
box.corner_radius_top_left *= scale | |
box.corner_radius_top_right *= scale | |
box.border_width_bottom *= scale | |
box.border_width_top *= scale | |
box.border_width_left *= scale | |
box.border_width_right *= scale | |
box.expand_margin_bottom *= scale | |
box.expand_margin_top *= scale | |
box.expand_margin_left *= scale | |
box.expand_margin_right *= scale | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment