More UI tweaks

This commit is contained in:
Henrik Rydgard committed 2013-08-13 00:06:23 +02:00
1 parent 76d0d5ceb3
commit 77fcfd0f20
5 files changed
+29 -1

No files matched your search

+8
View File
@@ -59,6 +59,14 @@ void UIScreen::key(const KeyInput &key) {
}
}
void DialogScreen::key(const KeyInput &key) {
if ((key.flags & KEY_DOWN) && key.keyCode == NKCODE_ESCAPE || key.keyCode == NKCODE_BACK || key.keyCode == NKCODE_BUTTON_B) {
screenManager()->finishDialog(this, DR_CANCEL);
} else {
UIScreen::key(key);
}
}
void UIScreen::axis(const AxisInput &axis) {
// Simple translation of hat to keys for Shield and other modern pads.
// TODO: Use some variant of keymap?
+6
View File
@@ -32,6 +32,12 @@ private:
int hatDown_;
};
class DialogScreen : public UIScreen {
public:
virtual void key(const KeyInput &key);
};
class PopupScreen : public UIScreen {
public:
PopupScreen(const std::string &title);
+3
View File
@@ -207,7 +207,10 @@ void Clickable::Key(const KeyInput &key) {
if (IsAcceptKeyCode(key.keyCode)) {
if (down_) {
Click();
down_ = false;
}
} else if (IsEscapeKeyCode(key.keyCode)) {
down_ = false;
}
}
}
+10 -1
View File
@@ -781,6 +781,16 @@ void ChoiceStrip::SetSelection(int sel) {
static_cast<StickyChoice *>(views_[selected_])->Press();
}
void ChoiceStrip::Key(const KeyInput &input) {
if (input.flags & KEY_DOWN) {
if (input.keyCode == NKCODE_BUTTON_L1 && selected_ > 0) {
SetSelection(selected_ - 1);
} else if (input.keyCode == NKCODE_BUTTON_R1 && selected_ < views_.size() - 1) {
SetSelection(selected_ + 1);
}
}
}
ListView::ListView(ListAdaptor *a, LayoutParams *layoutParams)
: ScrollView(ORIENT_VERTICAL, layoutParams), adaptor_(a) {
linLayout_ = new LinearLayout(ORIENT_VERTICAL);
@@ -858,7 +868,6 @@ static std::vector<int> focusMoves;
void KeyEvent(const KeyInput &key, ViewGroup *root) {
if (key.flags & KEY_DOWN) {
ILOG("ke: %i %02x", key.deviceId, key.keyCode);
// We ignore the device ID here. Anything with a DPAD is OK.
if (key.keyCode >= NKCODE_DPAD_UP && key.keyCode <= NKCODE_DPAD_RIGHT) {
lock_guard lock(focusLock);
+2
View File
@@ -225,6 +225,8 @@ public:
void AddChoice(const std::string &title);
int GetSelection() const { return selected_; }
void SetSelection(int sel);
virtual void Key(const KeyInput &input);
Event OnChoice;
private: