diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-12 19:13:34 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-12 19:13:34 +0100 |
| commit | a359219e33fdf3afb5ddfbb084563054a947b106 (patch) | |
| tree | 91dab9c21321f73152993183cd6e8cf4a04017f8 /src/components/MoveTable.hpp | |
Create project
Diffstat (limited to 'src/components/MoveTable.hpp')
| -rw-r--r-- | src/components/MoveTable.hpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/components/MoveTable.hpp b/src/components/MoveTable.hpp new file mode 100644 index 0000000..d220f5e --- /dev/null +++ b/src/components/MoveTable.hpp @@ -0,0 +1,65 @@ +#include "Component.hpp" +#include <cmath> + +#define IS_VISIBLE(e) \ + (((e.x + status->ScrollX) >= 0 && \ + ((e.x + status->ScrollX) <= status->CanvasWidth) && \ + (e.y + status->ScrollY) >= 0 && \ + ((e.y + status->ScrollY) <= status->CanvasHeight)) || \ + ((e.x + e.width + status->ScrollX) >= 0 && \ + ((e.x + e.width + status->ScrollX) <= status->CanvasWidth) && \ + (e.y + e.height + status->ScrollY) >= 0 && \ + ((e.y + e.height + status->ScrollY) <= status->CanvasHeight))) + +#define DRAW_DOTS(XX, YY) \ + { \ + Element e; \ + e.prop = Property::Text | Property::Dots; \ + e.x = (XX); \ + e.y = (YY); \ + e.width = status->MoveWidth; \ + e.height = status->MoveHeight; \ + e.text = "..."; \ + e.ShouldApplyScroll = true; \ + elements.push_back(e); \ + } + +#define DRAW_NB_(XX, YY, NB) \ + Element ln; \ + ln.prop = Property::Text | Property::Movenumber; \ + ln.text = std::to_string(NB); \ + ln.x = (XX); \ + ln.y = (YY); \ + ln.width = status->MarginBarWidth; \ + ln.height = status->MoveHeight; \ + ln.ShouldApplyScroll = true; \ + elements.push_back(ln); + +#define DRAW_NB(XX, YY, NB) \ + { DRAW_NB_(XX, YY, NB); } + +#define DRAW_NB_VAR(XX, YY, NB) \ + { \ + DRAW_NB_(XX, YY, NB); \ + VariationMargins.push_back(ln); \ + } + +namespace cgeditor { +class MoveTable : public Component { + std::uint32_t UpdateMoves(CGEHalfMove *, std::uint32_t, std::uint32_t,bool only_black); + std::int32_t CurrentMove; + double ImageWidth; + std::vector<Element> VariationMargins; + bool IsMouseOver(const Element &e) const; + std::uint32_t DrawComment(CGEHalfMove *m, std::uint32_t line, std::uint32_t indent, + const Element &move_bound, const char &indent_black); + std::uint32_t DrawVariations(CGEHalfMove *m, std::uint32_t line, std::uint32_t indent, + const Element &move_bound, + const char &indent_black); + +public: + MoveTable(Status *s); + void Refresh(); + std::vector<Element> GetVariationsMarging() { return (VariationMargins); } +}; +} // namespace cgeditor
\ No newline at end of file |
