diff --git a/.gitattributes b/.gitattributes
index f1e99ee8ca..36620d50f5 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,7 @@
+# Properly detect languages on Github
+*.h linguist-language=cpp
+drivers/* linguist-vendored
+
*.cpp eol=lf
*.h eol=lf
*.py eol=lf
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 1aee6d9aa2..6910b368d3 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -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);
}
diff --git a/core/os/os.h b/core/os/os.h
index 5fd2bd6c25..76dd235d24 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -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();
diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd
index cd8e0e185b..c856555122 100644
--- a/demos/misc/window_management/control.gd
+++ b/demos/misc/window_management/control.gd
@@ -43,6 +43,8 @@ func _fixed_process(delta):
get_node("Label_Screen0_Resolution").set_text(str("Screen0 Resolution:\n", OS.get_screen_size()))
get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n", OS.get_screen_position()))
+
+ get_node("Label_Screen0_DPI").set_text(str("Screen0 DPI:\n", OS.get_screen_dpi()))
if(OS.get_screen_count() > 1):
get_node("Button_Screen0").show()
@@ -51,11 +53,13 @@ func _fixed_process(delta):
get_node("Label_Screen1_Position").show()
get_node("Label_Screen1_Resolution").set_text(str("Screen1 Resolution:\n", OS.get_screen_size(1)))
get_node("Label_Screen1_Position").set_text(str("Screen1 Position:\n", OS.get_screen_position(1)))
+ get_node("Label_Screen1_DPI").set_text(str("Screen1 DPI:\n", OS.get_screen_dpi(1)))
else:
get_node("Button_Screen0").hide()
get_node("Button_Screen1").hide()
get_node("Label_Screen1_Resolution").hide()
get_node("Label_Screen1_Position").hide()
+ get_node("Label_Screen1_DPI").hide()
get_node("Button_Fullscreen").set_pressed(OS.is_window_fullscreen())
get_node("Button_FixedSize").set_pressed(!OS.is_window_resizable())
diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn
index 35662871f1..91174669cd 100644
Binary files a/demos/misc/window_management/window_management.scn and b/demos/misc/window_management/window_management.scn differ
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 4893f0c483..074c14443c 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -42293,8 +42293,10 @@ This method controls whether the position between two cached points is interpola
+ Enable certain nodes only when visible.
+ The VisibilityEnabler will disable [RigidBody] and [AnimationPlayer] nodes when they are not visible. It will only affect other nodes within the same scene as the VisibilityEnabler itself.
@@ -42303,6 +42305,7 @@ This method controls whether the position between two cached points is interpola
+ Set an enabler to true for all nodes of its type to be disabled when the VisibilityEnabler is not in view. See the constants for enablers and what they affect.
@@ -42311,13 +42314,16 @@ This method controls whether the position between two cached points is interpola
+ Returns whether the specified enabler was set to true or not.
+ This enabler will freeze [RigidBody] nodes.
+ This enabler will pause [AnimationPlayer] nodes.
@@ -42325,8 +42331,10 @@ This method controls whether the position between two cached points is interpola
+ Enable certain nodes only when visible.
+ The VisibilityEnabler2D will disable [RigidBody2D], [AnimationPlayer], and other nodes when they are not visible. It will only affect other nodes within the same scene as the VisibilityEnabler2D itself.
@@ -42335,6 +42343,7 @@ This method controls whether the position between two cached points is interpola
+ Set an enabler to true for all nodes of its type to be disabled when the VisibilityEnabler2D is not in view. See the constants for enablers and what they affect.
@@ -42343,19 +42352,25 @@ This method controls whether the position between two cached points is interpola
+ Returns whether the specified enabler was set to true or not.
+ This enabler will freeze [RigidBody2D] nodes.
+ This enabler will pause [AnimationPlayer] nodes.
+ This enabler will stop [Particles2D] nodes.
+ This enabler will stop the parent's _process function.
+ This enabler will stop the parent's _fixed_process function.
@@ -42363,48 +42378,57 @@ This method controls whether the position between two cached points is interpola
+ Detect when the node is visible on screen.
+ The VisibilityNotifier is used to notify when its bounding box enters the screen, is visible on the screen, or when it exits the screen.
+ Set the visibility bounding box of the VisibilityNotifier.
+ Return the visibility bounding box of the VisibilityNotifier.
+ Return true if any part of the bounding box is on the screen.
+ Emitted when the VisibilityNotifier enters the screen.
+ Emitted when the VisibilityNotifier enters a [Camera]'s view.
+ Emitted when the VisibilityNotifier exits the screen.
+ Emitted when the VisibilityNotifier exits a [Camera]'s view.
@@ -42413,48 +42437,57 @@ This method controls whether the position between two cached points is interpola
+ Detect when the node is visible on screen.
+ The VisibilityNotifier2D is used to notify when its bounding rectangle enters the screen, is visible on the screen, or when it exits the screen.
+ Set the visibility bounding rectangle of the VisibilityNotifier2D.
+ Return the visibility bounding rectangle of the VisibilityNotifier2D.
+ Return true if any part of the bounding rectangle is on the screen.
+ Emitted when the VisibilityNotifier2D enters the screen.
+ Emitted when the VisibilityNotifier2D enters a [Viewport].
+ Emitted when the VisibilityNotifier2D exits the screen.
+ Emitted when the VisibilityNotifier2D exits a [Viewport].
diff --git a/main/main.cpp b/main/main.cpp
index 0a92971bae..fba7a781bf 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -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;iget_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);
diff --git a/platform/android/java/res/drawable/icon.png b/platform/android/java/res/drawable/icon.png
index 013632ddf1..e334f5fa78 100644
Binary files a/platform/android/java/res/drawable/icon.png and b/platform/android/java/res/drawable/icon.png differ
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index d88dd89002..8d64686335 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -59,7 +59,7 @@ public:
bool force_quit;
Rasterizer *rasterizer;
VisualServer *visual_server;
- VideoMode current_videomode;
+
List args;
MainLoop *main_loop;
unsigned int event_id;
@@ -104,9 +104,22 @@ public:
bool minimized;
bool maximized;
bool zoomed;
+
Vector screens;
+ Vector 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();
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index c443fc2d0e..b614dd57aa 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -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 *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;
}
diff --git a/platform/windows/godot.ico b/platform/windows/godot.ico
index e57ce36529..3e52f2e52f 100644
Binary files a/platform/windows/godot.ico and b/platform/windows/godot.ico differ
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 51242d89bd..6342391383 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -118,6 +118,16 @@ void WindowDialog::set_title(const String& p_title) {
update();
}
+Size2 WindowDialog::get_minimum_size() const {
+
+ Ref 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) {
@@ -284,7 +349,7 @@ Button* AcceptDialog::add_cancel(const String &p_cancel) {
String c = p_cancel;
if (p_cancel=="")
- c="Cancel";
+ c=RTR("Cancel");
Button *b = swap_ok_cancel ? add_button(c,true) : add_button(c);
b->connect("pressed",this,"_closed");
return b;
@@ -341,7 +406,7 @@ AcceptDialog::AcceptDialog() {
hbc->add_spacer();
ok = memnew( Button );
- ok->set_text("OK");
+ ok->set_text(RTR("OK"));
hbc->add_child(ok);
hbc->add_spacer();
//add_child(ok);
@@ -351,7 +416,9 @@ AcceptDialog::AcceptDialog() {
set_as_toplevel(true);
hide_on_ok=true;
- set_title("Alert!");
+ set_title(RTR("Alert!"));
+
+ child=NULL;
}
@@ -372,6 +439,6 @@ Button *ConfirmationDialog::get_cancel() {
ConfirmationDialog::ConfirmationDialog() {
- set_title("Please Confirm...");
+ set_title(RTR("Please Confirm..."));
cancel = add_cancel();
}
diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h
index f256c49aee..d00bb41ff6 100644
--- a/scene/gui/dialogs.h
+++ b/scene/gui/dialogs.h
@@ -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);
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 1c6a97bab8..c8bd1cb5a1 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -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;
}
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index ceb40925ec..fd6e97d33f 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -3554,6 +3554,7 @@ void TextEdit::set_search_flags(uint32_t p_flags) {
void TextEdit::set_current_search_result(int line, int col) {
search_result_line = line;
search_result_col = col;
+ update();
}
void TextEdit::set_highlight_all_occurrences(const bool p_enabled) {
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index cd90bf52b6..9ebb7e7561 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -28,6 +28,7 @@
typedef Map > TexCacheMap;
static TexCacheMap *tex_cache;
+static int scale=1;
template
static Ref 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 make_stylebox(T p_src,float p_left, float p_top, flo
} else {
texture = Ref( 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 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 make_stylebox(T p_src,float p_left, float p_top, flo
static Ref sb_expand(Ref 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 make_icon(T p_src) {
Ref 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 make_empty_stylebox(float p_margin_left=-1, float p_margin_
Ref 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& t,const Ref & default_font,const Ref & large_font,Ref& default_icon, Ref& default_style,bool p_hidpi) {
+ if (p_hidpi)
+ scale=2;
+ else
+ scale=1;
tex_cache = memnew( TexCacheMap );
- Ref t( memnew( Theme ) );
-
//Ref 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 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 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 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 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 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 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 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 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 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 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 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 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 t( memnew( Theme ) );
+ Ref t;
+ t.instance();
+ Ref default_style;
+ Ref default_icon;
+ Ref 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 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( memnew( Texture ) );
- texture->create_from_image( error_img );
-
- Ref 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 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() );
diff --git a/scene/resources/default_theme/default_theme.h b/scene/resources/default_theme/default_theme.h
index 44569ba192..1e3b4b4081 100644
--- a/scene/resources/default_theme/default_theme.h
+++ b/scene/resources/default_theme/default_theme.h
@@ -12,10 +12,12 @@
#ifndef DEFAULT_THEME_H
#define DEFAULT_THEME_H
+#include "scene/resources/theme.h"
/**
@author Juan Linietsky
*/
+void fill_default_theme(Ref& theme,const Ref & default_font,const Ref & large_font,Ref& default_icon, Ref& default_style,bool p_hidpi);
void make_default_theme();
void clear_default_theme();
diff --git a/tools/Godot.app/Contents/Resources/Godot.icns b/tools/Godot.app/Contents/Resources/Godot.icns
index 4a3dc0415a..375f61437d 100644
Binary files a/tools/Godot.app/Contents/Resources/Godot.icns and b/tools/Godot.app/Contents/Resources/Godot.icns differ
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp
index a9e31a6561..f62209fafa 100644
--- a/tools/editor/code_editor.cpp
+++ b/tools/editor/code_editor.cpp
@@ -122,82 +122,30 @@ void FindReplaceBar::_unhandled_input(const InputEvent &p_event) {
}
}
-bool FindReplaceBar::_search(bool p_include_current, bool p_backwards) {
+bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col) {
+ int line, col;
String text=get_search_text();
- uint32_t flags=0;
- if (is_whole_words())
- flags|=TextEdit::SEARCH_WHOLE_WORDS;
- if (is_case_sensitive())
- flags|=TextEdit::SEARCH_MATCH_CASE;
- if (p_backwards)
- flags|=TextEdit::SEARCH_BACKWARDS;
-
- int line=text_edit->cursor_get_line();
- int col=text_edit->cursor_get_column();
-
- if (text_edit->is_selection_active() && !replace_all_mode) {
- line = text_edit->get_selection_from_line();
- col = text_edit->get_selection_from_column();
- }
-
- bool cursor_at_result=false;
-
- if (line==current_result_line && col>=current_result_col && col<=current_result_col+text.length()) {
- col=current_result_col;
- cursor_at_result=true;
- }
-
- if (!p_include_current) {
- if (p_backwards) {
- col-=text.length();
- if (col<0) {
- line-=1;
- if (line<0)
- line=text_edit->get_line_count()-1;
- col=text_edit->get_line(line).length();
- }
- } else if (cursor_at_result) {
- col+=text.length();
- if (col>text_edit->get_line(line).length()) {
- line+=1;
- if (line>=text_edit->get_line_count())
- line=0;
- col=0;
- }
- }
- }
-
- bool found = text_edit->search(text,flags,line,col,line,col);
-
- if (!found) {
- if (p_backwards) {
- line = text_edit->get_line_count()-1;
- col = text_edit->get_line(line).length()-1;
- } else {
- line = 0;
- col = 0;
- }
-
- found = text_edit->search(text,flags,line,col,line,col);
- }
+ bool found=text_edit->search(text,p_flags,p_from_line,p_from_col,line,col);
if (found) {
- text_edit->cursor_set_line(line);
- text_edit->cursor_set_column(p_backwards?col:col+text.length());
- text_edit->select(line,col,line,col+text.length());
+ if (!preserve_cursor) {
+ text_edit->cursor_set_line(line);
+ text_edit->cursor_set_column(col+text.length());
+ }
+
text_edit->set_search_text(text);
- text_edit->set_search_flags(flags);
+ text_edit->set_search_flags(p_flags);
text_edit->set_current_search_result(line,col);
- current_result_line = line;
- current_result_col = col;
+ result_line=line;
+ result_col=col;
set_error("");
} else {
- current_result_line = -1;
- current_result_col = -1;
+ result_line=-1;
+ result_col=-1;
text_edit->set_search_text("");
set_error(text.empty()?"":TTR("No Matches"));
}
@@ -207,8 +155,13 @@ bool FindReplaceBar::_search(bool p_include_current, bool p_backwards) {
void FindReplaceBar::_replace() {
- if (text_edit->get_selection_text()==get_search_text()) {
+ if (result_line!=-1 && result_col!=-1) {
+ text_edit->begin_complex_operation();
+
+ text_edit->select(result_line,result_col,result_line,result_col+get_search_text().length());
text_edit->insert_text_at_cursor(get_replace_text());
+
+ text_edit->end_complex_operation();
}
search_current();
@@ -232,28 +185,26 @@ void FindReplaceBar::_replace_all() {
text_edit->cursor_set_line(0);
text_edit->cursor_set_column(0);
+ int search_text_len=get_search_text().length();
int rc=0;
replace_all_mode = true;
text_edit->begin_complex_operation();
- while(_search(false)) {
-
- if (!text_edit->is_selection_active()) {
- // search selects
- break;
- }
+ while (search_next()) {
// replace area
- Point2i match_from(text_edit->get_selection_from_line(),text_edit->get_selection_from_column());
- Point2i match_to(text_edit->get_selection_to_line(),text_edit->get_selection_to_column());
+ Point2i match_from(result_line,result_col);
+ Point2i match_to(result_line,result_col+search_text_len);
if (match_from < prev_match)
break; // done
prev_match=match_to;
+ text_edit->select(result_line,result_col,result_line,match_to.y);
+
if (selection_enabled && is_selection_only()) {
if (match_fromselection_end)
@@ -264,7 +215,7 @@ void FindReplaceBar::_replace_all() {
if (match_to.x==selection_end.x)
selection_end.y+=get_replace_text().length() - get_search_text().length();
} else {
- //just replace
+ // just replace
text_edit->insert_text_at_cursor(get_replace_text());
}
@@ -290,26 +241,96 @@ void FindReplaceBar::_replace_all() {
set_error(vformat(TTR("Replaced %d Ocurrence(s)."), rc));
}
-void FindReplaceBar::search_current() {
+void FindReplaceBar::_get_search_from(int& r_line, int& r_col) {
- _search(true);
+ r_line=text_edit->cursor_get_line();
+ r_col=text_edit->cursor_get_column();
+
+ if (text_edit->is_selection_active() && !replace_all_mode) {
+ r_line=text_edit->get_selection_from_line();
+ r_col=text_edit->get_selection_to_column();
+ }
+
+ if (r_line==result_line && r_col>=result_col && r_col<=result_col+get_search_text().length()) {
+ r_col=result_col;
+ }
}
-void FindReplaceBar::search_prev() {
+bool FindReplaceBar::search_current() {
- _search(false, true);
+ uint32_t flags=0;
+
+ if (is_whole_words())
+ flags|=TextEdit::SEARCH_WHOLE_WORDS;
+ if (is_case_sensitive())
+ flags|=TextEdit::SEARCH_MATCH_CASE;
+
+ int line, col;
+ _get_search_from(line, col);
+
+ return _search(flags,line,col);
}
-void FindReplaceBar::search_next() {
+bool FindReplaceBar::search_prev() {
- _search();
+ uint32_t flags=0;
+ String text = get_search_text();
+
+ if (is_whole_words())
+ flags|=TextEdit::SEARCH_WHOLE_WORDS;
+ if (is_case_sensitive())
+ flags|=TextEdit::SEARCH_MATCH_CASE;
+
+ flags|=TextEdit::SEARCH_BACKWARDS;
+
+ int line, col;
+ _get_search_from(line, col);
+
+ col-=text.length();
+ if (col<0) {
+ line-=1;
+ if (line<0)
+ line=text_edit->get_line_count()-1;
+ col=text_edit->get_line(line).length();
+ }
+
+ return _search(flags,line,col);
+}
+
+bool FindReplaceBar::search_next() {
+
+ uint32_t flags=0;
+ String text = get_search_text();
+
+ if (is_whole_words())
+ flags|=TextEdit::SEARCH_WHOLE_WORDS;
+ if (is_case_sensitive())
+ flags|=TextEdit::SEARCH_MATCH_CASE;
+
+ int line, col;
+ _get_search_from(line, col);
+
+ if (line==result_line && col==result_col) {
+ col+=text.length();
+ if (col>text_edit->get_line(line).length()) {
+ line+=1;
+ if (line>=text_edit->get_line_count())
+ line=0;
+ col=0;
+ }
+ }
+
+ return _search(flags,line,col);
}
void FindReplaceBar::_hide_bar() {
+ if (replace_text->has_focus() || search_text->has_focus())
+ text_edit->grab_focus();
+
text_edit->set_search_text("");
- current_result_line = -1;
- current_result_col = -1;
+ result_line = -1;
+ result_col = -1;
replace_hbc->hide();
replace_options_hbc->hide();
hide();
@@ -354,6 +375,15 @@ void FindReplaceBar::_search_options_changed(bool p_pressed) {
search_current();
}
+void FindReplaceBar::_editor_text_changed() {
+
+ if (is_visible()) {
+ preserve_cursor=true;
+ search_current();
+ preserve_cursor=false;
+ }
+}
+
void FindReplaceBar::_search_text_changed(const String& p_text) {
search_current();
@@ -397,13 +427,14 @@ void FindReplaceBar::set_error(const String &p_label) {
void FindReplaceBar::set_text_edit(TextEdit *p_text_edit) {
text_edit = p_text_edit;
- text_edit->connect("_text_changed",this,"_search_text_changed",varray(String()));
+ text_edit->connect("text_changed",this,"_editor_text_changed");
}
void FindReplaceBar::_bind_methods() {
ObjectTypeDB::bind_method("_unhandled_input",&FindReplaceBar::_unhandled_input);
+ ObjectTypeDB::bind_method("_editor_text_changed",&FindReplaceBar::_editor_text_changed);
ObjectTypeDB::bind_method("_search_text_changed",&FindReplaceBar::_search_text_changed);
ObjectTypeDB::bind_method("_search_text_entered",&FindReplaceBar::_search_text_entered);
ObjectTypeDB::bind_method("_search_current",&FindReplaceBar::search_current);
@@ -419,6 +450,9 @@ void FindReplaceBar::_bind_methods() {
FindReplaceBar::FindReplaceBar() {
+ replace_all_mode=false;
+ preserve_cursor=false;
+
text_vbc = memnew(VBoxContainer);
add_child(text_vbc);
diff --git a/tools/editor/code_editor.h b/tools/editor/code_editor.h
index 52a36c979d..2e1bf46c02 100644
--- a/tools/editor/code_editor.h
+++ b/tools/editor/code_editor.h
@@ -83,13 +83,18 @@ class FindReplaceBar : public HBoxContainer {
TextEdit *text_edit;
- int current_result_line;
- int current_result_col;
+ int result_line;
+ int result_col;
bool replace_all_mode;
+ bool preserve_cursor;
+
+ void _get_search_from(int& r_line, int& r_col);
void _show_search();
void _hide_bar();
+
+ void _editor_text_changed();
void _search_options_changed(bool p_pressed);
void _search_text_changed(const String& p_text);
void _search_text_entered(const String& p_text);
@@ -98,7 +103,7 @@ protected:
void _notification(int p_what);
void _unhandled_input(const InputEvent &p_event);
- bool _search(bool p_include_current=false, bool p_backwards=false);
+ bool _search(uint32_t p_flags, int p_from_line, int p_from_col);
void _replace();
void _replace_all();
@@ -119,9 +124,9 @@ public:
void popup_search();
void popup_replace();
- void search_current();
- void search_prev();
- void search_next();
+ bool search_current();
+ bool search_prev();
+ bool search_next();
FindReplaceBar();
};
diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp
index b9d4949018..185ec17459 100644
--- a/tools/editor/editor_file_dialog.cpp
+++ b/tools/editor/editor_file_dialog.cpp
@@ -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 folder_thumbnail;
Ref 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();
}
diff --git a/tools/editor/editor_fonts.cpp b/tools/editor/editor_fonts.cpp
index 9bc24e6ca8..ff2267daf1 100644
--- a/tools/editor/editor_fonts.cpp
+++ b/tools/editor/editor_fonts.cpp
@@ -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 make_font(int p_height,int p_ascent, int p_valign, int p_charcount, const int *p_chars,const Ref &p_texture) {
@@ -80,7 +82,6 @@ static Ref make_font(int p_height,int p_ascent, int p_valign, int p_
void editor_register_fonts(Ref p_theme) {
-
/* Droid Sans */
Ref DroidSans;
@@ -115,12 +116,14 @@ void editor_register_fonts(Ref p_theme) {
/* Source Code Pro */
+
Ref dfmono;
dfmono.instance();
dfmono->set_font_ptr(_font_source_code_pro,_font_source_code_pro_size);
//dfd->set_force_autohinter(true); //just looks better..i think?
- MAKE_DROID_SANS(df,int(EditorSettings::get_singleton()->get("global/font_size")));
+ MAKE_DROID_SANS(df,int(EditorSettings::get_singleton()->get("global/font_size"))*EDSCALE);
+
p_theme->set_default_theme_font(df);
@@ -128,9 +131,9 @@ void editor_register_fonts(Ref p_theme) {
// Ref doc_title_font = make_font(_bi_font_doc_title_font_height,_bi_font_doc_title_font_ascent,0,_bi_font_doc_title_font_charcount,_bi_font_doc_title_font_characters,p_theme->get_icon("DocTitleFont","EditorIcons"));
// Ref doc_code_font = make_font(_bi_font_doc_code_font_height,_bi_font_doc_code_font_ascent,0,_bi_font_doc_code_font_charcount,_bi_font_doc_code_font_characters,p_theme->get_icon("DocCodeFont","EditorIcons"));
- MAKE_DROID_SANS(df_title,int(EDITOR_DEF("help/help_title_font_size",18)));
+ MAKE_DROID_SANS(df_title,int(EDITOR_DEF("help/help_title_font_size",18))*EDSCALE);
- MAKE_DROID_SANS(df_doc,int(EDITOR_DEF("help/help_font_size",16)));
+ MAKE_DROID_SANS(df_doc,int(EDITOR_DEF("help/help_font_size",16))*EDSCALE);
p_theme->set_font("doc","EditorFonts",df_doc);
@@ -139,16 +142,25 @@ void editor_register_fonts(Ref p_theme) {
Ref 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 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 di;
+ Ref ds;
+ fill_default_theme(p_theme,df,df_doc,di,ds,true);
+
+ }
+
}
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 8313e38f02..40dce6cbaa 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -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;
}
@@ -2722,7 +2723,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (!p_confirmed) {
confirmation->get_ok()->set_text(TTR("Yes"));
- confirmation->set_text("Open Project Manager? \n(Unsaved changes will be lost)");
+ confirmation->set_text(TTR("Open Project Manager? \n(Unsaved changes will be lost)"));
confirmation->popup_centered_minsize();
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;iset_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 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 );
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index db589bb1c3..e580931df3 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -85,6 +85,7 @@
#include "progress_dialog.h"
+#include "editor_scale.h"
/**
@author Juan Linietsky
*/
diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp
index d31cf9e0fd..13b424c231 100644
--- a/tools/editor/editor_resource_preview.cpp
+++ b/tools/editor/editor_resource_preview.cpp
@@ -4,7 +4,7 @@
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "globals.h"
-
+#include "editor_scale.h"
Ref EditorResourcePreviewGenerator::generate_from_path(const String& p_path) {
@@ -91,6 +91,7 @@ Ref 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
diff --git a/tools/editor/editor_scale.cpp b/tools/editor/editor_scale.cpp
new file mode 100644
index 0000000000..ecb1e1816f
--- /dev/null
+++ b/tools/editor/editor_scale.cpp
@@ -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;
+}
diff --git a/tools/editor/editor_scale.h b/tools/editor/editor_scale.h
new file mode 100644
index 0000000000..0f0e90595c
--- /dev/null
+++ b/tools/editor/editor_scale.h
@@ -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
diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub
index 14d2be66f6..f3216b092d 100644
--- a/tools/editor/icons/SCsub
+++ b/tools/editor/icons/SCsub
@@ -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 make_icon(const uint8_t* p_png) {\n")
s.write("\tRef 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")
diff --git a/tools/editor/icons/icon_godot.png b/tools/editor/icons/icon_godot.png
index e80820fc10..ff1370ee0f 100644
Binary files a/tools/editor/icons/icon_godot.png and b/tools/editor/icons/icon_godot.png differ
diff --git a/tools/editor/icons/source/icon_add_track.svg b/tools/editor/icons/source/icon_add_track.svg
new file mode 100644
index 0000000000..81c3489a29
--- /dev/null
+++ b/tools/editor/icons/source/icon_add_track.svg
@@ -0,0 +1,87 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_animated_sprite.svg b/tools/editor/icons/source/icon_animated_sprite.svg
new file mode 100644
index 0000000000..e123d09332
--- /dev/null
+++ b/tools/editor/icons/source/icon_animated_sprite.svg
@@ -0,0 +1,93 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_animated_sprite_3d.svg b/tools/editor/icons/source/icon_animated_sprite_3d.svg
new file mode 100644
index 0000000000..eddf6121ba
--- /dev/null
+++ b/tools/editor/icons/source/icon_animated_sprite_3d.svg
@@ -0,0 +1,93 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_animation_player.svg b/tools/editor/icons/source/icon_animation_player.svg
new file mode 100644
index 0000000000..eb1be35b5a
--- /dev/null
+++ b/tools/editor/icons/source/icon_animation_player.svg
@@ -0,0 +1,77 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_animation_tree_player.svg b/tools/editor/icons/source/icon_animation_tree_player.svg
new file mode 100644
index 0000000000..aeccbb8cdf
--- /dev/null
+++ b/tools/editor/icons/source/icon_animation_tree_player.svg
@@ -0,0 +1,77 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_control.svg b/tools/editor/icons/source/icon_control.svg
new file mode 100644
index 0000000000..0b8e043884
--- /dev/null
+++ b/tools/editor/icons/source/icon_control.svg
@@ -0,0 +1,93 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_dependency_changed.svg b/tools/editor/icons/source/icon_dependency_changed.svg
new file mode 100644
index 0000000000..74c48fc60d
--- /dev/null
+++ b/tools/editor/icons/source/icon_dependency_changed.svg
@@ -0,0 +1,93 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_dependency_changed_hl.svg b/tools/editor/icons/source/icon_dependency_changed_hl.svg
new file mode 100644
index 0000000000..3a833b6ddc
--- /dev/null
+++ b/tools/editor/icons/source/icon_dependency_changed_hl.svg
@@ -0,0 +1,93 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_dependency_local_changed.svg b/tools/editor/icons/source/icon_dependency_local_changed.svg
new file mode 100644
index 0000000000..9c55310e5c
--- /dev/null
+++ b/tools/editor/icons/source/icon_dependency_local_changed.svg
@@ -0,0 +1,99 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_dependency_local_changed_hl.svg b/tools/editor/icons/source/icon_dependency_local_changed_hl.svg
new file mode 100644
index 0000000000..3707a28cac
--- /dev/null
+++ b/tools/editor/icons/source/icon_dependency_local_changed_hl.svg
@@ -0,0 +1,99 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_dependency_ok.svg b/tools/editor/icons/source/icon_dependency_ok.svg
new file mode 100644
index 0000000000..757d085d23
--- /dev/null
+++ b/tools/editor/icons/source/icon_dependency_ok.svg
@@ -0,0 +1,83 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_dependency_ok_hl.svg b/tools/editor/icons/source/icon_dependency_ok_hl.svg
new file mode 100644
index 0000000000..030239146a
--- /dev/null
+++ b/tools/editor/icons/source/icon_dependency_ok_hl.svg
@@ -0,0 +1,83 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_duplicate.svg b/tools/editor/icons/source/icon_duplicate.svg
new file mode 100644
index 0000000000..6add5b94a8
--- /dev/null
+++ b/tools/editor/icons/source/icon_duplicate.svg
@@ -0,0 +1,90 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_edit.svg b/tools/editor/icons/source/icon_edit.svg
new file mode 100644
index 0000000000..a6eafccec7
--- /dev/null
+++ b/tools/editor/icons/source/icon_edit.svg
@@ -0,0 +1,77 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_edit_key.svg b/tools/editor/icons/source/icon_edit_key.svg
new file mode 100644
index 0000000000..100dcda572
--- /dev/null
+++ b/tools/editor/icons/source/icon_edit_key.svg
@@ -0,0 +1,83 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_edit_pivot.svg b/tools/editor/icons/source/icon_edit_pivot.svg
new file mode 100644
index 0000000000..74c874d9de
--- /dev/null
+++ b/tools/editor/icons/source/icon_edit_pivot.svg
@@ -0,0 +1,98 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_file_list.svg b/tools/editor/icons/source/icon_file_list.svg
new file mode 100644
index 0000000000..a556ddfc09
--- /dev/null
+++ b/tools/editor/icons/source/icon_file_list.svg
@@ -0,0 +1,114 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_folder.svg b/tools/editor/icons/source/icon_folder.svg
new file mode 100644
index 0000000000..651849b1c3
--- /dev/null
+++ b/tools/editor/icons/source/icon_folder.svg
@@ -0,0 +1,85 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_g_d_script.svg b/tools/editor/icons/source/icon_g_d_script.svg
new file mode 100644
index 0000000000..6015f1354a
--- /dev/null
+++ b/tools/editor/icons/source/icon_g_d_script.svg
@@ -0,0 +1,134 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_history.svg b/tools/editor/icons/source/icon_history.svg
new file mode 100644
index 0000000000..d32e5d4c73
--- /dev/null
+++ b/tools/editor/icons/source/icon_history.svg
@@ -0,0 +1,109 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_key.svg b/tools/editor/icons/source/icon_key.svg
new file mode 100644
index 0000000000..846db79785
--- /dev/null
+++ b/tools/editor/icons/source/icon_key.svg
@@ -0,0 +1,91 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_list_select.svg b/tools/editor/icons/source/icon_list_select.svg
new file mode 100644
index 0000000000..7ca55e27a6
--- /dev/null
+++ b/tools/editor/icons/source/icon_list_select.svg
@@ -0,0 +1,93 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_lock.svg b/tools/editor/icons/source/icon_lock.svg
new file mode 100644
index 0000000000..53daf88b39
--- /dev/null
+++ b/tools/editor/icons/source/icon_lock.svg
@@ -0,0 +1,102 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_loop.svg b/tools/editor/icons/source/icon_loop.svg
new file mode 100644
index 0000000000..360ee8db10
--- /dev/null
+++ b/tools/editor/icons/source/icon_loop.svg
@@ -0,0 +1,86 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_new.svg b/tools/editor/icons/source/icon_new.svg
new file mode 100644
index 0000000000..690d92764e
--- /dev/null
+++ b/tools/editor/icons/source/icon_new.svg
@@ -0,0 +1,77 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_node.svg b/tools/editor/icons/source/icon_node.svg
new file mode 100644
index 0000000000..22d9f9c2d9
--- /dev/null
+++ b/tools/editor/icons/source/icon_node.svg
@@ -0,0 +1,93 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_node_2d.svg b/tools/editor/icons/source/icon_node_2d.svg
new file mode 100644
index 0000000000..49873a39fd
--- /dev/null
+++ b/tools/editor/icons/source/icon_node_2d.svg
@@ -0,0 +1,93 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_packed_scene.svg b/tools/editor/icons/source/icon_packed_scene.svg
new file mode 100644
index 0000000000..ce8e6a981a
--- /dev/null
+++ b/tools/editor/icons/source/icon_packed_scene.svg
@@ -0,0 +1,114 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_progress.svg b/tools/editor/icons/source/icon_progress.svg
new file mode 100644
index 0000000000..6ba00f3b7f
--- /dev/null
+++ b/tools/editor/icons/source/icon_progress.svg
@@ -0,0 +1,112 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_remove.svg b/tools/editor/icons/source/icon_remove.svg
new file mode 100644
index 0000000000..9836f91036
--- /dev/null
+++ b/tools/editor/icons/source/icon_remove.svg
@@ -0,0 +1,84 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_rename.svg b/tools/editor/icons/source/icon_rename.svg
new file mode 100644
index 0000000000..a4a3160a95
--- /dev/null
+++ b/tools/editor/icons/source/icon_rename.svg
@@ -0,0 +1,94 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_save.svg b/tools/editor/icons/source/icon_save.svg
new file mode 100644
index 0000000000..9a82cba0b5
--- /dev/null
+++ b/tools/editor/icons/source/icon_save.svg
@@ -0,0 +1,78 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_spatial.svg b/tools/editor/icons/source/icon_spatial.svg
new file mode 100644
index 0000000000..4c997f56dd
--- /dev/null
+++ b/tools/editor/icons/source/icon_spatial.svg
@@ -0,0 +1,93 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_sprite.svg b/tools/editor/icons/source/icon_sprite.svg
new file mode 100644
index 0000000000..40cc4c3e7b
--- /dev/null
+++ b/tools/editor/icons/source/icon_sprite.svg
@@ -0,0 +1,94 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_sprite_3d.svg b/tools/editor/icons/source/icon_sprite_3d.svg
new file mode 100644
index 0000000000..8b24ebb107
--- /dev/null
+++ b/tools/editor/icons/source/icon_sprite_3d.svg
@@ -0,0 +1,94 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_tool_move.svg b/tools/editor/icons/source/icon_tool_move.svg
new file mode 100644
index 0000000000..0bb13e9c5a
--- /dev/null
+++ b/tools/editor/icons/source/icon_tool_move.svg
@@ -0,0 +1,157 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_tool_pan.svg b/tools/editor/icons/source/icon_tool_pan.svg
new file mode 100644
index 0000000000..e50beb1fb8
--- /dev/null
+++ b/tools/editor/icons/source/icon_tool_pan.svg
@@ -0,0 +1,108 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_tool_rotate.svg b/tools/editor/icons/source/icon_tool_rotate.svg
new file mode 100644
index 0000000000..9c4bd862d0
--- /dev/null
+++ b/tools/editor/icons/source/icon_tool_rotate.svg
@@ -0,0 +1,94 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_tool_scale.svg b/tools/editor/icons/source/icon_tool_scale.svg
new file mode 100644
index 0000000000..0d4dcfbbfe
--- /dev/null
+++ b/tools/editor/icons/source/icon_tool_scale.svg
@@ -0,0 +1,77 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_tool_select.svg b/tools/editor/icons/source/icon_tool_select.svg
new file mode 100644
index 0000000000..e92364eddd
--- /dev/null
+++ b/tools/editor/icons/source/icon_tool_select.svg
@@ -0,0 +1,78 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_tools.svg b/tools/editor/icons/source/icon_tools.svg
new file mode 100644
index 0000000000..91a1f5dcff
--- /dev/null
+++ b/tools/editor/icons/source/icon_tools.svg
@@ -0,0 +1,77 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_unlock.svg b/tools/editor/icons/source/icon_unlock.svg
new file mode 100644
index 0000000000..5bf2359d96
--- /dev/null
+++ b/tools/editor/icons/source/icon_unlock.svg
@@ -0,0 +1,95 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_wait_preview_1.svg b/tools/editor/icons/source/icon_wait_preview_1.svg
new file mode 100644
index 0000000000..89f30355eb
--- /dev/null
+++ b/tools/editor/icons/source/icon_wait_preview_1.svg
@@ -0,0 +1,112 @@
+
+
+
+
diff --git a/tools/editor/icons/source/icon_zoom.svg b/tools/editor/icons/source/icon_zoom.svg
new file mode 100644
index 0000000000..0ab5bc69c2
--- /dev/null
+++ b/tools/editor/icons/source/icon_zoom.svg
@@ -0,0 +1,77 @@
+
+
+
+
diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp
index f4d6af7e10..d5e6e3077e 100644
--- a/tools/editor/io_plugins/editor_font_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp
@@ -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!="") {
diff --git a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp
index 45da42969c..c20515f0f3 100644
--- a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp
@@ -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!="") {
diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp
index 120bdc6f44..ac0795f522 100644
--- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp
@@ -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 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");
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
index 3effb1d0aa..594d3f5bcd 100644
--- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
@@ -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