summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelenvironment.h
blob: ff39714cea2bafcb2355bf6f297a33c534852152 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/** 
 * @file llpanelenvironment.h
 * @brief LLPanelExperiences class definition
 *
 * $LicenseInfo:firstyear=2013&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2013, Linden Research, Inc.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License only.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 * $/LicenseInfo$
 */

#ifndef LL_LLPANELENVIRONMENT_H
#define LL_LLPANELENVIRONMENT_H

#include "llaccordionctrltab.h"
#include "llradiogroup.h"
#include "llcheckboxctrl.h"
#include "llsliderctrl.h"
#include "llsettingsdaycycle.h"
#include "llenvironment.h"
#include "llparcel.h"
#include "llsettingspicker.h"
#include "llfloatereditextdaycycle.h"
#include "llestateinfomodel.h"

class LLViewerRegion;

class LLPanelEnvironmentInfo : public LLPanel
{
    friend class LLSettingsDropTarget;
public:
                                LLPanelEnvironmentInfo();
    virtual                     ~LLPanelEnvironmentInfo();

    virtual bool                postBuild() override;
    virtual void                onOpen(const LLSD& key) override;

    virtual bool                isDirty() const override            { return getIsDirty(); }
    virtual void                onVisibilityChange(bool new_visibility) override;

    virtual void                refresh() override;

    virtual bool                isRegion() const = 0;
    virtual LLParcel *          getParcel() = 0;
    virtual bool                canEdit() = 0;
    virtual S32                 getParcelId() = 0;

protected:
    LOG_CLASS(LLPanelEnvironmentInfo);

    static const std::string    BTN_SELECTINV;
    static const std::string    BTN_EDIT;
    static const std::string    BTN_USEDEFAULT;
    static const std::string    BTN_RST_ALTITUDES;
    static const std::string    SLD_DAYLENGTH;
    static const std::string    SLD_DAYOFFSET;
    static const std::string    SLD_ALTITUDES;
    static const std::string    ICN_GROUND;
    static const std::string    ICN_WATER;
    static const std::string    CHK_ALLOWOVERRIDE;
    static const std::string    BTN_APPLY;
    static const std::string    BTN_CANCEL;
    static const std::string    LBL_TIMEOFDAY;
    static const std::string    PNL_SETTINGS;
    static const std::string    PNL_ENVIRONMENT_ALTITUDES;
    static const std::string    PNL_BUTTONS;
    static const std::string    PNL_DISABLED;
    static const std::string    PNL_REGION_MSG;
    static const std::string    TXT_DISABLED;
    static const std::string    SDT_DROP_TARGET;

    static const std::string    STR_LABEL_USEDEFAULT;
    static const std::string    STR_LABEL_USEREGION;
    static const std::string    STR_ALTITUDE_DESCRIPTION;
    static const std::string    STR_NO_PARCEL;
    static const std::string    STR_CROSS_REGION;
    static const std::string    STR_LEGACY;
    static const std::string    STR_DISALLOWED;
    static const std::string    STR_TOO_SMALL;

    static const S32            MINIMUM_PARCEL_SIZE;

    static const U32            DIRTY_FLAG_DAYCYCLE;
    static const U32            DIRTY_FLAG_DAYLENGTH;
    static const U32            DIRTY_FLAG_DAYOFFSET;
    static const U32            DIRTY_FLAG_ALTITUDES;

    static const U32            DIRTY_FLAG_MASK;

    bool                        setControlsEnabled(bool enabled);
    void                        setDirtyFlag(U32 flag);
    void                        clearDirtyFlag(U32 flag);
    bool                        getIsDirty() const                  { return (mDirtyFlag != 0); }
    bool                        getIsDirtyFlag(U32 flag) const      { return ((mDirtyFlag & flag) != 0); }
    U32                         getDirtyFlag() const                { return mDirtyFlag; }
    void                        updateAltLabel(const std::string &alt_prefix, U32 sky_index, F32 alt_value);
    void                        readjustAltLabels();

