From 94c066a34900845297c41c134a9a910124a5833d Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 16 Sep 2018 23:48:54 +0800 Subject: Develop toggle button. --- CruUI/graph/graph.cpp | 8 ++++++++ CruUI/graph/graph.h | 11 +++++++++++ 2 files changed, 19 insertions(+) (limited to 'CruUI/graph') diff --git a/CruUI/graph/graph.cpp b/CruUI/graph/graph.cpp index 00d5137d..94c7029e 100644 --- a/CruUI/graph/graph.cpp +++ b/CruUI/graph/graph.cpp @@ -213,5 +213,13 @@ namespace cru { d2d1_factory_->ReloadSystemMetrics() ); } + + ComPtr CreateSolidBrush(const D2D1_COLOR_F& color) + { + const auto device_context = graph::GraphManager::GetInstance()->GetD2D1DeviceContext(); + ComPtr solid_color_brush; + device_context->CreateSolidColorBrush(color, &solid_color_brush); + return solid_color_brush; + } } } diff --git a/CruUI/graph/graph.h b/CruUI/graph/graph.h index 990b51b3..fd062787 100644 --- a/CruUI/graph/graph.h +++ b/CruUI/graph/graph.h @@ -164,5 +164,16 @@ namespace cru { return graph_manager_->GetD2D1DeviceContext(); } + + Microsoft::WRL::ComPtr CreateSolidBrush(const D2D1_COLOR_F& color); + + inline void WithTransform(ID2D1DeviceContext* device_context, const D2D1_MATRIX_3X2_F matrix, Action&& action) + { + D2D1_MATRIX_3X2_F old_transform; + device_context->GetTransform(&old_transform); + device_context->SetTransform(old_transform * matrix); + action(device_context); + device_context->SetTransform(old_transform); + } } } -- cgit v1.2.3