-Some fixes to OSX retina scaling for window functions

-Implemented HiDPI detection and support for Godot Editor!
This commit is contained in:
Juan Linietsky 2016-05-30 00:28:29 -03:00
parent c7d24b7814
commit 9b1f8230ec
33 changed files with 421 additions and 242 deletions

View file

@ -548,6 +548,7 @@ OS::OS() {
_render_thread_mode=RENDER_THREAD_SAFE;
_time_scale=1.0;
_pixel_snap=false;
_allow_hidpi=true;
Math::seed(1234567);
}

View file

@ -60,6 +60,7 @@ class OS {
int _target_fps;
float _time_scale;
bool _pixel_snap;
bool _allow_hidpi;
char *last_error;
@ -418,6 +419,7 @@ public:
virtual void set_context(int p_context);
bool is_hidpi_allowed() const { return _allow_hidpi; }
OS();
virtual ~OS();

View file

@ -101,12 +101,13 @@ static bool init_fullscreen=false;
static bool init_use_custom_pos=false;
static bool debug_collisions=false;
static bool debug_navigation=false;
static bool allow_hidpi=true;
static Vector2 init_custom_pos;
static int video_driver_idx=-1;
static int audio_driver_idx=-1;
static String locale;
static bool use_debug_profiler=false;
static bool force_lowdpi=false;
static int init_screen=-1;
static String unescape_cmdline(const String& p_str) {
@ -157,6 +158,8 @@ void Main::print_help(const char* p_binary) {
OS::get_singleton()->print("%s",OS::get_singleton()->get_video_driver_name(i));
}
OS::get_singleton()->print(")\n");
OS::get_singleton()->print("\t-ldpi\t : Force low-dpi mode (OSX Only)");
OS::get_singleton()->print("\t-ad DRIVER\t : Audio Driver (");
for (int i=0;i<OS::get_singleton()->get_audio_driver_count();i++) {
@ -386,6 +389,9 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
goto error;
}
} else if (I->get()=="-ldpi") { // language
force_lowdpi=true;
} else if (I->get()=="-rfs") { // language
if (I->next()) {
@ -691,6 +697,9 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
video_mode.width=globals->get("display/width");
if (!force_res &&use_custom_res && globals->has("display/height"))
video_mode.height=globals->get("display/height");
if (!editor && (!bool(globals->get("display/allow_hidpi")) || force_lowdpi)) {
OS::get_singleton()->_allow_hidpi=false;
}
if (use_custom_res && globals->has("display/fullscreen"))
video_mode.fullscreen=globals->get("display/fullscreen");
if (use_custom_res && globals->has("display/resizable"))
@ -710,6 +719,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
GLOBAL_DEF("display/width",video_mode.width);
GLOBAL_DEF("display/height",video_mode.height);
GLOBAL_DEF("display/allow_hidpi",false);
GLOBAL_DEF("display/fullscreen",video_mode.fullscreen);
GLOBAL_DEF("display/resizable",video_mode.resizable);
GLOBAL_DEF("display/borderless_window", video_mode.borderless_window);

View file

@ -59,7 +59,7 @@ public:
bool force_quit;
Rasterizer *rasterizer;
VisualServer *visual_server;
VideoMode current_videomode;
List<String> args;
MainLoop *main_loop;
unsigned int event_id;
@ -104,9 +104,22 @@ public:
bool minimized;
bool maximized;
bool zoomed;
Vector<Rect2> screens;
Vector<int> screen_dpi;
Size2 window_size;
int current_screen;
Rect2 restore_rect;
float _mouse_scale(float p_scale) {
if (display_scale>1.0)
return p_scale;
else
return 1.0;
}
float display_scale;
protected:
virtual int get_video_driver_count() const;
@ -173,6 +186,9 @@ public:
virtual int get_current_screen() const;
virtual void set_current_screen(int p_screen);
virtual Point2 get_screen_position(int p_screen=0) const;
virtual Size2 get_screen_size(int p_screen=0) const;
virtual int get_screen_dpi(int p_screen=0) const;
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2& p_position);
virtual void set_window_size(const Size2 p_size);
@ -184,7 +200,6 @@ public:
virtual bool is_window_minimized() const;
virtual void set_window_maximized(bool p_enabled);
virtual bool is_window_maximized() const;
Size2 get_screen_size(int p_screen=0) const;
void run();

View file

@ -202,10 +202,10 @@ static int button_mask=0;
[OS_OSX::singleton->context update];
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
const NSRect fbRect = convertRectToBacking(contentRect);
const NSRect fbRect = contentRect;//convertRectToBacking(contentRect);
OS_OSX::singleton->current_videomode.width=fbRect.size.width;
OS_OSX::singleton->current_videomode.height=fbRect.size.height;
OS_OSX::singleton->window_size.width=fbRect.size.width*OS_OSX::singleton->display_scale;
OS_OSX::singleton->window_size.height=fbRect.size.height*OS_OSX::singleton->display_scale;
// _GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
@ -324,7 +324,7 @@ static int button_mask=0;
- (void)mouseDown:(NSEvent *)event
{
print_line("mouse down:");
//print_line("mouse down:");
button_mask|=BUTTON_MASK_LEFT;
InputEvent ev;
ev.type=InputEvent::MOUSE_BUTTON;
@ -383,14 +383,14 @@ static int button_mask=0;
prev_mouse_y=mouse_y;
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
const NSPoint p = [event locationInWindow];
mouse_x = p.x * [[event window] backingScaleFactor];
mouse_y = (contentRect.size.height - p.y) * [[event window] backingScaleFactor];
mouse_x = p.x * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
mouse_y = (contentRect.size.height - p.y) * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
ev.mouse_motion.x=mouse_x;
ev.mouse_motion.y=mouse_y;
ev.mouse_motion.global_x=mouse_x;
ev.mouse_motion.global_y=mouse_y;
ev.mouse_motion.relative_x=[event deltaX] * [[event window] backingScaleFactor];
ev.mouse_motion.relative_y=[event deltaY] * [[event window] backingScaleFactor];
ev.mouse_motion.relative_x=[event deltaX] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
ev.mouse_motion.relative_y=[event deltaY] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
ev.mouse_motion.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->input->set_mouse_pos(Point2(mouse_x,mouse_y));
@ -893,6 +893,15 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
kTISNotifySelectedKeyboardInputSourceChanged, NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
if (is_hidpi_allowed() && [[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)]) {
for (NSScreen *screen in [NSScreen screens]) {
float s = [screen backingScaleFactor];
if (s > display_scale) {
display_scale=s;
}
}
}
window_delegate = [[GodotWindowDelegate alloc] init];
// Don't use accumulation buffer support; it's not accelerated
@ -902,7 +911,7 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
window_object = [[GodotWindow alloc]
initWithContentRect:NSMakeRect(0, 0, p_desired.width, p_desired.height)
initWithContentRect:NSMakeRect(0, 0, p_desired.width/display_scale, p_desired.height/display_scale)
styleMask:styleMask
backing:NSBackingStoreBuffered
defer:NO];
@ -911,15 +920,11 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
window_view = [[GodotContentView alloc] init];
current_videomode = p_desired;
// Adjust for display density
const NSRect fbRect = convertRectToBacking(NSMakeRect(0, 0, p_desired.width, p_desired.height));
current_videomode.width = fbRect.size.width;
current_videomode.height = fbRect.size.height;
window_size.width = p_desired.width;
window_size.height = p_desired.height;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6 && display_scale>1) {
[window_view setWantsBestResolutionOpenGLSurface:YES];
//if (current_videomode.resizable)
[window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
@ -1062,9 +1067,28 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
printf("nscreen count %i\n", (int)[screenArray count]);
for (int i=0; i<[screenArray count]; i++) {
float displayScale = 1.0;
if (display_scale>1.0 && [[screenArray objectAtIndex: i] respondsToSelector:@selector(backingScaleFactor)]) {
displayScale = [[screenArray objectAtIndex: i] backingScaleFactor];
}
NSRect nsrect = [[screenArray objectAtIndex: i] visibleFrame];
screens.push_back(Rect2(nsrect.origin.x, nsrect.origin.y, nsrect.size.width, nsrect.size.height));
printf("added screen %i\n", screens.size());
Rect2 rect = Rect2(nsrect.origin.x, nsrect.origin.y, nsrect.size.width, nsrect.size.height);
rect.pos*=displayScale;
rect.size*=displayScale;
screens.push_back(rect);
NSDictionary *description = [[screenArray objectAtIndex: i] deviceDescription];
NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
CGSize displayPhysicalSize = CGDisplayScreenSize(
[[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
//printf("width: %i pwidth %i rect width %i\n",int(displayPixelSize.width*displayScale),int(displayPhysicalSize.width*displayScale),int(nsrect.size.width));
int dpi = (displayPixelSize.width * 25.4f / displayPhysicalSize.width)*displayScale;
screen_dpi.push_back(dpi);
};
restore_rect = Rect2(get_window_position(), get_window_size());
}
@ -1326,7 +1350,11 @@ void OS_OSX::set_video_mode(const VideoMode& p_video_mode,int p_screen) {
OS::VideoMode OS_OSX::get_video_mode(int p_screen) const {
return current_videomode;
VideoMode vm;
vm.width=window_size.width;
vm.height=window_size.height;
return vm;
}
void OS_OSX::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const {
@ -1354,6 +1382,12 @@ Point2 OS_OSX::get_screen_position(int p_screen) const {
return screens[p_screen].pos;
};
int OS_OSX::get_screen_dpi(int p_screen) const {
ERR_FAIL_INDEX_V(p_screen, screens.size(), 72);
return screen_dpi[p_screen];
}
Size2 OS_OSX::get_screen_size(int p_screen) const {
ERR_FAIL_INDEX_V(p_screen, screens.size(), Point2());
@ -1362,24 +1396,29 @@ Size2 OS_OSX::get_screen_size(int p_screen) const {
Point2 OS_OSX::get_window_position() const {
return Size2([window_object frame].origin.x, [window_object frame].origin.y);
Size2 wp([window_object frame].origin.x, [window_object frame].origin.y);
wp*=display_scale;
};
void OS_OSX::set_window_position(const Point2& p_position) {
[window_object setFrame:NSMakeRect(p_position.x, p_position.y, [window_object frame].size.width, [window_object frame].size.height) display:YES];
Point2 size=p_position;
size/=display_scale;
[window_object setFrame:NSMakeRect(size.x, size.y, [window_object frame].size.width, [window_object frame].size.height) display:YES];
};
Size2 OS_OSX::get_window_size() const {
return Size2([window_object frame].size.width, [window_object frame].size.height);
return window_size;
};
void OS_OSX::set_window_size(const Size2 p_size) {
Size2 size=p_size;
NSRect frame = [window_object frame];
[window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, p_size.x, p_size.y) display:YES];
[window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, size.x, size.y) display:YES];
};
void OS_OSX::set_window_fullscreen(bool p_enabled) {
@ -1690,5 +1729,7 @@ OS_OSX::OS_OSX() {
maximized = false;
minimized = false;
window_size=Vector2(1024,600);
zoomed = false;
display_scale=1.0;
}

View file

@ -118,6 +118,16 @@ void WindowDialog::set_title(const String& p_title) {
update();
}
Size2 WindowDialog::get_minimum_size() const {
Ref<Font> font = get_font("title_font","WindowDialog");
int msx=close_button->get_combined_minimum_size().x;
msx+=font->get_string_size(title).x;
return Size2(msx,1);
}
String WindowDialog::get_title() const {
return title;
@ -192,11 +202,9 @@ void AcceptDialog::_notification(int p_what) {
if (p_what==NOTIFICATION_MODAL_CLOSE) {
cancel_pressed();
} if (p_what==NOTIFICATION_DRAW) {
} if (p_what==NOTIFICATION_RESIZED) {
_update_child_rect();
}
}
@ -244,12 +252,69 @@ void AcceptDialog::register_text_enter(Node *p_line_edit) {
p_line_edit->connect("text_entered", this,"_builtin_text_entered");
}
void AcceptDialog::_update_child_rect() {
int margin = get_constant("margin","Dialogs");
Size2 size = get_size();
Size2 hminsize = hbc->get_combined_minimum_size();
Vector2 cpos(margin,margin);
Vector2 csize(size.x-margin*2,size.y-margin*3-hminsize.y);
label->set_pos(cpos);
label->set_size(csize);
if (child) {
child->set_pos(cpos);
child->set_size(csize);
}
cpos.y+=csize.y+margin;
csize.y=hminsize.y;
hbc->set_pos(cpos);
hbc->set_size(csize);
}
Size2 AcceptDialog::get_minimum_size() const {
int margin = get_constant("margin","Dialogs");
Size2 minsize = label->get_combined_minimum_size();
if (child) {
Size2 cminsize = child->get_combined_minimum_size();
minsize.x=MAX(cminsize.x,minsize.x);
minsize.y=MAX(cminsize.y,minsize.y);
}
Size2 hminsize = hbc->get_combined_minimum_size();
minsize.x = MAX(hminsize.x,minsize.x);
minsize.y+=hminsize.y;
minsize.x+=margin*2;
minsize.y+=margin*3; //one as separation between hbc and child
Size2 wmsize = WindowDialog::get_minimum_size();
minsize.x=MAX(wmsize.x,minsize.x);
return minsize;
}
void AcceptDialog::set_child_rect(Control *p_child) {
ERR_FAIL_COND(p_child->get_parent()!=this);
p_child->set_area_as_parent_rect(get_constant("margin","Dialogs"));
p_child->set_margin(MARGIN_BOTTOM, get_constant("button_margin","Dialogs")+10);
//p_child->set_area_as_parent_rect(get_constant("margin","Dialogs"));
child=p_child;
minimum_size_changed();
_update_child_rect();
}
void AcceptDialog::remove_child_notify(Node *p_child) {
if (p_child==child) {
child=NULL;
}
}
void AcceptDialog::_custom_action(const String& p_action) {
@ -352,6 +417,8 @@ AcceptDialog::AcceptDialog() {
hide_on_ok=true;
set_title("Alert!");
child=NULL;
}

View file

@ -64,6 +64,8 @@ public:
void set_title(const String& p_title);
String get_title() const;
Size2 get_minimum_size() const;
WindowDialog();
~WindowDialog();
@ -89,6 +91,7 @@ class AcceptDialog : public WindowDialog {
OBJ_TYPE(AcceptDialog,WindowDialog);
Control *child;
HBoxContainer *hbc;
Label *label;
Button *ok;
@ -100,10 +103,12 @@ class AcceptDialog : public WindowDialog {
void _ok_pressed();
void _close_pressed();
void _builtin_text_entered(const String& p_text);
void _update_child_rect();
static bool swap_ok_cancel;
virtual void remove_child_notify(Node *p_child);
protected:
@ -116,6 +121,8 @@ protected:
virtual void custom_action(const String&) {}
public:
Size2 get_minimum_size() const;
Label *get_label() { return label; }
static void set_swap_ok_cancel(bool p_swap);

View file

@ -411,6 +411,11 @@ void TabContainer::_notification(int p_what) {
panel->draw(ci, Rect2( 0, top_size.height, size.width, size.height-top_size.height));
} break;
case NOTIFICATION_READY:
case NOTIFICATION_THEME_CHANGED: {
call_deferred("set_current_tab",get_current_tab()); //wait until all changed theme
} break;
}
}

View file

@ -28,6 +28,7 @@
typedef Map<const void*,Ref<ImageTexture> > TexCacheMap;
static TexCacheMap *tex_cache;
static int scale=1;
template<class T>
static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, float p_right, float p_botton,float p_margin_left=-1, float p_margin_top=-1, float p_margin_right=-1, float p_margin_botton=-1, bool p_draw_center=true) {
@ -40,21 +41,24 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, flo
} else {
texture = Ref<ImageTexture>( memnew( ImageTexture ) );
texture->create_from_image( Image(p_src),ImageTexture::FLAG_FILTER );
Image img(p_src);
if (scale>1)
img.expand_x2_hq2x();
texture->create_from_image( img,ImageTexture::FLAG_FILTER );
(*tex_cache)[p_src]=texture;
}
Ref<StyleBoxTexture> style( memnew( StyleBoxTexture ) );
style->set_texture(texture);
style->set_margin_size( MARGIN_LEFT, p_left );
style->set_margin_size( MARGIN_RIGHT, p_right );
style->set_margin_size( MARGIN_BOTTOM, p_botton );
style->set_margin_size( MARGIN_TOP, p_top );
style->set_default_margin( MARGIN_LEFT, p_margin_left );
style->set_default_margin( MARGIN_RIGHT, p_margin_right );
style->set_default_margin( MARGIN_BOTTOM, p_margin_botton );
style->set_default_margin( MARGIN_TOP, p_margin_top );
style->set_margin_size( MARGIN_LEFT, p_left * scale);
style->set_margin_size( MARGIN_RIGHT, p_right * scale);
style->set_margin_size( MARGIN_BOTTOM, p_botton * scale);
style->set_margin_size( MARGIN_TOP, p_top * scale);
style->set_default_margin( MARGIN_LEFT, p_margin_left * scale);
style->set_default_margin( MARGIN_RIGHT, p_margin_right * scale);
style->set_default_margin( MARGIN_BOTTOM, p_margin_botton * scale);
style->set_default_margin( MARGIN_TOP, p_margin_top * scale);
style->set_draw_center(p_draw_center);
return style;
@ -63,10 +67,10 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, flo
static Ref<StyleBoxTexture> sb_expand(Ref<StyleBoxTexture> p_sbox,float p_left, float p_top, float p_right, float p_botton) {
p_sbox->set_expand_margin_size(MARGIN_LEFT,p_left);
p_sbox->set_expand_margin_size(MARGIN_TOP,p_top);
p_sbox->set_expand_margin_size(MARGIN_RIGHT,p_right);
p_sbox->set_expand_margin_size(MARGIN_BOTTOM,p_botton);
p_sbox->set_expand_margin_size(MARGIN_LEFT,p_left * scale);
p_sbox->set_expand_margin_size(MARGIN_TOP,p_top * scale);
p_sbox->set_expand_margin_size(MARGIN_RIGHT,p_right * scale);
p_sbox->set_expand_margin_size(MARGIN_BOTTOM,p_botton * scale);
return p_sbox;
}
@ -75,7 +79,10 @@ static Ref<Texture> make_icon(T p_src) {
Ref<ImageTexture> texture( memnew( ImageTexture ) );
texture->create_from_image( Image(p_src),ImageTexture::FLAG_FILTER );
Image img = Image(p_src);
if (scale>1)
img.expand_x2_hq2x();
texture->create_from_image( img,ImageTexture::FLAG_FILTER );
return texture;
}
@ -170,27 +177,24 @@ static Ref<StyleBox> make_empty_stylebox(float p_margin_left=-1, float p_margin_
Ref<StyleBox> style( memnew( StyleBoxEmpty) );
style->set_default_margin( MARGIN_LEFT, p_margin_left );
style->set_default_margin( MARGIN_RIGHT, p_margin_right );
style->set_default_margin( MARGIN_BOTTOM, p_margin_botton );
style->set_default_margin( MARGIN_TOP, p_margin_top );
style->set_default_margin( MARGIN_LEFT, p_margin_left * scale);
style->set_default_margin( MARGIN_RIGHT, p_margin_right * scale);
style->set_default_margin( MARGIN_BOTTOM, p_margin_botton * scale);
style->set_default_margin( MARGIN_TOP, p_margin_top * scale);
return style;
}
#ifndef DEFAULT_THEME_DISABLED
void make_default_theme() {
void fill_default_theme(Ref<Theme>& t,const Ref<Font> & default_font,const Ref<Font> & large_font,Ref<Texture>& default_icon, Ref<StyleBox>& default_style,bool p_hidpi) {
if (p_hidpi)
scale=2;
else
scale=1;
tex_cache = memnew( TexCacheMap );
Ref<Theme> t( memnew( Theme ) );
//Ref<BitmapFont> default_font = make_font(_bi_font_normal_height,_bi_font_normal_ascent,_bi_font_normal_valign,_bi_font_normal_charcount,_bi_font_normal_characters,make_icon(font_normal_png));
Ref<BitmapFont> default_font=make_font2(_builtin_normal_font_height,_builtin_normal_font_ascent,_builtin_normal_font_charcount,&_builtin_normal_font_charrects[0][0],_builtin_normal_font_kerning_pair_count,&_builtin_normal_font_kerning_pairs[0][0],_builtin_normal_font_img_width,_builtin_normal_font_img_height,_builtin_normal_font_img_data);
Ref<BitmapFont> source_font=make_font2(_builtin_source_font_height,_builtin_source_font_ascent,_builtin_source_font_charcount,&_builtin_source_font_charrects[0][0],_builtin_source_font_kerning_pair_count,&_builtin_source_font_kerning_pairs[0][0],_builtin_source_font_img_width,_builtin_source_font_img_height,_builtin_source_font_img_data);
Ref<BitmapFont> large_font=make_font2(_builtin_large_font_height,_builtin_large_font_ascent,_builtin_large_font_charcount,&_builtin_large_font_charrects[0][0],_builtin_large_font_kerning_pair_count,&_builtin_large_font_kerning_pairs[0][0],_builtin_large_font_img_width,_builtin_large_font_img_height,_builtin_large_font_img_data);
// Font Colors
@ -213,7 +217,7 @@ void make_default_theme() {
Ref<StyleBoxTexture> focus = make_stylebox( focus_png,5,5,5,5);
for(int i=0;i<4;i++) {
focus->set_expand_margin_size(Margin(i),1);
focus->set_expand_margin_size(Margin(i),1 *scale);
}
@ -239,7 +243,7 @@ void make_default_theme() {
t->set_color("font_color_hover","Button", control_font_color_hover );
t->set_color("font_color_disabled","Button", control_font_color_disabled );
t->set_constant("hseparation","Button", 2);
t->set_constant("hseparation","Button", 2 *scale);
// LinkButton
@ -249,7 +253,7 @@ void make_default_theme() {
t->set_color("font_color_pressed","LinkButton", control_font_color_pressed );
t->set_color("font_color_hover","LinkButton", control_font_color_hover );
t->set_constant("underline_spacing","LinkButton", 2 );
t->set_constant("underline_spacing","LinkButton", 2 *scale);
// ColorPickerButton
@ -266,16 +270,16 @@ void make_default_theme() {
t->set_color("font_color_hover","ColorPickerButton", Color(1,1,1,1) );
t->set_color("font_color_disabled","ColorPickerButton", Color(0.9,0.9,0.9,0.3) );
t->set_constant("hseparation","ColorPickerButton", 2 );
t->set_constant("hseparation","ColorPickerButton", 2 *scale);
// ToolButton
Ref<StyleBox> tb_empty = memnew( StyleBoxEmpty );
tb_empty->set_default_margin(MARGIN_LEFT,6);
tb_empty->set_default_margin(MARGIN_RIGHT,6);
tb_empty->set_default_margin(MARGIN_TOP,4);
tb_empty->set_default_margin(MARGIN_BOTTOM,4);
tb_empty->set_default_margin(MARGIN_LEFT,6 *scale);
tb_empty->set_default_margin(MARGIN_RIGHT,6 *scale);
tb_empty->set_default_margin(MARGIN_TOP,4 *scale);
tb_empty->set_default_margin(MARGIN_BOTTOM,4 *scale);
t->set_stylebox("normal","ToolButton", tb_empty);
t->set_stylebox("pressed","ToolButton", make_stylebox( button_pressed_png,4,4,4,4) );
@ -316,8 +320,8 @@ void make_default_theme() {
t->set_color("font_color_hover","OptionButton", control_font_color_hover );
t->set_color("font_color_disabled","OptionButton", control_font_color_disabled );
t->set_constant("hseparation","OptionButton", 2 );
t->set_constant("arrow_margin","OptionButton", 2 );
t->set_constant("hseparation","OptionButton", 2 *scale);
t->set_constant("arrow_margin","OptionButton", 2 *scale);
@ -336,7 +340,7 @@ void make_default_theme() {
t->set_color("font_color_hover","MenuButton", control_font_color_hover );
t->set_color("font_color_disabled","MenuButton", Color(1,1,1,0.3) );
t->set_constant("hseparation","MenuButton", 3 );
t->set_constant("hseparation","MenuButton", 3 *scale);
// ButtonGroup
@ -345,15 +349,15 @@ void make_default_theme() {
// CheckBox
Ref<StyleBox> cbx_empty = memnew( StyleBoxEmpty );
cbx_empty->set_default_margin(MARGIN_LEFT,22);
cbx_empty->set_default_margin(MARGIN_RIGHT,4);
cbx_empty->set_default_margin(MARGIN_TOP,4);
cbx_empty->set_default_margin(MARGIN_BOTTOM,5);
cbx_empty->set_default_margin(MARGIN_LEFT,22 *scale);
cbx_empty->set_default_margin(MARGIN_RIGHT,4 *scale);
cbx_empty->set_default_margin(MARGIN_TOP,4 *scale);
cbx_empty->set_default_margin(MARGIN_BOTTOM,5 *scale);
Ref<StyleBox> cbx_focus = focus;
cbx_focus->set_default_margin(MARGIN_LEFT,4);
cbx_focus->set_default_margin(MARGIN_RIGHT,22);
cbx_focus->set_default_margin(MARGIN_TOP,4);
cbx_focus->set_default_margin(MARGIN_BOTTOM,5);
cbx_focus->set_default_margin(MARGIN_LEFT,4 *scale);
cbx_focus->set_default_margin(MARGIN_RIGHT,22 *scale);
cbx_focus->set_default_margin(MARGIN_TOP,4 *scale);
cbx_focus->set_default_margin(MARGIN_BOTTOM,5 *scale);
t->set_stylebox("normal","CheckBox", cbx_empty );
t->set_stylebox("pressed","CheckBox", cbx_empty );
@ -373,18 +377,18 @@ void make_default_theme() {
t->set_color("font_color_hover","CheckBox", control_font_color_hover );
t->set_color("font_color_disabled","CheckBox", control_font_color_disabled );
t->set_constant("hseparation","CheckBox",4);
t->set_constant("check_vadjust","CheckBox",0);
t->set_constant("hseparation","CheckBox",4 *scale);
t->set_constant("check_vadjust","CheckBox",0 *scale);
// CheckButton
Ref<StyleBox> cb_empty = memnew( StyleBoxEmpty );
cb_empty->set_default_margin(MARGIN_LEFT,6);
cb_empty->set_default_margin(MARGIN_RIGHT,70);
cb_empty->set_default_margin(MARGIN_TOP,4);
cb_empty->set_default_margin(MARGIN_BOTTOM,4);
cb_empty->set_default_margin(MARGIN_LEFT,6 *scale);
cb_empty->set_default_margin(MARGIN_RIGHT,70 *scale);
cb_empty->set_default_margin(MARGIN_TOP,4 *scale);
cb_empty->set_default_margin(MARGIN_BOTTOM,4 *scale);
t->set_stylebox("normal","CheckButton", cb_empty );
t->set_stylebox("pressed","CheckButton", cb_empty );
@ -402,8 +406,8 @@ void make_default_theme() {
t->set_color("font_color_hover","CheckButton", control_font_color_hover );
t->set_color("font_color_disabled","CheckButton", control_font_color_disabled );
t->set_constant("hseparation","CheckButton",4);
t->set_constant("check_vadjust","CheckButton",0);
t->set_constant("hseparation","CheckButton",4 *scale);
t->set_constant("check_vadjust","CheckButton",0 *scale);
@ -414,10 +418,10 @@ void make_default_theme() {
t->set_color("font_color","Label", Color(1,1,1) );
t->set_color("font_color_shadow","Label", Color(0,0,0,0) );
t->set_constant("shadow_offset_x","Label", 1 );
t->set_constant("shadow_offset_y","Label", 1 );
t->set_constant("shadow_as_outline","Label", 0 );
t->set_constant("line_spacing","Label", 3 );
t->set_constant("shadow_offset_x","Label", 1 *scale);
t->set_constant("shadow_offset_y","Label", 1 *scale);
t->set_constant("shadow_as_outline","Label", 0 *scale);
t->set_constant("line_spacing","Label", 3 *scale);
@ -434,7 +438,7 @@ void make_default_theme() {
t->set_color("cursor_color","LineEdit", control_font_color_hover );
t->set_color("selection_color","LineEdit", font_color_selection );
t->set_constant("minimum_spaces","LineEdit", 12 );
t->set_constant("minimum_spaces","LineEdit", 12 *scale);
@ -475,7 +479,7 @@ void make_default_theme() {
t->set_constant("completion_lines","TextEdit", 7 );
t->set_constant("completion_max_width","TextEdit", 50 );
t->set_constant("completion_scroll_width","TextEdit", 3 );
t->set_constant("line_spacing","TextEdit",4 );
t->set_constant("line_spacing","TextEdit",4 *scale);
Ref<Texture> empty_icon = memnew( ImageTexture );
@ -555,10 +559,10 @@ void make_default_theme() {
t->set_color("title_color","WindowDialog", Color(0,0,0) );
t->set_constant("close_h_ofs","WindowDialog", 22 );
t->set_constant("close_v_ofs","WindowDialog", 20 );
t->set_constant("titlebar_height","WindowDialog", 18 );
t->set_constant("title_height","WindowDialog", 20 );
t->set_constant("close_h_ofs","WindowDialog", 22 *scale);
t->set_constant("close_v_ofs","WindowDialog", 20 *scale);
t->set_constant("titlebar_height","WindowDialog", 18 *scale);
t->set_constant("title_height","WindowDialog", 20 *scale);
// File Dialog
@ -572,7 +576,7 @@ void make_default_theme() {
Ref<StyleBoxTexture> selected = make_stylebox( selection_png,6,6,6,6);
for(int i=0;i<4;i++) {
selected->set_expand_margin_size(Margin(i),2);
selected->set_expand_margin_size(Margin(i),2 *scale);
}
t->set_stylebox("panel","PopupPanel", style_pp );
@ -598,8 +602,8 @@ void make_default_theme() {
t->set_color("font_color_disabled","PopupMenu", Color(0.4,0.4,0.4,0.8) );
t->set_color("font_color_hover","PopupMenu", control_font_color );
t->set_constant("hseparation","PopupMenu",4);
t->set_constant("vseparation","PopupMenu",4);
t->set_constant("hseparation","PopupMenu",4 *scale);
t->set_constant("vseparation","PopupMenu",4 *scale);
// GraphNode
@ -614,14 +618,14 @@ void make_default_theme() {
t->set_stylebox("selectedframe","GraphNode", graphsbselected );
t->set_stylebox("defaultframe", "GraphNode", graphsbdefault );
t->set_stylebox("defaultfocus", "GraphNode", graphsbdeffocus );
t->set_constant("separation","GraphNode", 1 );
t->set_constant("separation","GraphNode", 1 *scale);
t->set_icon("port","GraphNode", make_icon( graph_port_png ) );
t->set_icon("close","GraphNode", make_icon( graph_node_close_png ) );
t->set_font("title_font","GraphNode", default_font );
t->set_color("title_color","GraphNode", Color(0,0,0,1));
t->set_constant("title_offset","GraphNode", 18);
t->set_constant("close_offset","GraphNode", 18);
t->set_constant("port_offset","GraphNode", 3);
t->set_constant("title_offset","GraphNode", 18 *scale);
t->set_constant("close_offset","GraphNode", 18 *scale);
t->set_constant("port_offset","GraphNode", 3 *scale);
// Tree
@ -658,11 +662,11 @@ void make_default_theme() {
t->set_color("guide_color","Tree", Color(0,0,0,0.1) );
t->set_color("drop_position_color","Tree", Color(1,0.3,0.2) );
t->set_constant("hseparation","Tree",4);
t->set_constant("vseparation","Tree",4);
t->set_constant("guide_width","Tree",2);
t->set_constant("item_margin","Tree",12);
t->set_constant("button_margin","Tree",4);
t->set_constant("hseparation","Tree",4 *scale);
t->set_constant("vseparation","Tree",4 *scale);
t->set_constant("guide_width","Tree",2 *scale);
t->set_constant("item_margin","Tree",12 *scale);
t->set_constant("button_margin","Tree",4 *scale);
// ItemList
@ -674,7 +678,7 @@ void make_default_theme() {
t->set_constant("hseparation","ItemList",4);
t->set_constant("vseparation","ItemList",2);
t->set_constant("icon_margin","ItemList",4);
t->set_constant("line_separation","ItemList",2);
t->set_constant("line_separation","ItemList",2 *scale);
t->set_font("font","ItemList", default_font );
t->set_color("font_color","ItemList", control_font_color_lower );
t->set_color("font_color_selected","ItemList", control_font_color_pressed );
@ -695,8 +699,8 @@ void make_default_theme() {
Ref<StyleBoxTexture> tc_sb = sb_expand( make_stylebox( tab_container_bg_png,4,4,4,4,4,4,4,4),3,3,3,3);
tc_sb->set_expand_margin_size(MARGIN_TOP,2);
tc_sb->set_default_margin(MARGIN_TOP,8);
tc_sb->set_expand_margin_size(MARGIN_TOP,2 *scale);
tc_sb->set_default_margin(MARGIN_TOP,8 *scale);
t->set_stylebox("tab_fg","TabContainer", sb_expand( make_stylebox( tab_current_png,4,4,4,1,16,4,16,4),2,2,2,2) );
t->set_stylebox("tab_bg","TabContainer", sb_expand( make_stylebox( tab_behind_png,5,5,5,1,16,6,16,4),3,0,3,3) );
@ -714,11 +718,11 @@ void make_default_theme() {
t->set_color("font_color_fg","TabContainer", control_font_color_hover );
t->set_color("font_color_bg","TabContainer", control_font_color_low );
t->set_constant("side_margin","TabContainer", 8 );
t->set_constant("top_margin","TabContainer", 24);
t->set_constant("label_valign_fg","TabContainer", 0);
t->set_constant("label_valign_bg","TabContainer", 2);
t->set_constant("hseparation","TabContainer", 4);
t->set_constant("side_margin","TabContainer", 8 *scale);
t->set_constant("top_margin","TabContainer", 24 *scale);
t->set_constant("label_valign_fg","TabContainer", 0 *scale);
t->set_constant("label_valign_bg","TabContainer", 2 *scale);
t->set_constant("hseparation","TabContainer", 4 *scale);
@ -741,10 +745,10 @@ void make_default_theme() {
t->set_color("font_color_fg","Tabs", control_font_color_hover );
t->set_color("font_color_bg","Tabs", control_font_color_low );
t->set_constant("top_margin","Tabs", 24);
t->set_constant("label_valign_fg","Tabs", 0);
t->set_constant("label_valign_bg","Tabs", 2);
t->set_constant("hseparation","Tabs", 4);
t->set_constant("top_margin","Tabs", 24 *scale);
t->set_constant("label_valign_fg","Tabs", 0 *scale);
t->set_constant("label_valign_bg","Tabs", 2 *scale);
t->set_constant("hseparation","Tabs", 4 *scale);
@ -754,18 +758,17 @@ void make_default_theme() {
t->set_stylebox("separator","VSeparator", make_stylebox( hseparator_png,3,3,3,3) );
t->set_icon("close","Icons", make_icon(icon_close_png));
t->set_font("source","Fonts", source_font);
t->set_font("normal","Fonts", default_font );
t->set_font("large","Fonts", large_font );
t->set_constant("separation","HSeparator", 4);
t->set_constant("separation","VSeparator", 4);
t->set_constant("separation","HSeparator", 4 *scale);
t->set_constant("separation","VSeparator", 4 *scale);
// Dialogs
t->set_constant("margin","Dialogs",8);
t->set_constant("button_margin","Dialogs",32);
t->set_constant("margin","Dialogs",8 *scale);
t->set_constant("button_margin","Dialogs",32 *scale);
@ -778,11 +781,11 @@ void make_default_theme() {
// colorPicker
t->set_constant("value_height","ColorPicker", 23 );
t->set_constant("value_width","ColorPicker", 50);
t->set_constant("color_width","ColorPicker", 100);
t->set_constant("label_width","ColorPicker", 20);
t->set_constant("hseparator","ColorPicker", 4);
t->set_constant("value_height","ColorPicker", 23 *scale);
t->set_constant("value_width","ColorPicker", 50 *scale);
t->set_constant("color_width","ColorPicker", 100 *scale);
t->set_constant("label_width","ColorPicker", 20 *scale);
t->set_constant("hseparator","ColorPicker", 4 *scale);
t->set_icon("screen_picker","ColorPicker", make_icon( icon_color_pick_png ) );
t->set_icon("add_preset","ColorPicker", make_icon( icon_add_png ) );
@ -794,7 +797,7 @@ void make_default_theme() {
Ref<StyleBoxTexture> style_tt = make_stylebox( tooltip_bg_png,4,4,4,4);
for(int i=0;i<4;i++)
style_tt->set_expand_margin_size((Margin)i,4);
style_tt->set_expand_margin_size((Margin)i,4 *scale);
t->set_stylebox("panel","TooltipPanel", style_tt );
@ -822,9 +825,9 @@ void make_default_theme() {
t->set_color("font_color_selected","RichTextLabel", font_color_selection );
t->set_color("selection_color","RichTextLabel", Color(0.1,0.1,1,0.8) );
t->set_constant("line_separation","RichTextLabel", 1 );
t->set_constant("table_hseparation","RichTextLabel", 3 );
t->set_constant("table_vseparation","RichTextLabel", 3 );
t->set_constant("line_separation","RichTextLabel", 1 *scale);
t->set_constant("table_hseparation","RichTextLabel", 3 *scale);
t->set_constant("table_vseparation","RichTextLabel", 3 *scale);
@ -836,18 +839,18 @@ void make_default_theme() {
t->set_icon("grabber","VSplitContainer",make_icon(vsplitter_png));
t->set_icon("grabber","HSplitContainer",make_icon(hsplitter_png));
t->set_constant("separation","HBoxContainer",4);
t->set_constant("separation","VBoxContainer",4);
t->set_constant("margin_left","MarginContainer",8);
t->set_constant("margin_top","MarginContainer",0);
t->set_constant("margin_right","MarginContainer",0);
t->set_constant("margin_bottom","MarginContainer",0);
t->set_constant("hseparation","GridContainer",4);
t->set_constant("vseparation","GridContainer",4);
t->set_constant("separation","HSplitContainer",12);
t->set_constant("separation","VSplitContainer",12);
t->set_constant("autohide","HSplitContainer",1);
t->set_constant("autohide","VSplitContainer",1);
t->set_constant("separation","HBoxContainer",4 *scale);
t->set_constant("separation","VBoxContainer",4 *scale);
t->set_constant("margin_left","MarginContainer",8 *scale);
t->set_constant("margin_top","MarginContainer",0 *scale);
t->set_constant("margin_right","MarginContainer",0 *scale);
t->set_constant("margin_bottom","MarginContainer",0 *scale);
t->set_constant("hseparation","GridContainer",4 *scale);
t->set_constant("vseparation","GridContainer",4 *scale);
t->set_constant("separation","HSplitContainer",12 *scale);
t->set_constant("separation","VSplitContainer",12 *scale);
t->set_constant("autohide","HSplitContainer",1 *scale);
t->set_constant("autohide","VSplitContainer",1 *scale);
@ -863,8 +866,8 @@ void make_default_theme() {
t->set_color("font_color","HButtonArray", control_font_color_low );
t->set_color("font_color_selected","HButtonArray", control_font_color_hover );
t->set_constant("icon_separator","HButtonArray", 4 );
t->set_constant("button_separator","HButtonArray", 8 );
t->set_constant("icon_separator","HButtonArray", 4 *scale );
t->set_constant("button_separator","HButtonArray", 8 *scale );
t->set_stylebox("focus","HButtonArray", focus );
@ -881,8 +884,8 @@ void make_default_theme() {
t->set_color("font_color","VButtonArray", control_font_color_low );
t->set_color("font_color_selected","VButtonArray", control_font_color_hover );
t->set_constant("icon_separator","VButtonArray", 4);
t->set_constant("button_separator","VButtonArray", 8);
t->set_constant("icon_separator","VButtonArray", 4 *scale);
t->set_constant("button_separator","VButtonArray", 8 *scale);
t->set_stylebox("focus","VButtonArray", focus );
@ -914,45 +917,31 @@ void make_default_theme() {
// Theme
Theme::set_default( t );
Theme::set_default_icon( make_icon(error_icon_png) );
Theme::set_default_style( make_stylebox( error_icon_png,2,2,2,2) );
Theme::set_default_font( default_font );
default_icon= make_icon(error_icon_png) ;
default_style = make_stylebox( error_icon_png,2,2,2,2) ;
memdelete( tex_cache );
}
#else
#include "error_icon.xpm"
void make_default_theme() {
Ref<Theme> t( memnew( Theme ) );
Ref<Theme> t;
t.instance();
Ref<StyleBox> default_style;
Ref<Texture> default_icon;
Ref<BitmapFont> default_font=make_font2(_builtin_normal_font_height,_builtin_normal_font_ascent,_builtin_normal_font_charcount,&_builtin_normal_font_charrects[0][0],_builtin_normal_font_kerning_pair_count,&_builtin_normal_font_kerning_pairs[0][0],_builtin_normal_font_img_width,_builtin_normal_font_img_height,_builtin_normal_font_img_data);
Ref<BitmapFont> large_font=make_font2(_builtin_large_font_height,_builtin_large_font_ascent,_builtin_large_font_charcount,&_builtin_large_font_charrects[0][0],_builtin_large_font_kerning_pair_count,&_builtin_large_font_kerning_pairs[0][0],_builtin_large_font_img_width,_builtin_large_font_img_height,_builtin_large_font_img_data);
fill_default_theme(t,default_font,large_font,default_icon,default_style,false);
Image error_img(error_icon_xpm);
Ref<Texture> texture( memnew( Texture ) );
texture->create_from_image( error_img );
Ref<StyleBoxTexture> style( memnew( StyleBoxTexture ) );
style->set_texture(texture);
for(int i=0;i<4;i++) {
style->set_margin_size( Margin(),8);
style->set_default_margin( Margin(),8);
}
Ref<BitmapFont> f = make_default_font();
Theme::set_default( t );
Theme::set_default_icon( texture );
Theme::set_default_style( style );
Theme::set_default_font( f );
Theme::set_default_icon( default_icon );
Theme::set_default_style( default_style );
Theme::set_default_font( default_font );
}
#endif
void clear_default_theme() {
Theme::set_default( Ref<Theme>() );

View file

@ -12,10 +12,12 @@
#ifndef DEFAULT_THEME_H
#define DEFAULT_THEME_H
#include "scene/resources/theme.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
void fill_default_theme(Ref<Theme>& theme,const Ref<Font> & default_font,const Ref<Font> & large_font,Ref<Texture>& default_icon, Ref<StyleBox>& default_style,bool p_hidpi);
void make_default_theme();
void clear_default_theme();

View file

@ -7,7 +7,7 @@
#include "editor_settings.h"
#include "scene/gui/margin_container.h"
#include "os/file_access.h"
#include "editor_scale.h"
EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func=NULL;
EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func=NULL;
@ -347,7 +347,7 @@ void EditorFileDialog::_action_pressed() {
if (!valid) {
exterr->popup_centered_minsize(Size2(250,80));
exterr->popup_centered_minsize(Size2(250,80)*EDSCALE);
return;
}
@ -431,6 +431,7 @@ void EditorFileDialog::update_file_list() {
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
thumbnail_size*=EDSCALE;
Ref<Texture> folder_thumbnail;
Ref<Texture> file_thumbnail;
@ -840,7 +841,7 @@ void EditorFileDialog::_make_dir_confirm() {
_push_history();
} else {
mkdirerr->popup_centered_minsize(Size2(250,50));
mkdirerr->popup_centered_minsize(Size2(250,50)*EDSCALE);
}
makedirname->set_text(""); // reset label
}
@ -848,7 +849,7 @@ void EditorFileDialog::_make_dir_confirm() {
void EditorFileDialog::_make_dir() {
makedialog->popup_centered_minsize(Size2(250,80));
makedialog->popup_centered_minsize(Size2(250,80)*EDSCALE);
makedirname->grab_focus();
}

View file

@ -33,6 +33,8 @@
#include "builtin_fonts.h"
#include "editor_settings.h"
#include "scene/resources/dynamic_font.h"
#include "editor_scale.h"
#include "scene/resources/default_theme/default_theme.h"
static Ref<BitmapFont> make_font(int p_height,int p_ascent, int p_valign, int p_charcount, const int *p_chars,const Ref<Texture> &p_texture) {
@ -67,6 +69,7 @@ static Ref<BitmapFont> make_font(int p_height,int p_ascent, int p_valign, int p_
void editor_register_fonts(Ref<Theme> p_theme) {
Ref<DynamicFontData> dfd;
dfd.instance();
dfd->set_font_ptr(_font_droid_sans,_font_droid_sans_size);
@ -79,7 +82,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
Ref<DynamicFont> df;
df.instance();
df->set_size(int(EditorSettings::get_singleton()->get("global/font_size")));
df->set_size(int(EditorSettings::get_singleton()->get("global/font_size"))*EDSCALE);
df->set_font_data(dfd);
@ -91,12 +94,12 @@ void editor_register_fonts(Ref<Theme> p_theme) {
Ref<DynamicFont> df_title;
df_title.instance();
df_title->set_size(int(EDITOR_DEF("help/help_title_font_size",18)));
df_title->set_size(int(EDITOR_DEF("help/help_title_font_size",18))*EDSCALE);
df_title->set_font_data(dfd);
Ref<DynamicFont> df_doc;
df_doc.instance();
df_doc->set_size(int(EDITOR_DEF("help/help_font_size",16)));
df_doc->set_size(int(EDITOR_DEF("help/help_font_size",16))*EDSCALE);
df_doc->set_font_data(dfd);
p_theme->set_font("doc","EditorFonts",df_doc);
@ -105,16 +108,25 @@ void editor_register_fonts(Ref<Theme> p_theme) {
Ref<DynamicFont> df_code;
df_code.instance();
df_code->set_size(int(EditorSettings::get_singleton()->get("global/source_font_size")));
df_code->set_size(int(EditorSettings::get_singleton()->get("global/source_font_size"))*EDSCALE);
df_code->set_font_data(dfmono);
p_theme->set_font("source","EditorFonts",df_code);
Ref<DynamicFont> df_doc_code;
df_doc_code.instance();
df_doc_code->set_size(int(EDITOR_DEF("help/help_source_font_size",14)));
df_doc_code->set_size(int(EDITOR_DEF("help/help_source_font_size",14))*EDSCALE);
df_doc_code->set_font_data(dfmono);
p_theme->set_font("doc_source","EditorFonts",df_doc_code);
if (editor_is_hidpi()) {
//replace default theme
Ref<Texture> di;
Ref<StyleBox> ds;
fill_default_theme(p_theme,df,df_doc,di,ds,true);
}
}

View file

@ -984,6 +984,7 @@ void EditorNode::_save_scene_with_preview(String p_file) {
save.step(TTR("Creating Thumbnail"),3);
Image img = VS::get_singleton()->viewport_get_screen_capture(viewport);
int preview_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");;
preview_size*=EDSCALE;
int width,height;
if (img.get_width() > preview_size && img.get_width() >= img.get_height()) {
@ -2389,7 +2390,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
confirmation->get_ok()->set_text(TTR("Quit"));
//confirmation->get_cancel()->show();
confirmation->set_text(TTR("Exit the editor?"));
confirmation->popup_centered(Size2(180,70));
confirmation->popup_centered(Size2(180,70)*EDSCALE);
break;
}
@ -2826,7 +2827,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case SETTINGS_ABOUT: {
about->popup_centered(Size2(500,130));
about->popup_centered(Size2(500,130)*EDSCALE);
} break;
case SOURCES_REIMPORT: {
@ -5381,7 +5382,7 @@ EditorNode::EditorNode() {
dock_vb->add_child(dock_hb);
dock_select = memnew( Control );
dock_select->set_custom_minimum_size(Size2(128,64));
dock_select->set_custom_minimum_size(Size2(128,64)*EDSCALE);
dock_select->connect("input_event",this,"_dock_select_input");
dock_select->connect("draw",this,"_dock_select_draw");
dock_select->connect("mouse_exit",this,"_dock_popup_exit");
@ -5396,7 +5397,7 @@ EditorNode::EditorNode() {
//dock_select_popoup->set_(Size2(20,20));
for(int i=0;i<DOCK_SLOT_MAX;i++) {
dock_slot[i]->set_custom_minimum_size(Size2(230,220));
dock_slot[i]->set_custom_minimum_size(Size2(230,220)*EDSCALE);
dock_slot[i]->set_v_size_flags(Control::SIZE_EXPAND_FILL);
dock_slot[i]->set_popup(dock_select_popoup);
dock_slot[i]->connect("pre_popup_pressed",this,"_dock_pre_popup",varray(i));
@ -5436,7 +5437,7 @@ EditorNode::EditorNode() {
srt->add_child(scene_tabs);
scene_root_parent = memnew( PanelContainer );
scene_root_parent->set_custom_minimum_size(Size2(0,80));
scene_root_parent->set_custom_minimum_size(Size2(0,80)*EDSCALE);
//Ref<StyleBox> sp = scene_root_parent->get_stylebox("panel","TabContainer");
@ -5553,7 +5554,7 @@ EditorNode::EditorNode() {
{
Control *sp = memnew( Control );
sp->set_custom_minimum_size(Size2(30,0));
sp->set_custom_minimum_size(Size2(30,0)*EDSCALE);
menu_hb->add_child(sp);
}
@ -5742,7 +5743,7 @@ EditorNode::EditorNode() {
{
Control *sp = memnew( Control );
sp->set_custom_minimum_size(Size2(30,0));
sp->set_custom_minimum_size(Size2(30,0)*EDSCALE);
menu_hb->add_child(sp);
}
@ -5764,7 +5765,7 @@ EditorNode::EditorNode() {
{
Control *sp = memnew( Control );
sp->set_custom_minimum_size(Size2(30,0));
sp->set_custom_minimum_size(Size2(30,0)*EDSCALE);
menu_hb->add_child(sp);
}
@ -5800,7 +5801,7 @@ EditorNode::EditorNode() {
layout_dialog = memnew( EditorNameDialog );
gui_base->add_child(layout_dialog);
layout_dialog->set_hide_on_ok(false);
layout_dialog->set_size(Size2(175, 70));
layout_dialog->set_size(Size2(175, 70)*EDSCALE);
layout_dialog->connect("name_confirmed", this,"_dialog_action");
sources_button = memnew( ToolButton );

View file

@ -85,6 +85,7 @@
#include "progress_dialog.h"
#include "editor_scale.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/

View file

@ -4,7 +4,7 @@
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "globals.h"
#include "editor_scale.h"
Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String& p_path) {
@ -91,6 +91,7 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem& p_item,co
if (generated.is_valid()) {
//print_line("was generated");
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
thumbnail_size*=EDSCALE;
//wow it generated a preview... save cache
ResourceSaver::save(cache_base+".png",generated);
FileAccess *f=FileAccess::open(cache_base+".txt",FileAccess::WRITE);
@ -132,6 +133,7 @@ void EditorResourcePreview::_thread() {
uint64_t modtime = FileAccess::get_modified_time(item.path);
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
thumbnail_size*=EDSCALE;
if (cache.has(item.path)) {
//already has it because someone loaded it, just let it know it's ready

View file

@ -0,0 +1,7 @@
#include "editor_scale.h"
#include "os/os.h"
bool editor_is_hidpi() {
return OS::get_singleton()->get_screen_dpi(0) > 150;
}

View file

@ -0,0 +1,8 @@
#ifndef EDITOR_SCALE_H
#define EDITOR_SCALE_H
bool editor_is_hidpi();
#define EDSCALE (editor_is_hidpi() ? 2 : 1)
#endif // EDITOR_SCALE_H

View file

@ -11,6 +11,7 @@ def make_editor_icons_action(target, source, env):
s = cStringIO.StringIO()
s.write("#include \"editor_icons.h\"\n\n")
s.write("#include \"editor_scale.h\"\n\n")
s.write("#include \"scene/resources/theme.h\"\n\n")
for x in pixmaps:
@ -36,7 +37,7 @@ def make_editor_icons_action(target, source, env):
s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png) {\n")
s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n")
s.write("\tImage img(p_png);\n")
#s.write("\timg.expand_x2_hq2x();\n")
s.write("\tif (editor_is_hidpi()) img.expand_x2_hq2x();\n")
s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n")
s.write("\treturn texture;\n")
s.write("}\n\n")

View file

@ -510,13 +510,13 @@ class EditorFontImportDialog : public ConfirmationDialog {
if (source->get_line_edit()->get_text()=="") {
error_dialog->set_text(TTR("No source font file!"));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
if (dest->get_line_edit()->get_text()=="") {
error_dialog->set_text(TTR("No target font resource!"));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -528,7 +528,7 @@ class EditorFontImportDialog : public ConfirmationDialog {
if (rimd.is_null()) {
error_dialog->set_text(TTR("Can't load/process source font."));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -536,7 +536,7 @@ class EditorFontImportDialog : public ConfirmationDialog {
if (err!=OK) {
error_dialog->set_text(TTR("Couldn't save font."));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -573,7 +573,7 @@ public:
void popup_import(const String& p_path) {
popup_centered(Size2(600,500));
popup_centered(Size2(600,500)*EDSCALE);
if (p_path!="") {

View file

@ -173,7 +173,7 @@ public:
void popup_import(const String& p_path) {
popup_centered(Size2(400,400));
popup_centered(Size2(400,400)*EDSCALE);
if (p_path!="") {

View file

@ -221,7 +221,7 @@ public:
void popup_import(const String& p_path) {
popup_centered(Size2(400,400));
popup_centered(Size2(400,400)*EDSCALE);
if (p_path!="") {
Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_path);
@ -252,7 +252,7 @@ public:
if (samples.size()==0) {
error_dialog->set_text(TTR("No samples to import!"));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
}
if (save_path->get_text().strip_edges()=="") {
@ -293,7 +293,7 @@ public:
String dst = save_path->get_text();
if (dst=="") {
error_dialog->set_text(TTR("Save path is empty!"));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
}
dst = dst.plus_file(samples[i].get_file().basename()+".smp");

View file

@ -674,7 +674,7 @@ void EditorSceneImportDialog::_open_and_import() {
if (unsaved) {
confirm_open->popup_centered_minsize(Size2(300,80));
confirm_open->popup_centered_minsize(Size2(300,80)*EDSCALE);
} else {
_import(true);
}
@ -735,7 +735,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
Ref<Script> scr = ResourceLoader::load(script_path->get_text());
if (!scr.is_valid()) {
error_dialog->set_text(TTR("Couldn't load post-import script."));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -744,7 +744,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
if (!pi->get_script_instance()) {
error_dialog->set_text(TTR("Invalid/broken script for post-import."));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -788,7 +788,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
if (err || !scene) {
error_dialog->set_text(TTR("Error importing scene."));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -813,7 +813,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
if (err) {
error_dialog->set_text(TTR("Error importing scene."));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
if (wip_open)
@ -857,7 +857,7 @@ void EditorSceneImportDialog::_import_confirm() {
wip_save_file="";
error_dialog->set_text(TTR("Error importing scene."));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -892,7 +892,7 @@ void EditorSceneImportDialog::_browse_script() {
void EditorSceneImportDialog::popup_import(const String &p_from) {
popup_centered(Size2(750,550));
popup_centered(Size2(750,550)*EDSCALE);
if (p_from!="") {
Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_from);
if (rimd.is_null())

View file

@ -352,7 +352,7 @@ void EditorTextureImportDialog::_import() {
if (!files.size()) {
error_dialog->set_text(TTR("Please specify some files!"));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -382,7 +382,7 @@ void EditorTextureImportDialog::_import() {
if (files.size()==0) {
error_dialog->set_text(TTR("At least one file needed for Atlas."));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -406,7 +406,7 @@ void EditorTextureImportDialog::_import() {
if (err) {
error_dialog->set_text(TTR("Error importing:")+" "+dst_file.get_file());
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -415,7 +415,7 @@ void EditorTextureImportDialog::_import() {
if (files.size()!=1) {
error_dialog->set_text(TTR("Only one file is required for large texture."));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -439,7 +439,7 @@ void EditorTextureImportDialog::_import() {
if (err) {
error_dialog->set_text(TTR("Error importing:")+" "+dst_file.get_file());
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -464,7 +464,7 @@ void EditorTextureImportDialog::_import() {
if (err) {
error_dialog->set_text(TTR("Error importing:")+" "+dst_file.get_file());
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -492,7 +492,7 @@ void EditorTextureImportDialog::_browse_target() {
void EditorTextureImportDialog::popup_import(const String& p_from) {
popup_centered(Size2(600,500));
popup_centered(Size2(600,500)*EDSCALE);
if (p_from!="") {
Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_from);
ERR_FAIL_COND(!rimd.is_valid());

View file

@ -65,7 +65,7 @@ public:
if (!f) {
error_dialog->set_text(TTR("Invalid source!"));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -76,7 +76,7 @@ public:
if (csvh.size()<2) {
error_dialog->set_text(TTR("Invalid translation source!"));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
return;
}
@ -171,7 +171,7 @@ public:
void popup_import(const String& p_from) {
popup_centered(Size2(400,400));
popup_centered(Size2(400,400)*EDSCALE);
if (p_from!="") {
@ -232,12 +232,12 @@ public:
if (items.size()==0) {
error_dialog->set_text(TTR("No items to import!"));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
}
if (!save_path->get_text().begins_with("res://")) {
error_dialog->set_text(TTR("No target path!"));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
}
EditorProgress progress("import_xl",TTR("Import Translations"),items.size());
@ -259,7 +259,7 @@ public:
Error err = plugin->import(savefile,imd);
if (err!=OK) {
error_dialog->set_text(TTR("Couldn't import!"));
error_dialog->popup_centered(Size2(200,100));
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
} else if (add_to_project->is_pressed()) {
ProjectSettings::get_singleton()->add_translation(savefile);

View file

@ -7,7 +7,7 @@
#include "scene/resources/sample.h"
#include "scene/resources/mesh.h"
#include "scene/resources/bit_mask.h"
#include "tools/editor/editor_scale.h"
bool EditorTexturePreviewPlugin::handles(const String& p_type) const {
return (ObjectTypeDB::is_type(p_type,"ImageTexture") || ObjectTypeDB::is_type(p_type, "AtlasTexture"));
@ -36,6 +36,7 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES& p_from) {
img.clear_mipmaps();
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
thumbnail_size*=EDSCALE;
if (img.is_compressed()) {
if (img.decompress()!=OK)
return Ref<Texture>();
@ -111,6 +112,7 @@ Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES& p_from) {
Image img(bm->get_size().width,bm->get_size().height,0,Image::FORMAT_GRAYSCALE,data);
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
thumbnail_size*=EDSCALE;
if (img.is_compressed()) {
if (img.decompress()!=OK)
return Ref<Texture>();
@ -233,6 +235,7 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES& p_from) {
VS::get_singleton()->mesh_surface_set_material(sphere,0,RID());
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
thumbnail_size*=EDSCALE;
img.resize(thumbnail_size,thumbnail_size);
Ref<ImageTexture> ptex = Ref<ImageTexture>( memnew( ImageTexture ));
@ -401,6 +404,7 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES& p_from) {
int line = 0;
int col=0;
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
thumbnail_size*=EDSCALE;
Image img(thumbnail_size,thumbnail_size,0,Image::FORMAT_RGBA);
@ -501,7 +505,7 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) {
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
thumbnail_size*=EDSCALE;
DVector<uint8_t> img;
int w = thumbnail_size;
int h = thumbnail_size;
@ -815,6 +819,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES& p_from) {
VS::get_singleton()->instance_set_base(mesh_instance,RID());
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
thumbnail_size*=EDSCALE;
img.resize(thumbnail_size,thumbnail_size);
Ref<ImageTexture> ptex = Ref<ImageTexture>( memnew( ImageTexture ));

View file

@ -294,7 +294,7 @@ MaterialEditor::MaterialEditor() {
}
set_custom_minimum_size(Size2(1,150));
set_custom_minimum_size(Size2(1,150)*EDSCALE);
HBoxContainer *hb = memnew( HBoxContainer );
add_child(hb);

View file

@ -141,7 +141,7 @@ MeshEditor::MeshEditor() {
set_custom_minimum_size(Size2(1,150));
set_custom_minimum_size(Size2(1,150)*EDSCALE);
HBoxContainer *hb = memnew( HBoxContainer );
add_child(hb);

View file

@ -404,7 +404,7 @@ SampleEditor::SampleEditor() {
play->connect("pressed", this,"_play_pressed");
stop->connect("pressed", this,"_stop_pressed");
set_custom_minimum_size(Size2(1,150));
set_custom_minimum_size(Size2(1,150)*EDSCALE);
}

View file

@ -978,7 +978,7 @@ void ScriptEditor::_menu_option(int p_option) {
switch(p_option) {
case FILE_NEW: {
script_create_dialog->config("Node", ".gd");
script_create_dialog->popup_centered(Size2(300, 300));
script_create_dialog->popup_centered(Size2(300, 300)*EDSCALE);
} break;
case FILE_OPEN: {
@ -1100,7 +1100,7 @@ void ScriptEditor::_menu_option(int p_option) {
switch(p_option) {
case FILE_NEW: {
script_create_dialog->config("Node", ".gd");
script_create_dialog->popup_centered(Size2(300, 300));
script_create_dialog->popup_centered(Size2(300, 300)*EDSCALE);
} break;
case FILE_SAVE: {

View file

@ -30,7 +30,7 @@
#include "main/main.h"
#include "message_queue.h"
#include "os/os.h"
#include "editor_scale.h"
void BackgroundProgress::_add_task(const String& p_task,const String& p_label, int p_steps) {
_THREAD_SAFE_METHOD_
@ -48,7 +48,7 @@ void BackgroundProgress::_add_task(const String& p_task,const String& p_label, i
ec->set_v_size_flags(SIZE_EXPAND_FILL);
t.progress->set_area_as_parent_rect();
ec->add_child(t.progress);
ec->set_custom_minimum_size(Size2(80,5));
ec->set_custom_minimum_size(Size2(80,5)*EDSCALE);
t.hb->add_child(ec);
add_child(t.hb);
@ -160,7 +160,7 @@ void ProgressDialog::_notification(int p_what) {
void ProgressDialog::_popup() {
Size2 ms = main->get_combined_minimum_size();
ms.width = MAX(500,ms.width);
ms.width = MAX(500*EDSCALE,ms.width);
Ref<StyleBox> style = get_stylebox("panel","PopupMenu");

View file

@ -306,14 +306,14 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
slider->set_step((type==Variant::REAL) ? step : 1);
slider->set_val(v);
slider->show();
set_size(Size2(110,30));
set_size(Size2(110,30)*EDSCALE);
} else {
spinbox->set_min(min);
spinbox->set_max(max);
spinbox->set_step((type==Variant::REAL) ? step : 1);
spinbox->set_val(v);
spinbox->show();
set_size(Size2(70,35));
set_size(Size2(70,35)*EDSCALE);
}
@ -339,7 +339,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
}
set_size(checks20[19]->get_pos()+Size2(20,25));
set_size(checks20[19]->get_pos()+Size2(20,25)*EDSCALE);
} else if (hint==PROPERTY_HINT_EXP_EASING) {
@ -365,7 +365,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
type_button->show();
easing_draw->show();
set_size(Size2(200,150));
set_size(Size2(200,150)*EDSCALE);
} else if (hint==PROPERTY_HINT_FLAGS) {
menu->clear();
Vector<String> flags = hint_text.split(",");
@ -600,7 +600,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
color_picker->show();
color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA);
color_picker->set_color(v);
set_size( Size2(300, color_picker->get_combined_minimum_size().height+10));
set_size( Size2(300*EDSCALE, color_picker->get_combined_minimum_size().height+10*EDSCALE));
/*
int ofs=80;
int m=10;
@ -4286,7 +4286,7 @@ PropertyEditor *SectionedPropertyEditor::get_property_editor() {
SectionedPropertyEditor::SectionedPropertyEditor() {
VBoxContainer *left_vb = memnew( VBoxContainer);
left_vb->set_custom_minimum_size(Size2(160,0));
left_vb->set_custom_minimum_size(Size2(160,0)*EDSCALE);
add_child(left_vb);
sections = memnew( ItemList );

View file

@ -441,6 +441,7 @@ void ScenesDock::_update_files(bool p_keep_selection) {
return;
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
thumbnail_size*=EDSCALE;
Ref<Texture> folder_thumbnail;
Ref<Texture> file_thumbnail;
@ -454,6 +455,7 @@ void ScenesDock::_update_files(bool p_keep_selection) {
files->set_fixed_column_width(thumbnail_size*3/2);
files->set_max_text_lines(2);
files->set_min_icon_size(Size2(thumbnail_size,thumbnail_size));
files->set_max_icon_size(Size2(thumbnail_size,thumbnail_size));
if (!has_icon("ResizedFolder","EditorIcons")) {
Ref<ImageTexture> folder = get_icon("FolderBig","EditorIcons");
@ -1693,7 +1695,7 @@ ScenesDock::ScenesDock(EditorNode *p_editor) {
tree->set_hide_root(true);
split_box->add_child(tree);
tree->set_custom_minimum_size(Size2(0,200));
tree->set_custom_minimum_size(Size2(0,200)*EDSCALE);
tree->set_drag_forwarding(this);

View file

@ -1892,7 +1892,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
vmem_hb->add_child( memnew(Label(TTR("Total:")+" ")) );
vmem_total = memnew( LineEdit );
vmem_total->set_editable(false);
vmem_total->set_custom_minimum_size(Size2(100,1));
vmem_total->set_custom_minimum_size(Size2(100,1)*EDSCALE);
vmem_hb->add_child(vmem_total);
vmem_refresh = memnew( Button );
vmem_hb->add_child(vmem_refresh);