    void                        onSldDayLengthChanged(F32 value);
    void                        onSldDayOffsetChanged(F32 value);
    void                        onAltSliderCallback(LLUICtrl *cntrl, const LLSD &data);
    void                        onAltSliderMouseUp();

    void                        onBtnEdit();
    void                        onBtnSelect();
    void                        onBtnDefault();
    void                        onBtnRstAltitudes();

    void                        udpateApparentTimeOfDay();

    void                        onPickerCommitted(LLUUID item_id, std::string source);
    void                        onPickerCommitted(LLUUID item_id, S32 track_num = LLEnvironment::NO_TRACK);
    void                        onEditCommitted(LLSettingsDay::ptr_t newday);
    void                        onDayLenOffsetMouseUp();
    void                        commitDayLenOffsetChanges(bool need_callback);

    void                        onPickerAssetDownloaded(LLSettingsBase::ptr_t settings);
    void                        onEnvironmentReceived(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo);
    static void                 _onEnvironmentReceived(LLHandle<LLPanel> that_h, S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo);

    virtual bool                isLargeEnough() = 0;
    virtual void                refreshFromSource() = 0;

    std::string                 getNameForTrackIndex(S32 index);

    LLFloaterSettingsPicker *   getSettingsPicker(bool create = true);
    LLFloaterEditExtDayCycle *  getEditFloater(bool create = true);
    void                        updateEditFloater(const LLEnvironment::EnvironmentInfo::ptr_t &nextenv, bool enable);

    void                        setCrossRegion(bool val) { mCrossRegion = val; }
    void                        setNoSelection(bool val) { mNoSelection = val; }
    void                        setNoEnvironmentSupport(bool val) { mNoEnvironment = val; }

    LLEnvironment::EnvironmentInfo::ptr_t   mCurrentEnvironment;

    void                        onEnvironmentChanged(LLEnvironment::EnvSelection_t env, S32 version);

    class AltitudeData
    {
    public:
        AltitudeData() :
            mTrackIndex(0), mLabelIndex(0), mAltitude(0)
        {}
        AltitudeData(U32 track_index, U32 label_index, F32 altitude) :
            mTrackIndex(track_index), mLabelIndex(label_index), mAltitude(altitude)
        {}

        U32 mTrackIndex;
        U32 mLabelIndex;
        F32 mAltitude;
    };
    typedef std::map<std::string, AltitudeData>      altitudes_data_t;
    altitudes_data_t                mAltitudes;
    S32                             mCurEnvVersion; // used to filter duplicate callbacks/refreshes

protected:
    typedef boost::signals2::connection connection_t;

    void                            refreshFromEstate();
    bool                            mAllowOverride;

private:
    static void                     onIdlePlay(void *);

    connection_t                    mCommitConnection;
    connection_t                    mChangeMonitor;
    connection_t                    mUpdateConnection;

    LLHandle<LLFloater>             mSettingsFloater;
    LLHandle<LLFloater>             mEditFloater;
    S32                             mDirtyFlag;
    S32                             mEditorLastParcelId;
    LLUUID                          mEditorLastRegionId;
    bool                            mCrossRegion;
    bool                            mNoSelection;
    bool                            mNoEnvironment;

};

class LLSettingsDropTarget : public LLView
{
public:
    struct Params : public LLInitParam::Block<Params, LLView::Params>
    {
        Params()
        {
            changeDefault(mouse_opaque, false);
            changeDefault(follows.flags, FOLLOWS_ALL);
        }
    };
    LLSettingsDropTarget(const Params&);
    ~LLSettingsDropTarget() {};

    virtual bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
        EDragAndDropType cargo_type,
        void* cargo_data,
        EAcceptance* accept,
        std::string& tooltip_msg);
    void setPanel(LLPanelEnvironmentInfo* panel, std::string track) { mEnvironmentInfoPanel = panel;  mTrack = track; };
    void setDndEnabled(bool dnd_enabled) { mDndEnabled = dnd_enabled; };

protected:
    LLPanelEnvironmentInfo* mEnvironmentInfoPanel;
    std::string mTrack;
    bool                    mDndEnabled;
};
#endif // LL_LLPANELENVIRONMENT_H