From f993c1cd24ccef0fe5086d5f52834cb405b70590 Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 4 Oct 2015 06:05:30 +0000 Subject: [PATCH] UHD docs #1266 git-svn-id: svn://ultimatepp.org/upp/trunk@8976 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/Ctrl.cpp | 10 +-- uppsrc/CtrlCore/CtrlCore.h | 12 ++-- uppsrc/CtrlCore/src.tpp/Ctrl$en-us.tpp | 9 +++ .../CtrlCore/src.tpp/PasteClipUtil$en-us.tpp | 1 - uppsrc/CtrlCore/src.tpp/Zooming$en-us.tpp | 67 ++++++++++++++++++ .../srcdoc.tpp/CtrlDesignConcepts$en-us.tpp | 7 +- .../CtrlCore/srcdoc.tpp/Resolution$en-us.tpp | 68 +++++++++++++++++++ uppsrc/CtrlLib/ChWin32.cpp | 2 +- uppsrc/Draw/ImageOp.h | 10 +-- uppsrc/ide/idewin.cpp | 2 +- 10 files changed, 164 insertions(+), 24 deletions(-) create mode 100644 uppsrc/CtrlCore/src.tpp/Zooming$en-us.tpp create mode 100644 uppsrc/CtrlCore/srcdoc.tpp/Resolution$en-us.tpp diff --git a/uppsrc/CtrlCore/Ctrl.cpp b/uppsrc/CtrlCore/Ctrl.cpp index cf2f0268d..032849c8c 100644 --- a/uppsrc/CtrlCore/Ctrl.cpp +++ b/uppsrc/CtrlCore/Ctrl.cpp @@ -809,17 +809,17 @@ Font FontZ(int face, int height) return Font(face, Ctrl::VertLayoutZoom(height)); } -bool ApplicationHiDPIEnabled; +bool ApplicationUHDEnabled; -void Ctrl::SetHiDPIEnabled(bool set) +void Ctrl::SetUHDEnabled(bool set) { - ApplicationHiDPIEnabled = set; + ApplicationUHDEnabled = set; ReSkin(); } -bool Ctrl::IsHiDPIEnabled() +bool Ctrl::IsUHDEnabled() { - return ApplicationHiDPIEnabled; + return ApplicationUHDEnabled; } Font StdFontZ(int height) { return FontZ(Font::STDFONT, height); } diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 02d2dfc16..4c1e6818a 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -1205,8 +1205,8 @@ public: static void NoLayoutZoom(); static void GetZoomRatio(Size& m, Size& d); - static void SetHiDPIEnabled(bool set = true); - static bool IsHiDPIEnabled(); + static void SetUHDEnabled(bool set = true); + static bool IsUHDEnabled(); static bool ClickFocus(); static void ClickFocus(bool cf); @@ -1281,14 +1281,14 @@ Font StdFontZ(int height = 0); Font SansSerifZ(int height = 0); Font SerifZ(int height = 0); Font MonospaceZ(int height = 0); - -Font ScreenSansZ(int height = 0); -Font ScreenSerifZ(int height = 0); -Font ScreenFixedZ(int height = 0); Font RomanZ(int height = 0); Font ArialZ(int height = 0); Font CourierZ(int height = 0); +Font ScreenSansZ(int height = 0); // deprecated +Font ScreenSerifZ(int height = 0); // deprecated +Font ScreenFixedZ(int height = 0); // deprecated + int EditFieldIsThin(); Value TopSeparator1(); Value TopSeparator2(); diff --git a/uppsrc/CtrlCore/src.tpp/Ctrl$en-us.tpp b/uppsrc/CtrlCore/src.tpp/Ctrl$en-us.tpp index f562cd725..f5deb7034 100644 --- a/uppsrc/CtrlCore/src.tpp/Ctrl$en-us.tpp +++ b/uppsrc/CtrlCore/src.tpp/Ctrl$en-us.tpp @@ -2550,6 +2550,15 @@ ize]_[*@3 sz])&] [s2;b17;a17; Sets scaling factor to (1, 1). Same as SetZoomSize(Size(1, 1), Size(1, 1)).&] [s3; &] +[s4;%- &] +[s5;:Upp`:`:Ctrl`:`:SetUHDEnabled`(bool`):%- [@(0.0.255) void]_[* SetUHDEnabled]([@(0.0.255) b +ool]_[*@3 set])&] +[s2; Informs host platform that application is UHD ready.&] +[s3; &] +[s4;%- &] +[s5;:Upp`:`:Ctrl`:`:IsUHDEnabled`(`):%- [@(0.0.255) bool]_[* IsUHDEnabled]()&] +[s2; Returns the value set by SetUHDEnabled.&] +[s3;%- &] [s4; &] [s5;K:Ctrl`:`:GetWorkArea`(`):%- [*^`:`:Rect^@(64) Rect][*@(64) _][* GetWorkArea][*@(64) ()]&] [s2; Returns OS specific working area for the widget `- this is rectangle diff --git a/uppsrc/CtrlCore/src.tpp/PasteClipUtil$en-us.tpp b/uppsrc/CtrlCore/src.tpp/PasteClipUtil$en-us.tpp index 55e14988b..bb9082ff5 100644 --- a/uppsrc/CtrlCore/src.tpp/PasteClipUtil$en-us.tpp +++ b/uppsrc/CtrlCore/src.tpp/PasteClipUtil$en-us.tpp @@ -134,5 +134,4 @@ s]_[*@4 T]>_[@(0.0.255) bool]_[* AcceptInternal]([_^PasteClip^ PasteClip][@(0.0. onst]_[*@4 T][@(0.0.255) `&]_[* GetInternal]([_^PasteClip^ PasteClip][@(0.0.255) `&]_[*@3 d]) &] [s2;%% Returns a reference to variable of internal clip.&] -[s3;%% &] [s0;%% ]] \ No newline at end of file diff --git a/uppsrc/CtrlCore/src.tpp/Zooming$en-us.tpp b/uppsrc/CtrlCore/src.tpp/Zooming$en-us.tpp new file mode 100644 index 000000000..2e2c5b5ca --- /dev/null +++ b/uppsrc/CtrlCore/src.tpp/Zooming$en-us.tpp @@ -0,0 +1,67 @@ +topic ""; +[2 $$0,0#00000000000000000000000000000000:Default] +[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] +[l288;2 $$2,2#27521748481378242620020725143825:desc] +[0 $$3,0#96390100711032703541132217272105:end] +[H6;0 $$4,0#05600065144404261032431302351956:begin] +[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:item] +[l288;a4;*@5;1 $$6,6#70004532496200323422659154056402:requirement] +[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] +[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] +[b42;2 $$9,9#13035079074754324216151401829390:normal] +[{_} +[ {{10000@(113.42.0) [s0;%% [*@7;4 Function to support actual resolution]]}}&] +[s0;%% &] +[s0;%% This set of function is designed to simplify writing code +where screen coordinates are correctly computed based on current +dialog scale factor.&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:Zx`(int`): [@(0.0.255) int]_[* Zx]([@(0.0.255) int]_[*@3 cx])&] +[s2;%% Same as Ctrl`::HorzLayoutZoom([%-*@3 cx]).&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:Zy`(int`): [@(0.0.255) int]_[* Zy]([@(0.0.255) int]_[*@3 cy])&] +[s2;%% Same as Ctrl`::VertLayoutZoom([%-*@3 cy]).&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:Zsz`(int`,int`): [_^Upp`:`:Size^ Size]_[* Zsz]([@(0.0.255) int]_[*@3 cx], +[@(0.0.255) int]_[*@3 cy])&] +[s2;%% Same as Size(Zx([%-*@3 cx]), Zy([%-*@3 cy])).&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:Zsz`(Upp`:`:Size`): [_^Upp`:`:Size^ Size]_[* Zsz]([_^Upp`:`:Size^ Size]_[*@3 sz]) +&] +[s2;%% Same as Size(Zx([%-*@3 sz.cx]), Zy([%-*@3 sz.cy])).&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:FontZ`(int`,int`): [_^Upp`:`:Font^ Font]_[* FontZ]([@(0.0.255) int]_[*@3 face], +[@(0.0.255) int]_[*@3 height])&] +[s2;%% Returns font with height rescaled by vertical zoom factor. +Same as Font([%-*@3 face],_Ctrl`::VertLayoutZoom([%-*@3 height]).&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:StdFontZ`(int`): [_^Upp`:`:Font^ Font]_[* StdFontZ]([@(0.0.255) int]_[*@3 height]) +&] +[s2;%% Returns standard GUI font with height rescaled by vertical +zoom factor. Same as FontZ(Font`::STDFONT, [%-*@3 height]).&] +[s3; &] +[s4; &] +[s5;:Upp`:`:SansSerifZ`(int`): [_^Upp`:`:Font^ Font]_[* SansSerifZ]([@(0.0.255) int]_[*@3 hei +ght])&] +[s5;:Upp`:`:ArialZ`(int`): [_^Upp`:`:Font^ Font]_[* ArialZ]([@(0.0.255) int]_[*@3 height])&] +[s2;%% Same as FontZ(Font`::SANSSERIF, [%-*@3 height]).&] +[s3; &] +[s4; &] +[s5;:Upp`:`:SerifZ`(int`): [_^Upp`:`:Font^ Font]_[* SerifZ]([@(0.0.255) int]_[*@3 height])&] +[s5;:Upp`:`:RomanZ`(int`): [_^Upp`:`:Font^ Font]_[* RomanZ]([@(0.0.255) int]_[*@3 height])&] +[s2;%% Same as FontZ(Font`::SERIF, [%-*@3 height]).&] +[s3; &] +[s4; &] +[s5;:Upp`:`:MonospaceZ`(int`): [_^Upp`:`:Font^ Font]_[* MonospaceZ]([@(0.0.255) int]_[*@3 hei +ght])&] +[s5;:Upp`:`:CourierZ`(int`): [_^Upp`:`:Font^ Font]_[* CourierZ]([@(0.0.255) int]_[*@3 height]) +&] +[s2;%% Same as FontZ(Font`::MONOSPACE, [%-*@3 height]).&] +[s3;%% &] +[s0;%% ]] \ No newline at end of file diff --git a/uppsrc/CtrlCore/srcdoc.tpp/CtrlDesignConcepts$en-us.tpp b/uppsrc/CtrlCore/srcdoc.tpp/CtrlDesignConcepts$en-us.tpp index cd96bb60d..d937d1e38 100644 --- a/uppsrc/CtrlCore/srcdoc.tpp/CtrlDesignConcepts$en-us.tpp +++ b/uppsrc/CtrlCore/srcdoc.tpp/CtrlDesignConcepts$en-us.tpp @@ -83,10 +83,7 @@ both. If graphical data needs change as well, UpdateActionRefresh() is the chain to go, which will invoke an additional Paint(). ClearModify() acts recursively on all children too.&] [s0; &] -[s0; [* Accept / Reject]&] -[s0; &] -[s0; lorem ipsum :)&] -[s0; &] +[s0;* &] [s0; [* Refresh() strategies]&] [s0; &] [s0; Each U`+`+ Ctrl can be scheduled for Refresh() explicitly. This @@ -136,4 +133,4 @@ data without posting it to the Ctrl, and once every 200 ms, do your work..and let the Ctrl Refresh(), this still yields a good look and keeps the GUI responsive.&] [s0; &] -[s0; ] \ No newline at end of file +[s0; ]] \ No newline at end of file diff --git a/uppsrc/CtrlCore/srcdoc.tpp/Resolution$en-us.tpp b/uppsrc/CtrlCore/srcdoc.tpp/Resolution$en-us.tpp new file mode 100644 index 000000000..a75da8724 --- /dev/null +++ b/uppsrc/CtrlCore/srcdoc.tpp/Resolution$en-us.tpp @@ -0,0 +1,68 @@ +topic "Reacting to resolution"; +[2 $$0,0#00000000000000000000000000000000:Default] +[l288;i1120;a17;O9;~~~.1408;2 $$1,0#10431211400427159095818037425705:param] +[a83;*R6 $$2,5#31310162474203024125188417583966:caption] +[H4;b83;*4 $$3,5#07864147445237544204411237157677:title] +[i288;O9;C2 $$4,6#40027414424643823182269349404212:item] +[b42;a42;2 $$5,5#45413000475342174754091244180557:text] +[l288;b17;a17;2 $$6,6#27521748481378242620020725143825:desc] +[l321;C@5;1 $$7,7#20902679421464641399138805415013:code] +[b2503;2 $$8,0#65142375456100023862071332075487:separator] +[*@(0.0.255)2 $$9,0#83433469410354161042741608181528:base] +[C2 $$10,0#37138531426314131251341829483380:class] +[l288;a17;*1 $$11,11#70004532496200323422659154056402:requirement] +[i417;b42;a42;O9;~~~.416;2 $$12,12#10566046415157235020018451313112:tparam] +[b167;C2 $$13,13#92430459443460461911108080531343:item1] +[i288;a42;O9;C2 $$14,14#77422149456609303542238260500223:item2] +[*@2$(0.128.128)2 $$15,15#34511555403152284025741354420178:NewsDate] +[l321;*C$7;2 $$16,16#03451589433145915344929335295360:result] +[l321;b83;a83;*C$7;2 $$17,17#07531550463529505371228428965313:result`-line] +[l160;*C+117 $$18,5#88603949442205825958800053222425:package`-title] +[2 $$19,0#53580023442335529039900623488521:gap] +[C2 $$20,20#70211524482531209251820423858195:class`-nested] +[b50;2 $$21,21#03324558446220344731010354752573:Par] +[{_}%EN-US +[s2; Reacting to actual resolution, UHD support&] +[s0; While all widgets coordinates are always in pixels, applications +need to react actual settings of target GUI to scale things accordingly.&] +[s0; &] +[s0; In U`+`+, the basic scaling factor is always determined by standard +font size, which is read from host platform (scaling factor can +also be adjusted by application, but that is less relevant here).&] +[s0; &] +[s0; All layouts are designed in some artificial defined, relatively +small, `'basic font`' font size, then scaled based on ratios +of standard system font to this basic font. Also, it is possible +to scale individual dimensions by Ctrl`::`[Horz`|Vert`]LayoutZoom +or [^topic`:`/`/CtrlCore`/src`/Zooming`$en`-us^ Zx/Zy/Zsz] functions.&] +[s0; &] +[s0; This, when used appropriately, works well for host GUI font +size between 12`-22. When GUI font gets bigger, there starts +to be a problem with Images (e.g. button icons) being too small. +This is typical for UHD display.&] +[s0; &] +[s0; To resolve this problem, upscaled Images need to provided in +this case. This is not a problem for Images that are created +by code (because they can easily incorporate scaling factor into +the algorithm), but would be a problem for images from .iml resources.&] +[s0; &] +[s0; To this means, Image has Resolution info. This can have 3 values +`- None, Standard, UHD. This info can be adjusted in Icon designed.&] +[s0; &] +[s0; U`+`+ can be switched to [^topic`:`/`/Draw`/src`/UHD`$en`-us`#Upp`:`:SetUHDMode`(bool`)^ `" +UHD`" mode]. In this mode, if icon is retrieved from .iml and +it is in Standard resolution, it is upscaled 2x (relatively smart +algorithm is used so that it looks quite fine on UHD display). +Correspondingly, in standard mode, UHD resolution icons are downscaled.&] +[s0; &] +[s0; UHD is normally activated when standard icon height is greater +than 22.&] +[s0; &] +[s0; In addition to Zx/Zy/Zsz functions, U`+`+ also provides set +of [^topic`:`/`/Draw`/src`/UHD`$en`-us^ DPI functions] which simply +double arguments when UHD mode is active `- this is sometimes +better approach for scaling things that are related to icons.&] +[s0; &] +[s0; Last but not least, some host platforms (Windows) need to be +specifically informed that the application is able to handle +UHD. You can do this using Ctrl`::SetUHDEnabled.]] \ No newline at end of file diff --git a/uppsrc/CtrlLib/ChWin32.cpp b/uppsrc/CtrlLib/ChWin32.cpp index 5de9a18eb..7c73beea7 100644 --- a/uppsrc/CtrlLib/ChWin32.cpp +++ b/uppsrc/CtrlLib/ChWin32.cpp @@ -598,7 +598,7 @@ void ChSysInit() BOOL (STDAPICALLTYPE * SetProcessDPIAware)(void); DllFn(SetProcessDPIAware, "User32.dll", "SetProcessDPIAware"); - if(SetProcessDPIAware && Ctrl::IsHiDPIEnabled()) + if(SetProcessDPIAware && Ctrl::IsUHDEnabled()) (*SetProcessDPIAware)(); NONCLIENTMETRICS ncm; #if (WINVER >= 0x0600 && !defined(__MINGW32_VERSION)) diff --git a/uppsrc/Draw/ImageOp.h b/uppsrc/Draw/ImageOp.h index 84efece30..439c2b84e 100644 --- a/uppsrc/Draw/ImageOp.h +++ b/uppsrc/Draw/ImageOp.h @@ -195,11 +195,6 @@ Image CachedRescalePaintOnly(const Image& m, Size sz, int filter = Null); Image CachedSetColorKeepAlpha(const Image& img, Color color); Image CachedSetColorKeepAlphaPaintOnly(const Image& img, Color color); -// Obsolete, replace with RescaleFilter! -Image RescaleBicubic(const Image& src, Size sz, const Rect& src_rc, Gate2 progress = false); -Image RescaleBicubic(const Image& img, Size sz, Gate2 progress = false); -Image RescaleBicubic(const Image& img, int cx, int cy, Gate2 progress = false); - void SetUHDMode(bool b = true); bool IsUHDMode(); void SyncUHDMode(); @@ -209,3 +204,8 @@ Image DPI(const Image& img, int expected); inline int DPI(int a) { return IsUHDMode() ? 2 * a : a; } inline Size DPI(Size sz) { return IsUHDMode() ? 2 * sz : sz; } + +// Obsolete, replace with RescaleFilter! +Image RescaleBicubic(const Image& src, Size sz, const Rect& src_rc, Gate2 progress = false); +Image RescaleBicubic(const Image& img, Size sz, Gate2 progress = false); +Image RescaleBicubic(const Image& img, int cx, int cy, Gate2 progress = false); diff --git a/uppsrc/ide/idewin.cpp b/uppsrc/ide/idewin.cpp index f6fddb0f5..e4dc5c068 100644 --- a/uppsrc/ide/idewin.cpp +++ b/uppsrc/ide/idewin.cpp @@ -733,7 +733,7 @@ GUI_APP_MAIN void AppMain___() #endif { - Ctrl::SetHiDPIEnabled(); + Ctrl::SetUHDEnabled(); SetLanguage(LNG_ENGLISH); SetDefaultCharset(CHARSET_UTF8);