Refactor XCUI editor module layout
This commit is contained in:
96
new_editor/include/XCEditor/Collections/UIEditorScrollView.h
Normal file
96
new_editor/include/XCEditor/Collections/UIEditorScrollView.h
Normal file
@@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
enum class UIEditorScrollViewHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
Content,
|
||||
ScrollbarTrack,
|
||||
ScrollbarThumb
|
||||
};
|
||||
|
||||
struct UIEditorScrollViewState {
|
||||
bool focused = false;
|
||||
bool hovered = false;
|
||||
bool scrollbarHovered = false;
|
||||
bool draggingScrollbarThumb = false;
|
||||
};
|
||||
|
||||
struct UIEditorScrollViewMetrics {
|
||||
float scrollbarWidth = 10.0f;
|
||||
float scrollbarInset = 4.0f;
|
||||
float minThumbHeight = 28.0f;
|
||||
float cornerRounding = 8.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 2.0f;
|
||||
float wheelStep = 48.0f;
|
||||
};
|
||||
|
||||
struct UIEditorScrollViewPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.15f, 0.15f, 0.16f, 1.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.30f, 0.32f, 0.34f, 1.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.78f, 0.80f, 0.84f, 1.0f);
|
||||
::XCEngine::UI::UIColor scrollbarTrackColor =
|
||||
::XCEngine::UI::UIColor(0.19f, 0.19f, 0.21f, 1.0f);
|
||||
::XCEngine::UI::UIColor scrollbarThumbColor =
|
||||
::XCEngine::UI::UIColor(0.32f, 0.34f, 0.36f, 1.0f);
|
||||
::XCEngine::UI::UIColor scrollbarThumbHoverColor =
|
||||
::XCEngine::UI::UIColor(0.42f, 0.44f, 0.47f, 1.0f);
|
||||
::XCEngine::UI::UIColor scrollbarThumbActiveColor =
|
||||
::XCEngine::UI::UIColor(0.50f, 0.52f, 0.56f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorScrollViewLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect contentRect = {};
|
||||
::XCEngine::UI::UIRect scrollbarTrackRect = {};
|
||||
::XCEngine::UI::UIRect scrollbarThumbRect = {};
|
||||
float contentHeight = 0.0f;
|
||||
float verticalOffset = 0.0f;
|
||||
float maxOffset = 0.0f;
|
||||
bool hasScrollbar = false;
|
||||
};
|
||||
|
||||
struct UIEditorScrollViewHitTarget {
|
||||
UIEditorScrollViewHitTargetKind kind = UIEditorScrollViewHitTargetKind::None;
|
||||
};
|
||||
|
||||
bool IsUIEditorScrollViewPointInside(
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
float ClampUIEditorScrollViewOffset(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
float contentHeight,
|
||||
float verticalOffset,
|
||||
const UIEditorScrollViewMetrics& metrics = {});
|
||||
|
||||
UIEditorScrollViewLayout BuildUIEditorScrollViewLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
float contentHeight,
|
||||
float verticalOffset,
|
||||
const UIEditorScrollViewMetrics& metrics = {});
|
||||
|
||||
::XCEngine::UI::UIPoint ResolveUIEditorScrollViewContentOrigin(
|
||||
const UIEditorScrollViewLayout& layout);
|
||||
|
||||
UIEditorScrollViewHitTarget HitTestUIEditorScrollView(
|
||||
const UIEditorScrollViewLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorScrollViewBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorScrollViewLayout& layout,
|
||||
const UIEditorScrollViewState& state,
|
||||
const UIEditorScrollViewPalette& palette = {},
|
||||
const UIEditorScrollViewMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
Reference in New Issue
Block a user