summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterpreference.cpp
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2019-10-01 22:23:49 +0300
committerandreykproductengine <andreykproductengine@lindenlab.com>2019-10-01 22:23:49 +0300
commitfc03a5679e34a35f3e4773198b52cac1bd6be0b7 (patch)
treee3a724e7ee105826074756b90caac3ada71f64b3 /indra/newview/llfloaterpreference.cpp
parent5213c4f1ec108f0a68e185bec85f2c77ded6bacf (diff)
SL-6109 Better hover and docking of keybinder
Diffstat (limited to 'indra/newview/llfloaterpreference.cpp')
-rw-r--r--indra/newview/llfloaterpreference.cpp131
1 files changed, 46 insertions, 85 deletions
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<LLTextBase>("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<LLSetKeyBindDialog>("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<LLScrollListItem*> 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<LLSetKeyBindDialog>("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)