Commit 78c2ab5e authored by twanvl's avatar twanvl

Some more keyboard related tweaks.

parent edd8649d
...@@ -79,17 +79,23 @@ void DataEditor::selectFirst() { ...@@ -79,17 +79,23 @@ void DataEditor::selectFirst() {
selectByTabPos(0); selectByTabPos(0);
} }
bool DataEditor::selectNext() { bool DataEditor::selectNext() {
return selectByTabPos(currentTabPos() + 1); return selectByTabPos(currentTabPos() + 1, true);
} }
bool DataEditor::selectPrevious() { bool DataEditor::selectPrevious() {
return selectByTabPos(currentTabPos() - 1); return selectByTabPos(currentTabPos() - 1, false);
} }
bool DataEditor::selectByTabPos(int tab_pos) { bool DataEditor::selectByTabPos(int tab_pos, bool forward) {
if (tab_pos >= 0 && (size_t)tab_pos < by_tab_index.size()) { while (tab_pos >= 0 && (size_t)tab_pos < by_tab_index.size()) {
select(by_tab_index[tab_pos]); ValueViewer* v = by_tab_index[tab_pos];
return true; if (v->getField()->editable) {
} else if (!by_tab_index.empty()) { select(v);
return true;
}
// not enabled, maybe the next one?
tab_pos += forward ? 1 : -1;
}
if (!by_tab_index.empty()) {
// also select something! so when we regain focus the selected editor makes sense // also select something! so when we regain focus the selected editor makes sense
if (tab_pos < 0) select(by_tab_index.back()); if (tab_pos < 0) select(by_tab_index.back());
else select(by_tab_index.front()); else select(by_tab_index.front());
...@@ -235,7 +241,7 @@ void DataEditor::onMotion(wxMouseEvent& ev) { ...@@ -235,7 +241,7 @@ void DataEditor::onMotion(wxMouseEvent& ev) {
if (!HasCapture()) { if (!HasCapture()) {
// find editor under mouse // find editor under mouse
ValueViewer* new_hovered_viewer = nullptr; ValueViewer* new_hovered_viewer = nullptr;
FOR_EACH_EDITOR_REVERSE { // find high z index fields first FOR_EACH_REVERSE(v,viewers) { // find high z index fields first
if (v->containsPoint(pos) && v->getField()->editable) { if (v->containsPoint(pos) && v->getField()->editable) {
new_hovered_viewer = v.get(); new_hovered_viewer = v.get();
break; break;
...@@ -305,8 +311,6 @@ void DataEditor::selectFieldNoEvents(const RealPoint& p) { ...@@ -305,8 +311,6 @@ void DataEditor::selectFieldNoEvents(const RealPoint& p) {
return; return;
} }
} }
//% current_viewer = nullptr;
//% current_editor = nullptr;
} }
RealPoint DataEditor::mousePoint(const wxMouseEvent& ev) { RealPoint DataEditor::mousePoint(const wxMouseEvent& ev) {
......
...@@ -126,7 +126,7 @@ class DataEditor : public CardViewer { ...@@ -126,7 +126,7 @@ class DataEditor : public CardViewer {
void createTabIndex(); void createTabIndex();
/// Select the field with the given position in the by_tab_index list /// Select the field with the given position in the by_tab_index list
/** Returns success */ /** Returns success */
bool selectByTabPos(int tab_pos); bool selectByTabPos(int tab_pos, bool forward = true);
/// Find the tab pos of the current viewer, returns -1 if not found /// Find the tab pos of the current viewer, returns -1 if not found
int currentTabPos() const; int currentTabPos() const;
}; };
......
...@@ -18,7 +18,6 @@ DECLARE_TYPEOF_COLLECTION(ValueViewerP); ...@@ -18,7 +18,6 @@ DECLARE_TYPEOF_COLLECTION(ValueViewerP);
TextCtrl::TextCtrl(Window* parent, int id, bool multi_line, long style) TextCtrl::TextCtrl(Window* parent, int id, bool multi_line, long style)
: DataEditor(parent, id, style) : DataEditor(parent, id, style)
, value(nullptr)
, multi_line(multi_line) , multi_line(multi_line)
{} {}
TextCtrl::~TextCtrl() {} TextCtrl::~TextCtrl() {}
...@@ -36,6 +35,12 @@ void TextCtrl::draw(DC& dc) { ...@@ -36,6 +35,12 @@ void TextCtrl::draw(DC& dc) {
} }
} }
bool TextCtrl::AcceptsFocus() const {
return wxControl::AcceptsFocus() &&
!viewers.empty() &&
static_cast<FakeTextValue&>(*viewers.front()->getValue()).editable;
}
TextStyle& TextCtrl::getStyle() { TextStyle& TextCtrl::getStyle() {
assert(!viewers.empty()); assert(!viewers.empty());
......
...@@ -55,6 +55,8 @@ class TextCtrl : public DataEditor { ...@@ -55,6 +55,8 @@ class TextCtrl : public DataEditor {
virtual void draw(DC& dc); virtual void draw(DC& dc);
virtual bool AcceptsFocus() const;
virtual void onChangeSet(); virtual void onChangeSet();
protected: protected:
...@@ -62,7 +64,6 @@ class TextCtrl : public DataEditor { ...@@ -62,7 +64,6 @@ class TextCtrl : public DataEditor {
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
private: private:
String* value; ///< Value to edit
bool multi_line; ///< Multi line text control? bool multi_line; ///< Multi line text control?
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
......
...@@ -53,6 +53,7 @@ NewSetWindow::NewSetWindow(Window* parent) ...@@ -53,6 +53,7 @@ NewSetWindow::NewSetWindow(Window* parent)
} catch (FileNotFoundError e) { } catch (FileNotFoundError e) {
handle_error(e); handle_error(e);
} }
game_list->SetFocus();
UpdateWindowUI(wxUPDATE_UI_RECURSE); UpdateWindowUI(wxUPDATE_UI_RECURSE);
} }
......
...@@ -37,6 +37,7 @@ CardsPanel::CardsPanel(Window* parent, int id) ...@@ -37,6 +37,7 @@ CardsPanel::CardsPanel(Window* parent, int id)
notes = new TextCtrl(notesP, ID_NOTES, true); notes = new TextCtrl(notesP, ID_NOTES, true);
collapse_notes = new HoverButton(notesP, ID_COLLAPSE_NOTES, _("btn_collapse"), wxNullColour, false); collapse_notes = new HoverButton(notesP, ID_COLLAPSE_NOTES, _("btn_collapse"), wxNullColour, false);
collapse_notes->SetExtraStyle(wxWS_EX_PROCESS_UI_UPDATES); collapse_notes->SetExtraStyle(wxWS_EX_PROCESS_UI_UPDATES);
filter = nullptr;
// init sizer for notes panel // init sizer for notes panel
wxSizer* sn = new wxBoxSizer(wxVERTICAL); wxSizer* sn = new wxBoxSizer(wxVERTICAL);
wxSizer* sc = new wxBoxSizer(wxHORIZONTAL); wxSizer* sc = new wxBoxSizer(wxHORIZONTAL);
...@@ -124,6 +125,9 @@ void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) { ...@@ -124,6 +125,9 @@ void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
tb->AddTool(ID_CARD_REMOVE, _(""), load_resource_tool_image(_("card_del")), wxNullBitmap, wxITEM_NORMAL,_TOOLTIP_("remove card"), _HELP_("remove card")); tb->AddTool(ID_CARD_REMOVE, _(""), load_resource_tool_image(_("card_del")), wxNullBitmap, wxITEM_NORMAL,_TOOLTIP_("remove card"), _HELP_("remove card"));
tb->AddSeparator(); tb->AddSeparator();
tb->AddTool(ID_CARD_ROTATE, _(""), load_resource_tool_image(_("card_rotate")), wxNullBitmap,wxITEM_NORMAL, _TOOLTIP_("rotate card"), _HELP_("rotate card")); tb->AddTool(ID_CARD_ROTATE, _(""), load_resource_tool_image(_("card_rotate")), wxNullBitmap,wxITEM_NORMAL, _TOOLTIP_("rotate card"), _HELP_("rotate card"));
//% tb->AddSeparator();
//% if (!filter) filter = new wxTextCtrl(tb, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, wxSTATIC_BORDER);
//% tb->AddControl(filter);
tb->Realize(); tb->Realize();
// Menus // Menus
mb->Insert(2, menuCard, _MENU_("cards")); mb->Insert(2, menuCard, _MENU_("cards"));
...@@ -139,9 +143,11 @@ void CardsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) { ...@@ -139,9 +143,11 @@ void CardsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
tb->DeleteTool(ID_CARD_ADD); tb->DeleteTool(ID_CARD_ADD);
tb->DeleteTool(ID_CARD_REMOVE); tb->DeleteTool(ID_CARD_REMOVE);
tb->DeleteTool(ID_CARD_ROTATE); tb->DeleteTool(ID_CARD_ROTATE);
//% tb->DeleteTool(filter->GetId()); filter = nullptr;
// HACK: hardcoded size of rest of toolbar // HACK: hardcoded size of rest of toolbar
tb->DeleteToolByPos(12); // delete separator tb->DeleteToolByPos(12); // delete separator
tb->DeleteToolByPos(12); // delete separator tb->DeleteToolByPos(12); // delete separator
//% tb->DeleteToolByPos(12); // delete separator
// Menus // Menus
mb->Remove(3); mb->Remove(3);
mb->Remove(2); mb->Remove(2);
......
...@@ -77,6 +77,7 @@ class CardsPanel : public SetWindowPanel { ...@@ -77,6 +77,7 @@ class CardsPanel : public SetWindowPanel {
ImageCardList* card_list; ImageCardList* card_list;
TextCtrl* notes; TextCtrl* notes;
HoverButton* collapse_notes; HoverButton* collapse_notes;
wxTextCtrl* filter;
// --------------------------------------------------- : Menus & tools // --------------------------------------------------- : Menus & tools
IconMenu* menuCard, *menuFormat; IconMenu* menuCard, *menuFormat;
......
...@@ -39,8 +39,8 @@ KeywordsPanel::KeywordsPanel(Window* parent, int id) ...@@ -39,8 +39,8 @@ KeywordsPanel::KeywordsPanel(Window* parent, int id)
mode = new wxChoice(panel, ID_KEYWORD_MODE, wxDefaultPosition, wxDefaultSize, 0, nullptr); mode = new wxChoice(panel, ID_KEYWORD_MODE, wxDefaultPosition, wxDefaultSize, 0, nullptr);
match = new TextCtrl(panel, ID_MATCH, false); match = new TextCtrl(panel, ID_MATCH, false);
add_param = new wxButton(panel, ID_KEYWORD_ADD_PARAM, _BUTTON_("insert parameter")); add_param = new wxButton(panel, ID_KEYWORD_ADD_PARAM, _BUTTON_("insert parameter"));
ref_param = new wxButton(panel, ID_KEYWORD_REF_PARAM, _BUTTON_("refer parameter"));
reminder = new TextCtrl(panel, ID_REMINDER, true); // allow multiline for wordwrap reminder = new TextCtrl(panel, ID_REMINDER, true); // allow multiline for wordwrap
ref_param = new wxButton(panel, ID_KEYWORD_REF_PARAM, _BUTTON_("refer parameter"));
rules = new TextCtrl(panel, ID_RULES, true); rules = new TextCtrl(panel, ID_RULES, true);
errors = new wxStaticText(panel, wxID_ANY, _("")); errors = new wxStaticText(panel, wxID_ANY, _(""));
errors->SetForegroundColour(*wxRED); errors->SetForegroundColour(*wxRED);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment