From 07fd025eefc3c36058605dfd9ed369acad3a754f Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 15 Jan 2020 20:07:33 +0000 Subject: [PATCH] CtrlCore: Fixed scaling of DnD drag icon git-svn-id: svn://ultimatepp.org/upp/trunk@13894 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/CtrlCore.h | 2 +- uppsrc/CtrlCore/GtkDnD.cpp | 10 ++++++++-- uppsrc/CtrlCore/gtk3-todo.txt | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 332f20efe..a9b17f935 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -1220,7 +1220,7 @@ public: static Ctrl *GetDragAndDropTarget(); bool IsDragAndDropSource() { return this == GetDragAndDropSource(); } bool IsDragAndDropTarget() { return this == GetDragAndDropTarget(); } - static Size StdSampleSize() { return Size(126, 106); } + static Size StdSampleSize() { return Size(DPI(126), DPI(106)); } public: static void SetSkin(void (*skin)()); diff --git a/uppsrc/CtrlCore/GtkDnD.cpp b/uppsrc/CtrlCore/GtkDnD.cpp index cca5454c4..f3f03a68b 100644 --- a/uppsrc/CtrlCore/GtkDnD.cpp +++ b/uppsrc/CtrlCore/GtkDnD.cpp @@ -19,13 +19,19 @@ Ctrl *Ctrl::GetDragAndDropSource() return dnd_source; } +cairo_surface_t *CreateCairoSurface(const Image& img); + void Ctrl::GtkDragBegin(GtkWidget *widget, GdkDragContext *context, gpointer user_data) { if(IsNull(dnd_icon)) gtk_drag_set_icon_default(context); else { - ImageGdk m(dnd_icon); - gtk_drag_set_icon_pixbuf(context, m, 0, 0); + cairo_surface_t *surface = CreateCairoSurface(dnd_icon); + double scale = SCL(1); + cairo_surface_set_device_scale(surface, scale, scale); + cairo_surface_set_device_offset(surface, DPI(8), DPI(8)); + gtk_drag_set_icon_surface(context, surface); + cairo_surface_destroy(surface); } LLOG("GtkDragBegin"); } diff --git a/uppsrc/CtrlCore/gtk3-todo.txt b/uppsrc/CtrlCore/gtk3-todo.txt index f2acd0f20..f82189154 100644 --- a/uppsrc/CtrlCore/gtk3-todo.txt +++ b/uppsrc/CtrlCore/gtk3-todo.txt @@ -6,7 +6,6 @@ - Disabled empty combobox (FileSel::SelectDir) does not look nice - ide menu in X11 ch - TrayIconGtk warnings -- DnD Sample size UHD NTH: - spinbutton cosmetics @@ -70,3 +69,4 @@ DONE: - OpenGL - GtkWnd warnings - GtkDnD warnings +- DnD Sample size UHD