From 22322daf6f51da53740ff95ef2eaceed9a6efcae Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 25 Nov 2018 22:57:07 +0800 Subject: Develop basic functions of ScrollControl. --- src/main.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 376c03b8..5cc98a72 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,7 @@ #include "ui/controls/list_item.hpp" #include "ui/controls/popup_menu.hpp" #include "ui/controls/frame_layout.hpp" +#include "ui/controls/scroll_control.hpp" #include "graph/graph.hpp" using cru::String; @@ -27,6 +28,7 @@ using cru::ui::controls::Button; using cru::ui::controls::TextBox; using cru::ui::controls::ListItem; using cru::ui::controls::FrameLayout; +using cru::ui::controls::ScrollControl; int APIENTRY wWinMain( HINSTANCE hInstance, @@ -183,9 +185,16 @@ int APIENTRY wWinMain( } { - const auto text_block = CreateWithLayout(LayoutSideParams::Stretch(), LayoutSideParams::Stretch(), L"This is a very very very very very long sentence!!!"); + const auto scroll_view = CreateWithLayout(LayoutSideParams::Stretch(), LayoutSideParams::Stretch()); + + scroll_view->SetVerticalScrollBarVisibility(ScrollControl::ScrollBarVisibility::Always); + + const auto text_block = TextBlock::Create( + L"Love myself I do. Not everything, but I love the good as well as the bad. I love my crazy lifestyle, and I love my hard discipline. I love my freedom of speech and the way my eyes get dark when I'm tired. I love that I have learned to trust people with my heart, even if it will get broken. I am proud of everything that I am and will become."); text_block->SetSelectable(true); - layout->AddChild(text_block); + + scroll_view->AddChild(text_block); + layout->AddChild(scroll_view); } layout->AddChild(CreateWithLayout(LayoutSideParams::Content(Alignment::Start), LayoutSideParams::Content(), L"This is a little short sentence!!!")); -- cgit v1.2.3 From b88992fd00df7b8c243bc0e7d577ef2aa9437c3f Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 25 Nov 2018 23:11:06 +0800 Subject: Reorganize headers and add memory leak check. --- CruUI.vcxproj | 2 +- CruUI.vcxproj.filters | 6 +++--- src/any_map.hpp | 3 +++ src/application.hpp | 3 +++ src/base.hpp | 3 +-- src/cru_debug.hpp | 3 +++ src/cru_event.hpp | 3 +++ src/exception.hpp | 3 +++ src/format.hpp | 3 +++ src/global_macros.hpp | 9 --------- src/graph/graph.hpp | 3 +++ src/main.cpp | 7 ++++++- src/math_util.hpp | 3 +++ src/pre.hpp | 18 ++++++++++++++++++ src/system_headers.hpp | 2 ++ src/timer.hpp | 2 ++ src/ui/animations/animation.hpp | 3 +++ src/ui/border_property.hpp | 3 +++ src/ui/control.hpp | 3 +++ src/ui/controls/button.hpp | 3 +++ src/ui/controls/frame_layout.hpp | 3 +++ src/ui/controls/linear_layout.hpp | 3 +++ src/ui/controls/list_item.hpp | 3 +++ src/ui/controls/popup_menu.hpp | 3 +++ src/ui/controls/scroll_control.hpp | 3 +++ src/ui/controls/text_block.hpp | 3 +++ src/ui/controls/text_box.hpp | 3 +++ src/ui/controls/text_control.hpp | 3 +++ src/ui/controls/toggle_button.hpp | 3 +++ src/ui/convert_util.hpp | 3 +++ src/ui/cursor.hpp | 3 +++ src/ui/events/ui_event.hpp | 3 +++ src/ui/layout_base.hpp | 3 +++ src/ui/ui_base.hpp | 3 +++ src/ui/ui_manager.hpp | 3 +++ src/ui/window.hpp | 3 +++ 36 files changed, 117 insertions(+), 16 deletions(-) delete mode 100644 src/global_macros.hpp create mode 100644 src/pre.hpp (limited to 'src/main.cpp') diff --git a/CruUI.vcxproj b/CruUI.vcxproj index c397f1d0..30f39f28 100644 --- a/CruUI.vcxproj +++ b/CruUI.vcxproj @@ -159,7 +159,7 @@ - + diff --git a/CruUI.vcxproj.filters b/CruUI.vcxproj.filters index 7852404c..71025931 100644 --- a/CruUI.vcxproj.filters +++ b/CruUI.vcxproj.filters @@ -158,9 +158,6 @@ Header Files - - Header Files - Header Files @@ -191,6 +188,9 @@ Header Files + + Header Files + diff --git a/src/any_map.hpp b/src/any_map.hpp index ea6044b1..dfc54f3f 100644 --- a/src/any_map.hpp +++ b/src/any_map.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include #include #include diff --git a/src/application.hpp b/src/application.hpp index b9427826..a8d59cc8 100644 --- a/src/application.hpp +++ b/src/application.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "system_headers.hpp" #include #include diff --git a/src/base.hpp b/src/base.hpp index fdd736a0..64ce7f6e 100644 --- a/src/base.hpp +++ b/src/base.hpp @@ -1,8 +1,7 @@ #pragma once // ReSharper disable once CppUnusedIncludeDirective -#include "global_macros.hpp" - +#include "pre.hpp" #include #include diff --git a/src/cru_debug.hpp b/src/cru_debug.hpp index ed6fcaf6..17cc7b53 100644 --- a/src/cru_debug.hpp +++ b/src/cru_debug.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include #include "base.hpp" diff --git a/src/cru_event.hpp b/src/cru_event.hpp index 76a36b22..69832a0e 100644 --- a/src/cru_event.hpp +++ b/src/cru_event.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include #include #include diff --git a/src/exception.hpp b/src/exception.hpp index 68558478..b8cef604 100644 --- a/src/exception.hpp +++ b/src/exception.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "system_headers.hpp" #include diff --git a/src/format.hpp b/src/format.hpp index 3f6253ff..efd25f89 100644 --- a/src/format.hpp +++ b/src/format.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "base.hpp" namespace cru diff --git a/src/global_macros.hpp b/src/global_macros.hpp deleted file mode 100644 index eda57187..00000000 --- a/src/global_macros.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#ifdef _DEBUG -#define CRU_DEBUG -#endif - -#ifdef CRU_DEBUG -#define CRU_DEBUG_LAYOUT -#endif diff --git a/src/graph/graph.hpp b/src/graph/graph.hpp index 7771b48f..440b0594 100644 --- a/src/graph/graph.hpp +++ b/src/graph/graph.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "system_headers.hpp" #include #include diff --git a/src/main.cpp b/src/main.cpp index 5cc98a72..7b27d95e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,5 @@ +#include "pre.hpp" + #include "application.hpp" #include "ui/window.hpp" #include "ui/controls/linear_layout.hpp" @@ -36,6 +38,10 @@ int APIENTRY wWinMain( LPWSTR lpCmdLine, int nCmdShow) { +#ifdef CRU_DEBUG + _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); +#endif + Application application(hInstance); const auto window = Window::CreateOverlapped(); @@ -225,7 +231,6 @@ int APIENTRY wWinMain( window.AddChild(linear_layout); */ - window->Show(); return application.Run(); diff --git a/src/math_util.hpp b/src/math_util.hpp index 7b286346..b9830d6b 100644 --- a/src/math_util.hpp +++ b/src/math_util.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + // ReSharper disable once CppUnusedIncludeDirective #include #include diff --git a/src/pre.hpp b/src/pre.hpp new file mode 100644 index 00000000..03c51a94 --- /dev/null +++ b/src/pre.hpp @@ -0,0 +1,18 @@ +#pragma once + +#ifdef _DEBUG +#define CRU_DEBUG +#endif + +#ifdef CRU_DEBUG +#define CRU_DEBUG_LAYOUT +#endif + + +#ifdef CRU_DEBUG +// ReSharper disable once IdentifierTypo +// ReSharper disable once CppInconsistentNaming +#define _CRTDBG_MAP_ALLOC +#include +#include +#endif diff --git a/src/system_headers.hpp b/src/system_headers.hpp index d471678a..eabc7c25 100644 --- a/src/system_headers.hpp +++ b/src/system_headers.hpp @@ -1,5 +1,7 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" //include system headers diff --git a/src/timer.hpp b/src/timer.hpp index 3488db45..5055a3d8 100644 --- a/src/timer.hpp +++ b/src/timer.hpp @@ -1,5 +1,7 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" #include "system_headers.hpp" #include diff --git a/src/ui/animations/animation.hpp b/src/ui/animations/animation.hpp index f25e4699..2226f021 100644 --- a/src/ui/animations/animation.hpp +++ b/src/ui/animations/animation.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include #include "base.hpp" diff --git a/src/ui/border_property.hpp b/src/ui/border_property.hpp index 7766f5a3..4dee0e0f 100644 --- a/src/ui/border_property.hpp +++ b/src/ui/border_property.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "system_headers.hpp" #include "base.hpp" diff --git a/src/ui/control.hpp b/src/ui/control.hpp index 1ce4afe3..5f5285b6 100644 --- a/src/ui/control.hpp +++ b/src/ui/control.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "system_headers.hpp" #include #include diff --git a/src/ui/controls/button.hpp b/src/ui/controls/button.hpp index 50640b11..c53f7ed9 100644 --- a/src/ui/controls/button.hpp +++ b/src/ui/controls/button.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include #include "ui/control.hpp" diff --git a/src/ui/controls/frame_layout.hpp b/src/ui/controls/frame_layout.hpp index ca022780..45971584 100644 --- a/src/ui/controls/frame_layout.hpp +++ b/src/ui/controls/frame_layout.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include #include "ui/control.hpp" diff --git a/src/ui/controls/linear_layout.hpp b/src/ui/controls/linear_layout.hpp index b7ca42ec..deb51bd1 100644 --- a/src/ui/controls/linear_layout.hpp +++ b/src/ui/controls/linear_layout.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "ui/control.hpp" namespace cru::ui::controls diff --git a/src/ui/controls/list_item.hpp b/src/ui/controls/list_item.hpp index 1de89b5f..a77d13e6 100644 --- a/src/ui/controls/list_item.hpp +++ b/src/ui/controls/list_item.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include #include diff --git a/src/ui/controls/popup_menu.hpp b/src/ui/controls/popup_menu.hpp index d47e3eb6..a2916590 100644 --- a/src/ui/controls/popup_menu.hpp +++ b/src/ui/controls/popup_menu.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include #include #include diff --git a/src/ui/controls/scroll_control.hpp b/src/ui/controls/scroll_control.hpp index faf192ad..76762f21 100644 --- a/src/ui/controls/scroll_control.hpp +++ b/src/ui/controls/scroll_control.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include #include diff --git a/src/ui/controls/text_block.hpp b/src/ui/controls/text_block.hpp index 4d017da5..66f5defa 100644 --- a/src/ui/controls/text_block.hpp +++ b/src/ui/controls/text_block.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "text_control.hpp" namespace cru::ui::controls diff --git a/src/ui/controls/text_box.hpp b/src/ui/controls/text_box.hpp index 65f81fc3..3a30ecb2 100644 --- a/src/ui/controls/text_box.hpp +++ b/src/ui/controls/text_box.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "text_control.hpp" #include "timer.hpp" diff --git a/src/ui/controls/text_control.hpp b/src/ui/controls/text_control.hpp index 93120a44..762d85f3 100644 --- a/src/ui/controls/text_control.hpp +++ b/src/ui/controls/text_control.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "ui/control.hpp" namespace cru::ui::controls diff --git a/src/ui/controls/toggle_button.hpp b/src/ui/controls/toggle_button.hpp index 5de40ca5..4cbb4f37 100644 --- a/src/ui/controls/toggle_button.hpp +++ b/src/ui/controls/toggle_button.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "ui/control.hpp" namespace cru::ui::controls diff --git a/src/ui/convert_util.hpp b/src/ui/convert_util.hpp index 6deb7fff..5408f2e4 100644 --- a/src/ui/convert_util.hpp +++ b/src/ui/convert_util.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "system_headers.hpp" #include "ui_base.hpp" diff --git a/src/ui/cursor.hpp b/src/ui/cursor.hpp index 0b056365..273e524d 100644 --- a/src/ui/cursor.hpp +++ b/src/ui/cursor.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "system_headers.hpp" #include diff --git a/src/ui/events/ui_event.hpp b/src/ui/events/ui_event.hpp index c0585506..cc651832 100644 --- a/src/ui/events/ui_event.hpp +++ b/src/ui/events/ui_event.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "system_headers.hpp" #include diff --git a/src/ui/layout_base.hpp b/src/ui/layout_base.hpp index 7ae6f65c..2ae21837 100644 --- a/src/ui/layout_base.hpp +++ b/src/ui/layout_base.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include #include "base.hpp" diff --git a/src/ui/ui_base.hpp b/src/ui/ui_base.hpp index aaba343e..b898b2ed 100644 --- a/src/ui/ui_base.hpp +++ b/src/ui/ui_base.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include diff --git a/src/ui/ui_manager.hpp b/src/ui/ui_manager.hpp index 9ad68eff..f0e1e8ce 100644 --- a/src/ui/ui_manager.hpp +++ b/src/ui/ui_manager.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "system_headers.hpp" #include "base.hpp" diff --git a/src/ui/window.hpp b/src/ui/window.hpp index a3fba57a..7c82bf89 100644 --- a/src/ui/window.hpp +++ b/src/ui/window.hpp @@ -1,5 +1,8 @@ #pragma once +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + #include "system_headers.hpp" #include #include -- cgit v1.2.3