summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelmaininventory.h
blob: 3347ab904bca80beacada50bb84d8b59582eb0f0 (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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/**
 * @file llpanelmaininventory.h
 * @brief llpanelmaininventory.h
 * class definition
 *
 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2010, 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_LLPANELMAININVENTORY_H
#define LL_LLPANELMAININVENTORY_H

#include "llpanel.h"
#include "llinventoryobserver.h"
#include "llinventorypanel.h"
#include "lldndbutton.h"

#include "llfolderview.h"

class LLComboBox;
class LLFolderViewItem;
class LLInventoryPanel;
class LLInventoryGallery;
class LLSaveFolderState;
class LLFilterEditor;
class LLTabContainer;
class LLFloaterInventoryFinder;
class LLMenuButton;
class LLMenuGL;
class LLSidepanelInventory;
class LLToggleableMenu;
class LLFloater;
class LLFloaterSidePanelContainer;
class LLSidepanelInventory;
class LLPanelMarketplaceInbox;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLPanelMainInventory
//
// This is a panel used to view and control an agent's inventory,
// including all the fixin's (e.g. AllItems/RecentItems tabs, filter floaters).
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLPanelMainInventory : public LLPanel, LLInventoryObserver
{
public:
    friend class LLFloaterInventoryFinder;

    LLPanelMainInventory(const LLPanel::Params& p = getDefaultParams());
    ~LLPanelMainInventory();

    bool postBuild();

    enum EViewModeType
    {
        MODE_LIST,
        MODE_GALLERY,
        MODE_COMBINATION
    };

    virtual bool handleKeyHere(KEY key, MASK mask);

    // Inherited functionality
    /*virtual*/ bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
                                       EDragAndDropType cargo_type,
                                       void* cargo_data,
                                       EAcceptance* accept,
                                       std::string& tooltip_msg);
    /*virtual*/ void changed(U32);
    /*virtual*/ void draw();
    /*virtual*/ void    onVisibilityChange ( bool new_visibility );

    LLInventoryPanel* getPanel() { return mActivePanel; }
    LLInventoryPanel* getActivePanel() { return mActivePanel; }
    LLInventoryPanel* getAllItemsPanel();
    void selectAllItemsPanel();
    const LLInventoryPanel* getActivePanel() const { return mActivePanel; }
    void setActivePanel();

    bool isRecentItemsPanelSelected();

    const std::string& getFilterText() const { return mFilterText; }

    void setSelectCallback(const LLFolderView::signal_t::slot_type& cb);

    void onFilterEdit(const std::string& search_string );

    void setFocusFilterEditor();

    static LLFloaterSidePanelContainer* newWindow();
    static void newFolderWindow(LLUUID folder_id = LLUUID(), LLUUID item_to_select = LLUUID());

    void toggleFindOptions();

    void resetFilters();
    void resetAllItemsFilters();

    void findLinks(const LLUUID& item_id, const std::string& item_name);

    void onViewModeClick();
    void toggleViewMode();
    void initSingleFolderRoot(const LLUUID& start_folder_id = LLUUID::null);
    void initInventoryViews();
    void onUpFolderClicked();
    void onBackFolderClicked();
    void onForwardFolderClicked();
    void setSingleFolderViewRoot(const LLUUID& folder_id, bool clear_nav_history = true);
    void setGallerySelection(const LLUUID& item_id, bool new_window = false);
    LLUUID getSingleFolderViewRoot();
    bool isSingleFolderMode() { return mSingleFolderMode; }

    void scrollToGallerySelection();
    void scrollToInvPanelSelection();

    void setViewMode(EViewModeType mode);
    bool isListViewMode() { return (mViewMode == MODE_LIST); }
    bool isGalleryViewMode() { return (mViewMode == MODE_GALLERY); }
    bool isCombinationViewMode() { return (mViewMode == MODE_COMBINATION); }
    LLUUID getCurrentSFVRoot();
    std::string getLocalizedRootName();

    LLInventoryFilter& getCurrentFilter();

    void setParentSidepanel(LLSidepanelInventory* parent_sidepanel) { mParentSidepanel = parent_sidepanel; }
    void setInboxPanel(LLPanelMarketplaceInbox* inbox_panel) { mInboxPanel = inbox_panel; }

