feat: add clear button to console panel

This commit is contained in:
Brendan Hagan
2022-06-22 22:37:58 -04:00
parent d3bd691578
commit d3712460e8
7 changed files with 62 additions and 15 deletions
+1
View File
@@ -10,6 +10,7 @@ Features:
* Add Button to Center the loaded image in the Image Slice Window. * Add Button to Center the loaded image in the Image Slice Window.
* Add "Created At", "Last Modified At" columns to card list. * Add "Created At", "Last Modified At" columns to card list.
* Add filter box to Game and Stylesheet selection. * Add filter box to Game and Stylesheet selection.
* Add Clear button to console panel.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
HEAD: new items added as changes are made HEAD: new items added as changes are made
+11
View File
@@ -81,6 +81,9 @@ menu:
scatter: S&catter Plot 4 scatter: S&catter Plot 4
scatter pie: Sc&atter-Pie 5 scatter pie: Sc&atter-Pie 5
console: Console
clear console: &Clear Console Ctrl+L
window: &Window window: &Window
new window: &New Window new window: &New Window
cards tab: &Cards Alt+1 cards tab: &Cards Alt+1
@@ -197,6 +200,9 @@ help:
scatter: A scatter plot, the size indicates the number of cards scatter: A scatter plot, the size indicates the number of cards
scatter pie: A scatter plot where each item is a small pie graph scatter pie: A scatter plot where each item is a small pie graph
#console:
clear console: Clear the console
#window: #window:
new window: Creates another window to edit the same set new window: Creates another window to edit the same set
cards tab: Edit the cards in the set cards tab: Edit the cards in the set
@@ -353,6 +359,8 @@ tool:
smooth point: Smooth smooth point: Smooth
symmetric point: Symmetric symmetric point: Symmetric
clear console: Clear Console
############################################################## Toolbar help text ############################################################## Toolbar help text
tooltip: tooltip:
cards tab: cards tab:
@@ -428,6 +436,8 @@ tooltip:
smooth point: Make point smooth smooth point: Make point smooth
symmetric point: Make point symmetric symmetric point: Make point symmetric
clear console: Clear Console
############################################################## Labels in the GUI ############################################################## Labels in the GUI
label: label:
# Cards tab # Cards tab
@@ -583,6 +593,7 @@ button:
# Console panel # Console panel
evaluate: &Evaluate evaluate: &Evaluate
clear: &Clear
# Welcome # Welcome
new set: New set new set: New set
Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

