aboutsummaryrefslogtreecommitdiff
path: root/CruUI/ui/controls/text_block.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-09-10 00:09:52 +0800
committercrupest <crupest@outlook.com>2018-09-10 00:09:52 +0800
commitaa8ba64f4f580552ba14325dd3e04f38a3c9a1de (patch)
treecde762da1a0bfb24c28a8a3dfa5253ad95a5b809 /CruUI/ui/controls/text_block.cpp
parent74031db4b8c366531db5be8fa8d765483ab377b0 (diff)
downloadcru-aa8ba64f4f580552ba14325dd3e04f38a3c9a1de.tar.gz
cru-aa8ba64f4f580552ba14325dd3e04f38a3c9a1de.tar.bz2
cru-aa8ba64f4f580552ba14325dd3e04f38a3c9a1de.zip
...
Diffstat (limited to 'CruUI/ui/controls/text_block.cpp')
-rw-r--r--CruUI/ui/controls/text_block.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/CruUI/ui/controls/text_block.cpp b/CruUI/ui/controls/text_block.cpp
index 3649aea6..d15bd681 100644
--- a/CruUI/ui/controls/text_block.cpp
+++ b/CruUI/ui/controls/text_block.cpp
@@ -1,5 +1,7 @@
#include "text_block.h"
+#include <chrono>
+
#include "ui/window.h"
#include "graph/graph.h"
#include "exception.h"
@@ -27,9 +29,12 @@ namespace cru
void TextBlock::SetText(const String& text)
{
- const auto old_text = text_;
- text_ = text;
- OnTextChangedCore(old_text, text);
+ if (text_ != text)
+ {
+ const auto old_text = text_;
+ text_ = text;
+ OnTextChangedCore(old_text, text);
+ }
}
void TextBlock::SetBrush(const Microsoft::WRL::ComPtr<ID2D1Brush>& brush)
@@ -47,8 +52,12 @@ namespace cru
void TextBlock::OnSizeChangedCore(events::SizeChangedEventArgs& args)
{
+ auto before = std::chrono::steady_clock::now();
RecreateTextLayout();
Repaint();
+ auto after = std::chrono::steady_clock::now();
+ OutputDebugStringW((L"TextBlock OnSizeChangedCore time duration:" + std::to_wstring(std::chrono::duration_cast<std::chrono::milliseconds>(after - before).count()) + L"\n").c_str());
+
}
void TextBlock::OnDraw(ID2D1DeviceContext* device_context)