Skip to content

Commit 7221fec

Browse files
committed
Add PenAttributes struct
1 parent f73f192 commit 7221fec

File tree

5 files changed

+47
-0
lines changed

5 files changed

+47
-0
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ qt_add_qml_module(scratchcpp-render
4949
mouseeventhandler.h
5050
keyeventhandler.cpp
5151
keyeventhandler.h
52+
penattributes.h
5253
)
5354

5455
list(APPEND QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

src/penattributes.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-License-Identifier: LGPL-3.0-or-later
2+
3+
#pragma once
4+
5+
#include <QColor>
6+
7+
namespace scratchcpprender
8+
{
9+
10+
struct PenAttributes
11+
{
12+
QColor color = QColor(0, 0, 255);
13+
double diameter = 1;
14+
};
15+
16+
} // namespace scratchcpprender

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ add_subdirectory(scenemousearea)
3131
add_subdirectory(monitor_models)
3232
add_subdirectory(texture)
3333
add_subdirectory(skins)
34+
add_subdirectory(penattributes)

test/penattributes/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
add_executable(
2+
penattributes_test
3+
penattributes_test.cpp
4+
)
5+
6+
target_link_libraries(
7+
penattributes_test
8+
GTest::gtest_main
9+
scratchcpp-render
10+
qnanopainter
11+
)
12+
13+
add_test(penattributes_test)
14+
gtest_discover_tests(penattributes_test)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <penattributes.h>
2+
3+
#include "../common.h"
4+
5+
using namespace scratchcpprender;
6+
7+
TEST(PenAttributesTest, DefaultPenAttributes)
8+
{
9+
PenAttributes attr;
10+
ASSERT_EQ(attr.color.redF(), 0);
11+
ASSERT_EQ(attr.color.greenF(), 0);
12+
ASSERT_EQ(attr.color.blueF(), 1);
13+
ASSERT_EQ(attr.color.alphaF(), 1);
14+
ASSERT_EQ(attr.diameter, 1);
15+
}

0 commit comments

Comments
 (0)