From dae9d4bf88d2307cd4c30ec2eecf32ee3c0ff22d Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 18 Feb 2020 17:53:02 +0000 Subject: [PATCH] Core: Vector::operator<<(T&&) (thanks Novo) git-svn-id: svn://ultimatepp.org/upp/trunk@14034 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Vcont.h | 1 + uppsrc/Core/src.tpp/Vector_en-us.tpp | 14 +++++++++++--- uppsrc/CtrlCore/ToDo.txt | 2 +- uppsrc/CtrlLib/CtrlUtil.h | 4 ++-- uppsrc/ide/LayDes/item.cpp | 12 ++++++++++-- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/uppsrc/Core/Vcont.h b/uppsrc/Core/Vcont.h index 521626678..9dbcc9235 100644 --- a/uppsrc/Core/Vcont.h +++ b/uppsrc/Core/Vcont.h @@ -195,6 +195,7 @@ public: operator const T*() const { return (T*)vector; } Vector& operator<<(const T& x) { Add(x); return *this; } + Vector& operator<<(T&& x) { Add(pick(x)); return *this; } #ifdef UPP void Serialize(Stream& s) { StreamContainer(s, *this); } diff --git a/uppsrc/Core/src.tpp/Vector_en-us.tpp b/uppsrc/Core/src.tpp/Vector_en-us.tpp index 0ae2c744e..508715baf 100644 --- a/uppsrc/Core/src.tpp/Vector_en-us.tpp +++ b/uppsrc/Core/src.tpp/Vector_en-us.tpp @@ -463,16 +463,24 @@ onst]&] [s4;%- &] [s5;:Vector`:`:operator`<`<`(const T`&`):%- [_^Vector^ Vector][@(0.0.255) `&]_[* operator<< ]([@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&] -[s2; Operator replacement of [* void Add(const T`&x)]. By returning +[s2; Operator equivalent of [* void Add(const T`&x)]. By returning reference to to Vector allows adding more elements in single expression, thus e.g. allowing to construct temporary Vector as part of expression like Foo((Vector() << 1 << 2 << 4)).&] [s6; Requires T to have deep copy constructor.&] [s6; Invalidates iterators and references to Vector.&] -[s7; [*C@3 x]-|The value that is copied to newly created element.&] -[s7; [*/ Return value]-|Reference to Vector (`*this).&] [s3;%- &] [s4;%- &] +[s5;:Upp`:`:Vector`:`:operator`<`<`(T`&`&`):%- [_^Upp`:`:Vector^ Vector][@(0.0.255) `&]_[* o +perator<<]([*@4 T][@(0.0.255) `&`&]_[*@3 x])&] +[s2; Operator equivalent of [* void Add(TT`&x)]. By returning reference +to to Vector allows adding more elements in single expression, +thus e.g. allowing to construct temporary Vector as part of expression +like.&] +[s6; Requires T to have deep copy constructor.&] +[s6; Invalidates iterators and references to Vector.&] +[s3; &] +[s4;%- &] [s5;:Vector`:`:ToString`(`)const:%- [_^String^ String]_[* ToString]()_[@(0.0.255) const]&] [s2; Converts container into String, mostly for debugging purposes.&] [s3;%- &] diff --git a/uppsrc/CtrlCore/ToDo.txt b/uppsrc/CtrlCore/ToDo.txt index 436da5360..e23fc6dfd 100644 --- a/uppsrc/CtrlCore/ToDo.txt +++ b/uppsrc/CtrlCore/ToDo.txt @@ -2,7 +2,6 @@ - Inactive doc icon is not updated - [B] does not blink anymore - Make allocator work - MacOS crash when adding Label to TestChStyles -- Unknown layout type should have better visual NTH: @@ -19,6 +18,7 @@ DONE: - Classic is broken - ClassicCtrlsImg - Ide: When dark editor in light theme, svn history is invisible (as text is white) +- Unknown layout type should have better visual macos done: diff --git a/uppsrc/CtrlLib/CtrlUtil.h b/uppsrc/CtrlLib/CtrlUtil.h index 383786d63..3697ba2d5 100644 --- a/uppsrc/CtrlLib/CtrlUtil.h +++ b/uppsrc/CtrlLib/CtrlUtil.h @@ -346,7 +346,7 @@ public: FileSelNative(); }; -typedef FileSelector FileSelNative; +typedef FileSelNative FileSelector; #endif #endif @@ -394,7 +394,7 @@ public: FileSelNative(); }; -typedef FileSelector FileSelNative; +typedef FileSelNative FileSelector; #endif class CtrlMapper { diff --git a/uppsrc/ide/LayDes/item.cpp b/uppsrc/ide/LayDes/item.cpp index de166fc78..fb3c25fde 100644 --- a/uppsrc/ide/LayDes/item.cpp +++ b/uppsrc/ide/LayDes/item.cpp @@ -222,9 +222,17 @@ void LayoutItem::UnknownPaint(Draw& w) int q = FindProperty("SetLabel"); if(q >= 0 && IsString(~property[q])) DrawSmartText(w, 0, 0, csize.cx, ToUtf8((WString)~property[q])); - Size tsz = GetTextSize(type, LayFont()); + Font fnt = LayFont(); + String s = type; + Color ink = White(); + if(IsNull(s)) { + s = "Untyped"; + fnt.Italic(); + ink = LtCyan(); + } + Size tsz = GetTextSize(s, fnt); w.DrawRect(csize.cx - tsz.cx - tsz.cy, csize.cy - tsz.cy, tsz.cx + tsz.cy, tsz.cy, SGray()); - w.DrawText(csize.cx - tsz.cx - tsz.cy / 2, csize.cy - tsz.cy, type, LayFont(), White()); + w.DrawText(csize.cx - tsz.cx - tsz.cy / 2, csize.cy - tsz.cy, s, fnt, ink); } void LayoutItem::CreateMethods(EscValue& ctrl, const String& type, bool copy) const