aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaternamedesc.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llfloaternamedesc.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llfloaternamedesc.cpp')
-rw-r--r--linden/indra/newview/llfloaternamedesc.cpp221
1 files changed, 221 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaternamedesc.cpp b/linden/indra/newview/llfloaternamedesc.cpp
new file mode 100644
index 0000000..8d84f94
--- /dev/null
+++ b/linden/indra/newview/llfloaternamedesc.cpp
@@ -0,0 +1,221 @@
1/**
2 * @file llfloaternamedesc.cpp
3 * @brief LLFloaterNameDesc class implementation
4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "llfloaternamedesc.h"
31#include "lllineeditor.h"
32#include "llresmgr.h"
33#include "lltextbox.h"
34#include "llbutton.h"
35#include "llviewerwindow.h"
36#include "llfocusmgr.h"
37#include "llradiogroup.h"
38#include "llassetstorage.h"
39#include "lldbstrings.h"
40#include "lldir.h"
41#include "llviewercontrol.h"
42#include "llviewermenu.h"
43#include "llvieweruictrlfactory.h"
44
45const S32 PREVIEW_LINE_HEIGHT = 19;
46const S32 PREVIEW_CLOSE_BOX_SIZE = 16;
47const S32 PREVIEW_BORDER_WIDTH = 2;
48const S32 PREVIEW_RESIZE_HANDLE_SIZE = S32(RESIZE_HANDLE_WIDTH * OO_SQRT2) + PREVIEW_BORDER_WIDTH;
49const S32 PREVIEW_VPAD = 2;
50const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE;
51const S32 PREVIEW_HEADER_SIZE = 3 * PREVIEW_LINE_HEIGHT + PREVIEW_VPAD;
52const S32 PREF_BUTTON_WIDTH = 64;
53const S32 PREF_BUTTON_HEIGHT = 16;
54
55//-----------------------------------------------------------------------------
56// LLFloaterNameDesc()
57//-----------------------------------------------------------------------------
58LLFloaterNameDesc::LLFloaterNameDesc(const std::string& filename )
59 :
60 LLFloater("Name/Description Floater")
61{
62 mFilenameAndPath = filename;
63 mFilename.assign(strrchr( filename.c_str(), gDirUtilp->getDirDelimiter()[0]) + 1);
64 // SL-5521 Maintain capitalization of filename when making the inventory item. JC
65 //LLString::toLower(mFilename);
66 mIsAudio = FALSE;
67}
68
69//-----------------------------------------------------------------------------
70// postBuild()
71//-----------------------------------------------------------------------------
72BOOL LLFloaterNameDesc::postBuild()
73{
74 LLRect r;
75
76 LLString asset_name = mFilename;
77 LLString::replaceNonstandardASCII( asset_name, '?' );
78 LLString::replaceChar(asset_name, '|', '?');
79 LLString::stripNonprintable(asset_name);
80 LLString::trim(asset_name);
81
82 char* asset_name_str = (char*)asset_name.c_str();
83 char* end_p = strrchr(asset_name_str, '.'); // strip extension if exists
84 if( !end_p )
85 {
86 end_p = asset_name_str + strlen( asset_name_str );
87 }
88 else
89 if( !stricmp( end_p, ".wav") )
90 {
91 mIsAudio = TRUE;
92 }
93
94 S32 len = llmin( (S32) (DB_INV_ITEM_NAME_STR_LEN), (S32) (end_p - asset_name_str) );
95
96 asset_name = asset_name.substr( 0, len );
97
98 setTitle(mFilename);
99
100 centerWindow();
101
102 S32 line_width = mRect.getWidth() - 2 * PREVIEW_HPAD;
103 S32 y = mRect.getHeight() - PREVIEW_LINE_HEIGHT;
104
105 r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT );
106 y -= PREVIEW_LINE_HEIGHT;
107
108 r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT );
109
110 childSetCommitCallback("name_form", doCommit, this);
111 childSetValue("name_form", LLSD(asset_name));
112
113 LLLineEditor *NameEditor = LLViewerUICtrlFactory::getLineEditorByName(this, "name_form");
114 if (NameEditor)
115 {
116 NameEditor->setMaxTextLength(DB_INV_ITEM_NAME_STR_LEN);
117 NameEditor->setPrevalidate(&LLLineEditor::prevalidatePrintableNotPipe);
118 }
119
120 y -= llfloor(PREVIEW_LINE_HEIGHT * 1.2f);
121 y -= PREVIEW_LINE_HEIGHT;
122
123 r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT );
124 childSetCommitCallback("description_form", doCommit, this);
125 LLLineEditor *DescEditor = LLViewerUICtrlFactory::getLineEditorByName(this, "description_form");
126 if (DescEditor)
127 {
128 DescEditor->setMaxTextLength(DB_INV_ITEM_DESC_STR_LEN);
129 DescEditor->setPrevalidate(&LLLineEditor::prevalidatePrintableNotPipe);
130 }
131
132 y -= llfloor(PREVIEW_LINE_HEIGHT * 1.2f);
133
134 if (mIsAudio)
135 {
136 LLSD bitrate = gSavedSettings.getS32("AudioDefaultBitrate");
137
138 childSetValue("bitrate", bitrate);
139 }
140
141 // Cancel button
142 childSetAction("cancel_btn", onBtnCancel, this);
143
144 // OK button
145 childSetAction("ok_btn", onBtnOK, this);
146 setDefaultBtn("ok_btn");
147
148 return TRUE;
149}
150
151//-----------------------------------------------------------------------------
152// LLFloaterNameDesc()
153//-----------------------------------------------------------------------------
154LLFloaterNameDesc::~LLFloaterNameDesc()
155{
156 gFocusMgr.releaseFocusIfNeeded( this ); // calls onCommit()
157}
158
159//-----------------------------------------------------------------------------
160// centerWindow()
161//-----------------------------------------------------------------------------
162void LLFloaterNameDesc::centerWindow()
163{
164 LLRect window_rect = gViewerWindow->getRootView()->getRect();
165
166 S32 dialog_left = window_rect.mLeft + (window_rect.getWidth() - mRect.getWidth()) / 2;
167 S32 dialog_bottom = window_rect.mBottom + (window_rect.getHeight() - mRect.getHeight()) / 2;
168
169 translate( dialog_left - mRect.mLeft, dialog_bottom - mRect.mBottom );
170}
171
172// Sub-classes should override this function if they allow editing
173//-----------------------------------------------------------------------------
174// onCommit()
175//-----------------------------------------------------------------------------
176void LLFloaterNameDesc::onCommit()
177{
178}
179
180// static
181//-----------------------------------------------------------------------------
182// onCommit()
183//-----------------------------------------------------------------------------
184void LLFloaterNameDesc::doCommit( class LLUICtrl *, void* userdata )
185{
186 LLFloaterNameDesc* self = (LLFloaterNameDesc*) userdata;
187 self->onCommit();
188}
189
190// static
191//-----------------------------------------------------------------------------
192// onBtnOK()
193//-----------------------------------------------------------------------------
194void LLFloaterNameDesc::onBtnOK( void* userdata )
195{
196 LLFloaterNameDesc *fp =(LLFloaterNameDesc *)userdata;
197
198 fp->childDisable("ok_btn"); // don't allow inadvertent extra uploads
199
200 S32 bitrate = 0;
201
202 if (fp->mIsAudio)
203 {
204 bitrate = fp->childGetValue("bitrate").asInteger();
205 }
206 upload_new_resource(fp->mFilenameAndPath, // file
207 fp->childGetValue("name_form").asString(),
208 fp->childGetValue("description_form").asString(),
209 bitrate, LLAssetType::AT_NONE, LLInventoryType::IT_NONE);
210 fp->onClose(false);
211}
212
213// static
214//-----------------------------------------------------------------------------
215// onBtnCancel()
216//-----------------------------------------------------------------------------
217void LLFloaterNameDesc::onBtnCancel( void* userdata )
218{
219 LLFloaterNameDesc *fp =(LLFloaterNameDesc *)userdata;
220 fp->onClose(false);
221}