From a359219e33fdf3afb5ddfbb084563054a947b106 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sat, 12 Feb 2022 19:13:34 +0100 Subject: Create project --- src/Types.hpp | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/Types.hpp (limited to 'src/Types.hpp') diff --git a/src/Types.hpp b/src/Types.hpp new file mode 100644 index 0000000..db8b6f3 --- /dev/null +++ b/src/Types.hpp @@ -0,0 +1,88 @@ +#pragma once + +#include "CGEHalfMove.hpp" +#include + +namespace cgeditor { + +enum class Property : std::uint32_t { + None = 0, + Image = 1, + Rectangle = 1 << 1, + Text = 1 << 2, + On = 1 << 3, + Move = 1 << 4, + Margin = 1 << 5, + Menuitem = 1 << 6, // Is it a menu item + Comment = 1 << 7, + Black = 1 << 8, // Is it a move for black + Scrollbar = 1 << 9, + Horizontal = 1 << 10, // Is it an horizontal scrollbar + Scrollbarbg = 1 << 11, // Is it the background of the scrollbar + Button = 1 << 12, // Is it a button + Dots = 1 << 13, // Move dots + Movenumber = 1 << 14, + Current = 1 << 15, + Mouseover = 1 << 16 // Set on every element where mouse is over +}; +Property operator|(Property lhs, Property rhs); +Property &operator|=(Property &lhs, Property rhs); +bool operator&(Property lhs, Property rhs); + +class Element { +public: + Property prop = Property::None; + std::string text; + double x, y; + double width, height; + /// @brief Should element be scrolled + bool ShouldApplyScroll = false; + /// @brief For margin bar to avoid scrolling it vertically + bool IgnoreScrollY = false; + /// @brief Check if a given point is over the element + bool IsOver(const double &X, const double &Y) const; +}; + +typedef struct Event { + enum Type { CommentSelected, Promote, Delete, SetAsMainline, Goto, None }; + Type type = None; + /// @brief Move related to the event + CGEHalfMove *move = NULL; +} Event; + +/** + * @brief Chess Game Editor status + * Various parameters that can be tuned by the user. + * The user should manually set mouse event boolean + * for the editor to work properly + */ +typedef struct Status { + double MouseX = 0, MouseY = 0; + double LastMouseClicX = 0, LastMouseClicY = 0; + double CanvasWidth, CanvasHeight; + double MenuItemWidth = 150, MenuItemHeight = 50; + double MoveWidth = 100, MoveHeight = 50; + double MarginBarWidth = 50; + double ScrollbarWidth = 30; + double MenuX, MenuY; + double MoveX, MoveY; + std::uint16_t CommentLinePerRow = 2; + /// @brief Ask the editor to scroll for a specific amout of pixels + double EventVScroll = 0, EventHScroll = 0; + /// @brief Amount of pixel to scroll elements + double ScrollX = 0, ScrollY = 0; + /// @brief Set according to mouse events + bool LeftClick, RightClick; + /// @brief Can be use to close the menu + bool IsMenuOpen = false; + bool UseMoveImages = false; + double MoveTableMaxX = 0, MoveTableMaxY = 0; + /// @brief User should set it to true when mouse is dragging + bool IsDrag = false; + CGEHalfMove *Moves = NULL; + CGEHalfMove *CurrentMove = NULL; + CGEHalfMove *SelectedMove = NULL; + std::vector Events; +} Status; + +} // namespace cgeditor \ No newline at end of file -- cgit v1.2.3