protected:
    //
    // Misc functions
    //
    void setFilterTextFromFilter();
    void startSearch();

    void onSelectionChange(LLInventoryPanel *panel, const std::deque<LLFolderViewItem*>& items, bool user_action);

    static bool filtersVisible(void* user_data);
    void onClearSearch();
    static void onFoldersByName(void *user_data);
    static bool checkFoldersByName(void *user_data);

    static bool incrementalFind(LLFolderViewItem* first_item, const char *find_text, bool backward);
    void onFilterSelected();

    const std::string getFilterSubString();
    void setFilterSubString(const std::string& string);

    // menu callbacks
    void doToSelected(const LLSD& userdata);
    void closeAllFolders();
    void doCreate(const LLSD& userdata);
    void setSortBy(const LLSD& userdata);
    void saveTexture(const LLSD& userdata);
    bool isSaveTextureEnabled(const LLSD& userdata);
    void updateItemcountText();

    void updatePanelVisibility();
    void updateCombinationVisibility();

    void onFocusReceived();
    void onSelectSearchType();
    void updateSearchTypeCombo();
    void setSearchType(LLInventoryFilter::ESearchType type);

    LLSidepanelInventory* getParentSidepanelInventory();

private:
    LLFloaterInventoryFinder* getFinder();

    LLFilterEditor*             mFilterEditor;
    LLTabContainer*             mFilterTabs;
    LLUICtrl*                   mCounterCtrl;
    LLHandle<LLFloater>         mFinderHandle;
    LLInventoryPanel*           mActivePanel;
    LLInventoryPanel*           mAllItemsPanel = nullptr;
    LLInventoryPanel*           mRecentPanel = nullptr;
    LLInventoryPanel*           mWornItemsPanel = nullptr;
    bool                        mResortActivePanel;
    LLSaveFolderState*          mSavedFolderState;
    std::string                 mFilterText;
    std::string                 mFilterSubString;
    S32                         mItemCount;
    std::string                 mItemCountString;
    S32                         mCategoryCount;
    std::string                 mCategoryCountString;
    LLComboBox*                 mSearchTypeCombo;

    LLButton* mBackBtn;
    LLButton* mForwardBtn;
    LLButton* mUpBtn;
    LLButton* mViewModeBtn;
    LLLayoutPanel* mNavigationBtnsPanel;

    LLPanel* mDefaultViewPanel;
    LLPanel* mCombinationViewPanel;

    bool mSingleFolderMode;
    EViewModeType mViewMode;

    LLInventorySingleFolderPanel* mCombinationInventoryPanel;
    LLInventoryGallery* mCombinationGalleryPanel;
    LLPanel* mCombinationGalleryLayoutPanel;
    LLLayoutPanel* mCombinationListLayoutPanel;
    LLLayoutStack* mCombinationLayoutStack;

    boost::signals2::connection mListViewRootUpdatedConnection;
    boost::signals2::connection mGalleryRootUpdatedConnection;

    //////////////////////////////////////////////////////////////////////////////////
    // List Commands                                                                //
protected:
    void initListCommandsHandlers();
    void updateListCommands();
    void onAddButtonClick();
    void showActionMenu(LLMenuGL* menu, std::string spawning_view_name);
    void onClipboardAction(const LLSD& userdata);
    bool isActionEnabled(const LLSD& command_name);
    bool isActionChecked(const LLSD& userdata);
    void onCustomAction(const LLSD& command_name);
    bool isActionVisible(const LLSD& userdata);
    static bool hasSettingsInventory();
    static bool hasMaterialsInventory();
    void updateTitle();
    void updateNavButtons();

    void onCombinationRootChanged(bool gallery_clicked);
    void onCombinationGallerySelectionChanged(const LLUUID& category_id);
    void onCombinationInventorySelectionChanged(const std::deque<LLFolderViewItem*>& items, bool user_action);
    /**
     * Set upload cost in "Upload" sub menu.
     */
    void setUploadCostIfNeeded();
    void disableAddIfNeeded();
private:
    LLSidepanelInventory*       mParentSidepanel = nullptr;
    LLPanelMarketplaceInbox*    mInboxPanel = nullptr;

    LLToggleableMenu*           mMenuGearDefault;
    LLToggleableMenu*           mMenuViewDefault;
    LLToggleableMenu*           mMenuVisibility;
    LLMenuButton*               mGearMenuButton;
    LLMenuButton*               mViewMenuButton;
    LLMenuButton*               mVisibilityMenuButton;
    LLHandle<LLView>            mMenuAddHandle;

    bool                        mNeedUploadCost;

    bool                        mForceShowInvLayout;
    bool                        mReshapeInvLayout;
    LLUUID                      mCombInvUUIDNeedsRename;
    // List Commands                                                              //
    ////////////////////////////////////////////////////////////////////////////////
};

#endif // LL_LLPANELMAININVENTORY_H