SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
componentResize.hpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2026. Giulio Cocconi
3
4
SPDX-License-Identifier: GPL-3.0-or-later
5
*/
6
7
#pragma once
8
9
#include <QPointF>
10
#include <QRectF>
11
#include <array>
12
#include <
core/component.hpp
>
13
14
namespace
SILICON::ui
{
15
16
enum class
ResizeHandle
{
17
Left
,
18
Right
,
19
Top
,
20
Bottom
,
21
TopLeft
,
22
TopRight
,
23
BottomLeft
,
24
BottomRight
25
};
26
27
inline
constexpr
std::array
AllResizeHandles
{
28
ResizeHandle::TopLeft
,
ResizeHandle::TopRight
,
ResizeHandle::BottomLeft
,
29
ResizeHandle::BottomRight
,
ResizeHandle::Left
,
ResizeHandle::Right
,
30
ResizeHandle::Top
,
ResizeHandle::Bottom
};
31
32
inline
bool
resizesLeft
(
ResizeHandle
handle)
33
{
34
return
handle ==
ResizeHandle::Left
|| handle ==
ResizeHandle::TopLeft
35
|| handle ==
ResizeHandle::BottomLeft
;
36
}
37
38
inline
bool
resizesRight
(
ResizeHandle
handle)
39
{
40
return
handle ==
ResizeHandle::Right
|| handle ==
ResizeHandle::TopRight
41
|| handle ==
ResizeHandle::BottomRight
;
42
}
43
44
inline
bool
resizesTop
(
ResizeHandle
handle)
45
{
46
return
handle ==
ResizeHandle::Top
|| handle ==
ResizeHandle::TopLeft
47
|| handle ==
ResizeHandle::TopRight
;
48
}
49
50
inline
bool
resizesBottom
(
ResizeHandle
handle)
51
{
52
return
handle ==
ResizeHandle::Bottom
|| handle ==
ResizeHandle::BottomLeft
53
|| handle ==
ResizeHandle::BottomRight
;
54
}
55
56
inline
QPointF
resizeHandlePoint
(
const
QRectF& bounds,
ResizeHandle
handle)
57
{
58
return
{
resizesLeft
(handle) ? bounds.left()
59
:
resizesRight
(handle) ? bounds.right()
60
: bounds.center().x(),
61
resizesTop
(handle) ? bounds.top()
62
:
resizesBottom
(handle) ? bounds.bottom()
63
: bounds.center().y()};
64
}
65
68
inline
QPointF
resizeAnchor
(
const
QRectF& bounds,
ResizeHandle
handle)
69
{
70
return
{
resizesLeft
(handle) ? bounds.right()
71
:
resizesRight
(handle) ? bounds.left()
72
: bounds.center().x(),
73
resizesTop
(handle) ? bounds.bottom() : bounds.top()};
74
}
75
76
struct
ComponentResizeState
{
77
QPointF
position
;
78
core::PropertyMap
properties
;
79
80
bool
operator==
(
const
ComponentResizeState
&)
const
=
default
;
81
};
82
83
}
// namespace SILICON::ui
component.hpp
SILICON::core::PropertyMap
std::unordered_map< std::string, PropertyValue, TransparentStringHash, TransparentStringEqual > PropertyMap
Map from property names to their values.
Definition
component.hpp:145
SILICON::ui
Definition
actionGroups.hpp:14
SILICON::ui::resizesRight
bool resizesRight(ResizeHandle handle)
Definition
componentResize.hpp:38
SILICON::ui::resizesLeft
bool resizesLeft(ResizeHandle handle)
Definition
componentResize.hpp:32
SILICON::ui::resizesBottom
bool resizesBottom(ResizeHandle handle)
Definition
componentResize.hpp:50
SILICON::ui::ResizeHandle
ResizeHandle
Definition
componentResize.hpp:16
SILICON::ui::ResizeHandle::TopRight
@ TopRight
Definition
componentResize.hpp:22
SILICON::ui::ResizeHandle::Bottom
@ Bottom
Definition
componentResize.hpp:20
SILICON::ui::ResizeHandle::BottomRight
@ BottomRight
Definition
componentResize.hpp:24
SILICON::ui::ResizeHandle::Right
@ Right
Definition
componentResize.hpp:18
SILICON::ui::ResizeHandle::Left
@ Left
Definition
componentResize.hpp:17
SILICON::ui::ResizeHandle::BottomLeft
@ BottomLeft
Definition
componentResize.hpp:23
SILICON::ui::ResizeHandle::Top
@ Top
Definition
componentResize.hpp:19
SILICON::ui::ResizeHandle::TopLeft
@ TopLeft
Definition
componentResize.hpp:21
SILICON::ui::resizeAnchor
QPointF resizeAnchor(const QRectF &bounds, ResizeHandle handle)
Definition
componentResize.hpp:68
SILICON::ui::AllResizeHandles
constexpr std::array AllResizeHandles
Definition
componentResize.hpp:27
SILICON::ui::resizesTop
bool resizesTop(ResizeHandle handle)
Definition
componentResize.hpp:44
SILICON::ui::resizeHandlePoint
QPointF resizeHandlePoint(const QRectF &bounds, ResizeHandle handle)
Definition
componentResize.hpp:56
SILICON::ui::ComponentResizeState
Definition
componentResize.hpp:76
SILICON::ui::ComponentResizeState::properties
core::PropertyMap properties
Definition
componentResize.hpp:78
SILICON::ui::ComponentResizeState::position
QPointF position
Definition
componentResize.hpp:77
SILICON::ui::ComponentResizeState::operator==
bool operator==(const ComponentResizeState &) const =default
src
ui
circuit
diagram
componentResize.hpp
Generated by
1.17.0