From cb7386bb8ae50da06d5ef7a8bec0325cd0adb5b5 Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 9 Jan 2019 10:58:40 +0000 Subject: [PATCH] ide: Fixed LayDes Lbl/Var popup wrong size issue git-svn-id: svn://ultimatepp.org/upp/trunk@12656 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/uhdtodo.txt | 2 +- uppsrc/CtrlLib/DisplayPopup.cpp | 3 -- uppsrc/ide/LayDes/laydes.cpp | 75 ++++++++++++++------------------- 3 files changed, 32 insertions(+), 48 deletions(-) diff --git a/uppsrc/CtrlCore/uhdtodo.txt b/uppsrc/CtrlCore/uhdtodo.txt index 33872243e..4372ca533 100644 --- a/uppsrc/CtrlCore/uhdtodo.txt +++ b/uppsrc/CtrlCore/uhdtodo.txt @@ -3,7 +3,6 @@ UHD IconDes paste over CheckBox in layout designer Left-right cursor image weird miniborder (OpenWind only) -GTK is total mess, question is whether we should fix it... ------------------------------------ Progress cutoff of text @@ -28,3 +27,4 @@ SetLabel for switch is too small (scale usc number) Nos Galerie CheckBox Non-UHD testing mode Select product Nos icons +GTK is total mess, question is whether we should fix it... diff --git a/uppsrc/CtrlLib/DisplayPopup.cpp b/uppsrc/CtrlLib/DisplayPopup.cpp index e5a8a9c00..c0e729df2 100644 --- a/uppsrc/CtrlLib/DisplayPopup.cpp +++ b/uppsrc/CtrlLib/DisplayPopup.cpp @@ -14,7 +14,6 @@ void DisplayPopup::LeftDown(Point p, dword flags) void DisplayPopup::LeftDrag(Point p, dword flags) { - DLOG("LeftDrag"); ctrl->LeftDrag(Op(p), flags); } @@ -54,8 +53,6 @@ void DisplayPopup::Paint(Draw& w) { Rect r = GetSize(); w.DrawRect(r, SColorPaper); - DDUMP(display); - DDUMP(value); if(display) { display->PaintBackground(w, r, value, ink, paper, style); r.left += margin; diff --git a/uppsrc/ide/LayDes/laydes.cpp b/uppsrc/ide/LayDes/laydes.cpp index f6ec61a1d..9332bb992 100644 --- a/uppsrc/ide/LayDes/laydes.cpp +++ b/uppsrc/ide/LayDes/laydes.cpp @@ -363,56 +363,43 @@ Ctrl::LogPos MakeLogPos(Ctrl::LogPos p, const Rect& r, Size sz) struct IDisplay : public Display { Color paper, ink; + Font font; + + Size GetStdSize(const Value& q) const { + Size sz = GetSmartTextSize(~q, font); + sz.cx += 2 * DPI(4); + return sz; + } + void Paint(Draw& w, const Rect& r, const Value& q, Color, Color, dword s) const { w.DrawRect(r, paper); - DrawSmartText(w, r.left + 8, r.top, r.Width(), - String(IsString(q) ? q : StdConvert().Format(q)), StdFont(), ink); + DrawSmartText(w, r.left + DPI(4), r.top, r.Width(), ~q, font, ink); } - IDisplay(Color paper, Color ink) - : paper(paper), ink(ink) {} + IDisplay(Color paper, Color ink, Font font = StdFont()) + : paper(paper), ink(ink), font(font) {} }; struct TDisplay : public Display { Color paper, ink; + Font font; + + Size GetStdSize(const Value& q) const { + Size sz = GetSmartTextSize(~q, font); + sz.cx += 2 * DPI(4) + DPI(6) + sz.cy * 8 / 3; + return sz; + } void Paint(Draw& w, const Rect& r, const Value& q, Color, Color, dword s) const { w.DrawRect(r, paper); int dx = r.Height() * 8 / 3; Image icon = GetTypeIcon(String(q), dx, r.Height(), 1, paper); - w.DrawImage(r.left + 8, r.top + (r.Height() - icon.GetSize().cy) / 2, icon); - DrawSmartText(w, r.left + dx + 12, r.top, r.Width(), String(q), StdFont(), ink); + w.DrawImage(r.left + DPI(4), r.top + (r.Height() - icon.GetSize().cy) / 2, icon); + DrawSmartText(w, r.left + dx + DPI(6), r.top, r.Width(), ~q, font, ink); } - TDisplay(Color paper, Color ink) - : paper(paper), ink(ink) {} -}; - -struct IDisplayH : public Display { - Color paper, ink; - void Paint(Draw& w, const Rect& r, const Value& q, - Color, Color, dword s) const { - w.DrawRect(r, paper); - DrawSmartText(w, r.left + 8, r.top, r.Width(), - String(IsString(q) ? q : StdConvert().Format(q)), StdFont().Italic(), ink); - } - IDisplayH(Color paper, Color ink) - : paper(paper), ink(ink) {} -}; - -struct TDisplayH : public Display { - Color paper, ink; - - void Paint(Draw& w, const Rect& r, const Value& q, - Color, Color, dword s) const { - w.DrawRect(r, paper); - int dx = r.Height() * 8 / 3; - Image icon = GetTypeIcon(String(q), dx, r.Height(), 1, paper); - w.DrawImage(r.left + 8, r.top + (r.Height() - icon.GetSize().cy) / 2, icon); - DrawSmartText(w, r.left + dx + 12, r.top, r.Width(), String(q), StdFont().Italic(), ink); - } - TDisplayH(Color paper, Color ink) - : paper(paper), ink(ink) {} + TDisplay(Color paper, Color ink, Font font = StdFont()) + : paper(paper), ink(ink), font(font) {} }; void LayDes::SyncItems() @@ -438,15 +425,15 @@ void LayDes::SyncItems() void LayDes::SyncItem(int i, int style) { if(CurrentLayout().item[i].hide) { - static IDisplayH dnormal(SColorPaper, SColorText); - static IDisplayH dselect(SColorLtFace, SColorText); - static IDisplayH dcursor(SColorFace, SColorText); - static TDisplayH tnormal(SColorPaper, SColorText); - static TDisplayH tselect(SColorLtFace, SColorText); - static TDisplayH tcursor(SColorFace, SColorText); - static IDisplayH lnormal(SColorPaper, Green); - static IDisplayH lselect(SColorLtFace, Green); - static IDisplayH lcursor(SColorFace, Green); + static IDisplay dnormal(SColorPaper, SColorText, StdFont().Italic()); + static IDisplay dselect(SColorLtFace, SColorText, StdFont().Italic()); + static IDisplay dcursor(SColorFace, SColorText, StdFont().Italic()); + static TDisplay tnormal(SColorPaper, SColorText, StdFont().Italic()); + static TDisplay tselect(SColorLtFace, SColorText, StdFont().Italic()); + static TDisplay tcursor(SColorFace, SColorText, StdFont().Italic()); + static IDisplay lnormal(SColorPaper, Green, StdFont().Italic()); + static IDisplay lselect(SColorLtFace, Green, StdFont().Italic()); + static IDisplay lcursor(SColorFace, Green, StdFont().Italic()); const Display *noicon[] = { &dnormal, &dselect, &dcursor }; const Display *isicon[] = { &tnormal, &tselect, &tcursor }; const Display *label[] = { &lnormal, &lselect, &lcursor };