Clang formatting (#8)
* Deletes double gitignore & update correct one * Adds clang format check to CI * Aplies clang format to codebase * Update check-path to use GitHub workspace * Update clang-format version from 13 to 21 * File formating for extern files * Another file formating
This commit is contained in:
306
.clang-format
Normal file
306
.clang-format
Normal file
@@ -0,0 +1,306 @@
|
||||
# yaml-language-server: $schema=https://json.schemastore.org/clang-format.json
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCaseArrows: false
|
||||
AlignCaseColons: false
|
||||
AlignConsecutiveTableGenBreakingDAGArgColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveTableGenCondOperatorColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveTableGenDefinitionColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignEscapedNewlines: DontAlign
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 0
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowBreakBeforeNoexceptSpecifier: Never
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseExpressionOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortCompoundRequirementOnASingleLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BitFieldColonSpacing: Both
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: true
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterExternBlock: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: true
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakAdjacentStringLiterals: true
|
||||
BreakAfterAttributes: Leave
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakAfterReturnType: None
|
||||
BreakArrays: true
|
||||
BreakBeforeBinaryOperators: All
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInlineASMColon: OnlyMultiline
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakFunctionDefinitionParameters: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: true
|
||||
BreakTemplateDeclarations: Yes
|
||||
ColumnLimit: 100
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: true
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- forever
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^<Q.*'
|
||||
Priority: 200
|
||||
SortPriority: 200
|
||||
CaseSensitive: true
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: false
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertBraces: false
|
||||
InsertNewlineAtEOF: false
|
||||
InsertTrailingCommas: None
|
||||
IntegerLiteralSeparator:
|
||||
Binary: 0
|
||||
BinaryMinDigits: 0
|
||||
Decimal: 0
|
||||
DecimalMinDigits: 0
|
||||
Hex: 0
|
||||
HexMinDigits: 0
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLines:
|
||||
AtEndOfFile: false
|
||||
AtStartOfBlock: false
|
||||
AtStartOfFile: false
|
||||
LambdaBodyIndentation: Signature
|
||||
LineEnding: DeriveLF
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MainIncludeChar: Quote
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 4
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PackConstructorInitializers: BinPack
|
||||
PenaltyBreakAssignment: 150
|
||||
PenaltyBreakBeforeFirstCallParameter: 300
|
||||
PenaltyBreakComment: 500
|
||||
PenaltyBreakFirstLessLess: 400
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakScopeResolution: 500
|
||||
PenaltyBreakString: 600
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 50
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PenaltyReturnTypeOnItsOwnLine: 300
|
||||
PointerAlignment: Right
|
||||
PPIndentWidth: -1
|
||||
QualifierAlignment: Leave
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: false
|
||||
RemoveBracesLLVM: false
|
||||
RemoveParentheses: Leave
|
||||
RemoveSemicolon: false
|
||||
RequiresClausePosition: OwnLine
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SkipMacroDefinitionBody: false
|
||||
SortIncludes: CaseSensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: Lexicographic
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeJsonColon: false
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: false
|
||||
AfterPlacementOperator: true
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParens: Never
|
||||
SpacesInParensOptions:
|
||||
ExceptDoubleParentheses: false
|
||||
InCStyleCasts: false
|
||||
InConditionalStatements: false
|
||||
InEmptyParentheses: false
|
||||
Other: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Auto
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
- emit
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
- Q_CLASSINFO
|
||||
- Q_ENUM
|
||||
- Q_ENUM_NS
|
||||
- Q_FLAG
|
||||
- Q_FLAG_NS
|
||||
- Q_GADGET
|
||||
- Q_GADGET_EXPORT
|
||||
- Q_INTERFACES
|
||||
- Q_LOGGING_CATEGORY
|
||||
- Q_MOC_INCLUDE
|
||||
- Q_NAMESPACE
|
||||
- Q_NAMESPACE_EXPORT
|
||||
- Q_OBJECT
|
||||
- Q_PROPERTY
|
||||
- Q_REVISION
|
||||
- Q_DISABLE_COPY
|
||||
- Q_SET_OBJECT_NAME
|
||||
- QT_BEGIN_NAMESPACE
|
||||
- QT_END_NAMESPACE
|
||||
- QML_ADDED_IN_MINOR_VERSION
|
||||
- QML_ANONYMOUS
|
||||
- QML_ATTACHED
|
||||
- QML_DECLARE_TYPE
|
||||
- QML_DECLARE_TYPEINFO
|
||||
- QML_ELEMENT
|
||||
- QML_EXTENDED
|
||||
- QML_EXTENDED_NAMESPACE
|
||||
- QML_EXTRA_VERSION
|
||||
- QML_FOREIGN
|
||||
- QML_FOREIGN_NAMESPACE
|
||||
- QML_IMPLEMENTS_INTERFACES
|
||||
- QML_INTERFACE
|
||||
- QML_NAMED_ELEMENT
|
||||
- QML_REMOVED_IN_MINOR_VERSION
|
||||
- QML_SINGLETON
|
||||
- QML_UNAVAILABLE
|
||||
- QML_UNCREATABLE
|
||||
- QML_VALUE_TYPE
|
||||
TableGenBreakInsideDAGArg: DontBreak
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
VerilogBreakBetweenInstancePorts: true
|
||||
WhitespaceSensitiveMacros:
|
||||
- BOOST_PP_STRINGIZE
|
||||
- CF_SWIFT_NAME
|
||||
- NS_SWIFT_NAME
|
||||
- PP_STRINGIZE
|
||||
- STRINGIZE
|
||||
...
|
||||
13
.github/workflows/clang-format.yml
vendored
Normal file
13
.github/workflows/clang-format.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
name: Clang-format check
|
||||
on: pull_request
|
||||
jobs:
|
||||
formatting-check:
|
||||
name: Formatting Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run clang-format style check
|
||||
uses: jidicula/clang-format-action@v4.16.0
|
||||
with:
|
||||
clang-format-version: '21'
|
||||
check-path: '${{ github.workspace }}/src'
|
||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"cmake.sourceDirectory": "C:/Users/kalle/OneDrive/Workspace/Programmieren/skui2/src"
|
||||
"cmake.sourceDirectory": "C:/Users/kalle/OneDrive/Workspace/Programmieren/skui2/src",
|
||||
"editor.formatOnSave": true
|
||||
}
|
||||
@@ -16,8 +16,7 @@ static void resourceInit()
|
||||
Q_INIT_RESOURCE(breeze_icons);
|
||||
}
|
||||
|
||||
namespace BreezeIcons
|
||||
{
|
||||
namespace BreezeIcons {
|
||||
|
||||
void initIcons()
|
||||
{
|
||||
@@ -31,4 +30,4 @@ void initIcons()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace BreezeIcons
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
* This namespace contains utility functions to integrate the
|
||||
* Breeze icons into your application.
|
||||
*/
|
||||
namespace BreezeIcons
|
||||
{
|
||||
namespace BreezeIcons {
|
||||
|
||||
/**
|
||||
* Ensures the Breeze icon theme is available inside the :/icons resource folder
|
||||
@@ -28,6 +27,6 @@ namespace BreezeIcons
|
||||
*/
|
||||
BREEZEICONS_EXPORT void initIcons();
|
||||
|
||||
}
|
||||
} // namespace BreezeIcons
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,9 +8,7 @@ Document::Document(Viewport *viewport)
|
||||
this->viewport = viewport;
|
||||
}
|
||||
|
||||
Document::~Document()
|
||||
{
|
||||
}
|
||||
Document::~Document() {}
|
||||
|
||||
QJsonObject Document::save()
|
||||
{
|
||||
@@ -22,7 +20,7 @@ void Document::load(QJsonObject content)
|
||||
return;
|
||||
}
|
||||
|
||||
Visual* Document::createVisual(VisualType type)
|
||||
Visual *Document::createVisual(VisualType type)
|
||||
{
|
||||
VisualContainer container;
|
||||
container.type = type;
|
||||
@@ -47,5 +45,5 @@ Visual* Document::createVisual(VisualType type)
|
||||
container.ptr = nullptr;
|
||||
}
|
||||
|
||||
return static_cast<Visual*>(container.ptr);
|
||||
return static_cast<Visual *>(container.ptr);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef DOCUMENT_H
|
||||
#define DOCUMENT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QJsonObject>
|
||||
#include <QObject>
|
||||
|
||||
#include "viewport.h"
|
||||
#include "visual.h"
|
||||
@@ -21,14 +21,14 @@ public:
|
||||
QJsonObject save();
|
||||
void load(QJsonObject);
|
||||
|
||||
Visual* createVisual(VisualType type);
|
||||
Visual *createVisual(VisualType type);
|
||||
|
||||
DisplayMode display_mode = DisplayMode::Run;
|
||||
|
||||
private:
|
||||
unsigned int visual_uid_count = 0;
|
||||
QList <VisualContainer> visuals;
|
||||
QList <Outbound> outbounds;
|
||||
QList<VisualContainer> visuals;
|
||||
QList<Outbound> outbounds;
|
||||
|
||||
Viewport *viewport;
|
||||
};
|
||||
|
||||
@@ -28,15 +28,14 @@ MainWindow::~MainWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::loadInsertVisualMenu()
|
||||
{
|
||||
const VisualMenuAction wrapped_actions[] = {{"Test", VisualType::Test},
|
||||
{"Slider", VisualType::Slider}};
|
||||
|
||||
for(const VisualMenuAction &wraped_action : wrapped_actions){
|
||||
for (const VisualMenuAction &wraped_action : wrapped_actions) {
|
||||
QAction *menu_insert_action = new QAction(wraped_action.name);
|
||||
connect(menu_insert_action, &QAction::triggered, this, [this, wraped_action]{
|
||||
connect(menu_insert_action, &QAction::triggered, this, [this, wraped_action] {
|
||||
Visual *visual = focus_document->createVisual(wraped_action.type);
|
||||
connect(this, &MainWindow::modeChanged, visual, &Visual::setMode);
|
||||
});
|
||||
@@ -89,4 +88,3 @@ void MainWindow::on_mode_changed_button_clicked()
|
||||
}
|
||||
emit modeChanged(focus_document->display_mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
#include "viewport.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
struct VisualMenuAction
|
||||
|
||||
@@ -26,55 +26,56 @@ void ResizeBoundingBox::paintEvent(QPaintEvent *event)
|
||||
painter.setPen(Qt::blue);
|
||||
painter.drawRect(mapRectFromParent(box_geometry));
|
||||
|
||||
for(const QPoint center_positon : outerHitboxPositions()){
|
||||
painter.fillRect(
|
||||
mapRectFromParent(squareByCenter(center_positon, 6)),
|
||||
QBrush(Qt::green, Qt::SolidPattern));
|
||||
for (const QPoint center_positon : outerHitboxPositions()) {
|
||||
painter.fillRect(mapRectFromParent(squareByCenter(center_positon, 6)),
|
||||
QBrush(Qt::green, Qt::SolidPattern));
|
||||
}
|
||||
|
||||
// Debug: Show hitboxes (yellow) and geometry (red) of widget
|
||||
for(const QRect hitbox : hitboxes()) {
|
||||
for (const QRect hitbox : hitboxes()) {
|
||||
painter.setPen(Qt::yellow);
|
||||
painter.drawRect(mapRectFromParent(hitbox));
|
||||
}
|
||||
painter.setPen(Qt::red);
|
||||
painter.drawRect(QRect(
|
||||
mapFromParent(geometry().topLeft()),
|
||||
geometry().size() + QSize(-1, -1) // Shiriking size by 1, so that the the Rect will render inside the widget
|
||||
));
|
||||
painter.drawRect(
|
||||
QRect(mapFromParent(geometry().topLeft()),
|
||||
geometry().size()
|
||||
+ QSize(-1,
|
||||
-1) // Shiriking size by 1, so that the the Rect will render inside the widget
|
||||
));
|
||||
}
|
||||
|
||||
QRect ResizeBoundingBox::mapRectFromParent(QRect geometry)
|
||||
{
|
||||
return QRect(
|
||||
mapFromParent(geometry.topLeft()),
|
||||
geometry.size()
|
||||
);
|
||||
return QRect(mapFromParent(geometry.topLeft()), geometry.size());
|
||||
}
|
||||
|
||||
QRect ResizeBoundingBox::squareByCenter(QPoint position, int length)
|
||||
{
|
||||
return QRect(position.x() - length/2, position.y() - length/2, length, length);
|
||||
return QRect(position.x() - length / 2, position.y() - length / 2, length, length);
|
||||
}
|
||||
|
||||
QMap<DragDirection, QPoint> ResizeBoundingBox::outerHitboxPositions()
|
||||
{
|
||||
return QMap<DragDirection, QPoint>({
|
||||
{DragDirection::NorthWest, QPoint(box_geometry.topLeft())},
|
||||
{DragDirection::North, QPoint(box_geometry.left() + box_geometry.width() / 2, box_geometry.top())},
|
||||
{DragDirection::NorthEast, QPoint(box_geometry.topRight())},
|
||||
{DragDirection::East, QPoint(box_geometry.right(), box_geometry.top() + box_geometry.height() / 2)},
|
||||
{DragDirection::SouthEast, QPoint(box_geometry.bottomRight())},
|
||||
{DragDirection::South, QPoint(box_geometry.left() + box_geometry.width() / 2, box_geometry.bottom())},
|
||||
{DragDirection::SouthWest, QPoint(box_geometry.bottomLeft())},
|
||||
{DragDirection::West, QPoint(box_geometry.left(), box_geometry.top() + box_geometry.height() / 2)}
|
||||
});
|
||||
return QMap<DragDirection, QPoint>(
|
||||
{{DragDirection::NorthWest, QPoint(box_geometry.topLeft())},
|
||||
{DragDirection::North,
|
||||
QPoint(box_geometry.left() + box_geometry.width() / 2, box_geometry.top())},
|
||||
{DragDirection::NorthEast, QPoint(box_geometry.topRight())},
|
||||
{DragDirection::East,
|
||||
QPoint(box_geometry.right(), box_geometry.top() + box_geometry.height() / 2)},
|
||||
{DragDirection::SouthEast, QPoint(box_geometry.bottomRight())},
|
||||
{DragDirection::South,
|
||||
QPoint(box_geometry.left() + box_geometry.width() / 2, box_geometry.bottom())},
|
||||
{DragDirection::SouthWest, QPoint(box_geometry.bottomLeft())},
|
||||
{DragDirection::West,
|
||||
QPoint(box_geometry.left(), box_geometry.top() + box_geometry.height() / 2)}});
|
||||
}
|
||||
|
||||
QMap<DragDirection, QRect> ResizeBoundingBox::hitboxes()
|
||||
{
|
||||
QMap<DragDirection, QRect> hitboxes;
|
||||
for(auto [direction, center_position] : outerHitboxPositions().asKeyValueRange()){
|
||||
for (auto [direction, center_position] : outerHitboxPositions().asKeyValueRange()) {
|
||||
hitboxes[direction] = squareByCenter(center_position, OUTER_HITBOX_SIZE);
|
||||
}
|
||||
|
||||
@@ -86,8 +87,8 @@ QMap<DragDirection, QRect> ResizeBoundingBox::hitboxes()
|
||||
|
||||
DragDirection ResizeBoundingBox::containesHitbox(QPoint position)
|
||||
{
|
||||
for(auto [direction, hitbox] : hitboxes().asKeyValueRange()){
|
||||
if(mapRectFromParent(hitbox).contains(position)){
|
||||
for (auto [direction, hitbox] : hitboxes().asKeyValueRange()) {
|
||||
if (mapRectFromParent(hitbox).contains(position)) {
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
@@ -96,7 +97,7 @@ DragDirection ResizeBoundingBox::containesHitbox(QPoint position)
|
||||
|
||||
void ResizeBoundingBox::setHoverCursor(DragDirection direction)
|
||||
{
|
||||
switch(direction) {
|
||||
switch (direction) {
|
||||
case DragDirection::NorthWest:
|
||||
case DragDirection::SouthEast:
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
@@ -124,7 +125,7 @@ void ResizeBoundingBox::setHoverCursor(DragDirection direction)
|
||||
|
||||
void ResizeBoundingBox::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if(mouse_pressed) {
|
||||
if (mouse_pressed) {
|
||||
QPointF delta = event->globalPosition() - last_global_position;
|
||||
last_global_position = event->globalPosition();
|
||||
|
||||
@@ -137,12 +138,12 @@ void ResizeBoundingBox::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
void ResizeBoundingBox::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if(event->buttons() == Qt::LeftButton){
|
||||
if (event->buttons() == Qt::LeftButton) {
|
||||
mouse_pressed = true;
|
||||
last_global_position = event->globalPosition();
|
||||
last_geometry = geometry();
|
||||
|
||||
if(active_direction == DragDirection::Center) {
|
||||
if (active_direction == DragDirection::Center) {
|
||||
setCursor(Qt::ClosedHandCursor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef RESIZEBOUNDINGBOX_H
|
||||
#define RESIZEBOUNDINGBOX_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <QCursor>
|
||||
#include <QMargins>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QWidget>
|
||||
|
||||
const int OUTER_HITBOX_SIZE = 10;
|
||||
const QMargins WIDGET_MARGIN(20, 20, 20, 20);
|
||||
@@ -34,8 +34,8 @@ public:
|
||||
void setBoxMinimumSize(QSize);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent*) override;
|
||||
void mouseMoveEvent(QMouseEvent*) override;
|
||||
void mousePressEvent(QMouseEvent *) override;
|
||||
void mouseMoveEvent(QMouseEvent *) override;
|
||||
void mouseReleaseEvent(QMouseEvent *) override;
|
||||
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
@@ -115,8 +115,7 @@ void Visual::logInitiation()
|
||||
qInfo(visual) << QString("Initiated '%1'(%2) at 0x%3")
|
||||
.arg(info_class_name)
|
||||
.arg(QString::number(uid))
|
||||
.arg(reinterpret_cast<quintptr>(this), QT_POINTER_SIZE * 2, 16, QChar('0')
|
||||
);
|
||||
.arg(reinterpret_cast<quintptr>(this), QT_POINTER_SIZE * 2, 16, QChar('0'));
|
||||
}
|
||||
|
||||
// In Edit Mode all events in VIEWPORT_HANDLED_ON_EDIT_MODE need to get handled by the Viewport
|
||||
|
||||
16
src/visual.h
16
src/visual.h
@@ -1,16 +1,16 @@
|
||||
#ifndef VISUAL_H
|
||||
#define VISUAL_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLayout>
|
||||
#include <QDebug>
|
||||
#include <QLayout>
|
||||
#include <QLoggingCategory>
|
||||
#include <QString>
|
||||
#include <QMouseEvent>
|
||||
#include <QResizeEvent>
|
||||
#include <QMoveEvent>
|
||||
#include <QPoint>
|
||||
#include <QResizeEvent>
|
||||
#include <QSizeGrip>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
#include "interfacehandler.h"
|
||||
#include "resizeboundingbox.h"
|
||||
@@ -23,8 +23,9 @@ const QEvent::Type VIEWPORT_HANDLED_ON_EDIT_MODE[] = {QEvent::MouseButtonPress,
|
||||
QEvent::MouseButtonRelease,
|
||||
QEvent::MouseMove};
|
||||
|
||||
struct VisualContainer {
|
||||
void* ptr;
|
||||
struct VisualContainer
|
||||
{
|
||||
void *ptr;
|
||||
VisualType type;
|
||||
};
|
||||
|
||||
@@ -49,7 +50,8 @@ public slots:
|
||||
protected:
|
||||
QString info_name = "Base Class";
|
||||
QString info_class_name = "Visual";
|
||||
QString info_description = "This class is the base for every visual. If you can see this, the base class is called without a child.";
|
||||
QString info_description = "This class is the base for every visual. If you can see this, the "
|
||||
"base class is called without a child.";
|
||||
|
||||
void setMinimumSize(QSize);
|
||||
void makeInterface(InterfaceInfo, InterfaceDirection);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "test.h"
|
||||
|
||||
Test::Test(QWidget *parent, unsigned int uid) : Visual(parent, uid)
|
||||
Test::Test(QWidget *parent, unsigned int uid)
|
||||
: Visual(parent, uid)
|
||||
{
|
||||
setGeometry(QRect(200, 200, 200, 200));
|
||||
setMinimumSize(QSize(200, 200));
|
||||
|
||||
@@ -10,7 +10,6 @@ class Test : public Visual
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Test(QWidget *parent = nullptr, unsigned int uid = 0);
|
||||
|
||||
};
|
||||
|
||||
#endif // TEST_H
|
||||
|
||||
Reference in New Issue
Block a user