diff --git a/uppsrc/CtrlLib/Button.cpp b/uppsrc/CtrlLib/Button.cpp index b693e3c06..4c02d8f67 100644 --- a/uppsrc/CtrlLib/Button.cpp +++ b/uppsrc/CtrlLib/Button.cpp @@ -418,7 +418,7 @@ void Button::AssignAccessKeys(dword used) Button& Button::SetImage(const Image& _img) { - img = DPI(_img); + img = _img; monoimg = false; Refresh(); return *this; @@ -426,7 +426,7 @@ Button& Button::SetImage(const Image& _img) Button& Button::SetMonoImage(const Image& _img) { - img = DPI(_img); + img = _img; monoimg = true; Refresh(); return *this; diff --git a/uppsrc/CtrlLib/ChWin32.cpp b/uppsrc/CtrlLib/ChWin32.cpp index f2db7e476..38d2bf202 100644 --- a/uppsrc/CtrlLib/ChWin32.cpp +++ b/uppsrc/CtrlLib/ChWin32.cpp @@ -614,7 +614,9 @@ void ChSysInit() if(height > 0 && height < 200) // sanity.. Font::SetDefaultFont(Font(q >= 0 ? q : Font::SANSSERIF, height)); + bool uhd = GetStdFontCy() > 22; GUI_HiDPI_Write(GetStdFontCy() > 22); + SetUHDMode(uhd); GUI_GlobalStyle_Write(IsWinXP() && !ScreenInPaletteMode() && IsSysFlag(0x1022 /*SPI_GETFLATMENU*/) ? GUISTYLE_XP : GUISTYLE_CLASSIC); diff --git a/uppsrc/CtrlLib/ColorPusher.cpp b/uppsrc/CtrlLib/ColorPusher.cpp index 8fdaffd88..417f2111b 100644 --- a/uppsrc/CtrlLib/ColorPusher.cpp +++ b/uppsrc/CtrlLib/ColorPusher.cpp @@ -113,13 +113,14 @@ ColorButton::~ColorButton() {} Size ColorButton::GetMinSize() const { - return Size(24, 24); + return DPI(Size(24, 24)); } void ColorButton::Paint(Draw& w) { Size sz = GetSize(); Size isz = (IsNull(image) ? staticimage : image).GetSize(); + DDUMP(image.GetSize()); Point center = (sz - isz) / 2; if(GUI_GlobalStyle() >= GUISTYLE_XP) ChPaint(w, sz, style->look[!IsEnabled() ? CTRL_DISABLED : push ? CTRL_PRESSED diff --git a/uppsrc/CtrlLib/FileList.cpp b/uppsrc/CtrlLib/FileList.cpp index b7b3725f9..7857b280a 100644 --- a/uppsrc/CtrlLib/FileList.cpp +++ b/uppsrc/CtrlLib/FileList.cpp @@ -238,7 +238,7 @@ void FileList::Insert(int ii, m.isdir = isdir; m.unixexe = unixexe; m.hidden = hidden; - m.icon = DPI(icon); + m.icon = icon; m.name = name; m.font = font; m.ink = ink; @@ -264,7 +264,7 @@ void FileList::Set(int ii, m.isdir = isdir; m.unixexe = unixexe; m.hidden = hidden; - m.icon = DPI(icon); + m.icon = icon; m.name = name; m.font = font; m.ink = ink; @@ -293,7 +293,7 @@ void FileList::SetIcon(int ii, const Image& icon) Value v; File& m = CreateRawValue(v); m = Get(ii); - m.icon = DPI(icon); + m.icon = icon; ColumnList::Set(ii, v, !m.isdir); KillEdit(); } @@ -308,7 +308,7 @@ void FileList::Add(const String& name, const Image& icon, Font font, Color ink, m.isdir = isdir; m.unixexe = unixexe; m.hidden = hidden; - m.icon = DPI(icon); + m.icon = icon; m.name = name; m.font = font; m.ink = ink; diff --git a/uppsrc/CtrlLib/FileSel.cpp b/uppsrc/CtrlLib/FileSel.cpp index 9b08f5895..73d2661ba 100644 --- a/uppsrc/CtrlLib/FileSel.cpp +++ b/uppsrc/CtrlLib/FileSel.cpp @@ -487,7 +487,7 @@ bool Load(FileList& list, const String& dir, const char *patterns, bool dirs, StdFont() ); #ifdef PLATFORM_WIN32 - list.Add(t_("Network"), DPI(CtrlImg::Network()), StdFont().Bold(), SColorText, + list.Add(t_("Network"), CtrlImg::Network(), StdFont().Bold(), SColorText, true, -1, Null, SColorDisabled, Null, StdFont()); #endif } @@ -1584,7 +1584,7 @@ struct HomeDisplay : public Display { virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { w.DrawRect(r, paper); - Image img = DPI(CtrlImg::Home()); + Image img = CtrlImg::Home(); w.DrawImage(r.left, r.top + (r.Height() - img.GetSize().cx) / 2, CtrlImg::Home()); w.DrawText(r.left + Zx(20), diff --git a/uppsrc/CtrlLib/LabelBase.cpp b/uppsrc/CtrlLib/LabelBase.cpp index b0bf3f6d4..6c95c7d57 100644 --- a/uppsrc/CtrlLib/LabelBase.cpp +++ b/uppsrc/CtrlLib/LabelBase.cpp @@ -2,12 +2,6 @@ NAMESPACE_UPP -Image DPI(const Image& img, int excy) -{ - return GUI_HiDPI() && img.GetSize().cy <= excy ? CachedRescale(img, 2 * img.GetSize(), FILTER_LANCZOS3) - : img; -} - void CtrlsImageLook(Value *look, int i, int n) { while(n--) @@ -17,13 +11,13 @@ void CtrlsImageLook(Value *look, int i, int n) void CtrlsImageLook(Value *look, int i, const Image& image, const Color *color, int n) { for(int q = 0; q < n; q++) - *look++ = ChLookWith(CtrlsImg::Get(i++), DPI(image), *color++); + *look++ = ChLookWith(CtrlsImg::Get(i++), image, *color++); } void CtrlsImageLook(Value *look, int i, const Image& image, int n) { for(int q = 0; q < n; q++) - *look++ = ChLookWith(CtrlsImg::Get(i++), DPI(image)); + *look++ = ChLookWith(CtrlsImg::Get(i++), image); } String DeAmp(const char *s) diff --git a/uppsrc/CtrlLib/LabelBase.h b/uppsrc/CtrlLib/LabelBase.h index be8790b29..bbd3acba8 100644 --- a/uppsrc/CtrlLib/LabelBase.h +++ b/uppsrc/CtrlLib/LabelBase.h @@ -1,5 +1,3 @@ -Image DPI(const Image& img, int excy = 16); - enum { CTRL_NORMAL, CTRL_HOT, CTRL_PRESSED, CTRL_DISABLED, CTRL_CHECKED, CTRL_HOTCHECKED diff --git a/uppsrc/CtrlLib/MenuItem.cpp b/uppsrc/CtrlLib/MenuItem.cpp index 3eb19c709..1e9bf7817 100644 --- a/uppsrc/CtrlLib/MenuItem.cpp +++ b/uppsrc/CtrlLib/MenuItem.cpp @@ -210,7 +210,7 @@ void MenuItemBase::PaintTopItem(Draw& w, int state) { Bar::Item& MenuItem::Image(const UPP::Image& img) { - licon = DPI(img); + licon = img; if(IsDarkColorFace() && !nodarkadjust) licon = MakeImage(licon, AdjustForDarkBk); Refresh(); @@ -219,7 +219,7 @@ Bar::Item& MenuItem::Image(const UPP::Image& img) MenuItem& MenuItem::RightImage(const UPP::Image& img) { - ricon = DPI(img); + ricon = img; if(IsDarkColorFace() && !nodarkadjust) ricon = MakeImage(ricon, AdjustForDarkBk); Refresh(); @@ -307,7 +307,6 @@ void MenuItem::Paint(Draw& w) case RADIO0: li = CtrlImg::MenuRadio0(); break; case RADIO1: li = CtrlImg::MenuRadio1(); break; } - li = DPI(li); } Size isz = li.GetSize(); // Size isz = min(maxiconsize, imsz); diff --git a/uppsrc/CtrlLib/ToolButton.cpp b/uppsrc/CtrlLib/ToolButton.cpp index 23b2eb849..c74ee5a1b 100644 --- a/uppsrc/CtrlLib/ToolButton.cpp +++ b/uppsrc/CtrlLib/ToolButton.cpp @@ -170,7 +170,7 @@ Image ToolButton::GetImage() const Bar::Item& ToolButton::Image(const UPP::Image& img_) { - Upp::Image m = DPI(img_); + Upp::Image m = img_; if(!m.IsSame(img)) { img = m; Refresh(); diff --git a/uppsrc/Draw/Cham.cpp b/uppsrc/Draw/Cham.cpp index 265f1fa55..08f8ca6ab 100644 --- a/uppsrc/Draw/Cham.cpp +++ b/uppsrc/Draw/Cham.cpp @@ -130,8 +130,6 @@ Value ChBorder(const ColorF *colors, const Value& face) return RawToValue(b); } -Image DPI(const Image& img, int excy = 16); - Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op) { if(IsType(v)) { @@ -139,15 +137,14 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op) if(op == LOOK_PAINT) { LOGPNG(AsString(x.img.GetSerialId()), x.img); ChPaint(w, r, x.look); - Image m = DPI(x.img); - Point p = r.CenterPos(m.GetSize()) + x.offset; + Point p = r.CenterPos(x.img.GetSize()) + x.offset; if(x.colorfn) - w.DrawImage(p.x, p.y, m, (*x.colorfn)(x.ii)); + w.DrawImage(p.x, p.y, x.img, (*x.colorfn)(x.ii)); else if(!IsNull(x.color)) - w.DrawImage(p.x, p.y, m, x.color); + w.DrawImage(p.x, p.y, x.img, x.color); else - w.DrawImage(p.x, p.y, m); + w.DrawImage(p.x, p.y, x.img); return 1; } return sChOp(w, r, x.look, op); @@ -186,7 +183,7 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op) } if(IsType(v)) { Image img = v; - img = DPI(img); + img = img; Size isz = img.GetSize(); Size sz = r.GetSize(); Point p = img.GetHotSpot(); diff --git a/uppsrc/Draw/Draw.upp b/uppsrc/Draw/Draw.upp index 89949f95d..ecc454f42 100644 --- a/uppsrc/Draw/Draw.upp +++ b/uppsrc/Draw/Draw.upp @@ -54,6 +54,7 @@ file RescaleFilter.cpp optimize_speed, MakeCache.cpp, DrawRasterData.cpp, + Uhd.cpp, Iml.cpp, iml.h, iml_header.h, diff --git a/uppsrc/Draw/ImageOp.h b/uppsrc/Draw/ImageOp.h index df3177da6..7e82a952d 100644 --- a/uppsrc/Draw/ImageOp.h +++ b/uppsrc/Draw/ImageOp.h @@ -198,3 +198,8 @@ Image RescaleBicubic(const Image& src, Size sz, const Rect& src_rc, Gate2 progress = false); Image RescaleBicubic(const Image& img, int cx, int cy, Gate2 progress = false); +void SetUHDMode(bool b = true); +bool IsUHDMode(); + +Image DPI(const Image& m); +inline Size DPI(Size sz) { return IsUHDMode() ? 2 * sz : sz; } diff --git a/uppsrc/Draw/Iml.cpp b/uppsrc/Draw/Iml.cpp index 8278c3dba..c019ac3e5 100644 --- a/uppsrc/Draw/Iml.cpp +++ b/uppsrc/Draw/Iml.cpp @@ -78,7 +78,7 @@ Image Iml::Get(int i) for(int i = 0; i < cached.GetCount(); i++) cached[i] = Premultiply(cached[i]); } - m.image = cached[i]; + m.image = DPI(cached[i]); break; } i -= d.count; diff --git a/uppsrc/Draw/Uhd.cpp b/uppsrc/Draw/Uhd.cpp new file mode 100644 index 000000000..09590dc27 --- /dev/null +++ b/uppsrc/Draw/Uhd.cpp @@ -0,0 +1,40 @@ +#include "Draw.h" + +namespace Upp { + +static bool sUHDMode; + +void SetUHDMode(bool b) +{ + for(int i = 0; i < GetImlCount(); i++) + GetIml(i).Reset(); + sUHDMode = b; +} + +bool IsUHDMode() +{ + return sUHDMode; +} + +Image DPI(const Image& img) +{ + if(IsUHDMode()) { + if(img.GetResolution() == IMAGE_RESOLUTION_STANDARD) { + Image m = CachedRescale(img, 2 * img.GetSize(), FILTER_LANCZOS3); + ImageBuffer h(m); + h.SetResolution(IMAGE_RESOLUTION_UHD); + return h; + } + } + else { + if(img.GetResolution() == IMAGE_RESOLUTION_UHD) { + Image m = CachedRescale(img, img.GetSize() - 2, FILTER_LANCZOS3); + ImageBuffer h(m); + h.SetResolution(IMAGE_RESOLUTION_UHD); + return h; + } + } + return img; +} + +}; \ No newline at end of file diff --git a/uppsrc/RichEdit/FormatDlg.cpp b/uppsrc/RichEdit/FormatDlg.cpp index e0fd84469..d5adc48b0 100644 --- a/uppsrc/RichEdit/FormatDlg.cpp +++ b/uppsrc/RichEdit/FormatDlg.cpp @@ -267,7 +267,7 @@ ParaFormatting::ParaFormatting() bullet.Add(RichPara::BULLET_BOXWHITE, RichEditImg::BoxWhiteBullet()); bullet.Add(RichPara::BULLET_TEXT, RichEditImg::TextBullet()); bullet.SetDisplay(CenteredHighlightImageDisplay()); - bullet.SetLineCy(18); + bullet.SetLineCy(RichEditImg::RoundBullet().GetHeight() + Zy(2)); for(int i = 0; i < 8; i++) { DropList& list = n[i]; list.Add(Null); diff --git a/uppsrc/RichEdit/Ruler.cpp b/uppsrc/RichEdit/Ruler.cpp index a96db2319..93eb5fc68 100644 --- a/uppsrc/RichEdit/Ruler.cpp +++ b/uppsrc/RichEdit/Ruler.cpp @@ -70,9 +70,9 @@ void RichRuler::Paint(Draw& w) if(xp > tabpos) w.DrawRect(x0 + x, sz.cy - Zy(4), Zx(1), Zy(3), SColorShadow); } - w.DrawImage(Zx(4), Zy(6), DPI(newtabalign == ALIGN_RIGHT ? RichEditImg::RightTab() : - newtabalign == ALIGN_CENTER ? RichEditImg::CenterTab() : - RichEditImg::LeftTab())); + w.DrawImage(Zx(4), Zy(6), newtabalign == ALIGN_RIGHT ? RichEditImg::RightTab() : + newtabalign == ALIGN_CENTER ? RichEditImg::CenterTab() : + RichEditImg::LeftTab()); } int RichRuler::FindMarker(Point p)