summaryrefslogtreecommitdiff
path: root/indra/llui/llviewinject.h
blob: 7f18ec6fbe8fce6fbc9ecb2d92992f59bf3625fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
 * @file   llviewinject.h
 * @author Nat Goodspeed
 * @date   2011-08-16
 * @brief  Supplemental LLView functionality used for simulating UI events.
 * 
 * $LicenseInfo:firstyear=2011&license=viewerlgpl$
 * Copyright (c) 2011, Linden Research, Inc.
 * $/LicenseInfo$
 */

#if ! defined(LL_LLVIEWINJECT_H)
#define LL_LLVIEWINJECT_H

#include "llview.h"
#include <map>

namespace llview
{

    /**
     * TargetEvent is a callable with state, specifically intended for use as
     * an LLView::TemporaryDrilldownFunc. Instantiate it with the desired
     * target LLView*; pass it to a TemporaryDrilldownFunc instance;
     * TargetEvent::operator() will then attempt to direct subsequent mouse
     * events to the desired target LLView*. (This is an "attempt" because
     * LLView will still balk unless the target LLView and every parent are
     * visible and enabled.)
     */
    class TargetEvent
    {
    public:
        /**
         * Construct TargetEvent with the desired target LLView*. (See
         * LLUI::getInstance()->resolvePath() to obtain an LLView* given a string pathname.)
         * This sets up for operator().
         */
        TargetEvent(LLView* view);

        /**
         * This signature must match LLView::DrilldownFunc. When you install
         * this TargetEvent instance using LLView::TemporaryDrilldownFunc,
         * LLView will call this method to decide whether to propagate an
         * incoming mouse event to the passed child LLView*.
         */
        bool operator()(const LLView*, S32 x, S32 y) const;

    private:
        // For a given parent LLView, identify which child to select.
        typedef std::map<LLView*, LLView*> ChildMap;
        ChildMap mChildMap;
    };

} // llview namespace

#endif /* ! defined(LL_LLVIEWINJECT_H) */