97 lines
3.0 KiB
C
97 lines
3.0 KiB
C
|
|
#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 = 6.0f;
|
||
|
|
float borderThickness = 1.0f;
|
||
|
|
float focusedBorderThickness = 2.0f;
|
||
|
|
float wheelStep = 48.0f;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct UIEditorScrollViewPalette {
|
||
|
|
::XCEngine::UI::UIColor surfaceColor =
|
||
|
|
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor borderColor =
|
||
|
|
::XCEngine::UI::UIColor(0.29f, 0.29f, 0.29f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor focusedBorderColor =
|
||
|
|
::XCEngine::UI::UIColor(0.84f, 0.84f, 0.84f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor scrollbarTrackColor =
|
||
|
|
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor scrollbarThumbColor =
|
||
|
|
::XCEngine::UI::UIColor(0.31f, 0.31f, 0.31f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor scrollbarThumbHoverColor =
|
||
|
|
::XCEngine::UI::UIColor(0.38f, 0.38f, 0.38f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor scrollbarThumbActiveColor =
|
||
|
|
::XCEngine::UI::UIColor(0.46f, 0.46f, 0.46f, 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
|