From aa94a41353e5df639548ce2ca21a0db83f7c3027 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Thu, 29 Dec 2022 12:28:51 +0100 Subject: Debug pieces animation --- src/game_tab/left_panel/board/BoardCanvas.cpp | 25 ++++--------------------- src/game_tab/left_panel/board/BoardCanvas.hpp | 1 - 2 files changed, 4 insertions(+), 22 deletions(-) (limited to 'src/game_tab/left_panel/board') diff --git a/src/game_tab/left_panel/board/BoardCanvas.cpp b/src/game_tab/left_panel/board/BoardCanvas.cpp index 58c3fd6..7445c57 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.cpp +++ b/src/game_tab/left_panel/board/BoardCanvas.cpp @@ -16,11 +16,11 @@ BoardCanvas::BoardCanvas(wxFrame *parent) // The following should be called when using an EVT_PAINT handler SetBackgroundStyle(wxBG_STYLE_PAINT); duration=200; - duration_fast=100; + duration_fast=80; fps=30; - Bind(wxEVT_KEY_DOWN, &BoardCanvas::OnKeyEvent, this); - Bind(wxEVT_KEY_UP, &BoardCanvas::OnKeyEvent, this); + Bind(wxEVT_KEY_DOWN, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();}); + Bind(wxEVT_KEY_UP, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();}); } BoardCanvas::~BoardCanvas() { @@ -123,7 +123,7 @@ void BoardCanvas::Animate(std::string board, bool is_black_turn, std::mapboard[pfile + 8 * (7-prank)]=' '; wxMemoryDC memDC(*buffer); DrawBoard(memDC); - + // Now compute piece start position and translation vector (Copy paste from DrawBoard()) std::uint32_t piece_width = t->GetPiecesSizes(); std::uint32_t centrer_offset = (square_width - piece_width) / 2; @@ -369,23 +369,6 @@ void BoardCanvas::Swap() { Refresh(); } -void BoardCanvas::OnKeyEvent(wxKeyEvent &event) { - event.ResumePropagation(1); -event.Skip(); -return; - wxLogDebug("OnKeyEvent %d",event.GetUnicodeKey()); - if (event.GetKeyCode() == WXK_LEFT) { - wxCommandEvent previousEvent(PREVIOUS_MOVE_EVENT, GetId()); - //previousEvent.SetEventObject(this); - ProcessEvent(previousEvent); - } else if (event.GetKeyCode() == WXK_RIGHT) { - wxCommandEvent nextEvent(NEXT_MOVE_EVENT, GetId()); - //nextEvent.SetEventObject(this); - ProcessEvent(nextEvent); - } -} - - void BoardCanvas::SetClockTime(short hours, short min, short sec, bool IsBlack) { if (IsBlack) { diff --git a/src/game_tab/left_panel/board/BoardCanvas.hpp b/src/game_tab/left_panel/board/BoardCanvas.hpp index 1da45b2..eeff44d 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.hpp +++ b/src/game_tab/left_panel/board/BoardCanvas.hpp @@ -75,7 +75,6 @@ public: void ApplyPreferences(); void DrawBoard(wxDC &dc); void OnPaint(wxPaintEvent &event); - void OnKeyEvent(wxKeyEvent &event); void MouseEvent(wxMouseEvent &event); void Zoom(std::int32_t zoom); void Swap(); -- cgit v1.2.3