LibrePCB Developers Documentation
Loading...
Searching...
No Matches
uihelpers.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_UIHELPERS_H
21#define LIBREPCB_EDITOR_UIHELPERS_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "appwindow.h"
27
36
37#include <optional>
38
39/*******************************************************************************
40 * Namespace / Forward Declarations
41 ******************************************************************************/
42namespace librepcb {
43namespace editor {
44
45class EditorCommand;
46
47// l2s(): LibrePCB C++ to LibrePCB Slint UI type conversion
48// s2l(): LibrePCB Slint UI to LibrePCB C++ type conversion
49
50/*******************************************************************************
51 * Non-Member Functions
52 ******************************************************************************/
53
54static_assert(sizeof(ui::Int64) == 8);
55static_assert(sizeof(LengthBase_t) == 8);
56static_assert(sizeof(Angle) == sizeof(int));
57static_assert(sizeof(Ratio) == sizeof(int));
58
59qint64 s2l(const ui::Int64& v) noexcept;
60
61ui::Int64 l2s(const Length& v) noexcept;
62Length s2length(const ui::Int64& v) noexcept;
63std::optional<UnsignedLength> s2ulength(const ui::Int64& v) noexcept;
64std::optional<PositiveLength> s2plength(const ui::Int64& v) noexcept;
65
66int l2s(const Angle& v) noexcept;
67Angle s2angle(int v) noexcept;
68
69int l2s(const Ratio& v) noexcept;
70Ratio s2ratio(int v) noexcept;
71
72ui::GridStyle l2s(Theme::GridStyle v) noexcept;
73Theme::GridStyle s2l(ui::GridStyle v) noexcept;
74
75ui::LengthUnit l2s(const LengthUnit& v) noexcept;
76LengthUnit s2l(ui::LengthUnit v) noexcept;
77
78slint::cbindgen_private::TextHorizontalAlignment l2s(const HAlign& v) noexcept;
79HAlign s2l(slint::cbindgen_private::TextHorizontalAlignment v) noexcept;
80
81slint::cbindgen_private::TextVerticalAlignment l2s(const VAlign& v) noexcept;
82VAlign s2l(slint::cbindgen_private::TextVerticalAlignment v) noexcept;
83
84ui::NotificationType l2s(RuleCheckMessage::Severity v) noexcept;
85
86int l2s(Package::AssemblyType v) noexcept;
87std::optional<Package::AssemblyType> s2assemblyType(int v) noexcept;
88
89ui::ComponentPinoutDisplayMode l2s(const CmpSigPinDisplayType& v) noexcept;
90const CmpSigPinDisplayType& s2l(ui::ComponentPinoutDisplayMode v) noexcept;
91
92ui::EditorCommand l2s(const EditorCommand& cmd, ui::EditorCommand in) noexcept;
93bool isShortcut(const slint::private_api::KeyEvent& e,
94 const ui::EditorCommand& cmd) noexcept;
95
96ui::FeatureState toFs(bool enabled) noexcept;
97
98/*******************************************************************************
99 * End of File
100 ******************************************************************************/
101
102} // namespace editor
103} // namespace librepcb
104
105#endif
AssemblyType
Definition package.h:79
Severity
Message severity type (higher number = higher severity)
Definition rulecheckmessage.h:50
GridStyle
Definition theme.h:49
static ui::WireMode l2s(BoardEditorState_DrawTrace::WireMode v) noexcept
Definition board2dtab.cpp:100
std::optional< PositiveLength > s2plength(const ui::Int64 &v) noexcept
Definition uihelpers.cpp:61
static BoardEditorState_DrawTrace::WireMode s2l(ui::WireMode v) noexcept
Definition board2dtab.cpp:116
ui::FeatureState toFs(bool enabled) noexcept
Definition uihelpers.cpp:339
Angle s2angle(int v) noexcept
Definition uihelpers.cpp:70
Length s2length(const ui::Int64 &v) noexcept
Definition uihelpers.cpp:52
std::optional< UnsignedLength > s2ulength(const ui::Int64 &v) noexcept
Definition uihelpers.cpp:56
Ratio s2ratio(int v) noexcept
Definition uihelpers.cpp:78
std::optional< Package::AssemblyType > s2assemblyType(int v) noexcept
Definition uihelpers.cpp:225
bool isShortcut(const slint::private_api::KeyEvent &e, const ui::EditorCommand &cmd) noexcept
Definition uihelpers.cpp:313
Definition occmodel.cpp:77
qint64 LengthBase_t
This type is the ONLY base type to store all lengths (always in nanometers)!
Definition length.h:61