diff options
-rw-r--r-- | CruUI/main.cpp | 14 | ||||
-rw-r--r-- | CruUI/ui/control.cpp | 4 | ||||
-rw-r--r-- | CruUI/ui/control.h | 2 | ||||
-rw-r--r-- | CruUI/ui/controls/linear_layout.cpp | 4 | ||||
-rw-r--r-- | CruUI/ui/controls/text_block.cpp | 4 | ||||
-rw-r--r-- | CruUI/ui/controls/toggle_button.cpp | 2 | ||||
-rw-r--r-- | CruUI/ui/layout_base.h | 28 |
7 files changed, 29 insertions, 29 deletions
diff --git a/CruUI/main.cpp b/CruUI/main.cpp index 0fd747a1..7f5c1d1c 100644 --- a/CruUI/main.cpp +++ b/CruUI/main.cpp @@ -11,7 +11,7 @@ using cru::String; using cru::Application; using cru::ui::Window; using cru::ui::Alignment; -using cru::ui::LayoutLength; +using cru::ui::LayoutSideParams; using cru::ui::Thickness; using cru::ui::CreateWithLayout; using cru::ui::controls::LinearLayout; @@ -76,7 +76,7 @@ int APIENTRY wWinMain( //test 2 - const auto layout = CreateWithLayout<LinearLayout>(LayoutLength::Exactly(500), LayoutLength::Content()); + const auto layout = CreateWithLayout<LinearLayout>(LayoutSideParams::Exactly(500), LayoutSideParams::Content()); layout->mouse_click_event.AddHandler([layout](cru::ui::events::MouseButtonEventArgs& args) { @@ -85,7 +85,7 @@ int APIENTRY wWinMain( }); { - const auto inner_layout = CreateWithLayout<LinearLayout>(LayoutLength::Content(Alignment::End), LayoutLength::Content(), LinearLayout::Orientation::Horizontal); + const auto inner_layout = CreateWithLayout<LinearLayout>(LayoutSideParams::Content(Alignment::End), LayoutSideParams::Content(), LinearLayout::Orientation::Horizontal); inner_layout->AddChild(TextBlock::Create(L"Toggle debug border")); @@ -106,7 +106,7 @@ int APIENTRY wWinMain( } { - const auto text_block = CreateWithLayout<TextBlock>(LayoutLength::Exactly(200), LayoutLength::Exactly(80), L"Hello World!!!"); + const auto text_block = CreateWithLayout<TextBlock>(LayoutSideParams::Exactly(200), LayoutSideParams::Exactly(80), L"Hello World!!!"); text_block->mouse_click_event.AddHandler([layout](cru::ui::events::MouseButtonEventArgs& args) { @@ -117,13 +117,13 @@ int APIENTRY wWinMain( } { - const auto text_block = CreateWithLayout<TextBlock>(LayoutLength::Stretch(), LayoutLength::Stretch(), L"This is a very very very very very long sentence!!!"); + const auto text_block = CreateWithLayout<TextBlock>(LayoutSideParams::Stretch(), LayoutSideParams::Stretch(), L"This is a very very very very very long sentence!!!"); text_block->SetSelectable(true); layout->AddChild(text_block); } - layout->AddChild(CreateWithLayout<TextBlock>(LayoutLength::Content(Alignment::Start), LayoutLength::Content(), L"This is a little short sentence!!!")); - layout->AddChild(CreateWithLayout<TextBlock>(LayoutLength::Content(Alignment::End), LayoutLength::Stretch(), L"By crupest!!!")); + layout->AddChild(CreateWithLayout<TextBlock>(LayoutSideParams::Content(Alignment::Start), LayoutSideParams::Content(), L"This is a little short sentence!!!")); + layout->AddChild(CreateWithLayout<TextBlock>(LayoutSideParams::Content(Alignment::End), LayoutSideParams::Stretch(), L"By crupest!!!")); window.AddChild(layout); diff --git a/CruUI/ui/control.cpp b/CruUI/ui/control.cpp index baf18606..25f7c028 100644 --- a/CruUI/ui/control.cpp +++ b/CruUI/ui/control.cpp @@ -513,7 +513,7 @@ namespace cru { if (!layout_params->Validate()) throw std::runtime_error("LayoutParams is not valid. Please check it."); - auto&& get_available_length_for_child = [](const LayoutLength& layout_length, const float available_length) -> float + auto&& get_available_length_for_child = [](const LayoutSideParams& layout_length, const float available_length) -> float { switch (layout_length.mode) { @@ -545,7 +545,7 @@ namespace cru { max_child_size.height = size.height; }); - auto&& calculate_final_length = [](const LayoutLength& layout_length, const float length_for_children, const float max_child_length) -> float + auto&& calculate_final_length = [](const LayoutSideParams& layout_length, const float length_for_children, const float max_child_length) -> float { switch (layout_length.mode) { diff --git a/CruUI/ui/control.h b/CruUI/ui/control.h index 3810f5ac..78261a80 100644 --- a/CruUI/ui/control.h +++ b/CruUI/ui/control.h @@ -351,7 +351,7 @@ namespace cru Control* IsAncestorOrDescendant(Control* left, Control* right); template <typename TControl, typename... Args> - TControl* CreateWithLayout(const LayoutLength& width, const LayoutLength& height, Args&&... args) + TControl* CreateWithLayout(const LayoutSideParams& width, const LayoutSideParams& height, Args&&... args) { static_assert(std::is_base_of_v<Control, TControl>, "TControl is not a control class."); TControl* control = TControl::Create(std::forward<Args>(args)...); diff --git a/CruUI/ui/controls/linear_layout.cpp b/CruUI/ui/controls/linear_layout.cpp index 22bf26e9..8f537ea8 100644 --- a/CruUI/ui/controls/linear_layout.cpp +++ b/CruUI/ui/controls/linear_layout.cpp @@ -25,7 +25,7 @@ namespace cru::ui::controls if (!layout_params->Validate()) throw std::runtime_error("LayoutParams is not valid. Please check it."); - auto&& get_available_length_for_child = [](const LayoutLength& layout_length, const float available_length) -> float + auto&& get_available_length_for_child = [](const LayoutSideParams& layout_length, const float available_length) -> float { switch (layout_length.mode) { @@ -119,7 +119,7 @@ namespace cru::ui::controls actual_size_for_children.height -= rest_available_size_for_children.height; } - auto&& calculate_final_length = [](const LayoutLength& layout_length, const float length_for_children, const float max_child_length) -> float + auto&& calculate_final_length = [](const LayoutSideParams& layout_length, const float length_for_children, const float max_child_length) -> float { switch (layout_length.mode) { diff --git a/CruUI/ui/controls/text_block.cpp b/CruUI/ui/controls/text_block.cpp index 314870c5..8800fd91 100644 --- a/CruUI/ui/controls/text_block.cpp +++ b/CruUI/ui/controls/text_block.cpp @@ -205,7 +205,7 @@ namespace cru if (layout_params->width.mode == MeasureMode::Stretch && layout_params->height.mode == MeasureMode::Stretch) return available_size; - auto&& get_measure_length = [](const LayoutLength& layout_length, const float available_length) -> float + auto&& get_measure_length = [](const LayoutSideParams& layout_length, const float available_length) -> float { switch (layout_length.mode) { @@ -235,7 +235,7 @@ namespace cru const Size measure_result(metrics.width, metrics.height); - auto&& calculate_final_length = [](const LayoutLength& layout_length, const float measure_length, const float measure_result_length) -> float + auto&& calculate_final_length = [](const LayoutSideParams& layout_length, const float measure_length, const float measure_result_length) -> float { if ((layout_length.mode == MeasureMode::Stretch || layout_length.mode == MeasureMode::Exactly) diff --git a/CruUI/ui/controls/toggle_button.cpp b/CruUI/ui/controls/toggle_button.cpp index 9812a6f4..68bd0fc9 100644 --- a/CruUI/ui/controls/toggle_button.cpp +++ b/CruUI/ui/controls/toggle_button.cpp @@ -112,7 +112,7 @@ namespace cru::ui::controls { const auto layout_params = GetLayoutParams(); - auto&& get_measure_length = [](const LayoutLength& layout_length, const float available_length, const float fix_length) -> float + auto&& get_measure_length = [](const LayoutSideParams& layout_length, const float available_length, const float fix_length) -> float { switch (layout_length.mode) { diff --git a/CruUI/ui/layout_base.h b/CruUI/ui/layout_base.h index c3af463a..163b99b2 100644 --- a/CruUI/ui/layout_base.h +++ b/CruUI/ui/layout_base.h @@ -26,26 +26,26 @@ namespace cru Stretch }; - struct LayoutLength final + struct LayoutSideParams final { - constexpr static LayoutLength Exactly(const float length, const Alignment alignment = Alignment::Center) + constexpr static LayoutSideParams Exactly(const float length, const Alignment alignment = Alignment::Center) { - return LayoutLength(MeasureMode::Exactly, length, alignment); + return LayoutSideParams(MeasureMode::Exactly, length, alignment); } - constexpr static LayoutLength Content(const Alignment alignment = Alignment::Center) + constexpr static LayoutSideParams Content(const Alignment alignment = Alignment::Center) { - return LayoutLength(MeasureMode::Content, 0, alignment); + return LayoutSideParams(MeasureMode::Content, 0, alignment); } - constexpr static LayoutLength Stretch(const Alignment alignment = Alignment::Center) + constexpr static LayoutSideParams Stretch(const Alignment alignment = Alignment::Center) { - return LayoutLength(MeasureMode::Stretch, 0, alignment); + return LayoutSideParams(MeasureMode::Stretch, 0, alignment); } - constexpr LayoutLength() = default; + constexpr LayoutSideParams() = default; - constexpr explicit LayoutLength(const MeasureMode mode, const float length, const Alignment alignment) + constexpr explicit LayoutSideParams(const MeasureMode mode, const float length, const Alignment alignment) : length(length), mode(mode), alignment(alignment) { @@ -56,7 +56,7 @@ namespace cru if (mode == MeasureMode::Exactly && length < 0.0) { #ifdef CRU_DEBUG - ::OutputDebugStringW(L"LayoutLength validation error: mode is Exactly but length is less than 0.\n"); + ::OutputDebugStringW(L"LayoutSideParams validation error: mode is Exactly but length is less than 0.\n"); #endif return false; } @@ -82,22 +82,22 @@ namespace cru if (!width.Validate()) { #ifdef CRU_DEBUG - ::OutputDebugStringW(L"Width(LayoutLength) is not valid."); + ::OutputDebugStringW(L"Width(LayoutSideParams) is not valid."); #endif return false; } if (!height.Validate()) { #ifdef CRU_DEBUG - ::OutputDebugStringW(L"Height(LayoutLength) is not valid."); + ::OutputDebugStringW(L"Height(LayoutSideParams) is not valid."); #endif return false; } return true; } - LayoutLength width; - LayoutLength height; + LayoutSideParams width; + LayoutSideParams height; }; |