+2
View File
@@ -61,6 +61,8 @@ tool/graph_stack IMAGE "tool/graph_stack.png"
tool/graph_scatter IMAGE "tool/graph_scatter.png" tool/graph_scatter IMAGE "tool/graph_scatter.png"
tool/graph_scatter_pie IMAGE "tool/graph_scatter_pie.png" tool/graph_scatter_pie IMAGE "tool/graph_scatter_pie.png"
tool/clear_console IMAGE "tool/clear_console.png"
tool/window_cards IMAGE "tool/window_cards.png" tool/window_cards IMAGE "tool/window_cards.png"
tool/window_set_info IMAGE "tool/window_set_info.png" tool/window_set_info IMAGE "tool/window_set_info.png"
tool/window_style IMAGE "tool/window_style.png" tool/window_style IMAGE "tool/window_style.png"
+29
View File
@@ -81,6 +81,14 @@ public:
add_message(make_intrusive<ConsoleMessage>(type,text,joined_to_previous)); add_message(make_intrusive<ConsoleMessage>(type,text,joined_to_previous));
} }
void clear_console() {
messages.clear();
layout_all();
selection = messages.size();
update_scrollbar();
Refresh(false);
}
bool have_selection() const { bool have_selection() const {
return selection < messages.size(); return selection < messages.size();
} }
@@ -455,6 +463,7 @@ END_EVENT_TABLE()
ConsolePanel::ConsolePanel(Window* parent, int id) ConsolePanel::ConsolePanel(Window* parent, int id)
: SetWindowPanel(parent, id) : SetWindowPanel(parent, id)
, menuConsole(nullptr)
, messages(nullptr) , messages(nullptr)
, entry(nullptr) , entry(nullptr)
, is_active_window(false) , is_active_window(false)
@@ -467,10 +476,12 @@ ConsolePanel::ConsolePanel(Window* parent, int id)
entry_panel = new wxPanel(splitter, wxID_ANY); entry_panel = new wxPanel(splitter, wxID_ANY);
entry = new HistoryTextCtrl(entry_panel, wxID_ANY); entry = new HistoryTextCtrl(entry_panel, wxID_ANY);
wxButton* evaluate = new wxButton(entry_panel, ID_EVALUATE, _BUTTON_("evaluate")); wxButton* evaluate = new wxButton(entry_panel, ID_EVALUATE, _BUTTON_("evaluate"));
wxButton* clear = new wxButton(entry_panel, ID_CLEAR_CONSOLE, _BUTTON_("clear"));
// init sizer for entry_panel // init sizer for entry_panel
wxSizer* se = new wxBoxSizer(wxHORIZONTAL); wxSizer* se = new wxBoxSizer(wxHORIZONTAL);
se->Add(entry, 1, wxEXPAND, 2); se->Add(entry, 1, wxEXPAND, 2);
se->Add(evaluate, 0, wxEXPAND | wxLEFT, 2); se->Add(evaluate, 0, wxEXPAND | wxLEFT, 2);
se->Add(clear, 0, wxEXPAND | wxLEFT, 2);
entry_panel->SetSizer(se); entry_panel->SetSizer(se);
// init splitter // init splitter
splitter->SetMinimumPaneSize(40); splitter->SetMinimumPaneSize(40);
@@ -481,6 +492,14 @@ ConsolePanel::ConsolePanel(Window* parent, int id)
s->Add(splitter, 1, wxEXPAND); s->Add(splitter, 1, wxEXPAND);
s->SetSizeHints(this); s->SetSizeHints(this);
SetSizer(s); SetSizer(s);
// init menus
menuConsole = new wxMenu();
add_menu_item_tr(menuConsole, ID_CLEAR_CONSOLE, "clear_console", "clear console");
}
ConsolePanel::~ConsolePanel() {
delete menuConsole;
} }
void ConsolePanel::onChangeSet() { void ConsolePanel::onChangeSet() {
@@ -501,11 +520,18 @@ void ConsolePanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
// stop blinker // stop blinker
is_active_window = true; is_active_window = true;
stop_blinker(); stop_blinker();
add_tool_tr(tb, ID_CLEAR_CONSOLE, "clear_console", "clear console");
tb->Realize();
mb->Insert(2, menuConsole, _MENU_("console"));
} }
void ConsolePanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) { void ConsolePanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar // Toolbar
tb->DeleteTool(ID_CLEAR_CONSOLE);
// Menus // Menus
mb->Remove(2);
// we are no longer active, allow blinker // we are no longer active, allow blinker
is_active_window = false; is_active_window = false;
@@ -524,6 +550,9 @@ void ConsolePanel::onCommand(int id) {
if (id == ID_EVALUATE) { if (id == ID_EVALUATE) {
exec(entry->get_command_and_clear()); exec(entry->get_command_and_clear());
} }
else if (id == ID_CLEAR_CONSOLE) {
messages->clear_console();
}
} }
void ConsolePanel::onIdle(wxIdleEvent&) { void ConsolePanel::onIdle(wxIdleEvent&) {
+3
View File
@@ -20,6 +20,7 @@ class HistoryTextCtrl;
class ConsolePanel : public SetWindowPanel { class ConsolePanel : public SetWindowPanel {
public: public:
ConsolePanel(Window* parent, int id); ConsolePanel(Window* parent, int id);
~ConsolePanel();
// --------------------------------------------------- : UI // --------------------------------------------------- : UI
@@ -50,6 +51,8 @@ private:
wxPanel* entry_panel; wxPanel* entry_panel;
HistoryTextCtrl* entry; HistoryTextCtrl* entry;
wxMenu* menuConsole;
void get_pending_errors(); void get_pending_errors();
void exec(String const& code); void exec(String const& code);
+1
View File
@@ -209,6 +209,7 @@ enum ChildMenuID {
// Console panel // Console panel
ID_EVALUATE, ID_EVALUATE,
ID_CLEAR_CONSOLE,
// SymbolFont (Format menu) // SymbolFont (Format menu)
ID_INSERT_SYMBOL_MENU_MIN = 9001, ID_INSERT_SYMBOL_MENU_MIN = 9001,