From b9294516fc65f7a172ae119e20865b70c43c19c0 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 19 Sep 2019 16:55:28 +0300 Subject: SL-6109 Implement keybindings --- indra/newview/llfloaterpreference.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 951d11bbe5..95c255d697 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -170,7 +170,7 @@ public: void setParent(LLFloaterPreference* parent) { mParent = parent; } BOOL handleKeyHere(KEY key, MASK mask); - BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, LLMouseHandler::EClickType clicktype, BOOL down); + BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down); static void onCancel(void* user_data); private: @@ -214,11 +214,11 @@ BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask) return result; } -BOOL LLVoiceSetKeyDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, LLMouseHandler::EClickType clicktype, BOOL down) +BOOL LLVoiceSetKeyDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down) { BOOL result = FALSE; if (down - && (clicktype == LLMouseHandler::CLICK_MIDDLE || clicktype == LLMouseHandler::CLICK_BUTTON4 || clicktype == LLMouseHandler::CLICK_BUTTON5) + && (clicktype == CLICK_MIDDLE || clicktype == CLICK_BUTTON4 || clicktype == CLICK_BUTTON5) && mask == 0) { mParent->setMouse(clicktype); @@ -1674,21 +1674,21 @@ void LLFloaterPreference::setKey(KEY key) getChild("modifier_combo")->onCommit(); } -void LLFloaterPreference::setMouse(LLMouseHandler::EClickType click) +void LLFloaterPreference::setMouse(EMouseClickType click) { std::string bt_name; std::string ctrl_value; switch (click) { - case LLMouseHandler::CLICK_MIDDLE: + case CLICK_MIDDLE: bt_name = "middle_mouse"; ctrl_value = MIDDLE_MOUSE_CV; break; - case LLMouseHandler::CLICK_BUTTON4: + case CLICK_BUTTON4: bt_name = "button4_mouse"; ctrl_value = MOUSE_BUTTON_4_CV; break; - case LLMouseHandler::CLICK_BUTTON5: + case CLICK_BUTTON5: bt_name = "button5_mouse"; ctrl_value = MOUSE_BUTTON_5_CV; break; -- cgit v1.2.3 From 3633ccf1a1077d3e53e7f125d1dd5ed2aaa98906 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 19 Aug 2019 23:16:29 +0300 Subject: SL_6109 Rebinding --- indra/newview/llfloaterpreference.cpp | 330 +++++++++++++++++++++++++++++++++- 1 file changed, 324 insertions(+), 6 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 95c255d697..38ec8805a1 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -52,6 +52,7 @@ #include "llfavoritesbar.h" #include "llfloatersidepanelcontainer.h" #include "llfloaterimsession.h" +#include "llkeybindings.h" #include "llkeyboard.h" #include "llmodaldialog.h" #include "llnavigationbar.h" @@ -168,6 +169,7 @@ public: /*virtual*/ BOOL postBuild(); void setParent(LLFloaterPreference* parent) { mParent = parent; } + void setTmpParent(LLPanelPreferenceControls* parent) { mTmpParent = parent; } // todo: voice key will be removed, class renamved, so it will have only one parent BOOL handleKeyHere(KEY key, MASK mask); BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down); @@ -175,11 +177,13 @@ public: private: LLFloaterPreference* mParent; + LLPanelPreferenceControls* mTmpParent;// todo: voice key will be removed, class renamved, so it will have only one parent }; LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(const LLSD& key) : LLModalDialog(key), - mParent(NULL) + mParent(NULL), + mTmpParent(NULL) { } @@ -201,15 +205,30 @@ LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog() BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask) { BOOL result = TRUE; + + if (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT || key == KEY_NONE) + { + // temp + return false; + } + // todo, same for escape if (key == 'Q' && mask == MASK_CONTROL) { result = FALSE; - } + if (mTmpParent) + { + mTmpParent->onSetKey(KEY_NONE, MASK_NONE); + } + } else if (mParent) { mParent->setKey(key); } + else if (mTmpParent) + { + mTmpParent->onSetKey(key, mask); + } closeFloater(); return result; } @@ -217,11 +236,38 @@ BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask) BOOL LLVoiceSetKeyDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down) { BOOL result = FALSE; - if (down - && (clicktype == CLICK_MIDDLE || clicktype == CLICK_BUTTON4 || clicktype == CLICK_BUTTON5) - && mask == 0) + + if (clicktype == CLICK_LEFT) + { + if (down) + { + result = LLView::handleMouseDown(x, y, mask); + } + else + { + result = LLView::handleMouseUp(x, y, mask); + } + } + if (clicktype == LLMouseHandler::CLICK_LEFT) + { + result = LLView::handleDoubleClick(x, y, mask); + } + if (result) + { + return TRUE; + } + if (down && clicktype != LLMouseHandler::CLICK_RIGHT) //tmp + //&& (clicktype == LLMouseHandler::CLICK_MIDDLE || clicktype == LLMouseHandler::CLICK_BUTTON4 || clicktype == LLMouseHandler::CLICK_BUTTON5) + //&& mask == 0) { - mParent->setMouse(clicktype); + if (mParent) + { + mParent->setMouse(clicktype); + } + else if (mTmpParent) + { + mTmpParent->onSetMouse(clicktype, mask); + } result = TRUE; closeFloater(); } @@ -237,6 +283,11 @@ BOOL LLVoiceSetKeyDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseCli void LLVoiceSetKeyDialog::onCancel(void* user_data) { LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data; + // tmp needs 'no key' button + if (self->mTmpParent) + { + self->mTmpParent->onSetKey(KEY_NONE, MASK_NONE); + } self->closeFloater(); } @@ -2863,6 +2914,273 @@ void LLPanelPreferenceGraphics::setHardwareDefaults() resetDirtyChilds(); } + +//-------------------For LLPanelPreferenceControls' list--------------------------- +class LLGroupControlsListItem : public LLScrollListItem, public LLHandleProvider +{ +public: + LLGroupControlsListItem(const LLScrollListItem::Params& p) + : LLScrollListItem(p) + { + } + + LLGroupControlsListItem(const LLScrollListItem::Params& p, const LLUUID& icon_id) + : LLScrollListItem(p), mIconId(icon_id) + { + } + + void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding) + { + // todo: insert image and adjust rect + LLScrollListItem::draw(rect, fg_color, bg_color, highlight_color, column_padding); + } +private: + LLUUID mIconId; +}; + +static const std::string tmp_typetostring[LLControlBindings::CONTROL_NUM_INDICES] = { + "control_view_actions", + "control_about", + "control_orbit", + "control_pan", + "control_world_map", + "control_zoom", + "control_interactions", + "control_build", + "control_drag", + "control_edit", + "control_menu", + "control_open", + "control_touch", + "control_wear", + "control_movements", + "control_moveto", + "control_sit", + "control_teleportto", + "control_forward", + "control_backward", + "control_left", + "control_right", + "control_lstrafe", + "control_rstrafe", + "control_jump", + "control_down", + "control_run", + "control_toggle_run", + "control_fly", + "control_mediacontent", + "control_parcel", + "control_media", + "control_voice", + "control_toggle_voice", + "control_reserved", + "control_menu", + "control_reserved_select", + "control_shift_select", + "control_cntrl_select" +}; + +//------------------------LLPanelPreferenceControls-------------------------------- +static LLPanelInjector t_pref_contrls("panel_preference_controls"); + +BOOL LLPanelPreferenceControls::postBuild() +{ + //todo: on open instead of on the go + //todo: add pitch/yaw? + //todo: Scroll? + //todo: should be auto-expandable with menu items and should pull names from menu when possible + + + // populate list of controls + pControlsTable = getChild("controls_list"); + populateControlTable(); + + pControlsTable->setCommitCallback(boost::bind(&LLPanelPreferenceControls::onListCommit, this)); + + return TRUE; +} + +void LLPanelPreferenceControls::populateControlTable() +{ + pControlsTable->clearRows(); + + // todo: subsections need sorting? + std::string label; + LLScrollListCell::Params cell_params; + // init basic cell params + cell_params.font = LLFontGL::getFontSansSerif(); + cell_params.font_halign = LLFontGL::LEFT; + cell_params.column = ""; + cell_params.value = label; + + LLScrollListItem::Params item_params_blank; + cell_params.enabled = false; + item_params_blank.value = LLSD::Integer(-1); + item_params_blank.columns.add(cell_params); + cell_params.enabled = true; + + for (U32 i = LLControlBindings::CONTROL_VIEW_ACTIONS; i < LLControlBindings::CONTROL_NUM_INDICES; i++) + { + switch (i) + { + case LLControlBindings::CONTROL_VIEW_ACTIONS: + { + // same as below, but without separator + LLScrollListItem::Params item_params; + item_params.value = LLSD::Integer(i); + + label = getString(tmp_typetostring[i]); + cell_params.column = "lst_action"; + cell_params.value = label; + //dummy cells + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl1"; + cell_params.value = ""; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl2"; + cell_params.value = ""; + item_params.columns.add(cell_params); + LLUUID id; + LLGroupControlsListItem* item = new LLGroupControlsListItem(item_params, id); + pControlsTable->addRow(item, item_params, EAddPosition::ADD_BOTTOM); + break; + } + case LLControlBindings::CONTROL_INTERACTIONS: + case LLControlBindings::CONTROL_MOVEMENTS: + case LLControlBindings::CONTROL_MEDIACONTENT: + case LLControlBindings::CONTROL_RESERVED: + { + // insert blank + pControlsTable->addRow(item_params_blank, EAddPosition::ADD_BOTTOM); + // inster with icon + LLScrollListItem::Params item_params; + item_params.value = LLSD::Integer(i); + + label = getString(tmp_typetostring[i]); + cell_params.column = "lst_action"; + cell_params.value = label; + //dummy cells + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl1"; + cell_params.value = ""; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl2"; + cell_params.value = ""; + item_params.columns.add(cell_params); + LLUUID id; + LLGroupControlsListItem* item = new LLGroupControlsListItem(item_params, id); + pControlsTable->addRow(item, item_params, EAddPosition::ADD_BOTTOM); + break; + } + default: + { + //default insert + LLScrollListItem::Params item_params; + item_params.value = LLSD::Integer(i); + + // todo oddset + cell_params.column = "lst_action"; + label = getString(tmp_typetostring[i]); + cell_params.value = label; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl1"; + cell_params.value = gControlBindings.getPrimaryControl((LLControlBindings::EControlTypes)i).asString(); + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl2"; + cell_params.value = gControlBindings.getSecondaryControl((LLControlBindings::EControlTypes)i).asString(); + item_params.columns.add(cell_params); + + pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM); + break; + } + } + } +} + +void LLPanelPreferenceControls::cancel() +{ +} + +void LLPanelPreferenceControls::saveSettings() +{ +} + +void LLPanelPreferenceControls::resetDirtyChilds() +{ +} + +bool LLPanelPreferenceControls::hasDirtyChilds() +{ + return false; +} + +void LLPanelPreferenceControls::onListCommit() +{ + LLScrollListItem* item = pControlsTable->getFirstSelected(); + if (item == NULL) + { + return; + } + + S32 control = item->getValue().asInteger(); + + if (!gControlBindings.canAssignControl((LLControlBindings::EControlTypes)control)) + { + return; + } + + // todo: add code to determine what cell was clicked, probably cells themself should be clickable + + LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance("voice_set_key", LLSD(), TRUE); + if (dialog) + { + dialog->setTmpParent(this); // will be remade from being voice later + } +} + +void LLPanelPreferenceControls::onSetKey(KEY key, MASK mask) +{ + LLScrollListItem* item = pControlsTable->getFirstSelected(); + if (item == NULL) + { + return; + } + + LLControlBindings::EControlTypes control = (LLControlBindings::EControlTypes)item->getValue().asInteger(); + + if (!gControlBindings.canAssignControl(control)) + { + return; + } + + gControlBindings.registerPrimaryControl(control, LLMouseHandler::CLICK_NONE, key, mask); + + // instead of populating, update single element + populateControlTable(); +} + +void LLPanelPreferenceControls::onSetMouse(LLMouseHandler::EClickType click, MASK mask) +{ + + LLScrollListItem* item = pControlsTable->getFirstSelected(); + if (item == NULL) + { + return; + } + + LLControlBindings::EControlTypes control = (LLControlBindings::EControlTypes)item->getValue().asInteger(); + + if (!gControlBindings.canAssignControl(control)) + { + return; + } + + gControlBindings.registerPrimaryControl(control, click, KEY_NONE, mask); + + // instead of populating, update single element + populateControlTable(); +} + LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key) : LLFloater(key) { -- cgit v1.2.3 From 4df05c5a8995158922c7b7aacfef442ac8ae6fdd Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 17 Sep 2019 21:36:59 +0300 Subject: SL-6109 Keyaboard support ready --- indra/newview/llfloaterpreference.cpp | 680 ++++++++++++++++++---------------- 1 file changed, 366 insertions(+), 314 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 38ec8805a1..34cfe6ebb4 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -52,7 +52,6 @@ #include "llfavoritesbar.h" #include "llfloatersidepanelcontainer.h" #include "llfloaterimsession.h" -#include "llkeybindings.h" #include "llkeyboard.h" #include "llmodaldialog.h" #include "llnavigationbar.h" @@ -72,8 +71,9 @@ #include "lltrans.h" #include "llviewercontrol.h" #include "llviewercamera.h" -#include "llviewerwindow.h" +#include "llviewereventrecorder.h" #include "llviewermessage.h" +#include "llviewerwindow.h" #include "llviewershadermgr.h" #include "llviewerthrottle.h" #include "llvoavatarself.h" @@ -160,36 +160,49 @@ struct LabelTable : public LLInitParam::Block {} }; -class LLVoiceSetKeyDialog : public LLModalDialog +// Filters for LLSetKeyBindDialog +static const U32 ALLOW_MOUSE = 1; +static const U32 ALLOW_MASK_MOUSE = 2; +static const U32 ALLOW_KEYS = 4; //keyboard +static const U32 ALLOW_MASK_KEYS = 8; +static const U32 ALLOW_MASKS = 16; +static const U32 IGNORE_MASKS = 32; // For example W (aka Forward) should work regardless of SHIFT being pressed +static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASK_KEYS; + +class LLSetKeyBindDialog : public LLModalDialog { public: - LLVoiceSetKeyDialog(const LLSD& key); - ~LLVoiceSetKeyDialog(); - + LLSetKeyBindDialog(const LLSD& key); + ~LLSetKeyBindDialog(); + /*virtual*/ BOOL postBuild(); - - void setParent(LLFloaterPreference* parent) { mParent = parent; } - void setTmpParent(LLPanelPreferenceControls* parent) { mTmpParent = parent; } // todo: voice key will be removed, class renamved, so it will have only one parent - + + void setParent(LLPanelPreferenceControls* parent, U32 key_mask = DEFAULT_KEY_FILTER); + BOOL handleKeyHere(KEY key, MASK mask); BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down); static void onCancel(void* user_data); - + static void onBlank(void* user_data); + static void onDefault(void* user_data); + private: - LLFloaterPreference* mParent; - LLPanelPreferenceControls* mTmpParent;// todo: voice key will be removed, class renamved, so it will have only one parent + LLPanelPreferenceControls* mParent; + + U32 mKeyMask; }; -LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(const LLSD& key) +LLSetKeyBindDialog::LLSetKeyBindDialog(const LLSD& key) : LLModalDialog(key), mParent(NULL), - mTmpParent(NULL) + mKeyMask(DEFAULT_KEY_FILTER) { } //virtual -BOOL LLVoiceSetKeyDialog::postBuild() +BOOL LLSetKeyBindDialog::postBuild() { + childSetAction("SetEmpty", onBlank, this); + childSetAction("Default", onDefault, this); childSetAction("Cancel", onCancel, this); getChild("Cancel")->setFocus(TRUE); @@ -198,47 +211,85 @@ BOOL LLVoiceSetKeyDialog::postBuild() return TRUE; } -LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog() +void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_mask) +{ + mParent = parent; + mKeyMask = key_mask; + + LLTextBase *text_ctrl = getChild("descritption"); + + std::string input; + if ((key_mask & ALLOW_MOUSE) != 0) + { + input = getString("mouse"); + } + if ((key_mask & ALLOW_KEYS) != 0) + { + if (!input.empty()) + { + input += ", "; + } + input += getString("keyboard"); + } + text_ctrl->setTextArg("[INPUT]", input); +} + +LLSetKeyBindDialog::~LLSetKeyBindDialog() { } -BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask) +BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) { BOOL result = TRUE; - if (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT || key == KEY_NONE) + if ((key == 'Q' && mask == MASK_CONTROL) + || key == KEY_ESCAPE) + { + closeFloater(); + return true; + } + + // forbidden keys + if (key == KEY_NONE + || key == KEY_RETURN + || key == KEY_DELETE + || key == KEY_BACKSPACE) { - // temp return false; } - - // todo, same for escape - if (key == 'Q' && mask == MASK_CONTROL) - { - result = FALSE; - if (mTmpParent) - { - mTmpParent->onSetKey(KEY_NONE, MASK_NONE); - } + + if ((mKeyMask & ALLOW_MASKS) == 0 + && (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT)) + { + // mask by themself are not allowed + return false; + } + else if ((mKeyMask & ALLOW_KEYS) == 0) + { + // basic keys not allowed + return false; + } + else if ((mKeyMask & ALLOW_MASK_KEYS) == 0 && mask != 0) + { + // masked keys not allowed + return false; } + else if (mParent) { - mParent->setKey(key); - } - else if (mTmpParent) - { - mTmpParent->onSetKey(key, mask); + mParent->onSetKeyBind(CLICK_NONE, key, mask); } closeFloater(); return result; } -BOOL LLVoiceSetKeyDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down) +BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down) { BOOL result = FALSE; if (clicktype == CLICK_LEFT) { + // try handling buttons first if (down) { result = LLView::handleMouseDown(x, y, mask); @@ -248,30 +299,21 @@ BOOL LLVoiceSetKeyDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseCli result = LLView::handleMouseUp(x, y, mask); } } - if (clicktype == LLMouseHandler::CLICK_LEFT) - { - result = LLView::handleDoubleClick(x, y, mask); - } - if (result) - { - return TRUE; - } - if (down && clicktype != LLMouseHandler::CLICK_RIGHT) //tmp - //&& (clicktype == LLMouseHandler::CLICK_MIDDLE || clicktype == LLMouseHandler::CLICK_BUTTON4 || clicktype == LLMouseHandler::CLICK_BUTTON5) - //&& mask == 0) + + if (!result + && ((mKeyMask & ALLOW_MOUSE) != 0) + && (clicktype != CLICK_RIGHT || mask != 0) // reassigning menu button is not supported + && ((mKeyMask & ALLOW_MASK_MOUSE) != 0 || mask == 0)) { if (mParent) { - mParent->setMouse(clicktype); - } - else if (mTmpParent) - { - mTmpParent->onSetMouse(clicktype, mask); + mParent->onSetKeyBind(clicktype, KEY_NONE, mask); } result = TRUE; closeFloater(); } - else + + if (!result) { result = LLMouseHandler::handleAnyMouseClick(x, y, mask, clicktype, down); } @@ -280,17 +322,36 @@ BOOL LLVoiceSetKeyDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseCli } //static -void LLVoiceSetKeyDialog::onCancel(void* user_data) +void LLSetKeyBindDialog::onCancel(void* user_data) { - LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data; - // tmp needs 'no key' button - if (self->mTmpParent) - { - self->mTmpParent->onSetKey(KEY_NONE, MASK_NONE); - } + LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; self->closeFloater(); } +//static +void LLSetKeyBindDialog::onBlank(void* user_data) +{ + LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; + // tmp needs 'no key' button + if (self->mParent) + { + self->mParent->onSetKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE); + } + self->closeFloater(); +} + +//static +void LLSetKeyBindDialog::onDefault(void* user_data) +{ + LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; + // tmp needs 'no key' button + if (self->mParent) + { + self->mParent->onDefaultKeyBind(); + } + self->closeFloater(); +} + // global functions @@ -370,37 +431,6 @@ void handleAppearanceCameraMovementChanged(const LLSD& newvalue) } } -/*bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (0 == option && floater ) - { - if ( floater ) - { - floater->setAllIgnored(); - // LLFirstUse::disableFirstUse(); - floater->buildPopupLists(); - } - } - return false; -} - -bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if ( 0 == option && floater ) - { - if ( floater ) - { - floater->resetAllIgnored(); - //LLFirstUse::resetFirstUse(); - floater->buildPopupLists(); - } - } - return false; -} -*/ - void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator) { numerator = 0; @@ -435,7 +465,7 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) static bool registered_dialog = false; if (!registered_dialog) { - LLFloaterReg::add("voice_set_key", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("keybind_dialog", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); registered_dialog = true; } @@ -1711,53 +1741,6 @@ void LLFloaterPreference::onChangeQuality(const LLSD& data) void LLFloaterPreference::onClickSetKey() { - LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance("voice_set_key", LLSD(), TRUE); - if (dialog) - { - dialog->setParent(this); - } -} - -void LLFloaterPreference::setKey(KEY key) -{ - getChild("modifier_combo")->setValue(LLKeyboard::stringFromKey(key)); - // update the control right away since we no longer wait for apply - getChild("modifier_combo")->onCommit(); -} - -void LLFloaterPreference::setMouse(EMouseClickType click) -{ - std::string bt_name; - std::string ctrl_value; - switch (click) - { - case CLICK_MIDDLE: - bt_name = "middle_mouse"; - ctrl_value = MIDDLE_MOUSE_CV; - break; - case CLICK_BUTTON4: - bt_name = "button4_mouse"; - ctrl_value = MOUSE_BUTTON_4_CV; - break; - case CLICK_BUTTON5: - bt_name = "button5_mouse"; - ctrl_value = MOUSE_BUTTON_5_CV; - break; - default: - break; - } - - if (!ctrl_value.empty()) - { - LLUICtrl* p2t_line_editor = getChild("modifier_combo"); - // We are using text control names for readability and compatibility with voice - p2t_line_editor->setControlValue(ctrl_value); - LLPanel* advanced_preferences = dynamic_cast(p2t_line_editor->getParent()); - if (advanced_preferences) - { - p2t_line_editor->setValue(advanced_preferences->getString(bt_name)); - } - } } void LLFloaterPreference::onClickSetMiddleMouse() @@ -1782,18 +1765,6 @@ void LLFloaterPreference::onClickSetSounds() getChild("gesture_audio_play_btn")->setEnabled(!gSavedSettings.getBOOL("MuteSounds")); } -/* -void LLFloaterPreference::onClickSkipDialogs() -{ - LLNotificationsUtil::add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, this)); -} - -void LLFloaterPreference::onClickResetDialogs() -{ - LLNotificationsUtil::add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, this)); -} - */ - void LLFloaterPreference::onClickEnablePopup() { LLScrollListCtrl& disabled_popups = getChildRef("disabled_popups"); @@ -2794,7 +2765,7 @@ void LLPanelPreferenceGraphics::setPresetText() } } - if (hasDirtyChilds() && !preset_graphic_active.empty()) + if (hasDirtyChilds() && !preset_graphic_active.empty()) { gSavedSettings.setString("PresetGraphicActive", ""); preset_graphic_active.clear(); @@ -2914,98 +2885,124 @@ void LLPanelPreferenceGraphics::setHardwareDefaults() resetDirtyChilds(); } +//------------------------LLPanelPreferenceControls-------------------------------- +static LLPanelInjector t_pref_contrls("panel_preference_controls"); -//-------------------For LLPanelPreferenceControls' list--------------------------- -class LLGroupControlsListItem : public LLScrollListItem, public LLHandleProvider +LLPanelPreferenceControls::LLPanelPreferenceControls() + :LLPanelPreference(), + mEditingIndex(-1), + mEditingColumn(-1), + mEditingMode(0), + mShowKeyDialog(false) { -public: - LLGroupControlsListItem(const LLScrollListItem::Params& p) - : LLScrollListItem(p) - { - } - - LLGroupControlsListItem(const LLScrollListItem::Params& p, const LLUUID& icon_id) - : LLScrollListItem(p), mIconId(icon_id) - { - } - - void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding) - { - // todo: insert image and adjust rect - LLScrollListItem::draw(rect, fg_color, bg_color, highlight_color, column_padding); - } -private: - LLUUID mIconId; -}; - -static const std::string tmp_typetostring[LLControlBindings::CONTROL_NUM_INDICES] = { - "control_view_actions", - "control_about", - "control_orbit", - "control_pan", - "control_world_map", - "control_zoom", - "control_interactions", - "control_build", - "control_drag", - "control_edit", - "control_menu", - "control_open", - "control_touch", - "control_wear", - "control_movements", - "control_moveto", - "control_sit", - "control_teleportto", - "control_forward", - "control_backward", - "control_left", - "control_right", - "control_lstrafe", - "control_rstrafe", - "control_jump", - "control_down", - "control_run", - "control_toggle_run", - "control_fly", - "control_mediacontent", - "control_parcel", - "control_media", - "control_voice", - "control_toggle_voice", - "control_reserved", - "control_menu", - "control_reserved_select", - "control_shift_select", - "control_cntrl_select" -}; +} -//------------------------LLPanelPreferenceControls-------------------------------- -static LLPanelInjector t_pref_contrls("panel_preference_controls"); +LLPanelPreferenceControls::~LLPanelPreferenceControls() +{ +} BOOL LLPanelPreferenceControls::postBuild() { - //todo: on open instead of on the go //todo: add pitch/yaw? - //todo: Scroll? //todo: should be auto-expandable with menu items and should pull names from menu when possible // populate list of controls pControlsTable = getChild("controls_list"); - populateControlTable(); + pKeyModeBox = getChild("key_mode"); pControlsTable->setCommitCallback(boost::bind(&LLPanelPreferenceControls::onListCommit, this)); + pKeyModeBox->setCommitCallback(boost::bind(&LLPanelPreferenceControls::onModeCommit, this)); + getChild("restore_defaults")->setCommitCallback(boost::bind(&LLPanelPreferenceControls::onRestoreDefaults, this)); return TRUE; } +// Something of a workaround: cells don't handle clicks, so we catch a click, then process it on hover. +BOOL LLPanelPreferenceControls::handleHover(S32 x, S32 y, MASK mask) +{ + if (mShowKeyDialog) + { + if (mEditingIndex > 0 && mConflictHandler[mEditingMode].canAssignControl((LLKeyConflictHandler::EControlTypes)mEditingIndex)) + { + mEditingColumn = pControlsTable->getColumnIndexFromOffset(x); + + if (mEditingColumn >0) + { + LLSetKeyBindDialog* dialog = LLFloaterReg::showTypedInstance("keybind_dialog", LLSD(), TRUE); + if (dialog) + { + if (mConflictHandler[mEditingMode].getLoadedMode() == LLKeyConflictHandler::MODE_GENERAL) + { + dialog->setParent(this, DEFAULT_KEY_FILTER); + } + else + { + dialog->setParent(this, ALLOW_KEYS | ALLOW_MASK_KEYS); + } + } + } + } + mShowKeyDialog = false; + } + return LLPanelPreference::handleHover(x, y, mask); +} + +void LLPanelPreferenceControls::addGroupRow(const std::string &icon, S32 index) +{ + LLScrollListItem::Params item_params; + item_params.value = LLSD::Integer(-1); + + LLScrollListCell::Params icon_cell_params; + icon_cell_params.font = LLFontGL::getFontSansSerif(); + icon_cell_params.font_halign = LLFontGL::LEFT; + icon_cell_params.type = "icontext"; + + LLScrollListCell::Params cell_params; + // init basic cell params + cell_params.font = LLFontGL::getFontSansSerif(); + cell_params.font_halign = LLFontGL::LEFT; + + std::string control_name = LLKeyConflictHandler::getControlName((LLKeyConflictHandler::EControlTypes)index); + std::string label; + if (hasString(control_name)) + { + label = getString(control_name); + } + else + { + label = control_name; + } + icon_cell_params.column = "lst_action"; + icon_cell_params.text = label; + icon_cell_params.value = icon; + item_params.columns.add(icon_cell_params); + //dummy cells + cell_params.column = "lst_ctrl1"; + cell_params.value = ""; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl2"; + cell_params.value = ""; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl3"; + cell_params.value = ""; + item_params.columns.add(cell_params); + pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM); +} + +void LLPanelPreferenceControls::regenerateControls() +{ + mEditingMode = pKeyModeBox->getValue().asInteger(); + mConflictHandler[mEditingMode].loadFromSettings((LLKeyConflictHandler::EModes)mEditingMode); + populateControlTable(); +} + void LLPanelPreferenceControls::populateControlTable() { pControlsTable->clearRows(); // todo: subsections need sorting? - std::string label; + std::string label, control_name; LLScrollListCell::Params cell_params; // init basic cell params cell_params.font = LLFontGL::getFontSansSerif(); @@ -3013,81 +3010,71 @@ void LLPanelPreferenceControls::populateControlTable() cell_params.column = ""; cell_params.value = label; - LLScrollListItem::Params item_params_blank; - cell_params.enabled = false; - item_params_blank.value = LLSD::Integer(-1); - item_params_blank.columns.add(cell_params); - cell_params.enabled = true; - - for (U32 i = LLControlBindings::CONTROL_VIEW_ACTIONS; i < LLControlBindings::CONTROL_NUM_INDICES; i++) + S32 start = mEditingMode == LLKeyConflictHandler::MODE_GENERAL ? LLKeyConflictHandler::CONTROL_VIEW_ACTIONS : LLKeyConflictHandler::CONTROL_MOVEMENTS; + S32 end = mEditingMode == LLKeyConflictHandler::MODE_GENERAL ? LLKeyConflictHandler::CONTROL_NUM_INDICES : LLKeyConflictHandler::CONTROL_RESERVED; + for (S32 i = start; i < end; i++) { - switch (i) + LLKeyConflictHandler::EControlTypes type = (LLKeyConflictHandler::EControlTypes)i; + switch (type) { - case LLControlBindings::CONTROL_VIEW_ACTIONS: - { - // same as below, but without separator - LLScrollListItem::Params item_params; - item_params.value = LLSD::Integer(i); - - label = getString(tmp_typetostring[i]); - cell_params.column = "lst_action"; - cell_params.value = label; - //dummy cells - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl1"; - cell_params.value = ""; - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl2"; - cell_params.value = ""; - item_params.columns.add(cell_params); - LLUUID id; - LLGroupControlsListItem* item = new LLGroupControlsListItem(item_params, id); - pControlsTable->addRow(item, item_params, EAddPosition::ADD_BOTTOM); - break; - } - case LLControlBindings::CONTROL_INTERACTIONS: - case LLControlBindings::CONTROL_MOVEMENTS: - case LLControlBindings::CONTROL_MEDIACONTENT: - case LLControlBindings::CONTROL_RESERVED: - { - // insert blank - pControlsTable->addRow(item_params_blank, EAddPosition::ADD_BOTTOM); - // inster with icon - LLScrollListItem::Params item_params; - item_params.value = LLSD::Integer(i); - - label = getString(tmp_typetostring[i]); - cell_params.column = "lst_action"; - cell_params.value = label; - //dummy cells - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl1"; - cell_params.value = ""; - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl2"; - cell_params.value = ""; - item_params.columns.add(cell_params); - LLUUID id; - LLGroupControlsListItem* item = new LLGroupControlsListItem(item_params, id); - pControlsTable->addRow(item, item_params, EAddPosition::ADD_BOTTOM); - break; - } - default: + case LLKeyConflictHandler::CONTROL_VIEW_ACTIONS: + addSeparator(); + addGroupRow("Search_Icon", i); + break; + case LLKeyConflictHandler::CONTROL_INTERACTIONS: + addSeparator(); + addGroupRow("Command_Gestures_Icon", i); + break; + case LLKeyConflictHandler::CONTROL_MOVEMENTS: + addSeparator(); + addGroupRow("Move_Walk_Off", i); + break; + case LLKeyConflictHandler::CONTROL_MEDIACONTENT: + addSeparator(); + addGroupRow("Audio_Press", i); + break; + case LLKeyConflictHandler::CONTROL_CAMERA: + addSeparator(); + addGroupRow("Cam_FreeCam_Off", i); + break; + case LLKeyConflictHandler::CONTROL_EDIT_TITLE: + addSeparator(); + addGroupRow("Tool_Dozer", i); + break; + case LLKeyConflictHandler::CONTROL_RESERVED: + addSeparator(); + addGroupRow("Info_Small", i); + break; + default: { //default insert LLScrollListItem::Params item_params; item_params.value = LLSD::Integer(i); - // todo oddset cell_params.column = "lst_action"; - label = getString(tmp_typetostring[i]); + bool enabled = mConflictHandler[mEditingMode].canAssignControl(type); + control_name = LLKeyConflictHandler::getControlName(type); + if (hasString(control_name)) + { + label = getString(control_name); + } + else + { + label = control_name; + } cell_params.value = label; item_params.columns.add(cell_params); cell_params.column = "lst_ctrl1"; - cell_params.value = gControlBindings.getPrimaryControl((LLControlBindings::EControlTypes)i).asString(); + cell_params.value = mConflictHandler[mEditingMode].getControlString(type, 0); + cell_params.enabled = enabled; item_params.columns.add(cell_params); cell_params.column = "lst_ctrl2"; - cell_params.value = gControlBindings.getSecondaryControl((LLControlBindings::EControlTypes)i).asString(); + cell_params.value = mConflictHandler[mEditingMode].getControlString(type, 1); + cell_params.enabled = enabled; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl3"; + cell_params.value = mConflictHandler[mEditingMode].getControlString(type, 2); + cell_params.enabled = enabled; item_params.columns.add(cell_params); pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM); @@ -3095,23 +3082,64 @@ void LLPanelPreferenceControls::populateControlTable() } } } + + //temp + if (mEditingMode == LLKeyConflictHandler::MODE_GENERAL) + pControlsTable->setEnabled(false); } -void LLPanelPreferenceControls::cancel() +// Just a workaround to not care about first separator before headers (we can start from random header) +void LLPanelPreferenceControls::addSeparator() { + if (pControlsTable->getItemCount() > 0) + { + pControlsTable->addSeparator(EAddPosition::ADD_BOTTOM); + } } -void LLPanelPreferenceControls::saveSettings() +void LLPanelPreferenceControls::apply() { + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + { + if (mConflictHandler[i].hasUnsavedChanges()) + { + mConflictHandler[i].saveToSettings(); + } + } } -void LLPanelPreferenceControls::resetDirtyChilds() +void LLPanelPreferenceControls::cancel() { + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + { + if (mConflictHandler[i].hasUnsavedChanges()) + { + mConflictHandler[i].clear(); + } + } + pControlsTable->clear(); } -bool LLPanelPreferenceControls::hasDirtyChilds() +void LLPanelPreferenceControls::saveSettings() { - return false; + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + { + if (mConflictHandler[i].hasUnsavedChanges()) + { + mConflictHandler[i].saveToSettings(); + } + } + + S32 mode = pKeyModeBox->getValue().asInteger(); + if (mConflictHandler[mode].empty()) + { + regenerateControls(); + } +} + +void LLPanelPreferenceControls::resetDirtyChilds() +{ + regenerateControls(); } void LLPanelPreferenceControls::onListCommit() @@ -3124,61 +3152,85 @@ void LLPanelPreferenceControls::onListCommit() S32 control = item->getValue().asInteger(); - if (!gControlBindings.canAssignControl((LLControlBindings::EControlTypes)control)) + if (control <= 0) { return; } - - // todo: add code to determine what cell was clicked, probably cells themself should be clickable - LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance("voice_set_key", LLSD(), TRUE); - if (dialog) + if (!mConflictHandler[mEditingMode].canAssignControl((LLKeyConflictHandler::EControlTypes)control)) { - dialog->setTmpParent(this); // will be remade from being voice later + return; } + + // List does not tell us what cell was clicked, so we have to figure it out manually, but + // fresh mouse coordinates are not yet accessible during onCommit() and there are other issues, + // so we cheat: remember item user clicked at, trigger 'key dialog' on hover that comes next, + // use coordinates from hover to calculate cell + mEditingIndex = control; + mShowKeyDialog = true; } -void LLPanelPreferenceControls::onSetKey(KEY key, MASK mask) +void LLPanelPreferenceControls::onModeCommit() { - LLScrollListItem* item = pControlsTable->getFirstSelected(); - if (item == NULL) + regenerateControls(); +} + +void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask) +{ + LLKeyConflictHandler::EControlTypes control = (LLKeyConflictHandler::EControlTypes)mEditingIndex; + + if (!mConflictHandler[mEditingMode].canAssignControl(control)) { return; } - LLControlBindings::EControlTypes control = (LLControlBindings::EControlTypes)item->getValue().asInteger(); - - if (!gControlBindings.canAssignControl(control)) + pControlsTable->deselectAllItems(); + pControlsTable->selectByValue(mEditingIndex); + LLScrollListItem *item = pControlsTable->getFirstSelected(); + if (item && mEditingColumn > 0) { - return; + + mConflictHandler[mEditingMode].registerControl(control, mEditingColumn - 1, click, key, mask); + + LLScrollListCell *cell = item->getColumn(1); + cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 0)); + cell = item->getColumn(2); + cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 1)); + cell = item->getColumn(3); + cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 2)); } - gControlBindings.registerPrimaryControl(control, LLMouseHandler::CLICK_NONE, key, mask); + populateControlTable(); +} - // instead of populating, update single element +void LLPanelPreferenceControls::onRestoreDefaults() +{ + mConflictHandler[mEditingMode].resetToDefaults(); populateControlTable(); } -void LLPanelPreferenceControls::onSetMouse(LLMouseHandler::EClickType click, MASK mask) +void LLPanelPreferenceControls::onDefaultKeyBind() { + LLKeyConflictHandler::EControlTypes control = (LLKeyConflictHandler::EControlTypes)mEditingIndex; - LLScrollListItem* item = pControlsTable->getFirstSelected(); - if (item == NULL) + if (!mConflictHandler[mEditingMode].canAssignControl(control)) { return; } - LLControlBindings::EControlTypes control = (LLControlBindings::EControlTypes)item->getValue().asInteger(); - - if (!gControlBindings.canAssignControl(control)) + pControlsTable->deselectAllItems(); + pControlsTable->selectByValue(mEditingIndex); + LLScrollListItem *item = pControlsTable->getFirstSelected(); + if (item) { - return; - } + LLScrollListCell *cell = item->getColumn(mEditingColumn); - gControlBindings.registerPrimaryControl(control, click, KEY_NONE, mask); - - // instead of populating, update single element - populateControlTable(); + if (mEditingColumn > 0) + { + mConflictHandler[mEditingMode].resetToDefault(control, mEditingColumn - 1); + cell->setValue(mConflictHandler[mEditingMode].getControlString(control, mEditingColumn - 1)); + } + } } LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key) -- cgit v1.2.3 From c60b929fbb615f8d73f7bf42849b5628bf0f8f7a Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 25 Sep 2019 17:54:36 +0300 Subject: SL-6109 Mouse support ready --- indra/newview/llfloaterpreference.cpp | 92 +++++++++++++++++++++++++---------- 1 file changed, 65 insertions(+), 27 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 34cfe6ebb4..d7a8f9fd4f 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -166,7 +166,7 @@ static const U32 ALLOW_MASK_MOUSE = 2; static const U32 ALLOW_KEYS = 4; //keyboard static const U32 ALLOW_MASK_KEYS = 8; static const U32 ALLOW_MASKS = 16; -static const U32 IGNORE_MASKS = 32; // For example W (aka Forward) should work regardless of SHIFT being pressed +static const U32 CAN_IGNORE_MASKS = 32; // For example W (aka Forward) should work regardless of SHIFT being pressed static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASK_KEYS; class LLSetKeyBindDialog : public LLModalDialog @@ -176,6 +176,7 @@ public: ~LLSetKeyBindDialog(); /*virtual*/ BOOL postBuild(); + /*virtual*/ void onClose(bool app_quiting); void setParent(LLPanelPreferenceControls* parent, U32 key_mask = DEFAULT_KEY_FILTER); @@ -186,18 +187,23 @@ public: static void onDefault(void* user_data); private: - LLPanelPreferenceControls* mParent; + LLPanelPreferenceControls* pParent; + LLCheckBoxCtrl* pCheckBox; U32 mKeyMask; }; LLSetKeyBindDialog::LLSetKeyBindDialog(const LLSD& key) : LLModalDialog(key), - mParent(NULL), + pParent(NULL), mKeyMask(DEFAULT_KEY_FILTER) { } +LLSetKeyBindDialog::~LLSetKeyBindDialog() +{ +} + //virtual BOOL LLSetKeyBindDialog::postBuild() { @@ -205,15 +211,24 @@ BOOL LLSetKeyBindDialog::postBuild() childSetAction("Default", onDefault, this); childSetAction("Cancel", onCancel, this); getChild("Cancel")->setFocus(TRUE); - + + pCheckBox = getChild("ignore_masks"); + gFocusMgr.setKeystrokesOnly(TRUE); return TRUE; } +//virtual +void LLSetKeyBindDialog::onClose(bool app_quiting) +{ + pParent = NULL; + LLModalDialog::onClose(app_quiting); +} + void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_mask) { - mParent = parent; + pParent = parent; mKeyMask = key_mask; LLTextBase *text_ctrl = getChild("descritption"); @@ -232,10 +247,10 @@ void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_ma input += getString("keyboard"); } text_ctrl->setTextArg("[INPUT]", input); -} -LLSetKeyBindDialog::~LLSetKeyBindDialog() -{ + bool can_ignore_masks = (key_mask & CAN_IGNORE_MASKS) != 0; + pCheckBox->setVisible(can_ignore_masks); + pCheckBox->setValue(false); } BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) @@ -249,10 +264,19 @@ BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) return true; } + if (key == KEY_DELETE) + { + if (pParent) + { + pParent->onSetKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); + } + closeFloater(); + return true; + } + // forbidden keys if (key == KEY_NONE || key == KEY_RETURN - || key == KEY_DELETE || key == KEY_BACKSPACE) { return false; @@ -275,9 +299,9 @@ BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) return false; } - else if (mParent) + if (pParent) { - mParent->onSetKeyBind(CLICK_NONE, key, mask); + pParent->onSetKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); } closeFloater(); return result; @@ -305,9 +329,9 @@ BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClic && (clicktype != CLICK_RIGHT || mask != 0) // reassigning menu button is not supported && ((mKeyMask & ALLOW_MASK_MOUSE) != 0 || mask == 0)) { - if (mParent) + if (pParent) { - mParent->onSetKeyBind(clicktype, KEY_NONE, mask); + pParent->onSetKeyBind(clicktype, KEY_NONE, mask, pCheckBox->getValue().asBoolean()); } result = TRUE; closeFloater(); @@ -333,9 +357,9 @@ void LLSetKeyBindDialog::onBlank(void* user_data) { LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; // tmp needs 'no key' button - if (self->mParent) + if (self->pParent) { - self->mParent->onSetKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE); + self->pParent->onSetKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); } self->closeFloater(); } @@ -345,9 +369,9 @@ void LLSetKeyBindDialog::onDefault(void* user_data) { LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; // tmp needs 'no key' button - if (self->mParent) + if (self->pParent) { - self->mParent->onDefaultKeyBind(); + self->pParent->onDefaultKeyBind(); } self->closeFloater(); } @@ -2921,6 +2945,23 @@ BOOL LLPanelPreferenceControls::postBuild() // Something of a workaround: cells don't handle clicks, so we catch a click, then process it on hover. BOOL LLPanelPreferenceControls::handleHover(S32 x, S32 y, MASK mask) { + /*S32 column = pControlsTable->getColumnIndexFromOffset(x); + LLScrollListItem* item = pControlsTable->hitItem(x, y); + static LLScrollListCell* last_cell = NULL; + if (item && column > 0) + { + LLScrollListCell* cell = item->getColumn(column); + if (cell) + { + cell->highlightText(0, CHAR_MAX); + if (last_cell != NULL && last_cell !=cell) + { + last_cell->highlightText(0, 0); + } + last_cell = cell; + } + }*/ + if (mShowKeyDialog) { if (mEditingIndex > 0 && mConflictHandler[mEditingMode].canAssignControl((LLKeyConflictHandler::EControlTypes)mEditingIndex)) @@ -2932,14 +2973,14 @@ BOOL LLPanelPreferenceControls::handleHover(S32 x, S32 y, MASK mask) LLSetKeyBindDialog* dialog = LLFloaterReg::showTypedInstance("keybind_dialog", LLSD(), TRUE); if (dialog) { - if (mConflictHandler[mEditingMode].getLoadedMode() == LLKeyConflictHandler::MODE_GENERAL) - { + /*if (mConflictHandler[mEditingMode].getLoadedMode() == LLKeyConflictHandler::MODE_GENERAL) + {*/ dialog->setParent(this, DEFAULT_KEY_FILTER); - } + /*} else { dialog->setParent(this, ALLOW_KEYS | ALLOW_MASK_KEYS); - } + }*/ } } } @@ -3082,10 +3123,6 @@ void LLPanelPreferenceControls::populateControlTable() } } } - - //temp - if (mEditingMode == LLKeyConflictHandler::MODE_GENERAL) - pControlsTable->setEnabled(false); } // Just a workaround to not care about first separator before headers (we can start from random header) @@ -3175,7 +3212,8 @@ void LLPanelPreferenceControls::onModeCommit() regenerateControls(); } -void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask) +// todo: copy onSetKeyBind to interface and inherit from interface +void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore_mask) { LLKeyConflictHandler::EControlTypes control = (LLKeyConflictHandler::EControlTypes)mEditingIndex; @@ -3190,7 +3228,7 @@ void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MAS if (item && mEditingColumn > 0) { - mConflictHandler[mEditingMode].registerControl(control, mEditingColumn - 1, click, key, mask); + mConflictHandler[mEditingMode].registerControl(control, mEditingColumn - 1, click, key, mask, ignore_mask); LLScrollListCell *cell = item->getColumn(1); cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 0)); -- cgit v1.2.3 From 4ae2165c4516a74012d30610b4c53de6d3ccaf90 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 25 Sep 2019 22:23:09 +0300 Subject: SL-6109 LMB DLMB in progress --- indra/newview/llfloaterpreference.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index d7a8f9fd4f..0af6249351 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -167,7 +167,7 @@ static const U32 ALLOW_KEYS = 4; //keyboard static const U32 ALLOW_MASK_KEYS = 8; static const U32 ALLOW_MASKS = 16; static const U32 CAN_IGNORE_MASKS = 32; // For example W (aka Forward) should work regardless of SHIFT being pressed -static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASK_KEYS; +static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASK_KEYS | CAN_IGNORE_MASKS; class LLSetKeyBindDialog : public LLModalDialog { @@ -2919,6 +2919,10 @@ LLPanelPreferenceControls::LLPanelPreferenceControls() mEditingMode(0), mShowKeyDialog(false) { + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + { + mConflictHandler[i].setLoadMode((LLKeyConflictHandler::EModes)i); + } } LLPanelPreferenceControls::~LLPanelPreferenceControls() @@ -3243,7 +3247,10 @@ void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MAS void LLPanelPreferenceControls::onRestoreDefaults() { - mConflictHandler[mEditingMode].resetToDefaults(); + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + { + mConflictHandler[mEditingMode].resetToDefaults(); + } populateControlTable(); } -- cgit v1.2.3 From 2532a2ee9ee9003e2c6b72f8da19979a9e3dd2f6 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 26 Sep 2019 22:28:18 +0300 Subject: SL-6109 Conflict resolution --- indra/newview/llfloaterpreference.cpp | 164 +++++++++++++++++++++------------- 1 file changed, 104 insertions(+), 60 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 0af6249351..4852a9d93e 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -222,7 +222,11 @@ BOOL LLSetKeyBindDialog::postBuild() //virtual void LLSetKeyBindDialog::onClose(bool app_quiting) { - pParent = NULL; + if (pParent) + { + pParent->onCancelKeyBind(); + pParent = NULL; + } LLModalDialog::onClose(app_quiting); } @@ -269,6 +273,7 @@ BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) if (pParent) { pParent->onSetKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); + pParent = NULL; } closeFloater(); return true; @@ -302,6 +307,7 @@ BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) if (pParent) { pParent->onSetKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); + pParent = NULL; } closeFloater(); return result; @@ -332,6 +338,7 @@ BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClic if (pParent) { pParent->onSetKeyBind(clicktype, KEY_NONE, mask, pCheckBox->getValue().asBoolean()); + pParent = NULL; } result = TRUE; closeFloater(); @@ -360,6 +367,7 @@ void LLSetKeyBindDialog::onBlank(void* user_data) if (self->pParent) { self->pParent->onSetKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); + self->pParent = NULL; } self->closeFloater(); } @@ -372,6 +380,7 @@ void LLSetKeyBindDialog::onDefault(void* user_data) if (self->pParent) { self->pParent->onDefaultKeyBind(); + self->pParent = NULL; } self->closeFloater(); } @@ -2917,11 +2926,12 @@ LLPanelPreferenceControls::LLPanelPreferenceControls() mEditingIndex(-1), mEditingColumn(-1), mEditingMode(0), - mShowKeyDialog(false) + mShowKeyDialog(false), + mHighlightedCell(NULL) { - for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) { - mConflictHandler[i].setLoadMode((LLKeyConflictHandler::EModes)i); + mConflictHandler[i].setLoadMode((LLKeyConflictHandler::ESourceMode)i); } } @@ -2949,46 +2959,34 @@ BOOL LLPanelPreferenceControls::postBuild() // Something of a workaround: cells don't handle clicks, so we catch a click, then process it on hover. BOOL LLPanelPreferenceControls::handleHover(S32 x, S32 y, MASK mask) { - /*S32 column = pControlsTable->getColumnIndexFromOffset(x); - LLScrollListItem* item = pControlsTable->hitItem(x, y); - static LLScrollListCell* last_cell = NULL; - if (item && column > 0) - { - LLScrollListCell* cell = item->getColumn(column); - if (cell) - { - cell->highlightText(0, CHAR_MAX); - if (last_cell != NULL && last_cell !=cell) - { - last_cell->highlightText(0, 0); - } - last_cell = cell; - } - }*/ - if (mShowKeyDialog) { - if (mEditingIndex > 0 && mConflictHandler[mEditingMode].canAssignControl((LLKeyConflictHandler::EControlTypes)mEditingIndex)) + mShowKeyDialog = false; + if (mEditingIndex > 0 + && mConflictHandler[mEditingMode].canAssignControl((LLKeyConflictHandler::EControlTypes)mEditingIndex)) { - mEditingColumn = pControlsTable->getColumnIndexFromOffset(x); - - if (mEditingColumn >0) + LLScrollListItem* item = pControlsTable->getFirstSelected(); // don't use pControlsTable->hitItem(x, y) dur to drift; + if (item) { - LLSetKeyBindDialog* dialog = LLFloaterReg::showTypedInstance("keybind_dialog", LLSD(), TRUE); - if (dialog) + mEditingColumn = pControlsTable->getColumnIndexFromOffset(x); + if (mEditingColumn > 0) { - /*if (mConflictHandler[mEditingMode].getLoadedMode() == LLKeyConflictHandler::MODE_GENERAL) - {*/ - dialog->setParent(this, DEFAULT_KEY_FILTER); - /*} - else + LLScrollListCell* cell = item->getColumn(mEditingColumn); + if (cell) { - dialog->setParent(this, ALLOW_KEYS | ALLOW_MASK_KEYS); - }*/ + LLSetKeyBindDialog* dialog = LLFloaterReg::showTypedInstance("keybind_dialog", LLSD(), TRUE); + if (dialog) + { + dialog->setParent(this, DEFAULT_KEY_FILTER); + cell->setHighlighted(true); + mHighlightedCell = cell; + pControlsTable->deselectAllItems(); + return TRUE; + } + } } } } - mShowKeyDialog = false; } return LLPanelPreference::handleHover(x, y, mask); } @@ -3038,7 +3036,7 @@ void LLPanelPreferenceControls::addGroupRow(const std::string &icon, S32 index) void LLPanelPreferenceControls::regenerateControls() { mEditingMode = pKeyModeBox->getValue().asInteger(); - mConflictHandler[mEditingMode].loadFromSettings((LLKeyConflictHandler::EModes)mEditingMode); + mConflictHandler[mEditingMode].loadFromSettings((LLKeyConflictHandler::ESourceMode)mEditingMode); populateControlTable(); } @@ -3046,6 +3044,12 @@ void LLPanelPreferenceControls::populateControlTable() { pControlsTable->clearRows(); + if (mHighlightedCell) + { + mHighlightedCell->setHighlighted(false); + mHighlightedCell = NULL; + } + // todo: subsections need sorting? std::string label, control_name; LLScrollListCell::Params cell_params; @@ -3138,20 +3142,50 @@ void LLPanelPreferenceControls::addSeparator() } } +void LLPanelPreferenceControls::updateTable() +{ + std::vector list = pControlsTable->getAllData(); + for (S32 i = 0; i < list.size(); ++i) + { + S32 value = list[i]->getValue().asInteger(); + if (value > 0) + { + LLKeyConflictHandler::EControlTypes control = (LLKeyConflictHandler::EControlTypes)value; + LLScrollListCell* cell = list[i]->getColumn(1); + cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 0)); + cell = list[i]->getColumn(2); + cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 1)); + cell = list[i]->getColumn(3); + cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 2)); + } + } + + if (mHighlightedCell) + { + mHighlightedCell->setHighlighted(false); + mHighlightedCell = NULL; + } +} + void LLPanelPreferenceControls::apply() { - for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) { if (mConflictHandler[i].hasUnsavedChanges()) { mConflictHandler[i].saveToSettings(); } } + if (mHighlightedCell) + { + mHighlightedCell->setHighlighted(false); + mHighlightedCell = NULL; + } } void LLPanelPreferenceControls::cancel() { - for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) { if (mConflictHandler[i].hasUnsavedChanges()) { @@ -3159,11 +3193,16 @@ void LLPanelPreferenceControls::cancel() } } pControlsTable->clear(); + if (mHighlightedCell) + { + mHighlightedCell->setHighlighted(false); + mHighlightedCell = NULL; + } } void LLPanelPreferenceControls::saveSettings() { - for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) { if (mConflictHandler[i].hasUnsavedChanges()) { @@ -3176,6 +3215,11 @@ void LLPanelPreferenceControls::saveSettings() { regenerateControls(); } + else if (mHighlightedCell) + { + mHighlightedCell->setHighlighted(false); + mHighlightedCell = NULL; + } } void LLPanelPreferenceControls::resetDirtyChilds() @@ -3209,6 +3253,12 @@ void LLPanelPreferenceControls::onListCommit() // use coordinates from hover to calculate cell mEditingIndex = control; mShowKeyDialog = true; + + if (mHighlightedCell) + { + mHighlightedCell->setHighlighted(false); + mHighlightedCell = NULL; + } } void LLPanelPreferenceControls::onModeCommit() @@ -3228,30 +3278,20 @@ void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MAS pControlsTable->deselectAllItems(); pControlsTable->selectByValue(mEditingIndex); - LLScrollListItem *item = pControlsTable->getFirstSelected(); - if (item && mEditingColumn > 0) + if ( mEditingColumn > 0) { - mConflictHandler[mEditingMode].registerControl(control, mEditingColumn - 1, click, key, mask, ignore_mask); - - LLScrollListCell *cell = item->getColumn(1); - cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 0)); - cell = item->getColumn(2); - cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 1)); - cell = item->getColumn(3); - cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 2)); } - populateControlTable(); + updateTable(); } void LLPanelPreferenceControls::onRestoreDefaults() { - for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) { mConflictHandler[mEditingMode].resetToDefaults(); } - populateControlTable(); } void LLPanelPreferenceControls::onDefaultKeyBind() @@ -3265,16 +3305,20 @@ void LLPanelPreferenceControls::onDefaultKeyBind() pControlsTable->deselectAllItems(); pControlsTable->selectByValue(mEditingIndex); - LLScrollListItem *item = pControlsTable->getFirstSelected(); - if (item) + + if (mEditingColumn > 0) { - LLScrollListCell *cell = item->getColumn(mEditingColumn); + mConflictHandler[mEditingMode].resetToDefault(control, mEditingColumn - 1); + } + updateTable(); +} - if (mEditingColumn > 0) - { - mConflictHandler[mEditingMode].resetToDefault(control, mEditingColumn - 1); - cell->setValue(mConflictHandler[mEditingMode].getControlString(control, mEditingColumn - 1)); - } +void LLPanelPreferenceControls::onCancelKeyBind() +{ + if (mHighlightedCell) + { + mHighlightedCell->setHighlighted(false); + mHighlightedCell = NULL; } } -- cgit v1.2.3 From 0b8021870335ff9b9684fb193c6e0fe2f02b4091 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 27 Sep 2019 19:53:33 +0300 Subject: SL-6109 Cleanup, run commands, and preparation for tooltip support --- indra/newview/llfloaterpreference.cpp | 369 +++++++++++++++++++++------------- 1 file changed, 233 insertions(+), 136 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 4852a9d93e..f94a52a232 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -185,18 +185,53 @@ public: static void onCancel(void* user_data); static void onBlank(void* user_data); static void onDefault(void* user_data); + static void onClickTimeout(void* user_data, MASK mask); + + class Updater; private: + void setKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore); LLPanelPreferenceControls* pParent; LLCheckBoxCtrl* pCheckBox; - U32 mKeyMask; + U32 mKeyFilterMask; + Updater *pUpdater; +}; + +class LLSetKeyBindDialog::Updater : public LLEventTimer +{ +public: + + typedef boost::function callback_t; + + Updater(callback_t cb, F32 period, MASK mask) + :LLEventTimer(period), + mMask(mask), + mCallback(cb) + { + mEventTimer.start(); + } + + virtual ~Updater(){} + +protected: + BOOL tick() + { + mCallback(mMask); + // Deletes itseft after execution + return TRUE; + } + +private: + MASK mMask; + callback_t mCallback; }; LLSetKeyBindDialog::LLSetKeyBindDialog(const LLSD& key) : LLModalDialog(key), pParent(NULL), - mKeyMask(DEFAULT_KEY_FILTER) + mKeyFilterMask(DEFAULT_KEY_FILTER), + pUpdater(NULL) { } @@ -227,13 +262,19 @@ void LLSetKeyBindDialog::onClose(bool app_quiting) pParent->onCancelKeyBind(); pParent = NULL; } + if (pUpdater) + { + // Doubleclick timer has't fired, delete it + delete pUpdater; + pUpdater = NULL; + } LLModalDialog::onClose(app_quiting); } void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_mask) { pParent = parent; - mKeyMask = key_mask; + mKeyFilterMask = key_mask; LLTextBase *text_ctrl = getChild("descritption"); @@ -259,24 +300,18 @@ void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_ma BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) { - BOOL result = TRUE; - if ((key == 'Q' && mask == MASK_CONTROL) || key == KEY_ESCAPE) { closeFloater(); - return true; + return TRUE; } if (key == KEY_DELETE) { - if (pParent) - { - pParent->onSetKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); - pParent = NULL; - } + setKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); closeFloater(); - return true; + return FALSE; } // forbidden keys @@ -284,40 +319,41 @@ BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) || key == KEY_RETURN || key == KEY_BACKSPACE) { - return false; + return FALSE; } - if ((mKeyMask & ALLOW_MASKS) == 0 + if ((mKeyFilterMask & ALLOW_MASKS) == 0 && (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT)) { // mask by themself are not allowed - return false; + return FALSE; } - else if ((mKeyMask & ALLOW_KEYS) == 0) + else if ((mKeyFilterMask & ALLOW_KEYS) == 0) { // basic keys not allowed - return false; + return FALSE; } - else if ((mKeyMask & ALLOW_MASK_KEYS) == 0 && mask != 0) + else if ((mKeyFilterMask & ALLOW_MASK_KEYS) == 0 && mask != 0) { // masked keys not allowed - return false; + return FALSE; } - if (pParent) - { - pParent->onSetKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); - pParent = NULL; - } - closeFloater(); - return result; + setKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); + closeFloater(); + return TRUE; } BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down) { BOOL result = FALSE; - - if (clicktype == CLICK_LEFT) + if (!pParent) + { + // we already processed 'down' event, this is 'up', consume + closeFloater(); + result = TRUE; + } + if (!result && clicktype == CLICK_LEFT) { // try handling buttons first if (down) @@ -328,25 +364,38 @@ BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClic { result = LLView::handleMouseUp(x, y, mask); } + if (result) + { + setFocus(TRUE); + gFocusMgr.setKeystrokesOnly(TRUE); + } + // ignore selection related combinations + else if (down && (mask & (MASK_SHIFT | MASK_CONTROL)) == 0) + { + // this can be a double click, wait a bit; + if (!pUpdater) + { + // Note: default doubleclick time is 500ms, but can stretch up to 5s + pUpdater = new Updater(boost::bind(&onClickTimeout, this, _1), 0.7f, mask); + result = TRUE; + } + } } if (!result - && ((mKeyMask & ALLOW_MOUSE) != 0) + && (clicktype != CLICK_LEFT) // subcases were handled above + && ((mKeyFilterMask & ALLOW_MOUSE) != 0) && (clicktype != CLICK_RIGHT || mask != 0) // reassigning menu button is not supported - && ((mKeyMask & ALLOW_MASK_MOUSE) != 0 || mask == 0)) + && ((mKeyFilterMask & ALLOW_MASK_MOUSE) != 0 || mask == 0)) // reserved for selection { - if (pParent) + setKeyBind(clicktype, KEY_NONE, mask, pCheckBox->getValue().asBoolean()); + result = TRUE; + if (!down) { - pParent->onSetKeyBind(clicktype, KEY_NONE, mask, pCheckBox->getValue().asBoolean()); - pParent = NULL; + // wait for 'up' event before closing + // alternative: set pUpdater + closeFloater(); } - result = TRUE; - closeFloater(); - } - - if (!result) - { - result = LLMouseHandler::handleAnyMouseClick(x, y, mask, clicktype, down); } return result; @@ -356,7 +405,7 @@ BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClic void LLSetKeyBindDialog::onCancel(void* user_data) { LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; - self->closeFloater(); + self->closeFloater(); } //static @@ -364,11 +413,7 @@ void LLSetKeyBindDialog::onBlank(void* user_data) { LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; // tmp needs 'no key' button - if (self->pParent) - { - self->pParent->onSetKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); - self->pParent = NULL; - } + self->setKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); self->closeFloater(); } @@ -376,7 +421,6 @@ void LLSetKeyBindDialog::onBlank(void* user_data) void LLSetKeyBindDialog::onDefault(void* user_data) { LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; - // tmp needs 'no key' button if (self->pParent) { self->pParent->onDefaultKeyBind(); @@ -385,6 +429,27 @@ void LLSetKeyBindDialog::onDefault(void* user_data) self->closeFloater(); } +//static +void LLSetKeyBindDialog::onClickTimeout(void* user_data, MASK mask) +{ + LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; + + // timer will delete itself after timeout + self->pUpdater = NULL; + + self->setKeyBind(CLICK_LEFT, KEY_NONE, mask, self->pCheckBox->getValue().asBoolean()); + self->closeFloater(); +} + +void LLSetKeyBindDialog::setKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore) +{ + if (pParent) + { + pParent->onSetKeyBind(click, key, mask, ignore); + pParent = NULL; + } +} + // global functions @@ -2921,9 +2986,72 @@ void LLPanelPreferenceGraphics::setHardwareDefaults() //------------------------LLPanelPreferenceControls-------------------------------- static LLPanelInjector t_pref_contrls("panel_preference_controls"); +//name of control and name of icon if it is a group, likely 'TEMP' until xml gets properly populated +typedef std::vector > controls_to_icon_t; +static const controls_to_icon_t commands_and_headers = +{ + //{ "control_view_actions", "Search_Icon" }, + //{ "control_interactions", "Command_Gestures_Icon" }, + { "control_movements", "Move_Walk_Off" }, + { "walk_to", "" }, + { "teleport_to", "" }, + { "push_forward", "" }, + { "push_backward", "" }, + { "turn_left", "" }, + { "turn_right", "" }, + { "slide_left", "" }, + { "slide_right", "" }, + { "jump", "" }, + { "push_down", "" }, + { "run_forward", "" }, + { "run_backward", "" }, + { "run_left", "" }, + { "run_right", "" }, + { "toggle_run", "" }, + { "toggle_fly", "" }, + { "toggle_sit", "" }, + { "stop_moving", "" }, + { "control_camera", "Cam_FreeCam_Off" }, + { "look_up", "" }, + { "look_down", "" }, + { "move_forward", "" }, + { "move_backward", "" }, + { "move_forward_fast", "" }, + { "move_backward_fast", "" }, + { "move_forward_sitting", "" }, + { "move_backward_sitting", "" }, + { "spin_over", "" }, + { "spin_under", "" }, + { "spin_over_sitting", "" }, + { "spin_under_sitting", "" }, + { "pan_up", "" }, + { "pan_down", "" }, + { "pan_left", "" }, + { "pan_right", "" }, + { "pan_in", "" }, + { "pan_out", "" }, + { "spin_around_ccw", "" }, + { "spin_around_cw", "" }, + { "spin_around_ccw_sitting", "" }, + { "spin_around_cw_sitting", "" }, + { "control_edit_title", "Tool_Dozer" }, + { "edit_avatar_spin_ccw", "" }, + { "edit_avatar_spin_cw", "" }, + { "edit_avatar_spin_over", "" }, + { "edit_avatar_spin_under", "" }, + { "edit_avatar_move_forward", "" }, + { "edit_avatar_move_backward", "" }, + { "control_mediacontent", "Audio_Press" }, + { "toggle_pause_media", "" }, + { "toggle_enable_media", "" }, + { "voice_follow_key", "" }, + { "toggle_voice", "" }, + { "start_chat", "" }, + { "start_gesture", "" }, +}; + LLPanelPreferenceControls::LLPanelPreferenceControls() :LLPanelPreference(), - mEditingIndex(-1), mEditingColumn(-1), mEditingMode(0), mShowKeyDialog(false), @@ -2962,8 +3090,8 @@ BOOL LLPanelPreferenceControls::handleHover(S32 x, S32 y, MASK mask) if (mShowKeyDialog) { mShowKeyDialog = false; - if (mEditingIndex > 0 - && mConflictHandler[mEditingMode].canAssignControl((LLKeyConflictHandler::EControlTypes)mEditingIndex)) + if (!mEditingControl.empty() + && mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) { LLScrollListItem* item = pControlsTable->getFirstSelected(); // don't use pControlsTable->hitItem(x, y) dur to drift; if (item) @@ -2991,10 +3119,10 @@ BOOL LLPanelPreferenceControls::handleHover(S32 x, S32 y, MASK mask) return LLPanelPreference::handleHover(x, y, mask); } -void LLPanelPreferenceControls::addGroupRow(const std::string &icon, S32 index) +void LLPanelPreferenceControls::addGroupRow(const std::string &control_name, const std::string &icon) { LLScrollListItem::Params item_params; - item_params.value = LLSD::Integer(-1); + item_params.value = ""; LLScrollListCell::Params icon_cell_params; icon_cell_params.font = LLFontGL::getFontSansSerif(); @@ -3006,7 +3134,6 @@ void LLPanelPreferenceControls::addGroupRow(const std::string &icon, S32 index) cell_params.font = LLFontGL::getFontSansSerif(); cell_params.font_halign = LLFontGL::LEFT; - std::string control_name = LLKeyConflictHandler::getControlName((LLKeyConflictHandler::EControlTypes)index); std::string label; if (hasString(control_name)) { @@ -3059,76 +3186,48 @@ void LLPanelPreferenceControls::populateControlTable() cell_params.column = ""; cell_params.value = label; - S32 start = mEditingMode == LLKeyConflictHandler::MODE_GENERAL ? LLKeyConflictHandler::CONTROL_VIEW_ACTIONS : LLKeyConflictHandler::CONTROL_MOVEMENTS; - S32 end = mEditingMode == LLKeyConflictHandler::MODE_GENERAL ? LLKeyConflictHandler::CONTROL_NUM_INDICES : LLKeyConflictHandler::CONTROL_RESERVED; - for (S32 i = start; i < end; i++) + controls_to_icon_t::const_iterator iter = commands_and_headers.begin(); + controls_to_icon_t::const_iterator end = commands_and_headers.end(); + for (; iter != end; ++iter) { - LLKeyConflictHandler::EControlTypes type = (LLKeyConflictHandler::EControlTypes)i; - switch (type) + if (iter->second.empty()) { - case LLKeyConflictHandler::CONTROL_VIEW_ACTIONS: - addSeparator(); - addGroupRow("Search_Icon", i); - break; - case LLKeyConflictHandler::CONTROL_INTERACTIONS: - addSeparator(); - addGroupRow("Command_Gestures_Icon", i); - break; - case LLKeyConflictHandler::CONTROL_MOVEMENTS: - addSeparator(); - addGroupRow("Move_Walk_Off", i); - break; - case LLKeyConflictHandler::CONTROL_MEDIACONTENT: - addSeparator(); - addGroupRow("Audio_Press", i); - break; - case LLKeyConflictHandler::CONTROL_CAMERA: - addSeparator(); - addGroupRow("Cam_FreeCam_Off", i); - break; - case LLKeyConflictHandler::CONTROL_EDIT_TITLE: - addSeparator(); - addGroupRow("Tool_Dozer", i); - break; - case LLKeyConflictHandler::CONTROL_RESERVED: - addSeparator(); - addGroupRow("Info_Small", i); - break; - default: + // general control + LLScrollListItem::Params item_params; + item_params.value = LLSD(iter->first); + + cell_params.column = "lst_action"; + bool enabled = mConflictHandler[mEditingMode].canAssignControl(iter->first); + if (hasString(iter->first)) { - //default insert - LLScrollListItem::Params item_params; - item_params.value = LLSD::Integer(i); - - cell_params.column = "lst_action"; - bool enabled = mConflictHandler[mEditingMode].canAssignControl(type); - control_name = LLKeyConflictHandler::getControlName(type); - if (hasString(control_name)) - { - label = getString(control_name); - } - else - { - label = control_name; - } - cell_params.value = label; - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl1"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(type, 0); - cell_params.enabled = enabled; - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl2"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(type, 1); - cell_params.enabled = enabled; - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl3"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(type, 2); - cell_params.enabled = enabled; - item_params.columns.add(cell_params); - - pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM); - break; + label = getString(iter->first); } + else + { + label = iter->first; + } + cell_params.value = label; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl1"; + cell_params.value = mConflictHandler[mEditingMode].getControlString(iter->first, 0); + cell_params.enabled = enabled; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl2"; + cell_params.value = mConflictHandler[mEditingMode].getControlString(iter->first, 1); + cell_params.enabled = enabled; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl3"; + cell_params.value = mConflictHandler[mEditingMode].getControlString(iter->first, 2); + cell_params.enabled = enabled; + item_params.columns.add(cell_params); + + pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM); + } + else + { + // header + addSeparator(); + addGroupRow(iter->first, iter->second); } } } @@ -3144,13 +3243,13 @@ void LLPanelPreferenceControls::addSeparator() void LLPanelPreferenceControls::updateTable() { + mEditingControl.clear(); std::vector list = pControlsTable->getAllData(); for (S32 i = 0; i < list.size(); ++i) { - S32 value = list[i]->getValue().asInteger(); - if (value > 0) + std::string control = list[i]->getValue(); + if (!control.empty()) { - LLKeyConflictHandler::EControlTypes control = (LLKeyConflictHandler::EControlTypes)value; LLScrollListCell* cell = list[i]->getColumn(1); cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 0)); cell = list[i]->getColumn(2); @@ -3207,6 +3306,7 @@ void LLPanelPreferenceControls::saveSettings() if (mConflictHandler[i].hasUnsavedChanges()) { mConflictHandler[i].saveToSettings(); + mConflictHandler[i].clear(); } } @@ -3229,20 +3329,21 @@ void LLPanelPreferenceControls::resetDirtyChilds() void LLPanelPreferenceControls::onListCommit() { + mShowKeyDialog = false; LLScrollListItem* item = pControlsTable->getFirstSelected(); if (item == NULL) { return; } - S32 control = item->getValue().asInteger(); + std::string control = item->getValue(); - if (control <= 0) + if (control.empty()) { return; } - if (!mConflictHandler[mEditingMode].canAssignControl((LLKeyConflictHandler::EControlTypes)control)) + if (!mConflictHandler[mEditingMode].canAssignControl(control)) { return; } @@ -3251,7 +3352,7 @@ void LLPanelPreferenceControls::onListCommit() // fresh mouse coordinates are not yet accessible during onCommit() and there are other issues, // so we cheat: remember item user clicked at, trigger 'key dialog' on hover that comes next, // use coordinates from hover to calculate cell - mEditingIndex = control; + mEditingControl = control; mShowKeyDialog = true; if (mHighlightedCell) @@ -3269,18 +3370,16 @@ void LLPanelPreferenceControls::onModeCommit() // todo: copy onSetKeyBind to interface and inherit from interface void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore_mask) { - LLKeyConflictHandler::EControlTypes control = (LLKeyConflictHandler::EControlTypes)mEditingIndex; - - if (!mConflictHandler[mEditingMode].canAssignControl(control)) + if (!mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) { return; } pControlsTable->deselectAllItems(); - pControlsTable->selectByValue(mEditingIndex); + pControlsTable->selectByValue(mEditingControl); if ( mEditingColumn > 0) { - mConflictHandler[mEditingMode].registerControl(control, mEditingColumn - 1, click, key, mask, ignore_mask); + mConflictHandler[mEditingMode].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, ignore_mask); } updateTable(); @@ -3296,19 +3395,17 @@ void LLPanelPreferenceControls::onRestoreDefaults() void LLPanelPreferenceControls::onDefaultKeyBind() { - LLKeyConflictHandler::EControlTypes control = (LLKeyConflictHandler::EControlTypes)mEditingIndex; - - if (!mConflictHandler[mEditingMode].canAssignControl(control)) + if (!mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) { return; } pControlsTable->deselectAllItems(); - pControlsTable->selectByValue(mEditingIndex); + pControlsTable->selectByValue(mEditingControl); if (mEditingColumn > 0) { - mConflictHandler[mEditingMode].resetToDefault(control, mEditingColumn - 1); + mConflictHandler[mEditingMode].resetToDefault(mEditingControl, mEditingColumn - 1); } updateTable(); } -- cgit v1.2.3 From 04081c0bc882cecb7647648eb035f0f2334bf983 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 1 Oct 2019 22:23:49 +0300 Subject: SL-6109 Better hover and docking of keybinder --- indra/newview/llfloaterpreference.cpp | 131 ++++++++++++---------------------- 1 file changed, 46 insertions(+), 85 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index f94a52a232..47cc93175e 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -43,6 +43,7 @@ #include "llcombobox.h" #include "llcommandhandler.h" #include "lldirpicker.h" +#include "lldrawfrustum.h" #include "lleventtimer.h" #include "llfeaturemanager.h" #include "llfocusmgr.h" @@ -169,14 +170,15 @@ static const U32 ALLOW_MASKS = 16; static const U32 CAN_IGNORE_MASKS = 32; // For example W (aka Forward) should work regardless of SHIFT being pressed static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASK_KEYS | CAN_IGNORE_MASKS; -class LLSetKeyBindDialog : public LLModalDialog +class LLSetKeyBindDialog : public LLModalDialog, public LLDrawFrustum { public: LLSetKeyBindDialog(const LLSD& key); ~LLSetKeyBindDialog(); /*virtual*/ BOOL postBuild(); - /*virtual*/ void onClose(bool app_quiting); + /*virtual*/ void onClose(bool app_quiting); + /*virtual*/ void draw(); void setParent(LLPanelPreferenceControls* parent, U32 key_mask = DEFAULT_KEY_FILTER); @@ -271,9 +273,18 @@ void LLSetKeyBindDialog::onClose(bool app_quiting) LLModalDialog::onClose(app_quiting); } +//virtual +void LLSetKeyBindDialog::draw() +{ + LLRect local_rect; + drawFrustum(local_rect, this, (LLView*)getDragHandle(), hasFocus()); + LLModalDialog::draw(); +} + void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_mask) { pParent = parent; + setFrustumOrigin(parent); mKeyFilterMask = key_mask; LLTextBase *text_ctrl = getChild("descritption"); @@ -3053,9 +3064,7 @@ static const controls_to_icon_t commands_and_headers = LLPanelPreferenceControls::LLPanelPreferenceControls() :LLPanelPreference(), mEditingColumn(-1), - mEditingMode(0), - mShowKeyDialog(false), - mHighlightedCell(NULL) + mEditingMode(0) { for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) { @@ -3084,41 +3093,6 @@ BOOL LLPanelPreferenceControls::postBuild() return TRUE; } -// Something of a workaround: cells don't handle clicks, so we catch a click, then process it on hover. -BOOL LLPanelPreferenceControls::handleHover(S32 x, S32 y, MASK mask) -{ - if (mShowKeyDialog) - { - mShowKeyDialog = false; - if (!mEditingControl.empty() - && mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) - { - LLScrollListItem* item = pControlsTable->getFirstSelected(); // don't use pControlsTable->hitItem(x, y) dur to drift; - if (item) - { - mEditingColumn = pControlsTable->getColumnIndexFromOffset(x); - if (mEditingColumn > 0) - { - LLScrollListCell* cell = item->getColumn(mEditingColumn); - if (cell) - { - LLSetKeyBindDialog* dialog = LLFloaterReg::showTypedInstance("keybind_dialog", LLSD(), TRUE); - if (dialog) - { - dialog->setParent(this, DEFAULT_KEY_FILTER); - cell->setHighlighted(true); - mHighlightedCell = cell; - pControlsTable->deselectAllItems(); - return TRUE; - } - } - } - } - } - } - return LLPanelPreference::handleHover(x, y, mask); -} - void LLPanelPreferenceControls::addGroupRow(const std::string &control_name, const std::string &icon) { LLScrollListItem::Params item_params; @@ -3170,13 +3144,7 @@ void LLPanelPreferenceControls::regenerateControls() void LLPanelPreferenceControls::populateControlTable() { pControlsTable->clearRows(); - - if (mHighlightedCell) - { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; - } - + // todo: subsections need sorting? std::string label, control_name; LLScrollListCell::Params cell_params; @@ -3243,6 +3211,7 @@ void LLPanelPreferenceControls::addSeparator() void LLPanelPreferenceControls::updateTable() { + pControlsTable->deselectAllItems(); mEditingControl.clear(); std::vector list = pControlsTable->getAllData(); for (S32 i = 0; i < list.size(); ++i) @@ -3258,12 +3227,6 @@ void LLPanelPreferenceControls::updateTable() cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 2)); } } - - if (mHighlightedCell) - { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; - } } void LLPanelPreferenceControls::apply() @@ -3275,11 +3238,6 @@ void LLPanelPreferenceControls::apply() mConflictHandler[i].saveToSettings(); } } - if (mHighlightedCell) - { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; - } } void LLPanelPreferenceControls::cancel() @@ -3292,11 +3250,6 @@ void LLPanelPreferenceControls::cancel() } } pControlsTable->clear(); - if (mHighlightedCell) - { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; - } } void LLPanelPreferenceControls::saveSettings() @@ -3315,11 +3268,6 @@ void LLPanelPreferenceControls::saveSettings() { regenerateControls(); } - else if (mHighlightedCell) - { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; - } } void LLPanelPreferenceControls::resetDirtyChilds() @@ -3329,7 +3277,6 @@ void LLPanelPreferenceControls::resetDirtyChilds() void LLPanelPreferenceControls::onListCommit() { - mShowKeyDialog = false; LLScrollListItem* item = pControlsTable->getFirstSelected(); if (item == NULL) { @@ -3340,11 +3287,20 @@ void LLPanelPreferenceControls::onListCommit() if (control.empty()) { + pControlsTable->deselectAllItems(); return; } if (!mConflictHandler[mEditingMode].canAssignControl(control)) { + pControlsTable->deselectAllItems(); + return; + } + + S32 cell_ind = item->getSelectedCell(); + if (cell_ind <= 0) + { + pControlsTable->deselectAllItems(); return; } @@ -3352,13 +3308,27 @@ void LLPanelPreferenceControls::onListCommit() // fresh mouse coordinates are not yet accessible during onCommit() and there are other issues, // so we cheat: remember item user clicked at, trigger 'key dialog' on hover that comes next, // use coordinates from hover to calculate cell - mEditingControl = control; - mShowKeyDialog = true; - if (mHighlightedCell) + LLScrollListCell* cell = item->getColumn(cell_ind); + if (cell) + { + LLSetKeyBindDialog* dialog = LLFloaterReg::getTypedInstance("keybind_dialog", LLSD()); + if (dialog) + { + mEditingControl = control; + mEditingColumn = cell_ind; + dialog->setParent(this, DEFAULT_KEY_FILTER); + + LLFloater* root_floater = gFloaterView->getParentFloater(this); + if (root_floater) + root_floater->addDependentFloater(dialog); + dialog->openFloater(); + dialog->setFocus(TRUE); + } + } + else { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; + pControlsTable->deselectAllItems(); } } @@ -3375,8 +3345,6 @@ void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MAS return; } - pControlsTable->deselectAllItems(); - pControlsTable->selectByValue(mEditingControl); if ( mEditingColumn > 0) { mConflictHandler[mEditingMode].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, ignore_mask); @@ -3399,10 +3367,7 @@ void LLPanelPreferenceControls::onDefaultKeyBind() { return; } - - pControlsTable->deselectAllItems(); - pControlsTable->selectByValue(mEditingControl); - + if (mEditingColumn > 0) { mConflictHandler[mEditingMode].resetToDefault(mEditingControl, mEditingColumn - 1); @@ -3412,11 +3377,7 @@ void LLPanelPreferenceControls::onDefaultKeyBind() void LLPanelPreferenceControls::onCancelKeyBind() { - if (mHighlightedCell) - { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; - } + pControlsTable->deselectAllItems(); } LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key) -- cgit v1.2.3 From 2e656ed358af28f56c8b900345956d431f8c7b4d Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 2 Oct 2019 20:51:47 +0300 Subject: SL-6109 Removed obsolete control, moved table init to xml, cleanup --- indra/newview/llfloaterpreference.cpp | 245 ++++++++-------------------------- 1 file changed, 52 insertions(+), 193 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 47cc93175e..3668f71feb 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -564,8 +564,7 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) mGotPersonalInfo(false), mOriginalIMViaEmail(false), mLanguageChanged(false), - mAvatarDataInitialized(false), - mClickActionDirty(false) + mAvatarDataInitialized(false) { LLConversationLog::instance().addObserver(this); @@ -587,7 +586,6 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) mCommitCallbackRegistrar.add("Pref.ResetCache", boost::bind(&LLFloaterPreference::onClickResetCache, this)); mCommitCallbackRegistrar.add("Pref.ClickSkin", boost::bind(&LLFloaterPreference::onClickSkin, this,_1, _2)); mCommitCallbackRegistrar.add("Pref.SelectSkin", boost::bind(&LLFloaterPreference::onSelectSkin, this)); - mCommitCallbackRegistrar.add("Pref.VoiceSetKey", boost::bind(&LLFloaterPreference::onClickSetKey, this)); mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse", boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this)); mCommitCallbackRegistrar.add("Pref.SetSounds", boost::bind(&LLFloaterPreference::onClickSetSounds, this)); mCommitCallbackRegistrar.add("Pref.ClickEnablePopup", boost::bind(&LLFloaterPreference::onClickEnablePopup, this)); @@ -615,8 +613,6 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) sSkin = gSavedSettings.getString("SkinCurrent"); - mCommitCallbackRegistrar.add("Pref.ClickActionChange", boost::bind(&LLFloaterPreference::onClickActionChange, this)); - gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged, _2)); @@ -883,12 +879,6 @@ void LLFloaterPreference::apply() } saveAvatarProperties(); - - if (mClickActionDirty) - { - updateClickActionSettings(); - mClickActionDirty = false; - } } void LLFloaterPreference::cancel() @@ -921,12 +911,6 @@ void LLFloaterPreference::cancel() // reverts any changes to current skin gSavedSettings.setString("SkinCurrent", sSkin); - if (mClickActionDirty) - { - updateClickActionControls(); - mClickActionDirty = false; - } - LLFloaterPreferenceProxy * advanced_proxy_settings = LLFloaterReg::findTypedInstance("prefs_proxy"); if (advanced_proxy_settings) { @@ -1008,9 +992,6 @@ void LLFloaterPreference::onOpen(const LLSD& key) onChangeTextureFolder(); onChangeSoundFolder(); onChangeAnimationFolder(); - - // Load (double-)click to walk/teleport settings. - updateClickActionControls(); // Enabled/disabled popups, might have been changed by user actions // while preferences floater was closed. @@ -1848,10 +1829,6 @@ void LLFloaterPreference::onChangeQuality(const LLSD& data) refresh(); } -void LLFloaterPreference::onClickSetKey() -{ -} - void LLFloaterPreference::onClickSetMiddleMouse() { LLUICtrl* p2t_line_editor = getChild("modifier_combo"); @@ -2335,11 +2312,6 @@ void LLFloaterPreference::onClickAdvanced() } } -void LLFloaterPreference::onClickActionChange() -{ - mClickActionDirty = true; -} - void LLFloaterPreference::onClickPermsDefault() { LLFloaterReg::showInstance("perms_default"); @@ -2377,26 +2349,6 @@ void LLFloaterPreference::onLogChatHistorySaved() } } -void LLFloaterPreference::updateClickActionSettings() -{ - const int single_clk_action = getChild("single_click_action_combo")->getValue().asInteger(); - const int double_clk_action = getChild("double_click_action_combo")->getValue().asInteger(); - - gSavedSettings.setBOOL("ClickToWalk", single_clk_action == 1); - gSavedSettings.setBOOL("DoubleClickAutoPilot", double_clk_action == 1); - gSavedSettings.setBOOL("DoubleClickTeleport", double_clk_action == 2); -} - -void LLFloaterPreference::updateClickActionControls() -{ - const bool click_to_walk = gSavedSettings.getBOOL("ClickToWalk"); - const bool dbl_click_to_walk = gSavedSettings.getBOOL("DoubleClickAutoPilot"); - const bool dbl_click_to_teleport = gSavedSettings.getBOOL("DoubleClickTeleport"); - - getChild("single_click_action_combo")->setValue((int)click_to_walk); - getChild("double_click_action_combo")->setValue(dbl_click_to_teleport ? 2 : (int)dbl_click_to_walk); -} - void LLFloaterPreference::applyUIColor(LLUICtrl* ctrl, const LLSD& param) { LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue())); @@ -2997,70 +2949,6 @@ void LLPanelPreferenceGraphics::setHardwareDefaults() //------------------------LLPanelPreferenceControls-------------------------------- static LLPanelInjector t_pref_contrls("panel_preference_controls"); -//name of control and name of icon if it is a group, likely 'TEMP' until xml gets properly populated -typedef std::vector > controls_to_icon_t; -static const controls_to_icon_t commands_and_headers = -{ - //{ "control_view_actions", "Search_Icon" }, - //{ "control_interactions", "Command_Gestures_Icon" }, - { "control_movements", "Move_Walk_Off" }, - { "walk_to", "" }, - { "teleport_to", "" }, - { "push_forward", "" }, - { "push_backward", "" }, - { "turn_left", "" }, - { "turn_right", "" }, - { "slide_left", "" }, - { "slide_right", "" }, - { "jump", "" }, - { "push_down", "" }, - { "run_forward", "" }, - { "run_backward", "" }, - { "run_left", "" }, - { "run_right", "" }, - { "toggle_run", "" }, - { "toggle_fly", "" }, - { "toggle_sit", "" }, - { "stop_moving", "" }, - { "control_camera", "Cam_FreeCam_Off" }, - { "look_up", "" }, - { "look_down", "" }, - { "move_forward", "" }, - { "move_backward", "" }, - { "move_forward_fast", "" }, - { "move_backward_fast", "" }, - { "move_forward_sitting", "" }, - { "move_backward_sitting", "" }, - { "spin_over", "" }, - { "spin_under", "" }, - { "spin_over_sitting", "" }, - { "spin_under_sitting", "" }, - { "pan_up", "" }, - { "pan_down", "" }, - { "pan_left", "" }, - { "pan_right", "" }, - { "pan_in", "" }, - { "pan_out", "" }, - { "spin_around_ccw", "" }, - { "spin_around_cw", "" }, - { "spin_around_ccw_sitting", "" }, - { "spin_around_cw_sitting", "" }, - { "control_edit_title", "Tool_Dozer" }, - { "edit_avatar_spin_ccw", "" }, - { "edit_avatar_spin_cw", "" }, - { "edit_avatar_spin_over", "" }, - { "edit_avatar_spin_under", "" }, - { "edit_avatar_move_forward", "" }, - { "edit_avatar_move_backward", "" }, - { "control_mediacontent", "Audio_Press" }, - { "toggle_pause_media", "" }, - { "toggle_enable_media", "" }, - { "voice_follow_key", "" }, - { "toggle_voice", "" }, - { "start_chat", "" }, - { "start_gesture", "" }, -}; - LLPanelPreferenceControls::LLPanelPreferenceControls() :LLPanelPreference(), mEditingColumn(-1), @@ -3078,10 +2966,6 @@ LLPanelPreferenceControls::~LLPanelPreferenceControls() BOOL LLPanelPreferenceControls::postBuild() { - //todo: add pitch/yaw? - //todo: should be auto-expandable with menu items and should pull names from menu when possible - - // populate list of controls pControlsTable = getChild("controls_list"); pKeyModeBox = getChild("key_mode"); @@ -3093,47 +2977,6 @@ BOOL LLPanelPreferenceControls::postBuild() return TRUE; } -void LLPanelPreferenceControls::addGroupRow(const std::string &control_name, const std::string &icon) -{ - LLScrollListItem::Params item_params; - item_params.value = ""; - - LLScrollListCell::Params icon_cell_params; - icon_cell_params.font = LLFontGL::getFontSansSerif(); - icon_cell_params.font_halign = LLFontGL::LEFT; - icon_cell_params.type = "icontext"; - - LLScrollListCell::Params cell_params; - // init basic cell params - cell_params.font = LLFontGL::getFontSansSerif(); - cell_params.font_halign = LLFontGL::LEFT; - - std::string label; - if (hasString(control_name)) - { - label = getString(control_name); - } - else - { - label = control_name; - } - icon_cell_params.column = "lst_action"; - icon_cell_params.text = label; - icon_cell_params.value = icon; - item_params.columns.add(icon_cell_params); - //dummy cells - cell_params.column = "lst_ctrl1"; - cell_params.value = ""; - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl2"; - cell_params.value = ""; - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl3"; - cell_params.value = ""; - item_params.columns.add(cell_params); - pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM); -} - void LLPanelPreferenceControls::regenerateControls() { mEditingMode = pKeyModeBox->getValue().asInteger(); @@ -3144,58 +2987,74 @@ void LLPanelPreferenceControls::regenerateControls() void LLPanelPreferenceControls::populateControlTable() { pControlsTable->clearRows(); - - // todo: subsections need sorting? - std::string label, control_name; + pControlsTable->clearColumns(); + + std::string filename; + switch ((LLKeyConflictHandler::ESourceMode)mEditingMode) + { + case LLKeyConflictHandler::MODE_THIRD_PERSON: + case LLKeyConflictHandler::MODE_FIRST_PERSON: + case LLKeyConflictHandler::MODE_EDIT: + case LLKeyConflictHandler::MODE_EDIT_AVATAR: + case LLKeyConflictHandler::MODE_SITTING: + filename = "control_table_contents.xml"; + break; + default: + // 'saved settings' mode doesn't have UI or actual settings yet + LL_INFOS() << "Unimplemented mode" << LL_ENDL; + return; + } + + std::string full_filename = gDirUtilp->findSkinnedFilenameBaseLang(LLDir::XUI, filename); + LLSimpleXUIParser parser; + LLScrollListCtrl::Contents contents; + if (!parser.readXUI(full_filename, contents) + || !contents.validateBlock()) + { + LL_INFOS() << "Failed to load" << LL_ENDL; + return; + } + + for (LLInitParam::ParamIterator::const_iterator row_it = contents.columns.begin(); + row_it != contents.columns.end(); + ++row_it) + { + pControlsTable->addColumn(*row_it); + } + LLScrollListCell::Params cell_params; // init basic cell params cell_params.font = LLFontGL::getFontSansSerif(); cell_params.font_halign = LLFontGL::LEFT; cell_params.column = ""; - cell_params.value = label; + cell_params.value = ""; - controls_to_icon_t::const_iterator iter = commands_and_headers.begin(); - controls_to_icon_t::const_iterator end = commands_and_headers.end(); - for (; iter != end; ++iter) + + for (LLInitParam::ParamIterator::const_iterator row_it = contents.rows.begin(); + row_it != contents.rows.end(); + ++row_it) { - if (iter->second.empty()) + std::string control = row_it->value.getValue().asString(); + if (!control.empty() && control != "menu_separator") { - // general control - LLScrollListItem::Params item_params; - item_params.value = LLSD(iter->first); - - cell_params.column = "lst_action"; - bool enabled = mConflictHandler[mEditingMode].canAssignControl(iter->first); - if (hasString(iter->first)) - { - label = getString(iter->first); - } - else - { - label = iter->first; - } - cell_params.value = label; - item_params.columns.add(cell_params); + // At the moment 4 collumns are hardcoded + LLScrollListItem::Params item_params(*row_it); + bool enabled = mConflictHandler[mEditingMode].canAssignControl(control); + item_params.enabled.setValue(enabled); cell_params.column = "lst_ctrl1"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(iter->first, 0); - cell_params.enabled = enabled; + cell_params.value = mConflictHandler[mEditingMode].getControlString(control, 0); item_params.columns.add(cell_params); cell_params.column = "lst_ctrl2"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(iter->first, 1); - cell_params.enabled = enabled; + cell_params.value = mConflictHandler[mEditingMode].getControlString(control, 1); item_params.columns.add(cell_params); cell_params.column = "lst_ctrl3"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(iter->first, 2); - cell_params.enabled = enabled; + cell_params.value = mConflictHandler[mEditingMode].getControlString(control, 2); item_params.columns.add(cell_params); - pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM); } else { - // header - addSeparator(); - addGroupRow(iter->first, iter->second); + pControlsTable->addRow(*row_it, EAddPosition::ADD_BOTTOM); } } } @@ -3211,7 +3070,6 @@ void LLPanelPreferenceControls::addSeparator() void LLPanelPreferenceControls::updateTable() { - pControlsTable->deselectAllItems(); mEditingControl.clear(); std::vector list = pControlsTable->getAllData(); for (S32 i = 0; i < list.size(); ++i) @@ -3227,6 +3085,7 @@ void LLPanelPreferenceControls::updateTable() cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 2)); } } + pControlsTable->deselectAllItems(); } void LLPanelPreferenceControls::apply() -- cgit v1.2.3 From 13a25be08f0c81a759076907d7950baf4f2c3ef2 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 3 Oct 2019 19:46:12 +0300 Subject: SL-6109 Better menu accelerator support and slight reorganization --- indra/newview/llfloaterpreference.cpp | 306 +--------------------------------- 1 file changed, 3 insertions(+), 303 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 3668f71feb..e71c7d58e2 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -43,7 +43,6 @@ #include "llcombobox.h" #include "llcommandhandler.h" #include "lldirpicker.h" -#include "lldrawfrustum.h" #include "lleventtimer.h" #include "llfeaturemanager.h" #include "llfocusmgr.h" @@ -161,306 +160,6 @@ struct LabelTable : public LLInitParam::Block {} }; -// Filters for LLSetKeyBindDialog -static const U32 ALLOW_MOUSE = 1; -static const U32 ALLOW_MASK_MOUSE = 2; -static const U32 ALLOW_KEYS = 4; //keyboard -static const U32 ALLOW_MASK_KEYS = 8; -static const U32 ALLOW_MASKS = 16; -static const U32 CAN_IGNORE_MASKS = 32; // For example W (aka Forward) should work regardless of SHIFT being pressed -static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASK_KEYS | CAN_IGNORE_MASKS; - -class LLSetKeyBindDialog : public LLModalDialog, public LLDrawFrustum -{ -public: - LLSetKeyBindDialog(const LLSD& key); - ~LLSetKeyBindDialog(); - - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onClose(bool app_quiting); - /*virtual*/ void draw(); - - void setParent(LLPanelPreferenceControls* parent, U32 key_mask = DEFAULT_KEY_FILTER); - - BOOL handleKeyHere(KEY key, MASK mask); - BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down); - static void onCancel(void* user_data); - static void onBlank(void* user_data); - static void onDefault(void* user_data); - static void onClickTimeout(void* user_data, MASK mask); - - class Updater; - -private: - void setKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore); - LLPanelPreferenceControls* pParent; - LLCheckBoxCtrl* pCheckBox; - - U32 mKeyFilterMask; - Updater *pUpdater; -}; - -class LLSetKeyBindDialog::Updater : public LLEventTimer -{ -public: - - typedef boost::function callback_t; - - Updater(callback_t cb, F32 period, MASK mask) - :LLEventTimer(period), - mMask(mask), - mCallback(cb) - { - mEventTimer.start(); - } - - virtual ~Updater(){} - -protected: - BOOL tick() - { - mCallback(mMask); - // Deletes itseft after execution - return TRUE; - } - -private: - MASK mMask; - callback_t mCallback; -}; - -LLSetKeyBindDialog::LLSetKeyBindDialog(const LLSD& key) - : LLModalDialog(key), - pParent(NULL), - mKeyFilterMask(DEFAULT_KEY_FILTER), - pUpdater(NULL) -{ -} - -LLSetKeyBindDialog::~LLSetKeyBindDialog() -{ -} - -//virtual -BOOL LLSetKeyBindDialog::postBuild() -{ - childSetAction("SetEmpty", onBlank, this); - childSetAction("Default", onDefault, this); - childSetAction("Cancel", onCancel, this); - getChild("Cancel")->setFocus(TRUE); - - pCheckBox = getChild("ignore_masks"); - - gFocusMgr.setKeystrokesOnly(TRUE); - - return TRUE; -} - -//virtual -void LLSetKeyBindDialog::onClose(bool app_quiting) -{ - if (pParent) - { - pParent->onCancelKeyBind(); - pParent = NULL; - } - if (pUpdater) - { - // Doubleclick timer has't fired, delete it - delete pUpdater; - pUpdater = NULL; - } - LLModalDialog::onClose(app_quiting); -} - -//virtual -void LLSetKeyBindDialog::draw() -{ - LLRect local_rect; - drawFrustum(local_rect, this, (LLView*)getDragHandle(), hasFocus()); - LLModalDialog::draw(); -} - -void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_mask) -{ - pParent = parent; - setFrustumOrigin(parent); - mKeyFilterMask = key_mask; - - LLTextBase *text_ctrl = getChild("descritption"); - - std::string input; - if ((key_mask & ALLOW_MOUSE) != 0) - { - input = getString("mouse"); - } - if ((key_mask & ALLOW_KEYS) != 0) - { - if (!input.empty()) - { - input += ", "; - } - input += getString("keyboard"); - } - text_ctrl->setTextArg("[INPUT]", input); - - bool can_ignore_masks = (key_mask & CAN_IGNORE_MASKS) != 0; - pCheckBox->setVisible(can_ignore_masks); - pCheckBox->setValue(false); -} - -BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) -{ - if ((key == 'Q' && mask == MASK_CONTROL) - || key == KEY_ESCAPE) - { - closeFloater(); - return TRUE; - } - - if (key == KEY_DELETE) - { - setKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); - closeFloater(); - return FALSE; - } - - // forbidden keys - if (key == KEY_NONE - || key == KEY_RETURN - || key == KEY_BACKSPACE) - { - return FALSE; - } - - if ((mKeyFilterMask & ALLOW_MASKS) == 0 - && (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT)) - { - // mask by themself are not allowed - return FALSE; - } - else if ((mKeyFilterMask & ALLOW_KEYS) == 0) - { - // basic keys not allowed - return FALSE; - } - else if ((mKeyFilterMask & ALLOW_MASK_KEYS) == 0 && mask != 0) - { - // masked keys not allowed - return FALSE; - } - - setKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); - closeFloater(); - return TRUE; -} - -BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down) -{ - BOOL result = FALSE; - if (!pParent) - { - // we already processed 'down' event, this is 'up', consume - closeFloater(); - result = TRUE; - } - if (!result && clicktype == CLICK_LEFT) - { - // try handling buttons first - if (down) - { - result = LLView::handleMouseDown(x, y, mask); - } - else - { - result = LLView::handleMouseUp(x, y, mask); - } - if (result) - { - setFocus(TRUE); - gFocusMgr.setKeystrokesOnly(TRUE); - } - // ignore selection related combinations - else if (down && (mask & (MASK_SHIFT | MASK_CONTROL)) == 0) - { - // this can be a double click, wait a bit; - if (!pUpdater) - { - // Note: default doubleclick time is 500ms, but can stretch up to 5s - pUpdater = new Updater(boost::bind(&onClickTimeout, this, _1), 0.7f, mask); - result = TRUE; - } - } - } - - if (!result - && (clicktype != CLICK_LEFT) // subcases were handled above - && ((mKeyFilterMask & ALLOW_MOUSE) != 0) - && (clicktype != CLICK_RIGHT || mask != 0) // reassigning menu button is not supported - && ((mKeyFilterMask & ALLOW_MASK_MOUSE) != 0 || mask == 0)) // reserved for selection - { - setKeyBind(clicktype, KEY_NONE, mask, pCheckBox->getValue().asBoolean()); - result = TRUE; - if (!down) - { - // wait for 'up' event before closing - // alternative: set pUpdater - closeFloater(); - } - } - - return result; -} - -//static -void LLSetKeyBindDialog::onCancel(void* user_data) -{ - LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; - self->closeFloater(); -} - -//static -void LLSetKeyBindDialog::onBlank(void* user_data) -{ - LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; - // tmp needs 'no key' button - self->setKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); - self->closeFloater(); -} - -//static -void LLSetKeyBindDialog::onDefault(void* user_data) -{ - LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; - if (self->pParent) - { - self->pParent->onDefaultKeyBind(); - self->pParent = NULL; - } - self->closeFloater(); -} - -//static -void LLSetKeyBindDialog::onClickTimeout(void* user_data, MASK mask) -{ - LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; - - // timer will delete itself after timeout - self->pUpdater = NULL; - - self->setKeyBind(CLICK_LEFT, KEY_NONE, mask, self->pCheckBox->getValue().asBoolean()); - self->closeFloater(); -} - -void LLSetKeyBindDialog::setKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore) -{ - if (pParent) - { - pParent->onSetKeyBind(click, key, mask, ignore); - pParent = NULL; - } -} - // global functions @@ -3197,11 +2896,11 @@ void LLPanelPreferenceControls::onModeCommit() } // todo: copy onSetKeyBind to interface and inherit from interface -void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore_mask) +bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore_mask) { if (!mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) { - return; + return true; } if ( mEditingColumn > 0) @@ -3210,6 +2909,7 @@ void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MAS } updateTable(); + return true; } void LLPanelPreferenceControls::onRestoreDefaults() -- cgit v1.2.3 From e211372923bed31e632bc9825913d3d57cdc2d52 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 3 Oct 2019 22:45:29 +0300 Subject: SL-6109 Remade 'ignore' list processing, renamed and reformed keybindings --- indra/newview/llfloaterpreference.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index e71c7d58e2..9e1330dca7 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2875,7 +2875,7 @@ void LLPanelPreferenceControls::onListCommit() { mEditingControl = control; mEditingColumn = cell_ind; - dialog->setParent(this, DEFAULT_KEY_FILTER); + dialog->setParent(this, pControlsTable, DEFAULT_KEY_FILTER); LLFloater* root_floater = gFloaterView->getParentFloater(this); if (root_floater) @@ -2895,6 +2895,14 @@ void LLPanelPreferenceControls::onModeCommit() regenerateControls(); } +void LLPanelPreferenceControls::onRestoreDefaults() +{ + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) + { + mConflictHandler[mEditingMode].resetToDefaults(); + } +} + // todo: copy onSetKeyBind to interface and inherit from interface bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore_mask) { @@ -2905,21 +2913,13 @@ bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MAS if ( mEditingColumn > 0) { - mConflictHandler[mEditingMode].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, ignore_mask); + mConflictHandler[mEditingMode].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, true); } updateTable(); return true; } -void LLPanelPreferenceControls::onRestoreDefaults() -{ - for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) - { - mConflictHandler[mEditingMode].resetToDefaults(); - } -} - void LLPanelPreferenceControls::onDefaultKeyBind() { if (!mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) -- cgit v1.2.3 From 6597c7696783ce56f89b34a4b6440363635be6a6 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 28 Oct 2019 17:52:31 +0200 Subject: SL-6109 - Fixed line endings in xml file - Removed obsolete UI element and it's code - Fixed issue with return value caused by rebase --- indra/newview/llfloaterpreference.cpp | 35 ----------------------------------- 1 file changed, 35 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 9e1330dca7..15e6c91ad0 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -285,7 +285,6 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) mCommitCallbackRegistrar.add("Pref.ResetCache", boost::bind(&LLFloaterPreference::onClickResetCache, this)); mCommitCallbackRegistrar.add("Pref.ClickSkin", boost::bind(&LLFloaterPreference::onClickSkin, this,_1, _2)); mCommitCallbackRegistrar.add("Pref.SelectSkin", boost::bind(&LLFloaterPreference::onSelectSkin, this)); - mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse", boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this)); mCommitCallbackRegistrar.add("Pref.SetSounds", boost::bind(&LLFloaterPreference::onClickSetSounds, this)); mCommitCallbackRegistrar.add("Pref.ClickEnablePopup", boost::bind(&LLFloaterPreference::onClickEnablePopup, this)); mCommitCallbackRegistrar.add("Pref.ClickDisablePopup", boost::bind(&LLFloaterPreference::onClickDisablePopup, this)); @@ -1528,21 +1527,6 @@ void LLFloaterPreference::onChangeQuality(const LLSD& data) refresh(); } -void LLFloaterPreference::onClickSetMiddleMouse() -{ - LLUICtrl* p2t_line_editor = getChild("modifier_combo"); - - // update the control right away since we no longer wait for apply - p2t_line_editor->setControlValue(MIDDLE_MOUSE_CV); - - //push2talk button "middle mouse" control value is in English, need to localize it for presentation - LLPanel* advanced_preferences = dynamic_cast(p2t_line_editor->getParent()); - if (advanced_preferences) - { - p2t_line_editor->setValue(advanced_preferences->getString("middle_mouse")); - } -} - void LLFloaterPreference::onClickSetSounds() { // Disable Enable gesture sounds checkbox if the master sound is disabled @@ -2229,25 +2213,6 @@ BOOL LLPanelPreference::postBuild() getChild("mute_chb_label")->setClickedCallback(boost::bind(&toggleMuteWhenMinimized)); } - //////////////////////PanelAdvanced /////////////////// - if (hasChild("modifier_combo", TRUE)) - { - //localizing if push2talk button is set to middle mouse - std::string modifier_value = getChild("modifier_combo")->getValue().asString(); - if (MIDDLE_MOUSE_CV == modifier_value) - { - getChild("modifier_combo")->setValue(getString("middle_mouse")); - } - else if (MOUSE_BUTTON_4_CV == modifier_value) - { - getChild("modifier_combo")->setValue(getString("button4_mouse")); - } - else if (MOUSE_BUTTON_5_CV == modifier_value) - { - getChild("modifier_combo")->setValue(getString("button5_mouse")); - } - } - //////////////////////PanelSetup /////////////////// if (hasChild("max_bandwidth"), TRUE) { -- cgit v1.2.3 From 7a14cf420397b225d53f9bb3c7544a766627cf5c Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 30 Oct 2019 20:48:54 +0200 Subject: SL-6109 Now changes are applied on the go and reverted on cancel --- indra/newview/llfloaterpreference.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 15e6c91ad0..7cf009c3ef 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2865,6 +2865,8 @@ void LLPanelPreferenceControls::onRestoreDefaults() for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) { mConflictHandler[mEditingMode].resetToDefaults(); + // Apply changes to viewer as 'temporary' + mConflictHandler[mEditingMode].saveToSettings(true); } } @@ -2879,6 +2881,8 @@ bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MAS if ( mEditingColumn > 0) { mConflictHandler[mEditingMode].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, true); + // Apply changes to viewer as 'temporary' + mConflictHandler[mEditingMode].saveToSettings(true); } updateTable(); @@ -2895,6 +2899,8 @@ void LLPanelPreferenceControls::onDefaultKeyBind() if (mEditingColumn > 0) { mConflictHandler[mEditingMode].resetToDefault(mEditingControl, mEditingColumn - 1); + // Apply changes to viewer as 'temporary' + mConflictHandler[mEditingMode].saveToSettings(true); } updateTable(); } -- cgit v1.2.3 From b5b266c4d2bdf71d89f5d2545e7d6e7966082c90 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 4 Nov 2019 15:48:45 +0200 Subject: SL-6109 - Fixed defaults not restoring reliably - Fixed temporary changes not lifting reliably - Fixed switching modes was dropping changes to mode we switch to --- indra/newview/llfloaterpreference.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 7cf009c3ef..0abd014a2c 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2618,6 +2618,7 @@ LLPanelPreferenceControls::LLPanelPreferenceControls() mEditingColumn(-1), mEditingMode(0) { + // MODE_COUNT - 1 because there are currently no settings assigned to 'saved settings'. for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) { mConflictHandler[i].setLoadMode((LLKeyConflictHandler::ESourceMode)i); @@ -2857,17 +2858,25 @@ void LLPanelPreferenceControls::onListCommit() void LLPanelPreferenceControls::onModeCommit() { - regenerateControls(); + mEditingMode = pKeyModeBox->getValue().asInteger(); + if (mConflictHandler[mEditingMode].empty()) + { + // opening for first time + mConflictHandler[mEditingMode].loadFromSettings((LLKeyConflictHandler::ESourceMode)mEditingMode); + } + populateControlTable(); } void LLPanelPreferenceControls::onRestoreDefaults() { for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) { - mConflictHandler[mEditingMode].resetToDefaults(); + mConflictHandler[i].resetToDefaults(); // Apply changes to viewer as 'temporary' - mConflictHandler[mEditingMode].saveToSettings(true); + mConflictHandler[i].saveToSettings(true); } + + updateTable(); } // todo: copy onSetKeyBind to interface and inherit from interface -- cgit v1.2.3 From 73a1877ff0abcba46f66ef55440274119427723b Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 7 Nov 2019 20:09:25 +0200 Subject: SL-6109 - Edit mode appears to be obsolete and is not used, cleaned up - Improved ability to set defaults - Improved some labels - Made buttons bigger to accomodate languages with longer descriptions - Added ability to assign key for all modes simultaneously --- indra/newview/llfloaterpreference.cpp | 85 ++++++++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 16 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 0abd014a2c..50b7f16ec7 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2637,7 +2637,7 @@ BOOL LLPanelPreferenceControls::postBuild() pControlsTable->setCommitCallback(boost::bind(&LLPanelPreferenceControls::onListCommit, this)); pKeyModeBox->setCommitCallback(boost::bind(&LLPanelPreferenceControls::onModeCommit, this)); - getChild("restore_defaults")->setCommitCallback(boost::bind(&LLPanelPreferenceControls::onRestoreDefaults, this)); + getChild("restore_defaults")->setCommitCallback(boost::bind(&LLPanelPreferenceControls::onRestoreDefaultsBtn, this)); return TRUE; } @@ -2659,7 +2659,6 @@ void LLPanelPreferenceControls::populateControlTable() { case LLKeyConflictHandler::MODE_THIRD_PERSON: case LLKeyConflictHandler::MODE_FIRST_PERSON: - case LLKeyConflictHandler::MODE_EDIT: case LLKeyConflictHandler::MODE_EDIT_AVATAR: case LLKeyConflictHandler::MODE_SITTING: filename = "control_table_contents.xml"; @@ -2867,20 +2866,42 @@ void LLPanelPreferenceControls::onModeCommit() populateControlTable(); } -void LLPanelPreferenceControls::onRestoreDefaults() +void LLPanelPreferenceControls::onRestoreDefaultsBtn() { - for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) + LLNotificationsUtil::add("PreferenceControlsDefaults", LLSD(), LLSD(), boost::bind(&LLPanelPreferenceControls::onRestoreDefaultsResponse, this, _1, _2)); +} + +void LLPanelPreferenceControls::onRestoreDefaultsResponse(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + switch(option) { - mConflictHandler[i].resetToDefaults(); + case 0: // All + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) + { + mConflictHandler[i].resetToDefaults(); + // Apply changes to viewer as 'temporary' + mConflictHandler[i].saveToSettings(true); + } + + updateTable(); + break; + case 1: // Current + mConflictHandler[mEditingMode].resetToDefaults(); // Apply changes to viewer as 'temporary' - mConflictHandler[i].saveToSettings(true); - } + mConflictHandler[mEditingMode].saveToSettings(true); - updateTable(); + updateTable(); + break; + case 2: // Cancel + default: + //exit; + break; + } } // todo: copy onSetKeyBind to interface and inherit from interface -bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore_mask) +bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool all_modes) { if (!mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) { @@ -2889,16 +2910,32 @@ bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MAS if ( mEditingColumn > 0) { - mConflictHandler[mEditingMode].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, true); - // Apply changes to viewer as 'temporary' - mConflictHandler[mEditingMode].saveToSettings(true); + if (all_modes) + { + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) + { + if (mConflictHandler[i].empty()) + { + mConflictHandler[i].loadFromSettings((LLKeyConflictHandler::ESourceMode)i); + } + mConflictHandler[i].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, true); + // Apply changes to viewer as 'temporary' + mConflictHandler[i].saveToSettings(true); + } + } + else + { + mConflictHandler[mEditingMode].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, true); + // Apply changes to viewer as 'temporary' + mConflictHandler[mEditingMode].saveToSettings(true); + } } updateTable(); return true; } -void LLPanelPreferenceControls::onDefaultKeyBind() +void LLPanelPreferenceControls::onDefaultKeyBind(bool all_modes) { if (!mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) { @@ -2907,9 +2944,25 @@ void LLPanelPreferenceControls::onDefaultKeyBind() if (mEditingColumn > 0) { - mConflictHandler[mEditingMode].resetToDefault(mEditingControl, mEditingColumn - 1); - // Apply changes to viewer as 'temporary' - mConflictHandler[mEditingMode].saveToSettings(true); + if (all_modes) + { + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) + { + if (mConflictHandler[i].empty()) + { + mConflictHandler[i].loadFromSettings((LLKeyConflictHandler::ESourceMode)i); + } + mConflictHandler[i].resetToDefault(mEditingControl, mEditingColumn - 1); + // Apply changes to viewer as 'temporary' + mConflictHandler[i].saveToSettings(true); + } + } + else + { + mConflictHandler[mEditingMode].resetToDefault(mEditingControl, mEditingColumn - 1); + // Apply changes to viewer as 'temporary' + mConflictHandler[mEditingMode].saveToSettings(true); + } } updateTable(); } -- cgit v1.2.3 From e7d383be8a9734a5008690b8a7e1b179e2f2a718 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Sun, 10 Nov 2019 14:40:07 +0200 Subject: SL-6109 localization support for control table --- indra/newview/llfloaterpreference.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 50b7f16ec7..0896493f07 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2669,21 +2669,26 @@ void LLPanelPreferenceControls::populateControlTable() return; } - std::string full_filename = gDirUtilp->findSkinnedFilenameBaseLang(LLDir::XUI, filename); - LLSimpleXUIParser parser; + LLXMLNodePtr xmlNode; LLScrollListCtrl::Contents contents; - if (!parser.readXUI(full_filename, contents) - || !contents.validateBlock()) + if (!LLUICtrlFactory::getLayeredXMLNode(filename, xmlNode)) + { + LL_WARNS() << "Failed to load " << filename << LL_ENDL; + return; + } + LLXUIParser parser; + parser.readXUI(xmlNode, contents, filename); + + if (!contents.validateBlock()) { - LL_INFOS() << "Failed to load" << LL_ENDL; return; } - for (LLInitParam::ParamIterator::const_iterator row_it = contents.columns.begin(); - row_it != contents.columns.end(); - ++row_it) + for (LLInitParam::ParamIterator::const_iterator col_it = contents.columns.begin(); + col_it != contents.columns.end(); + ++col_it) { - pControlsTable->addColumn(*row_it); + pControlsTable->addColumn(*col_it); } LLScrollListCell::Params cell_params; -- cgit v1.2.3 From 629cd92c47e90a1fb8711c46bd406476d01e9b9b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 12 Jun 2020 18:51:13 +0300 Subject: SL-13421 Removed camera control keybindings from mouselook --- indra/newview/llfloaterpreference.cpp | 116 ++++++++++++++++++++++++++-------- 1 file changed, 89 insertions(+), 27 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 0896493f07..42defac250 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2649,39 +2649,21 @@ void LLPanelPreferenceControls::regenerateControls() populateControlTable(); } -void LLPanelPreferenceControls::populateControlTable() +bool LLPanelPreferenceControls::addControlTableColumns(const std::string &filename) { - pControlsTable->clearRows(); - pControlsTable->clearColumns(); - - std::string filename; - switch ((LLKeyConflictHandler::ESourceMode)mEditingMode) - { - case LLKeyConflictHandler::MODE_THIRD_PERSON: - case LLKeyConflictHandler::MODE_FIRST_PERSON: - case LLKeyConflictHandler::MODE_EDIT_AVATAR: - case LLKeyConflictHandler::MODE_SITTING: - filename = "control_table_contents.xml"; - break; - default: - // 'saved settings' mode doesn't have UI or actual settings yet - LL_INFOS() << "Unimplemented mode" << LL_ENDL; - return; - } - LLXMLNodePtr xmlNode; LLScrollListCtrl::Contents contents; if (!LLUICtrlFactory::getLayeredXMLNode(filename, xmlNode)) { - LL_WARNS() << "Failed to load " << filename << LL_ENDL; - return; + LL_WARNS() << "Failed to load " << filename << LL_ENDL; + return false; } LLXUIParser parser; parser.readXUI(xmlNode, contents, filename); if (!contents.validateBlock()) { - return; + return false; } for (LLInitParam::ParamIterator::const_iterator col_it = contents.columns.begin(); @@ -2691,6 +2673,26 @@ void LLPanelPreferenceControls::populateControlTable() pControlsTable->addColumn(*col_it); } + return true; +} + +bool LLPanelPreferenceControls::addControlTableRows(const std::string &filename) +{ + LLXMLNodePtr xmlNode; + LLScrollListCtrl::Contents contents; + if (!LLUICtrlFactory::getLayeredXMLNode(filename, xmlNode)) + { + LL_WARNS() << "Failed to load " << filename << LL_ENDL; + return false; + } + LLXUIParser parser; + parser.readXUI(xmlNode, contents, filename); + + if (!contents.validateBlock()) + { + return false; + } + LLScrollListCell::Params cell_params; // init basic cell params cell_params.font = LLFontGL::getFontSansSerif(); @@ -2706,7 +2708,7 @@ void LLPanelPreferenceControls::populateControlTable() std::string control = row_it->value.getValue().asString(); if (!control.empty() && control != "menu_separator") { - // At the moment 4 collumns are hardcoded + // At the moment viewer is hardcoded to assume that there are 4 collumns LLScrollListItem::Params item_params(*row_it); bool enabled = mConflictHandler[mEditingMode].canAssignControl(control); item_params.enabled.setValue(enabled); @@ -2723,17 +2725,77 @@ void LLPanelPreferenceControls::populateControlTable() } else { + // Separator example: + // + // + // pControlsTable->addRow(*row_it, EAddPosition::ADD_BOTTOM); } } + return true; +} + +void LLPanelPreferenceControls::addControlTableSeparator() +{ + pControlsTable->addSeparator(EAddPosition::ADD_BOTTOM); } -// Just a workaround to not care about first separator before headers (we can start from random header) -void LLPanelPreferenceControls::addSeparator() +void LLPanelPreferenceControls::populateControlTable() { - if (pControlsTable->getItemCount() > 0) + pControlsTable->clearRows(); + pControlsTable->clearColumns(); + + // add columns + std::string filename; + switch ((LLKeyConflictHandler::ESourceMode)mEditingMode) { - pControlsTable->addSeparator(EAddPosition::ADD_BOTTOM); + case LLKeyConflictHandler::MODE_THIRD_PERSON: + case LLKeyConflictHandler::MODE_FIRST_PERSON: + case LLKeyConflictHandler::MODE_EDIT_AVATAR: + case LLKeyConflictHandler::MODE_SITTING: + filename = "control_table_contents_columns_basic.xml"; + break; + default: + // Either unknown mode or MODE_SAVED_SETTINGS + // It doesn't have UI or actual settings yet + LL_INFOS() << "Unimplemented mode" << LL_ENDL; + return; + } + addControlTableColumns(filename); + + switch ((LLKeyConflictHandler::ESourceMode)mEditingMode) + { + case LLKeyConflictHandler::MODE_FIRST_PERSON: + addControlTableRows("control_table_contents_movement.xml"); + addControlTableSeparator(); + addControlTableRows("control_table_contents_media.xml"); + break; + case LLKeyConflictHandler::MODE_THIRD_PERSON: + case LLKeyConflictHandler::MODE_EDIT_AVATAR: + case LLKeyConflictHandler::MODE_SITTING: + addControlTableRows("control_table_contents_movement.xml"); + addControlTableSeparator(); + + // contains couple 'sitting' options, might be good idea to recheck + // those and move to own group with sitting/spinning icon + addControlTableRows("control_table_contents_camera.xml"); + addControlTableSeparator(); + + // Do we need this outside of MODE_EDIT_AVATAR? + addControlTableRows("control_table_contents_editing.xml"); + addControlTableSeparator(); + + addControlTableRows("control_table_contents_media.xml"); + break; + default: + // 'saved settings' mode doesn't have UI or actual settings yet + LL_INFOS() << "Unimplemented mode" << LL_ENDL; + return; } } -- cgit v1.2.3 From c604b274fb4ab218a89fc03a4ea5cc1b739ad65f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 12 Jun 2020 20:09:43 +0300 Subject: SL-13421 Separated some sitting-exclusive controls --- indra/newview/llfloaterpreference.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 42defac250..604f054aa5 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2768,32 +2768,34 @@ void LLPanelPreferenceControls::populateControlTable() } addControlTableColumns(filename); - switch ((LLKeyConflictHandler::ESourceMode)mEditingMode) + + if (mEditingMode == LLKeyConflictHandler::MODE_FIRST_PERSON) { - case LLKeyConflictHandler::MODE_FIRST_PERSON: addControlTableRows("control_table_contents_movement.xml"); addControlTableSeparator(); addControlTableRows("control_table_contents_media.xml"); - break; - case LLKeyConflictHandler::MODE_THIRD_PERSON: - case LLKeyConflictHandler::MODE_EDIT_AVATAR: - case LLKeyConflictHandler::MODE_SITTING: + } + // MODE_THIRD_PERSON; MODE_EDIT_AVATAR; MODE_SITTING + else if (mEditingMode < LLKeyConflictHandler::MODE_SAVED_SETTINGS) + { + // In case of 'sitting' mode, movements still apply due to vehicles addControlTableRows("control_table_contents_movement.xml"); addControlTableSeparator(); - // contains couple 'sitting' options, might be good idea to recheck - // those and move to own group with sitting/spinning icon - addControlTableRows("control_table_contents_camera.xml"); + addControlTableRows("control_table_contents_camera.xml"); + if (mEditingMode == LLKeyConflictHandler::MODE_SITTING) + { + addControlTableRows("control_table_contents_camera_sitting.xml"); + } addControlTableSeparator(); - // Do we need this outside of MODE_EDIT_AVATAR? addControlTableRows("control_table_contents_editing.xml"); addControlTableSeparator(); addControlTableRows("control_table_contents_media.xml"); - break; - default: - // 'saved settings' mode doesn't have UI or actual settings yet + } + else + { LL_INFOS() << "Unimplemented mode" << LL_ENDL; return; } -- cgit v1.2.3 From e578491be761fefa34e4041458e2cf5badc81873 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 15 Jun 2020 20:35:58 +0300 Subject: SL-13418 Restored previously removed 'click on land' controls from 'move & view' According to UX UI engineer. Also adapted it to new system, but it needs a better solution. --- indra/newview/llfloaterpreference.cpp | 212 +++++++++++++++++++++++++++++++++- 1 file changed, 210 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 604f054aa5..ac2b0172c7 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -311,6 +311,8 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) sSkin = gSavedSettings.getString("SkinCurrent"); + mCommitCallbackRegistrar.add("Pref.ClickActionChange", boost::bind(&LLFloaterPreference::onClickActionChange, this)); + gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged, _2)); @@ -609,6 +611,8 @@ void LLFloaterPreference::cancel() // reverts any changes to current skin gSavedSettings.setString("SkinCurrent", sSkin); + updateClickActionViews(); + LLFloaterPreferenceProxy * advanced_proxy_settings = LLFloaterReg::findTypedInstance("prefs_proxy"); if (advanced_proxy_settings) { @@ -690,6 +694,9 @@ void LLFloaterPreference::onOpen(const LLSD& key) onChangeTextureFolder(); onChangeSoundFolder(); onChangeAnimationFolder(); + + // Load (double-)click to walk/teleport settings. + updateClickActionViews(); // Enabled/disabled popups, might have been changed by user actions // while preferences floater was closed. @@ -1486,6 +1493,7 @@ void LLFloaterPreference::refresh() { advanced->refresh(); } + updateClickActionViews(); } void LLFloaterPreferenceGraphicsAdvanced::refresh() @@ -1995,6 +2003,11 @@ void LLFloaterPreference::onClickAdvanced() } } +void LLFloaterPreference::onClickActionChange() +{ + updateClickActionControls(); +} + void LLFloaterPreference::onClickPermsDefault() { LLFloaterReg::showInstance("perms_default"); @@ -2032,6 +2045,86 @@ void LLFloaterPreference::onLogChatHistorySaved() } } +void LLFloaterPreference::updateClickActionControls() +{ + const int single_clk_action = getChild("single_click_action_combo")->getValue().asInteger(); + const int double_clk_action = getChild("double_click_action_combo")->getValue().asInteger(); + + // Todo: This is a very ugly way to get access to keybindings. + // Reconsider possible options. + // Potential option: make constructor of LLKeyConflictHandler private + // but add a getter that will return shared pointer for specific + // mode, pointer should only exist so long as there are external users. + // In such case we won't need to do this 'dynamic_cast' nightmare. + // updateTable() can also be avoided + LLTabContainer* tabcontainer = getChild("pref core"); + for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); + iter != tabcontainer->getChildList()->end(); ++iter) + { + LLView* view = *iter; + LLPanelPreferenceControls* panel = dynamic_cast(view); + if (panel) + { + panel->setKeyBind("walk_to", + EMouseClickType::CLICK_LEFT, + KEY_NONE, + MASK_NONE, + single_clk_action == 1); + + panel->setKeyBind("walk_to", + EMouseClickType::CLICK_DOUBLELEFT, + KEY_NONE, + MASK_NONE, + double_clk_action == 1); + + panel->setKeyBind("teleport_to", + EMouseClickType::CLICK_DOUBLELEFT, + KEY_NONE, + MASK_NONE, + double_clk_action == 2); + + panel->updateTable(); + } + } +} + +void LLFloaterPreference::updateClickActionViews() +{ + bool click_to_walk = false; + bool dbl_click_to_walk = false; + bool dbl_click_to_teleport = false; + + // Todo: This is a very ugly way to get access to keybindings. + // Reconsider possible options. + LLTabContainer* tabcontainer = getChild("pref core"); + for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); + iter != tabcontainer->getChildList()->end(); ++iter) + { + LLView* view = *iter; + LLPanelPreferenceControls* panel = dynamic_cast(view); + if (panel) + { + click_to_walk = panel->canKeyBindHandle("walk_to", + EMouseClickType::CLICK_LEFT, + KEY_NONE, + MASK_NONE); + + dbl_click_to_walk = panel->canKeyBindHandle("walk_to", + EMouseClickType::CLICK_DOUBLELEFT, + KEY_NONE, + MASK_NONE); + + dbl_click_to_teleport = panel->canKeyBindHandle("teleport_to", + EMouseClickType::CLICK_DOUBLELEFT, + KEY_NONE, + MASK_NONE); + } + } + + getChild("single_click_action_combo")->setValue((int)click_to_walk); + getChild("double_click_action_combo")->setValue(dbl_click_to_teleport ? 2 : (int)dbl_click_to_walk); +} + void LLFloaterPreference::applyUIColor(LLUICtrl* ctrl, const LLSD& param) { LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue())); @@ -2856,7 +2949,7 @@ void LLPanelPreferenceControls::saveSettings() } S32 mode = pKeyModeBox->getValue().asInteger(); - if (mConflictHandler[mode].empty()) + if (mConflictHandler[mode].empty() || pControlsTable->isEmpty()) { regenerateControls(); } @@ -2951,6 +3044,13 @@ void LLPanelPreferenceControls::onRestoreDefaultsResponse(const LLSD& notificati mConflictHandler[i].resetToDefaults(); // Apply changes to viewer as 'temporary' mConflictHandler[i].saveToSettings(true); + + // notify comboboxes in move&view about potential change + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance("preferences"); + if (instance) + { + instance->updateClickActionViews(); + } } updateTable(); @@ -2960,6 +3060,16 @@ void LLPanelPreferenceControls::onRestoreDefaultsResponse(const LLSD& notificati // Apply changes to viewer as 'temporary' mConflictHandler[mEditingMode].saveToSettings(true); + if (mEditingMode == LLKeyConflictHandler::MODE_THIRD_PERSON) + { + // notify comboboxes in move&view about potential change + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance("preferences"); + if (instance) + { + instance->updateClickActionViews(); + } + } + updateTable(); break; case 2: // Cancel @@ -2969,7 +3079,80 @@ void LLPanelPreferenceControls::onRestoreDefaultsResponse(const LLSD& notificati } } -// todo: copy onSetKeyBind to interface and inherit from interface +// Bypass to let Move & view read values without need to create own key binding handler +// Assumes third person view +// Might be better idea to just move whole mConflictHandler into LLFloaterPreference +bool LLPanelPreferenceControls::canKeyBindHandle(const std::string &control, EMouseClickType click, KEY key, MASK mask) +{ + S32 mode = LLKeyConflictHandler::MODE_THIRD_PERSON; + if (mConflictHandler[mode].empty()) + { + // opening for first time + mConflictHandler[mode].loadFromSettings(LLKeyConflictHandler::MODE_THIRD_PERSON); + } + + return mConflictHandler[mode].canHandleControl(control, click, key, mask); +} + +// Bypass to let Move & view modify values without need to create own key binding handler +// Assumes third person view +// Might be better idea to just move whole mConflictHandler into LLFloaterPreference +void LLPanelPreferenceControls::setKeyBind(const std::string &control, EMouseClickType click, KEY key, MASK mask, bool set) +{ + S32 mode = LLKeyConflictHandler::MODE_THIRD_PERSON; + if (mConflictHandler[mode].empty()) + { + // opening for first time + mConflictHandler[mode].loadFromSettings(LLKeyConflictHandler::MODE_THIRD_PERSON); + } + + if (!mConflictHandler[mode].canAssignControl(mEditingControl)) + { + return; + } + + bool already_recorded = mConflictHandler[mode].canHandleControl(control, click, key, mask); + if (set) + { + if (already_recorded) + { + // nothing to do + return; + } + + // find free spot to add data, if no free spot, assign to first + S32 index = 0; + for (S32 i = 0; i < 3; i++) + { + if (mConflictHandler[mode].getControl(control, i).isEmpty()) + { + index = i; + break; + } + } + mConflictHandler[mode].registerControl(control, index, click, key, mask, true); + } + else if (!set) + { + if (!already_recorded) + { + // nothing to do + return; + } + + // find specific control and reset it + for (S32 i = 0; i < 3; i++) + { + LLKeyData data = mConflictHandler[mode].getControl(control, i); + if (data.mMouse == click && data.mKey == key && data.mMask == mask) + { + mConflictHandler[mode].clearControl(control, i); + } + } + } +} + +// from LLSetKeybindDialog's interface bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool all_modes) { if (!mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) @@ -3001,6 +3184,21 @@ bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MAS } updateTable(); + + if ((mEditingMode == LLKeyConflictHandler::MODE_THIRD_PERSON || all_modes) + && (mEditingControl == "walk_to" + || mEditingControl == "teleport_to" + || click == CLICK_LEFT + || click == CLICK_DOUBLELEFT)) + { + // notify comboboxes in move&view about potential change + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance("preferences"); + if (instance) + { + instance->updateClickActionViews(); + } + } + return true; } @@ -3034,6 +3232,16 @@ void LLPanelPreferenceControls::onDefaultKeyBind(bool all_modes) } } updateTable(); + + if (mEditingMode == LLKeyConflictHandler::MODE_THIRD_PERSON || all_modes) + { + // notify comboboxes in move&view about potential change + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance("preferences"); + if (instance) + { + instance->updateClickActionViews(); + } + } } void LLPanelPreferenceControls::onCancelKeyBind() -- cgit v1.2.3 From 74aba5768e62f2260ac44c5244145a0a689bf3d5 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 16 Jun 2020 09:27:41 +0300 Subject: SL-13418 Move and view panel now applies changes on the go --- indra/newview/llfloaterpreference.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index ac2b0172c7..697e3253df 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2083,7 +2083,7 @@ void LLFloaterPreference::updateClickActionControls() MASK_NONE, double_clk_action == 2); - panel->updateTable(); + panel->updateAndApply(); } } } @@ -3152,6 +3152,13 @@ void LLPanelPreferenceControls::setKeyBind(const std::string &control, EMouseCli } } +void LLPanelPreferenceControls::updateAndApply() +{ + S32 mode = LLKeyConflictHandler::MODE_THIRD_PERSON; + mConflictHandler[mode].saveToSettings(true); + updateTable(); +} + // from LLSetKeybindDialog's interface bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool all_modes) { -- cgit v1.2.3 From f6662ffb26208a40f7c823c67e53f36b0267b71c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 17 Jun 2020 09:51:05 +0300 Subject: SL-13469 Fixed use of wrong clear function --- indra/newview/llfloaterpreference.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 697e3253df..b8edf4ad84 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2934,7 +2934,8 @@ void LLPanelPreferenceControls::cancel() mConflictHandler[i].clear(); } } - pControlsTable->clear(); + pControlsTable->clearRows(); + pControlsTable->clearColumns(); } void LLPanelPreferenceControls::saveSettings() -- cgit v1.2.3 From 7717097f7cfa1deaa934b9846c22523f53c600d3 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 23 Jun 2020 20:29:00 +0300 Subject: SL-6109 Teleport and autopilot should not work in some cases Hides teleport_to and walk_to also optimizes couple things. --- indra/newview/llfloaterpreference.cpp | 79 +++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 27 deletions(-) (limited to 'indra/newview/llfloaterpreference.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index b8edf4ad84..f4a19d06b0 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2801,20 +2801,34 @@ bool LLPanelPreferenceControls::addControlTableRows(const std::string &filename) std::string control = row_it->value.getValue().asString(); if (!control.empty() && control != "menu_separator") { - // At the moment viewer is hardcoded to assume that there are 4 collumns - LLScrollListItem::Params item_params(*row_it); + bool show = true; bool enabled = mConflictHandler[mEditingMode].canAssignControl(control); - item_params.enabled.setValue(enabled); - cell_params.column = "lst_ctrl1"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(control, 0); - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl2"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(control, 1); - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl3"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(control, 2); - item_params.columns.add(cell_params); - pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM); + if (!enabled) + { + // If empty: this is a placeholder to make sure user won't assign + // value by accident, don't show it + // If not empty: predefined control combination user should see + // to know that combination is reserved + show = !mConflictHandler[mEditingMode].isControlEmpty(control); + // example: teleport_to and walk_to in first person view, and + // sitting related functions, see generatePlaceholders() + } + + if (show) + { + // At the moment viewer is hardcoded to assume that columns are named as lst_ctrl%d + LLScrollListItem::Params item_params(*row_it); + item_params.enabled.setValue(enabled); + + S32 num_columns = pControlsTable->getNumColumns(); + for (S32 col = 1; col < num_columns; col++) + { + cell_params.column = llformat("lst_ctrl%d", col); + cell_params.value = mConflictHandler[mEditingMode].getControlString(control, col - 1); + item_params.columns.add(cell_params); + } + pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM); + } } else { @@ -2825,7 +2839,8 @@ bool LLPanelPreferenceControls::addControlTableRows(const std::string &filename) // type = "icon" // color = "0 0 0 0.7" // halign = "center" - // value = "menu_separator" /> + // value = "menu_separator" + // column = "lst_action" / > // pControlsTable->addRow(*row_it, EAddPosition::ADD_BOTTOM); } @@ -2835,7 +2850,16 @@ bool LLPanelPreferenceControls::addControlTableRows(const std::string &filename) void LLPanelPreferenceControls::addControlTableSeparator() { - pControlsTable->addSeparator(EAddPosition::ADD_BOTTOM); + LLScrollListItem::Params separator_params; + separator_params.enabled(false); + LLScrollListCell::Params column_params; + column_params.type = "icon"; + column_params.value = "menu_separator"; + column_params.column = "lst_action"; + column_params.color = LLColor4(0.f, 0.f, 0.f, 0.7f); + column_params.font_halign = LLFontGL::HCENTER; + separator_params.columns.add(column_params); + pControlsTable->addRow(separator_params, EAddPosition::ADD_BOTTOM); } void LLPanelPreferenceControls::populateControlTable() @@ -2843,7 +2867,7 @@ void LLPanelPreferenceControls::populateControlTable() pControlsTable->clearRows(); pControlsTable->clearColumns(); - // add columns + // Add columns std::string filename; switch ((LLKeyConflictHandler::ESourceMode)mEditingMode) { @@ -2861,9 +2885,11 @@ void LLPanelPreferenceControls::populateControlTable() } addControlTableColumns(filename); - + // Add rows. + // Each file represents individual visual group (movement/camera/media...) if (mEditingMode == LLKeyConflictHandler::MODE_FIRST_PERSON) { + // Don't display whole camera and editing groups addControlTableRows("control_table_contents_movement.xml"); addControlTableSeparator(); addControlTableRows("control_table_contents_media.xml"); @@ -2872,14 +2898,11 @@ void LLPanelPreferenceControls::populateControlTable() else if (mEditingMode < LLKeyConflictHandler::MODE_SAVED_SETTINGS) { // In case of 'sitting' mode, movements still apply due to vehicles + // but walk_to is not supported and will be hidden by addControlTableRows addControlTableRows("control_table_contents_movement.xml"); addControlTableSeparator(); addControlTableRows("control_table_contents_camera.xml"); - if (mEditingMode == LLKeyConflictHandler::MODE_SITTING) - { - addControlTableRows("control_table_contents_camera_sitting.xml"); - } addControlTableSeparator(); addControlTableRows("control_table_contents_editing.xml"); @@ -2903,12 +2926,14 @@ void LLPanelPreferenceControls::updateTable() std::string control = list[i]->getValue(); if (!control.empty()) { - LLScrollListCell* cell = list[i]->getColumn(1); - cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 0)); - cell = list[i]->getColumn(2); - cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 1)); - cell = list[i]->getColumn(3); - cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 2)); + LLScrollListCell* cell = NULL; + + S32 num_columns = pControlsTable->getNumColumns(); + for (S32 col = 1; col < num_columns; col++) + { + cell = list[i]->getColumn(col); + cell->setValue(mConflictHandler[mEditingMode].getControlString(control, col - 1)); + } } } pControlsTable->deselectAllItems(); -- cgit v1.2.3