Skip to content

Commit a9b38a2

Browse files
committed
[ADD] Window decorator management
1 parent 89b78fe commit a9b38a2

19 files changed

Lines changed: 528 additions & 200 deletions

File tree

CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
1616

1717
########################################### START DEBUG FLAGS ###########################################
1818
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 ")
19-
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g3")
20-
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g3")
21-
############################################ END DEBUG FLAGS ############################################
19+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g3 ")
20+
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g3 ")
21+
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -g3")############################################ END DEBUG FLAGS ############################################
2222

2323
########################################### START SOURCE PATH ##########################################
2424
set(TDL_EXAMPLES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/example)
@@ -42,7 +42,7 @@ set(CMAKE_EXTERNAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
4242

4343
########################################### START CUSTOM TARGETS ########################################
4444
add_custom_target(install_libs
45-
COMMAND sudo ${CMAKE_COMMAND} --build . --target install
45+
COMMAND sudo ${CMAKE_COMMAND} --build . --target install -j
4646
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
4747
)
4848

@@ -58,10 +58,16 @@ add_custom_target(build_demo
5858
)
5959

6060
add_custom_target(configure_examples
61-
COMMAND ${CMAKE_COMMAND} -S ${TDL_EXAMPLES_DIR} -B ${TDL_EXAMPLES_BUILD_DIR}
61+
COMMAND ${CMAKE_COMMAND} -S ${TDL_EXAMPLES_DIR} -B ${TDL_EXAMPLES_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug
6262
COMMENT "Configuring example project"
6363
)
6464

65+
add_custom_target(run_with_asan
66+
COMMAND LD_PRELOAD=$(shell $(CMAKE_C_COMPILER) -print-file-name=libasan.so) ../demo/demo 2> log
67+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
68+
COMMENT "Running application with AddressSanitizer preloaded"
69+
)
70+
6571
add_dependencies(build_demo install_libs)
6672
add_dependencies(build_demo configure_examples)
6773
########################################### END CUSTOM TARGETS ##########################################
@@ -159,7 +165,7 @@ add_subdirectory(${TDL_ASCII_DIR}) # install .so library for ascii
159165
########################################### END INSTALLATION #############################################
160166

161167
########################################### START EXPORT CONFIG ##########################################
162-
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/tdl
168+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/TDL
163169
DESTINATION include
164170
FILES_MATCHING PATTERN "*.hpp")
165171

example/fileSystem/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ int main() {
1313
}
1414

1515
tdl::Window win("file system", tdl::Vector2u(800,600));
16-
win.setPosition(tdl::Vector2u(100,100));
16+
win.setPosition(tdl::Vector2i(100,100));
1717
tdl::Display::getInstance().addWindow(&win);
1818
int j = 0;
1919
int x, y = 10;

include/TDL/Graphics/Display/Display.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ namespace tdl
4444
return instance;
4545
}
4646

47+
static void destroyInstance() {
48+
Display &instance = getInstance();
49+
instance.~Display();
50+
}
51+
4752
Display(const Display &d) = delete;
4853
Display &operator=(const Display &d) = delete;
4954

@@ -53,6 +58,7 @@ namespace tdl
5358
~Display() {
5459
_eventNotifier.joinKeyboardThread();
5560
_eventNotifier.joinMouseThread();
61+
delete _drawMethode;
5662
}
5763

5864
void addWindow(Window *win)
@@ -87,10 +93,9 @@ namespace tdl
8793
void clear(Pixel background = Pixel(0, 0, 0, 255))
8894
{
8995
for (auto &win : _windows) {
90-
win->clear(win->getBackground());
96+
win->clearWin();
9197
}
92-
_previousFrame = _currentFrame;
93-
_currentFrame->fill(background);
98+
this->FrameBuffer::clear(background);
9499
}
95100

96101
/**

include/TDL/Graphics/Display/Strategy/TTY/TtyMethode.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ namespace tdl {
4444
private:
4545
int _fd; /**< The file descriptor of the TTY. */
4646
struct fb_var_screeninfo _vinfo; /**< The variable information of the framebuffer. */
47+
struct fb_var_screeninfo _vinfo_old; /**< The variable information of the framebuffer. */
4748
struct fb_fix_screeninfo _finfo; /**< The fixed information of the framebuffer. */
4849
long int _screensize; /*!< the size of the screen in bytes */
4950
char *_fbp; /*!< the framebuffer pointer */
5051
std::unique_ptr<char[]> _startScreen; /*!< the screen at the start of the program */
5152
Vector2u _size; /*!< the terminal size */
53+
int _ttyfd;
5254
};
5355
}
5456

include/TDL/Graphics/FrameBuffer/Feature/Placeable.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,35 @@
3333
* @brief sets the position of the object.
3434
* @param position The position of the object.
3535
*/
36-
void setPosition(const Vector2u &position);
36+
void setPosition(const Vector2i &position);
3737

3838
/**
3939
* @overload
4040
* @brief sets the position of the object.
4141
* @param x The x position of the object.
4242
* @param y The y position of the object.
4343
*/
44-
void setPosition(u_int32_t x, u_int32_t y);
44+
void setPosition(int32_t x, int32_t y);
4545

4646
/**
4747
* @brief gets the position of the object.
4848
* @return The position of the object.
4949
*/
50-
const Vector2u &getPosition() const;
50+
const Vector2i &getPosition() const;
5151

5252
/**
5353
* @brief moves the object by a given offset.
5454
* @param offset The offset to move the object by.
5555
*/
56-
void move(const Vector2u &offset);
56+
void move(const Vector2i &offset);
5757

5858
/**
5959
* @overload
6060
* @brief moves the object by a given offset.
6161
* @param offsetX The x offset to move the object by.
6262
* @param offsetY The y offset to move the object by.
6363
*/
64-
void move(u_int32_t offsetX, u_int32_t offsetY);
64+
void move(int32_t offsetX, int32_t offsetY);
6565

6666
/**
6767
* @brief gets the transformation of the object.
@@ -70,7 +70,7 @@
7070
const Transform &getTransform() const;
7171

7272
protected:
73-
Vector2u m_position; /**< The position of the object. */
73+
Vector2i m_position; /**< The position of the object. */
7474
mutable Transform m_transform; /**< The transformation matrix of the object. */
7575
mutable bool TransformNeedUpdate; /**< A flag to check if the transformation matrix needs to be updated. */
7676
};

0 commit comments

Comments
 (0)