2026-04-07 16:57:04 +08:00
|
|
|
#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;
|
2026-04-10 00:41:28 +08:00
|
|
|
float cornerRounding = 8.0f;
|
2026-04-07 16:57:04 +08:00
|
|
|
float borderThickness = 1.0f;
|
|
|
|
|
float focusedBorderThickness = 2.0f;
|
|
|
|
|
float wheelStep = 48.0f;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct UIEditorScrollViewPalette {
|
|
|
|
|
::XCEngine::UI::UIColor surfaceColor =
|
2026-04-10 00:41:28 +08:00
|
|
|
::XCEngine::UI::UIColor(0.15f, 0.15f, 0.16f, 1.0f);
|
2026-04-07 16:57:04 +08:00
|
|
|
::XCEngine::UI::UIColor borderColor =
|
2026-04-10 00:41:28 +08:00
|
|
|
::XCEngine::UI::UIColor(0.30f, 0.32f, 0.34f, 1.0f);
|
2026-04-07 16:57:04 +08:00
|
|
|
::XCEngine::UI::UIColor focusedBorderColor =
|
2026-04-10 00:41:28 +08:00
|
|
|
::XCEngine::UI::UIColor(0.78f, 0.80f, 0.84f, 1.0f);
|
2026-04-07 16:57:04 +08:00
|
|
|
::XCEngine::UI::UIColor scrollbarTrackColor =
|
2026-04-10 00:41:28 +08:00
|
|
|
::XCEngine::UI::UIColor(0.19f, 0.19f, 0.21f, 1.0f);
|
2026-04-07 16:57:04 +08:00
|
|
|
::XCEngine::UI::UIColor scrollbarThumbColor =
|
2026-04-10 00:41:28 +08:00
|
|
|
::XCEngine::UI::UIColor(0.32f, 0.34f, 0.36f, 1.0f);
|
2026-04-07 16:57:04 +08:00
|
|
|
::XCEngine::UI::UIColor scrollbarThumbHoverColor =
|
2026-04-10 00:41:28 +08:00
|
|
|
::XCEngine::UI::UIColor(0.42f, 0.44f, 0.47f, 1.0f);
|
2026-04-07 16:57:04 +08:00
|
|
|
::XCEngine::UI::UIColor scrollbarThumbActiveColor =
|
2026-04-10 00:41:28 +08:00
|
|
|
::XCEngine::UI::UIColor(0.50f, 0.52f, 0.56f, 1.0f);
|
2026-04-07 16:57:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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
|