aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-12-30 13:17:06 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-12-30 13:17:06 +0100
commit98e31a2c11fc1ae3dbc93576956ce3f4faad7fbd (patch)
tree54b7df1f6e3b5887ecc7072ae719911c29ec4427
parent2fd237a78ffd78e198bfb68ba2fc9fa296a1fe9f (diff)
Improve UI
-rw-r--r--src/game_tab/left_panel/GameTabLeftPanel.cpp19
-rw-r--r--src/game_tab/left_panel/GameTabLeftPanel.hpp2
-rw-r--r--src/game_tab/left_panel/board/BoardCanvas.cpp20
-rw-r--r--src/game_tab/left_panel/board/BoardCanvas.hpp4
-rw-r--r--src/gui.cpp5
-rw-r--r--src/gui.h2
-rw-r--r--tools/wxFrameBuilder.fbp80
7 files changed, 116 insertions, 16 deletions
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.cpp b/src/game_tab/left_panel/GameTabLeftPanel.cpp
index d1604e4..c5bf8ae 100644
--- a/src/game_tab/left_panel/GameTabLeftPanel.cpp
+++ b/src/game_tab/left_panel/GameTabLeftPanel.cpp
@@ -4,9 +4,13 @@
GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
: TabGameLeftPanel(parent), game(game), repeat(false) {
+ // Configure toolbal
+ game_toolbar->AddTool(0, wxT("Exit application"),
+ wxArtProvider::GetBitmap(wxART_FILE_SAVE, wxART_TOOLBAR));
+
// Add board
board_canvas = new BoardCanvas((wxFrame *)this);
- main_sizer->Insert(0, board_canvas, 1, wxEXPAND);
+ main_sizer->Insert(1, board_canvas, 1, wxEXPAND);
// Configure buttons
swap_button->SetBitmapLabel(LoadPNG("swap"));
@@ -22,6 +26,16 @@ GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnZoomOut, this, ZOOM_OUT_BTN);
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();});
+ game_toolbar->Bind(wxEVT_TOOL,&GameTabLeftPanel::OnToolClick,this);
+}
+
+void GameTabLeftPanel::OnToolClick(wxCommandEvent &event){
+ short id=event.GetId();
+ if(id==0){
+ if(related_file.size()>0){
+ // Todo implement save file
+ }
+ }
}
void GameTabLeftPanel::PreviousMove(bool isKeyDown) {
@@ -90,7 +104,8 @@ void GameTabLeftPanel::Notify(bool animate, bool backward) {
last_absolute_move=m->GetAbsoluteMove();
}
board_canvas->SetupBoard(chessarbiter::FENParser::Parse(fen).board,
- game->IsBlackToPlay(), captures);
+ game->IsBlackToPlay(), captures,
+ game->GetTag("White"),game->GetTag("Black"));
}
else{
if(backward && last_absolute_move.size()>0){
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.hpp b/src/game_tab/left_panel/GameTabLeftPanel.hpp
index d254ace..25cbcf0 100644
--- a/src/game_tab/left_panel/GameTabLeftPanel.hpp
+++ b/src/game_tab/left_panel/GameTabLeftPanel.hpp
@@ -14,6 +14,7 @@ class GameTabLeftPanel : public TabGameLeftPanel {
void NotifyEditor();
std::string last_absolute_move;
bool repeat;
+ std::string related_file;
public:
GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game);
@@ -27,4 +28,5 @@ public:
void OnSwap(wxCommandEvent &event);
void OnRefreshBoard(wxCommandEvent &event);
void ApplyPreferences();
+ void OnToolClick(wxCommandEvent &event);
}; \ No newline at end of file
diff --git a/src/game_tab/left_panel/board/BoardCanvas.cpp b/src/game_tab/left_panel/board/BoardCanvas.cpp
index 0d75c62..47b7661 100644
--- a/src/game_tab/left_panel/board/BoardCanvas.cpp
+++ b/src/game_tab/left_panel/board/BoardCanvas.cpp
@@ -75,7 +75,7 @@ void BoardCanvas::OnPaint(wxPaintEvent &event) {
adata.frame++;
if(adata.frame>=adata.frames){
adata.reuseBuffer=false;
- SetupBoard(adata.final_board, adata.final_is_black_turn, adata.final_captures);
+ SetupBoard(adata.final_board, adata.final_is_black_turn, adata.final_captures,white_player,black_player);
}
}
}
@@ -103,10 +103,13 @@ void BoardCanvas::ApplyPreferences() {
}
void BoardCanvas::SetupBoard(std::string board, bool is_black_turn,
- std::map<char, std::uint8_t> captures) {
+ std::map<char, std::uint8_t> captures,
+ std::string white_player, std::string black_player) {
this->board = board;
this->is_black_turn = is_black_turn;
this->captures = captures;
+ this->white_player=white_player;
+ this->black_player=black_player;
Refresh();
}
@@ -208,8 +211,9 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
if(rank==7){ // Bottom numbers
dc.DrawText(wxString((char)('a'+7-file)),
x+square_width/2-numbers_size.x/2,y+square_width);
- }
+ }
+ // Draw pieces
std::uint8_t prank = rank;
std::uint8_t pfile = file;
if (black_side) {
@@ -252,13 +256,16 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
badgeWidth);
dc.DrawRectangle(badge);
- // Draw captures first for white then for black
+ // Draw captures (+player names) first for white then for black
std::uint32_t captures_size = t_captures->GetPiecesSizes();
std::uint8_t padding = numbers_size.y+10;
std::uint32_t offsetX = 0;
std::uint32_t offsetY = -(captures_size + padding);
+ std::uint32_t offsetYPlayerName=offsetY-captures_size;
+ // White
if (black_side) {
offsetY = 8 * square_width + padding;
+ offsetYPlayerName = offsetY+captures_size;
}
for (char p : {'P', 'N', 'B', 'R', 'Q'}) {
if (captures.find(p) != captures.end()) {
@@ -269,11 +276,15 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
offsetX += captures_size / 2;
}
}
+ dc.DrawText(wxString(black_player),boardX,boardY + offsetYPlayerName);
+ // Black
offsetX = 0;
if (black_side) {
offsetY = -(captures_size + padding);
+ offsetYPlayerName = offsetY-captures_size;
} else {
offsetY = 8 * square_width + padding;
+ offsetYPlayerName = offsetY+captures_size;
}
for (char p : {'p', 'n', 'b', 'r', 'q'}) {
if (captures.find(p) != captures.end()) {
@@ -284,6 +295,7 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
offsetX += captures_size / 2;
}
}
+ dc.DrawText(wxString(white_player),boardX,boardY + offsetYPlayerName);
// Draw dragging piece
if (DrawDraggingPiece) {
diff --git a/src/game_tab/left_panel/board/BoardCanvas.hpp b/src/game_tab/left_panel/board/BoardCanvas.hpp
index d3ce5c4..2ea44ae 100644
--- a/src/game_tab/left_panel/board/BoardCanvas.hpp
+++ b/src/game_tab/left_panel/board/BoardCanvas.hpp
@@ -74,6 +74,7 @@ class BoardCanvas : public wxPanel {
Theme *t, *t_captures;
// Board to draw (char version)
std::string board;
+ std::string white_player,black_player;
// Various canvas state variables
bool black_side, is_dragging, valid_drag, is_black_turn;
@@ -99,7 +100,8 @@ public:
void Zoom(std::int32_t zoom);
void Swap();
void SetupBoard(std::string board, bool is_black_turn,
- std::map<char, std::uint8_t> captures);
+ std::map<char, std::uint8_t> captures,
+ std::string white_player, std::string black_player);
void Animate(const std::string &board, bool is_black_turn, std::map<char, std::uint8_t> captures, std::string src, std::string dst,bool faster);
void SetClockTime(short hours, short min, short sec, bool IsBlack);
DECLARE_EVENT_TABLE()
diff --git a/src/gui.cpp b/src/gui.cpp
index de87bcc..4702692 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -392,6 +392,11 @@ TabGameLeftPanel::TabGameLeftPanel( wxWindow* parent, wxWindowID id, const wxPoi
{
main_sizer = new wxBoxSizer( wxVERTICAL );
+ game_toolbar = new wxToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL );
+ game_toolbar->Realize();
+
+ main_sizer->Add( game_toolbar, 0, wxEXPAND, 5 );
+
wxBoxSizer* bar_sizer;
bar_sizer = new wxBoxSizer( wxHORIZONTAL );
diff --git a/src/gui.h b/src/gui.h
index 705c8a7..3380e02 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -37,6 +37,7 @@
#include <wx/checkbox.h>
#include <wx/splitter.h>
#include <wx/notebook.h>
+#include <wx/toolbar.h>
#include <wx/bmpbuttn.h>
#include <wx/combobox.h>
@@ -258,6 +259,7 @@ class TabGameLeftPanel : public wxPanel
protected:
wxBoxSizer* main_sizer;
+ wxToolBar* game_toolbar;
wxBitmapButton* zoomin_button;
wxBitmapButton* zoomout_button;
wxBitmapButton* swap_button;
diff --git a/tools/wxFrameBuilder.fbp b/tools/wxFrameBuilder.fbp
index 40e735f..ab8d3d3 100644
--- a/tools/wxFrameBuilder.fbp
+++ b/tools/wxFrameBuilder.fbp
@@ -3743,6 +3743,68 @@
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
+ <object class="wxToolBar" expanded="1">
+ <property name="BottomDockable">1</property>
+ <property name="LeftDockable">1</property>
+ <property name="RightDockable">1</property>
+ <property name="TopDockable">1</property>
+ <property name="aui_layer"></property>
+ <property name="aui_name"></property>
+ <property name="aui_position"></property>
+ <property name="aui_row"></property>
+ <property name="best_size"></property>
+ <property name="bg"></property>
+ <property name="bitmapsize"></property>
+ <property name="caption"></property>
+ <property name="caption_visible">1</property>
+ <property name="center_pane">0</property>
+ <property name="close_button">1</property>
+ <property name="context_help"></property>
+ <property name="context_menu">1</property>
+ <property name="default_pane">0</property>
+ <property name="dock">Dock</property>
+ <property name="dock_fixed">0</property>
+ <property name="docking">Left</property>
+ <property name="enabled">1</property>
+ <property name="fg"></property>
+ <property name="floatable">1</property>
+ <property name="font"></property>
+ <property name="gripper">0</property>
+ <property name="hidden">0</property>
+ <property name="id">wxID_ANY</property>
+ <property name="margins"></property>
+ <property name="max_size"></property>
+ <property name="maximize_button">0</property>
+ <property name="maximum_size"></property>
+ <property name="min_size"></property>
+ <property name="minimize_button">0</property>
+ <property name="minimum_size"></property>
+ <property name="moveable">1</property>
+ <property name="name">game_toolbar</property>
+ <property name="packing">1</property>
+ <property name="pane_border">1</property>
+ <property name="pane_position"></property>
+ <property name="pane_size"></property>
+ <property name="permission">protected</property>
+ <property name="pin_button">1</property>
+ <property name="pos"></property>
+ <property name="resize">Resizable</property>
+ <property name="separation">5</property>
+ <property name="show">1</property>
+ <property name="size"></property>
+ <property name="style">wxTB_HORIZONTAL</property>
+ <property name="subclass">; ; forward_declare</property>
+ <property name="toolbar_pane">0</property>
+ <property name="tooltip"></property>
+ <property name="window_extra_style"></property>
+ <property name="window_name"></property>
+ <property name="window_style"></property>
+ </object>
+ </object>
+ <object class="sizeritem" expanded="1">
+ <property name="border">5</property>
+ <property name="flag">wxEXPAND</property>
+ <property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bar_sizer</property>
@@ -4035,7 +4097,7 @@
</object>
</object>
</object>
- <object class="Panel" expanded="1">
+ <object class="Panel" expanded="0">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
@@ -4058,16 +4120,16 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
- <object class="wxBoxSizer" expanded="1">
+ <object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">main_sizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
- <object class="sizeritem" expanded="1">
+ <object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">1</property>
- <object class="wxNotebook" expanded="1">
+ <object class="wxNotebook" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@@ -4120,11 +4182,11 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
- <object class="notebookpage" expanded="1">
+ <object class="notebookpage" expanded="0">
<property name="bitmap"></property>
<property name="label">Editor</property>
<property name="select">0</property>
- <object class="wxPanel" expanded="1">
+ <object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@@ -4175,7 +4237,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
- <object class="wxBoxSizer" expanded="1">
+ <object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">editor_page_sizer</property>
<property name="orient">wxVERTICAL</property>
@@ -4374,11 +4436,11 @@
<property name="window_style"></property>
</object>
</object>
- <object class="sizeritem" expanded="1">
+ <object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">1</property>
- <object class="wxPanel" expanded="1">
+ <object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>