rename keycode, mousecode enumerations
This commit is contained in:
@@ -135,7 +135,7 @@ void GUI::actMouse(float delta, const CursorState& cursor) {
|
||||
}
|
||||
this->hover = hover;
|
||||
|
||||
if (input.jclicked(mousecode::BUTTON_1)) {
|
||||
if (input.jclicked(Mousecode::BUTTON_1)) {
|
||||
if (pressed == nullptr && this->hover) {
|
||||
pressed = hover;
|
||||
if (doubleClickTimer < doubleClickDelay) {
|
||||
@@ -158,13 +158,13 @@ void GUI::actMouse(float delta, const CursorState& cursor) {
|
||||
focus->defocus();
|
||||
focus = nullptr;
|
||||
}
|
||||
} else if (!input.clicked(mousecode::BUTTON_1) && pressed) {
|
||||
} else if (!input.clicked(Mousecode::BUTTON_1) && pressed) {
|
||||
pressed->mouseRelease(cursor.pos.x, cursor.pos.y);
|
||||
pressed = nullptr;
|
||||
}
|
||||
|
||||
if (hover) {
|
||||
for (mousecode code : MOUSECODES_ALL) {
|
||||
for (Mousecode code : MOUSECODES_ALL) {
|
||||
if (input.jclicked(code)) {
|
||||
hover->clicked(code);
|
||||
}
|
||||
@@ -173,7 +173,7 @@ void GUI::actMouse(float delta, const CursorState& cursor) {
|
||||
}
|
||||
|
||||
void GUI::actFocused() {
|
||||
if (input.jpressed(keycode::ESCAPE)) {
|
||||
if (input.jpressed(Keycode::ESCAPE)) {
|
||||
focus->defocus();
|
||||
focus = nullptr;
|
||||
return;
|
||||
@@ -187,8 +187,8 @@ void GUI::actFocused() {
|
||||
|
||||
const auto& cursor = input.getCursor();
|
||||
if (!cursor.locked) {
|
||||
if (input.clicked(mousecode::BUTTON_1) &&
|
||||
(input.jclicked(mousecode::BUTTON_1) || cursor.delta.x ||
|
||||
if (input.clicked(Mousecode::BUTTON_1) &&
|
||||
(input.jclicked(Mousecode::BUTTON_1) || cursor.delta.x ||
|
||||
cursor.delta.y)) {
|
||||
if (!doubleClicked) {
|
||||
focus->mouseMove(cursor.pos.x, cursor.pos.y);
|
||||
|
||||
@@ -25,15 +25,15 @@ void InputBindBox::drawBackground(const DrawContext& pctx, const Assets&) {
|
||||
label->setText(util::str2wstr_utf8(binding.text()));
|
||||
}
|
||||
|
||||
void InputBindBox::clicked(mousecode button) {
|
||||
void InputBindBox::clicked(Mousecode button) {
|
||||
if (isFocused()) {
|
||||
binding.reset(button);
|
||||
defocus();
|
||||
}
|
||||
}
|
||||
|
||||
void InputBindBox::keyPressed(keycode key) {
|
||||
if (key != keycode::ESCAPE) {
|
||||
void InputBindBox::keyPressed(Keycode key) {
|
||||
if (key != Keycode::ESCAPE) {
|
||||
binding.reset(key);
|
||||
}
|
||||
defocus();
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace gui {
|
||||
const DrawContext& pctx, const Assets& assets
|
||||
) override;
|
||||
|
||||
virtual void clicked(mousecode button) override;
|
||||
virtual void keyPressed(keycode key) override;
|
||||
virtual void clicked(Mousecode button) override;
|
||||
virtual void keyPressed(Keycode key) override;
|
||||
virtual bool isFocuskeeper() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ bool SlotView::isHighlighted() const {
|
||||
|
||||
void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) {
|
||||
const auto& input = gui.getInput();
|
||||
if (layout.taking && input.pressed(keycode::LEFT_SHIFT)) {
|
||||
if (layout.taking && input.pressed(Keycode::LEFT_SHIFT)) {
|
||||
if (layout.shareFunc) {
|
||||
layout.shareFunc(layout.index, stack);
|
||||
}
|
||||
@@ -348,7 +348,7 @@ void SlotView::performRightClick(ItemStack& stack, ItemStack& grabbed) {
|
||||
}
|
||||
}
|
||||
|
||||
void SlotView::clicked(mousecode button) {
|
||||
void SlotView::clicked(Mousecode button) {
|
||||
if (bound == nullptr)
|
||||
return;
|
||||
auto exchangeSlot =
|
||||
@@ -359,9 +359,9 @@ void SlotView::clicked(mousecode button) {
|
||||
ItemStack& grabbed = exchangeSlot->getStack();
|
||||
ItemStack& stack = *bound;
|
||||
|
||||
if (button == mousecode::BUTTON_1) {
|
||||
if (button == Mousecode::BUTTON_1) {
|
||||
performLeftClick(stack, grabbed);
|
||||
} else if (button == mousecode::BUTTON_2) {
|
||||
} else if (button == Mousecode::BUTTON_2) {
|
||||
performRightClick(stack, grabbed);
|
||||
}
|
||||
if (layout.updateFunc) {
|
||||
@@ -370,7 +370,7 @@ void SlotView::clicked(mousecode button) {
|
||||
}
|
||||
|
||||
void SlotView::onFocus() {
|
||||
clicked(mousecode::BUTTON_1);
|
||||
clicked(Mousecode::BUTTON_1);
|
||||
}
|
||||
|
||||
const std::wstring& SlotView::getTooltip() const {
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace gui {
|
||||
void setHighlighted(bool flag);
|
||||
bool isHighlighted() const;
|
||||
|
||||
virtual void clicked(mousecode) override;
|
||||
virtual void clicked(Mousecode) override;
|
||||
virtual void onFocus() override;
|
||||
virtual const std::wstring& getTooltip() const override;
|
||||
|
||||
|
||||
@@ -824,10 +824,10 @@ void TextBox::onInput() {
|
||||
refreshSyntax();
|
||||
}
|
||||
|
||||
void TextBox::performEditingKeyboardEvents(keycode key) {
|
||||
bool shiftPressed = gui.getInput().pressed(keycode::LEFT_SHIFT);
|
||||
void TextBox::performEditingKeyboardEvents(Keycode key) {
|
||||
bool shiftPressed = gui.getInput().pressed(Keycode::LEFT_SHIFT);
|
||||
bool breakSelection = getSelectionLength() != 0 && !shiftPressed;
|
||||
if (key == keycode::BACKSPACE) {
|
||||
if (key == Keycode::BACKSPACE) {
|
||||
if (!eraseSelected() && caret > 0 && input.length() > 0) {
|
||||
if (caret > input.length()) {
|
||||
caret = input.length();
|
||||
@@ -839,7 +839,7 @@ void TextBox::performEditingKeyboardEvents(keycode key) {
|
||||
onInput();
|
||||
}
|
||||
}
|
||||
} else if (key == keycode::DELETE) {
|
||||
} else if (key == Keycode::DELETE) {
|
||||
if (!eraseSelected() && caret < input.length()) {
|
||||
historian->onErase(caret, input.substr(caret, 1));
|
||||
input = input.substr(0, caret) + input.substr(caret + 1);
|
||||
@@ -847,7 +847,7 @@ void TextBox::performEditingKeyboardEvents(keycode key) {
|
||||
onInput();
|
||||
}
|
||||
}
|
||||
} else if (key == keycode::ENTER) {
|
||||
} else if (key == Keycode::ENTER) {
|
||||
if (multiline) {
|
||||
paste(L"\n");
|
||||
} else {
|
||||
@@ -856,42 +856,42 @@ void TextBox::performEditingKeyboardEvents(keycode key) {
|
||||
consumer(getText());
|
||||
}
|
||||
}
|
||||
} else if (key == keycode::TAB) {
|
||||
} else if (key == Keycode::TAB) {
|
||||
paste(L" ");
|
||||
} else if (key == keycode::LEFT) {
|
||||
} else if (key == Keycode::LEFT) {
|
||||
stepLeft(shiftPressed, breakSelection);
|
||||
} else if (key == keycode::RIGHT) {
|
||||
} else if (key == Keycode::RIGHT) {
|
||||
stepRight(shiftPressed, breakSelection);
|
||||
} else if (key == keycode::UP && onUpPressed) {
|
||||
} else if (key == Keycode::UP && onUpPressed) {
|
||||
onUpPressed();
|
||||
} else if (key == keycode::DOWN && onDownPressed) {
|
||||
} else if (key == Keycode::DOWN && onDownPressed) {
|
||||
onDownPressed();
|
||||
}
|
||||
}
|
||||
|
||||
void TextBox::keyPressed(keycode key) {
|
||||
void TextBox::keyPressed(Keycode key) {
|
||||
const auto& inputEvents = gui.getInput();
|
||||
if (editable) {
|
||||
performEditingKeyboardEvents(key);
|
||||
}
|
||||
if (inputEvents.pressed(keycode::LEFT_CONTROL) && key != keycode::LEFT_CONTROL) {
|
||||
if (inputEvents.pressed(Keycode::LEFT_CONTROL) && key != Keycode::LEFT_CONTROL) {
|
||||
if (controlCombinationsHandler) {
|
||||
if (controlCombinationsHandler(static_cast<int>(key))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Copy selected text to clipboard
|
||||
if (key == keycode::C || key == keycode::X) {
|
||||
if (key == Keycode::C || key == Keycode::X) {
|
||||
std::string text = util::wstr2str_utf8(getSelection());
|
||||
if (!text.empty()) {
|
||||
gui.getInput().setClipboardText(text.c_str());
|
||||
}
|
||||
if (editable && key == keycode::X) {
|
||||
if (editable && key == Keycode::X) {
|
||||
eraseSelected();
|
||||
}
|
||||
}
|
||||
// Paste text from clipboard
|
||||
if (key == keycode::V && editable) {
|
||||
if (key == Keycode::V && editable) {
|
||||
const char* text = inputEvents.getClipboardText();
|
||||
if (text) {
|
||||
historian->sync(); // flush buffer before combination
|
||||
@@ -902,18 +902,18 @@ void TextBox::keyPressed(keycode key) {
|
||||
}
|
||||
}
|
||||
// Select/deselect all
|
||||
if (key == keycode::A) {
|
||||
if (key == Keycode::A) {
|
||||
if (selectionStart == selectionEnd) {
|
||||
select(0, input.length());
|
||||
} else {
|
||||
resetSelection();
|
||||
}
|
||||
}
|
||||
if (key == keycode::Z) {
|
||||
if (key == Keycode::Z) {
|
||||
historian->undo();
|
||||
refreshSyntax();
|
||||
}
|
||||
if (key == keycode::Y) {
|
||||
if (key == Keycode::Y) {
|
||||
historian->redo();
|
||||
refreshSyntax();
|
||||
}
|
||||
@@ -948,11 +948,11 @@ std::shared_ptr<UINode> TextBox::getAt(const glm::vec2& pos) {
|
||||
void TextBox::setOnUpPressed(const runnable& callback) {
|
||||
if (callback == nullptr) {
|
||||
onUpPressed = [this]() {
|
||||
if (inputEvents.pressed(keycode::LEFT_CONTROL)) {
|
||||
if (inputEvents.pressed(Keycode::LEFT_CONTROL)) {
|
||||
scrolled(1);
|
||||
return;
|
||||
}
|
||||
bool shiftPressed = inputEvents.pressed(keycode::LEFT_SHIFT);
|
||||
bool shiftPressed = inputEvents.pressed(Keycode::LEFT_SHIFT);
|
||||
bool breakSelection = getSelectionLength() != 0 && !shiftPressed;
|
||||
stepDefaultUp(shiftPressed, breakSelection);
|
||||
};
|
||||
@@ -964,11 +964,11 @@ void TextBox::setOnUpPressed(const runnable& callback) {
|
||||
void TextBox::setOnDownPressed(const runnable& callback) {
|
||||
if (callback == nullptr) {
|
||||
onDownPressed = [this]() {
|
||||
if (inputEvents.pressed(keycode::LEFT_CONTROL)) {
|
||||
if (inputEvents.pressed(Keycode::LEFT_CONTROL)) {
|
||||
scrolled(-1);
|
||||
return;
|
||||
}
|
||||
bool shiftPressed = inputEvents.pressed(keycode::LEFT_SHIFT);
|
||||
bool shiftPressed = inputEvents.pressed(Keycode::LEFT_SHIFT);
|
||||
bool breakSelection = getSelectionLength() != 0 && !shiftPressed;
|
||||
stepDefaultDown(shiftPressed, breakSelection);
|
||||
};
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace gui {
|
||||
/// @brief Set maxLocalCaret to local (line) caret position
|
||||
void resetMaxLocalCaret();
|
||||
|
||||
void performEditingKeyboardEvents(keycode key);
|
||||
void performEditingKeyboardEvents(Keycode key);
|
||||
|
||||
void refreshLabel();
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace gui {
|
||||
virtual void draw(const DrawContext& pctx, const Assets& assets) override;
|
||||
virtual void drawBackground(const DrawContext& pctx, const Assets& assets) override;
|
||||
virtual void typed(unsigned int codepoint) override;
|
||||
virtual void keyPressed(keycode key) override;
|
||||
virtual void keyPressed(Keycode key) override;
|
||||
virtual std::shared_ptr<UINode> getAt(const glm::vec2& pos) override;
|
||||
virtual void setOnUpPressed(const runnable &callback);
|
||||
virtual void setOnDownPressed(const runnable &callback);
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace gui {
|
||||
virtual void onFocus() {focused = true;}
|
||||
virtual void doubleClick(int x, int y);
|
||||
virtual void click(int x, int y);
|
||||
virtual void clicked(mousecode button) {}
|
||||
virtual void clicked(Mousecode button) {}
|
||||
virtual void mouseMove(int x, int y) {};
|
||||
virtual void mouseRelease(int x, int y);
|
||||
virtual void scrolled(int value);
|
||||
@@ -188,7 +188,7 @@ namespace gui {
|
||||
virtual bool isFocuskeeper() const {return false;}
|
||||
|
||||
virtual void typed(unsigned int codepoint) {};
|
||||
virtual void keyPressed(keycode key) {};
|
||||
virtual void keyPressed(Keycode key) {};
|
||||
|
||||
/// @brief Check if screen position is inside of the element
|
||||
/// @param pos screen position
|
||||
|
||||
@@ -68,11 +68,11 @@ void guiutil::alert(
|
||||
panel->refresh();
|
||||
|
||||
auto& input = engine.getInput();
|
||||
panel->keepAlive(input.addKeyCallback(keycode::ENTER, [on_hidden_final]() {
|
||||
panel->keepAlive(input.addKeyCallback(Keycode::ENTER, [on_hidden_final]() {
|
||||
on_hidden_final();
|
||||
return true;
|
||||
}));
|
||||
panel->keepAlive(input.addKeyCallback(keycode::ESCAPE, [on_hidden_final]() {
|
||||
panel->keepAlive(input.addKeyCallback(Keycode::ESCAPE, [on_hidden_final]() {
|
||||
on_hidden_final();
|
||||
return true;
|
||||
}));
|
||||
@@ -138,11 +138,11 @@ void guiutil::confirm(
|
||||
}));
|
||||
|
||||
panel->add(subpanel);
|
||||
panel->keepAlive(input.addKeyCallback(keycode::ENTER, [=]() {
|
||||
panel->keepAlive(input.addKeyCallback(Keycode::ENTER, [=]() {
|
||||
on_confirm_final();
|
||||
return true;
|
||||
}));
|
||||
panel->keepAlive(input.addKeyCallback(keycode::ESCAPE, [=]() {
|
||||
panel->keepAlive(input.addKeyCallback(Keycode::ESCAPE, [=]() {
|
||||
on_deny_final();
|
||||
return true;
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user