From fc03a5679e34a35f3e4773198b52cac1bd6be0b7 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 ++++++++------------- indra/newview/llfloaterpreference.h | 3 - .../default/xui/en/panel_preferences_controls.xml | 10 +- 3 files changed, 51 insertions(+), 93 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 088a0820aa..16f2426d1b 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"); @@ -3104,9 +3115,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) { @@ -3135,41 +3144,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; @@ -3221,13 +3195,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; @@ -3294,6 +3262,7 @@ void LLPanelPreferenceControls::addSeparator() void LLPanelPreferenceControls::updateTable() { + pControlsTable->deselectAllItems(); mEditingControl.clear(); std::vector list = pControlsTable->getAllData(); for (S32 i = 0; i < list.size(); ++i) @@ -3309,12 +3278,6 @@ void LLPanelPreferenceControls::updateTable() cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 2)); } } - - if (mHighlightedCell) - { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; - } } void LLPanelPreferenceControls::apply() @@ -3326,11 +3289,6 @@ void LLPanelPreferenceControls::apply() mConflictHandler[i].saveToSettings(); } } - if (mHighlightedCell) - { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; - } } void LLPanelPreferenceControls::cancel() @@ -3343,11 +3301,6 @@ void LLPanelPreferenceControls::cancel() } } pControlsTable->clear(); - if (mHighlightedCell) - { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; - } } void LLPanelPreferenceControls::saveSettings() @@ -3366,11 +3319,6 @@ void LLPanelPreferenceControls::saveSettings() { regenerateControls(); } - else if (mHighlightedCell) - { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; - } } void LLPanelPreferenceControls::resetDirtyChilds() @@ -3380,7 +3328,6 @@ void LLPanelPreferenceControls::resetDirtyChilds() void LLPanelPreferenceControls::onListCommit() { - mShowKeyDialog = false; LLScrollListItem* item = pControlsTable->getFirstSelected(); if (item == NULL) { @@ -3391,11 +3338,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; } @@ -3403,13 +3359,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(); } } @@ -3426,8 +3396,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); @@ -3450,10 +3418,7 @@ void LLPanelPreferenceControls::onDefaultKeyBind() { return; } - - pControlsTable->deselectAllItems(); - pControlsTable->selectByValue(mEditingControl); - + if (mEditingColumn > 0) { mConflictHandler[mEditingMode].resetToDefault(mEditingControl, mEditingColumn - 1); @@ -3463,11 +3428,7 @@ void LLPanelPreferenceControls::onDefaultKeyBind() void LLPanelPreferenceControls::onCancelKeyBind() { - if (mHighlightedCell) - { - mHighlightedCell->setHighlighted(false); - mHighlightedCell = NULL; - } + pControlsTable->deselectAllItems(); } LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key) diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 2fe3b98abd..9100a91356 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -302,7 +302,6 @@ public: ~LLPanelPreferenceControls(); BOOL postBuild(); - BOOL handleHover(S32 x, S32 y, MASK mask); void apply(); void cancel(); @@ -325,12 +324,10 @@ private: LLScrollListCtrl* pControlsTable; LLComboBox *pKeyModeBox; - LLScrollListCell *mHighlightedCell; LLKeyConflictHandler mConflictHandler[LLKeyConflictHandler::MODE_COUNT]; std::string mEditingControl; S32 mEditingColumn; S32 mEditingMode; - bool mShowKeyDialog; }; class LLFloaterPreferenceGraphicsAdvanced : public LLFloater diff --git a/indra/newview/skins/default/xui/en/panel_preferences_controls.xml b/indra/newview/skins/default/xui/en/panel_preferences_controls.xml index 385d4796a0..b7b5280825 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_controls.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_controls.xml @@ -255,14 +255,14 @@ height="23" width="110" name="key_mode"> - +