aboutsummaryrefslogtreecommitdiff
path: root/CruUI/ui/controls/text_block.h
diff options
context:
space:
mode:
Diffstat (limited to 'CruUI/ui/controls/text_block.h')
-rw-r--r--CruUI/ui/controls/text_block.h17
1 files changed, 5 insertions, 12 deletions
diff --git a/CruUI/ui/controls/text_block.h b/CruUI/ui/controls/text_block.h
index db22e3c7..3fed2283 100644
--- a/CruUI/ui/controls/text_block.h
+++ b/CruUI/ui/controls/text_block.h
@@ -39,7 +39,7 @@ namespace cru
class TextBlock : public Control
{
public:
- using TextLayoutHandler = Action<Microsoft::WRL::ComPtr<IDWriteTextLayout>>;
+ using TextLayoutHandlerPtr = FunctionPtr<void(Microsoft::WRL::ComPtr<IDWriteTextLayout>)>;
static TextBlock* Create(
const String& text = L"",
@@ -85,16 +85,9 @@ namespace cru
void SetTextFormat(const Microsoft::WRL::ComPtr<IDWriteTextFormat>& text_format);
- void AddTextLayoutHandler(std::shared_ptr<TextLayoutHandler> handler)
- {
- text_layout_handlers_.push_back(std::move(handler));
- }
- void RemoveTextLayoutHandler(const std::shared_ptr<TextLayoutHandler>& handler)
- {
- const auto find_result = std::find(text_layout_handlers_.cbegin(), text_layout_handlers_.cend(), handler);
- if (find_result != text_layout_handlers_.cend())
- text_layout_handlers_.erase(find_result);
- }
+ void AddTextLayoutHandler(TextLayoutHandlerPtr handler);
+
+ void RemoveTextLayoutHandler(const TextLayoutHandlerPtr& handler);
protected:
void OnSizeChangedCore(events::SizeChangedEventArgs& args) override final;
@@ -122,7 +115,7 @@ namespace cru
Microsoft::WRL::ComPtr<IDWriteTextFormat> text_format_;
Microsoft::WRL::ComPtr<IDWriteTextLayout> text_layout_;
- Vector<std::shared_ptr<TextLayoutHandler>> text_layout_handlers_;
+ Vector<TextLayoutHandlerPtr> text_layout_handlers_;
bool is_selecting_ = false;
unsigned mouse_down_position_ = 0;