diff --git a/uppsrc/CtrlLib/EditCtrl.h b/uppsrc/CtrlLib/EditCtrl.h index 7665d97c5..0b5c609c9 100644 --- a/uppsrc/CtrlLib/EditCtrl.h +++ b/uppsrc/CtrlLib/EditCtrl.h @@ -144,7 +144,7 @@ protected: void RefreshAll(); int LowChar(int c) const { return 0x25af /*c + 0x2400*/; } int GetCharWidth(int c) const { return font[c < 32 ? LowChar(c) : c]; } - int GetTextCx(const wchar *text, int n, bool password, Font fnt) const; + int GetTextCx(const wchar *text, int n, bool password) const; void Paints(Draw& w, int& x, int fcy, const wchar *&txt, Color ink, Color paper, int n, bool pwd, Font fnt, Color underline, bool showspaces); int GetStringCx(const wchar *text, int n); diff --git a/uppsrc/CtrlLib/EditField.cpp b/uppsrc/CtrlLib/EditField.cpp index fe37a6ba9..611e0714f 100644 --- a/uppsrc/CtrlLib/EditField.cpp +++ b/uppsrc/CtrlLib/EditField.cpp @@ -148,7 +148,7 @@ void EditField::CancelMode() dropcaret.Clear(); } -int EditField::GetTextCx(const wchar *txt, int n, bool password, Font fnt) const +int EditField::GetTextCx(const wchar *txt, int n, bool password) const { if(password) return n * font['*']; @@ -161,7 +161,7 @@ int EditField::GetTextCx(const wchar *txt, int n, bool password, Font fnt) const int EditField::GetCaret(int cursor) const { - return GetTextCx(text, cursor, password, font); + return GetTextCx(text, cursor, password); } int EditField::GetViewHeight(Font font) @@ -250,7 +250,7 @@ void EditField::Paints(Draw& w, int& x, int fcy, const wchar *&txt, bool showspaces) { if(n < 0) return; - int cx = GetTextCx(txt, n, password, font); + int cx = GetTextCx(txt, n, password); w.DrawRect(x, 0, cx, fcy, paper); if(password) { String h; diff --git a/uppsrc/Draw/Iml.cpp b/uppsrc/Draw/Iml.cpp index 2ff8cbe60..d5a65ca70 100644 --- a/uppsrc/Draw/Iml.cpp +++ b/uppsrc/Draw/Iml.cpp @@ -49,18 +49,30 @@ void Iml::Init(int n) void Iml::Reset() { - int n = map.GetCount(); - map.Clear(); - Init(n); + for(IImage& m : map) + m.loaded = false; } +static StaticMutex sImlLock; + void Iml::Set(int i, const Image& img) -{ +{ // TODO: MT map[i].image = img; map[i].loaded = true; } -static StaticMutex sImlLock; +Image Iml::Get(int i) +{ + IImage& m = map[i]; + if(!m.loaded) { + Mutex::Lock __(sImlLock); + if(!m.loaded) { + m.image = MakeImlImage(GetId(i), [&](int mode, const String& id) { return GetRaw(mode, id); }, global_flags); + m.loaded = true; + } + } + return m.image; +} ImageIml Iml::GetRaw(int mode, int i) { @@ -141,19 +153,6 @@ Image MakeImlImage(const String& id, Function G return im.image; } -Image Iml::Get(int i) -{ - IImage& m = map[i]; - if(!m.loaded) { - Mutex::Lock __(sImlLock); - if(!m.loaded) { - m.image = MakeImlImage(GetId(i), [&](int mode, const String& id) { return GetRaw(mode, id); }, global_flags); - m.loaded = true; - } - } - return m.image; -} - Iml::Iml(const char **name, int n) : name(name) { diff --git a/uppsrc/Draw/iml_header.h b/uppsrc/Draw/iml_header.h index 3e13a8dc9..be14e385c 100644 --- a/uppsrc/Draw/iml_header.h +++ b/uppsrc/Draw/iml_header.h @@ -39,8 +39,8 @@ public: static void Reset() { Iml().Reset(); } -#define IMAGE_BEGIN(n) static UPP::Image n() { return Get(I_##n); } -#define IMAGE_ID(n) static UPP::Image n() { return Get(I_##n); } +#define IMAGE_BEGIN(n) static UPP::Image n(); +#define IMAGE_ID(n) static UPP::Image n(); #include IMAGEFILE #undef IMAGE_BEGIN #undef IMAGE_ID diff --git a/uppsrc/Draw/iml_source.h b/uppsrc/Draw/iml_source.h index 5ebc84247..60f81c88e 100644 --- a/uppsrc/Draw/iml_source.h +++ b/uppsrc/Draw/iml_source.h @@ -151,6 +151,15 @@ struct COMBINE(IMAGECLASS, __Reg) { static COMBINE(IMAGECLASS, __Reg) COMBINE(IMAGECLASS, ___Reg); +#undef IMAGE_BEGIN +#undef IMAGE_ID + +#define IMAGE_BEGIN(n) UPP::Image IMAGECLASS::n() { return Get(I_##n); } +#define IMAGE_ID(n) UPP::Image IMAGECLASS::n() { return Get(I_##n); } +#include IMAGEFILE +#undef IMAGE_BEGIN +#undef IMAGE_ID + #undef IMAGE_BEGIN_DATA #undef IMAGE_DATA #undef IMAGE_END_DATA