PageRenderTime 31ms CodeModel.GetById 24ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llviewinject.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 49 lines | 18 code | 3 blank | 28 comment | 4 complexity | 4c7a721c6feba80ae00d76910a398b9a MD5 | raw file
 1/**
 2 * @file   llviewinject.cpp
 3 * @author Nat Goodspeed
 4 * @date   2011-08-16
 5 * @brief  Implementation for llviewinject.
 6 * 
 7 * $LicenseInfo:firstyear=2011&license=viewerlgpl$
 8 * Copyright (c) 2011, Linden Research, Inc.
 9 * $/LicenseInfo$
10 */
11
12// Precompiled header
13#include "linden_common.h"
14// associated header
15#include "llviewinject.h"
16// STL headers
17// std headers
18// external library headers
19// other Linden headers
20
21llview::TargetEvent::TargetEvent(LLView* view)
22{
23    // Walk up the view tree from target LLView to the root (NULL). If
24    // passed NULL, iterate 0 times.
25    for (; view; view = view->getParent())
26    {
27        // At each level, operator() is going to ask: for a particular parent
28        // LLView*, which of its children should I select? So for this view's
29        // parent, select this view.
30        mChildMap[view->getParent()] = view;
31    }
32}
33
34bool llview::TargetEvent::operator()(const LLView* view, S32 /*x*/, S32 /*y*/) const
35{
36    // We are being called to decide whether to direct an incoming mouse event
37    // to this child view. (Normal LLView processing is to check whether the
38    // incoming (x, y) is within the view.) Look up the parent to decide
39    // whether, for that parent, this is the previously-selected child.
40    ChildMap::const_iterator found(mChildMap.find(view->getParent()));
41    // If we're looking at a child whose parent isn't even in the map, never
42    // mind.
43    if (found == mChildMap.end())
44    {
45        return false;
46    }
47    // So, is this the predestined child for this parent?
48    return (view == found->second);
49}