mirror of
https://gitlab.com/manzerbredes/cgeditor.git
synced 2025-04-19 03:59:44 +00:00
Create project
This commit is contained in:
commit
a359219e33
24 changed files with 2152 additions and 0 deletions
88
src/Types.hpp
Normal file
88
src/Types.hpp
Normal file
|
@ -0,0 +1,88 @@
|
|||
#pragma once
|
||||
|
||||
#include "CGEHalfMove.hpp"
|
||||
#include <string>
|
||||
|
||||
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<Event> Events;
|
||||
} Status;
|
||||
|
||||
} // namespace cgeditor
|
Loading…
Add table
Add a link
Reference in a new issue