diff options
author | Jacek Antonelli | 2008-08-15 23:45:07 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:07 -0500 |
commit | 8465910c79b8e746e04fd581cca2d60399e569b9 (patch) | |
tree | f43fec3e83c46e0d6190dca923d6fb268b52ffdd /linden/indra/newview/llviewertexteditor.cpp | |
parent | Second Life viewer sources 1.18.2.1 (diff) | |
download | meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.zip meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.tar.gz meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.tar.bz2 meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.tar.xz |
Second Life viewer sources 1.18.3.2-RC
Diffstat (limited to 'linden/indra/newview/llviewertexteditor.cpp')
-rw-r--r-- | linden/indra/newview/llviewertexteditor.cpp | 91 |
1 files changed, 76 insertions, 15 deletions
diff --git a/linden/indra/newview/llviewertexteditor.cpp b/linden/indra/newview/llviewertexteditor.cpp index 3369125..754132d 100644 --- a/linden/indra/newview/llviewertexteditor.cpp +++ b/linden/indra/newview/llviewertexteditor.cpp | |||
@@ -55,6 +55,68 @@ | |||
55 | 55 | ||
56 | extern BOOL gPacificDaylightTime; | 56 | extern BOOL gPacificDaylightTime; |
57 | 57 | ||
58 | ///---------------------------------------------------------------------------- | ||
59 | /// Class LLEmbeddedNotecardOpener | ||
60 | ///---------------------------------------------------------------------------- | ||
61 | class LLEmbeddedNotecardOpener : public LLInventoryCallback | ||
62 | { | ||
63 | LLViewerTextEditor* mTextEditor; | ||
64 | |||
65 | public: | ||
66 | LLEmbeddedNotecardOpener() | ||
67 | : mTextEditor(NULL) | ||
68 | { | ||
69 | } | ||
70 | |||
71 | void setEditor(LLViewerTextEditor* e) {mTextEditor = e;} | ||
72 | |||
73 | // override | ||
74 | void fire(const LLUUID& inv_item) | ||
75 | { | ||
76 | if(!mTextEditor) | ||
77 | { | ||
78 | // The parent text editor may have vanished by now. | ||
79 | // In that case just quit. | ||
80 | return; | ||
81 | } | ||
82 | |||
83 | LLInventoryItem* item = gInventory.getItem(inv_item); | ||
84 | if(!item) | ||
85 | { | ||
86 | llwarns << "Item add reported, but not found in inventory!: " << inv_item << llendl; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | // See if we can bring an existing preview to the front | ||
91 | if(!LLPreview::show(item->getUUID(), true)) | ||
92 | { | ||
93 | if(!gSavedSettings.getBOOL("ShowNewInventory")) | ||
94 | { | ||
95 | // There isn't one, so make a new preview | ||
96 | S32 left, top; | ||
97 | gFloaterView->getNewFloaterPosition(&left, &top); | ||
98 | LLRect rect = gSavedSettings.getRect("NotecardEditorRect"); | ||
99 | rect.translate(left - rect.mLeft, top - rect.mTop); | ||
100 | LLPreviewNotecard* preview; | ||
101 | preview = new LLPreviewNotecard("preview notecard", | ||
102 | rect, | ||
103 | LLString("Embedded Note: ") + item->getName(), | ||
104 | item->getUUID(), | ||
105 | LLUUID::null, | ||
106 | item->getAssetUUID(), | ||
107 | true, | ||
108 | (LLViewerInventoryItem*)item); | ||
109 | preview->setSourceID(LLUUID::null); | ||
110 | preview->setFocus(TRUE); | ||
111 | |||
112 | // Force to be entirely onscreen. | ||
113 | gFloaterView->adjustToFitScreen(preview, FALSE); | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | }; | ||
119 | |||
58 | //////////////////////////////////////////////////////////// | 120 | //////////////////////////////////////////////////////////// |
59 | // LLEmbeddedItems | 121 | // LLEmbeddedItems |
60 | // | 122 | // |
@@ -497,14 +559,21 @@ LLViewerTextEditor::LLViewerTextEditor(const LLString& name, | |||
497 | const LLFontGL* font, | 559 | const LLFontGL* font, |
498 | BOOL allow_embedded_items) | 560 | BOOL allow_embedded_items) |
499 | : LLTextEditor(name, rect, max_length, default_text, font, allow_embedded_items), | 561 | : LLTextEditor(name, rect, max_length, default_text, font, allow_embedded_items), |
500 | mDragItemSaved(FALSE) | 562 | mDragItemSaved(FALSE), |
563 | mInventoryCallback(new LLEmbeddedNotecardOpener) | ||
501 | { | 564 | { |
502 | mEmbeddedItemList = new LLEmbeddedItems(this); | 565 | mEmbeddedItemList = new LLEmbeddedItems(this); |
566 | mInventoryCallback->setEditor(this); | ||
503 | } | 567 | } |
504 | 568 | ||
505 | LLViewerTextEditor::~LLViewerTextEditor() | 569 | LLViewerTextEditor::~LLViewerTextEditor() |
506 | { | 570 | { |
507 | delete mEmbeddedItemList; | 571 | delete mEmbeddedItemList; |
572 | |||
573 | |||
574 | // The inventory callback may still be in use by gInventoryCallbackManager... | ||
575 | // so set its reference to this to null. | ||
576 | mInventoryCallback->setEditor(NULL); | ||
508 | } | 577 | } |
509 | 578 | ||
510 | /////////////////////////////////////////////////////////////////// | 579 | /////////////////////////////////////////////////////////////////// |
@@ -1279,22 +1348,14 @@ void LLViewerTextEditor::openEmbeddedLandmark( LLInventoryItem* item ) | |||
1279 | open_landmark((LLViewerInventoryItem*)item, " preview landmark", FALSE, item->getUUID(), TRUE); | 1348 | open_landmark((LLViewerInventoryItem*)item, " preview landmark", FALSE, item->getUUID(), TRUE); |
1280 | } | 1349 | } |
1281 | 1350 | ||
1282 | |||
1283 | void LLViewerTextEditor::openEmbeddedNotecard( LLInventoryItem* item, BOOL saved ) | 1351 | void LLViewerTextEditor::openEmbeddedNotecard( LLInventoryItem* item, BOOL saved ) |
1284 | { | 1352 | { |
1285 | if (saved) | 1353 | if (saved) |
1286 | { | 1354 | { |
1287 | // Pop-up the notecard floater. | 1355 | // An LLInventoryItem needs to be in an inventory to be opened. |
1288 | // Note: Previously would copy to inventory and rely on autodisplay to view. | 1356 | // This will give the item to the viewer's agent. |
1289 | // Now that autodisplay can be turned off, we need to make this case display always. | 1357 | // The callback will attempt to open it if its not already opened. |
1290 | // besides, there's no point adding to inventory -MG | 1358 | copyInventory(item, gInventoryCallbacks.registerCB(mInventoryCallback)); |
1291 | open_notecard( | ||
1292 | (LLViewerInventoryItem*)item, | ||
1293 | LLString("Embedded Note: ") + item->getName(), // title | ||
1294 | mObjectID, | ||
1295 | FALSE, // show_keep_discard | ||
1296 | LLUUID::null, // source_id | ||
1297 | TRUE); // take_focus | ||
1298 | } | 1359 | } |
1299 | else | 1360 | else |
1300 | { | 1361 | { |
@@ -1369,11 +1430,11 @@ bool LLViewerTextEditor::importStream(std::istream& str) | |||
1369 | return success; | 1430 | return success; |
1370 | } | 1431 | } |
1371 | 1432 | ||
1372 | void LLViewerTextEditor::copyInventory(LLInventoryItem* item) | 1433 | void LLViewerTextEditor::copyInventory(const LLInventoryItem* item, U32 callback_id) |
1373 | { | 1434 | { |
1374 | copy_inventory_from_notecard(mObjectID, | 1435 | copy_inventory_from_notecard(mObjectID, |
1375 | mNotecardInventoryID, | 1436 | mNotecardInventoryID, |
1376 | item); | 1437 | item, callback_id); |
1377 | } | 1438 | } |
1378 | 1439 | ||
1379 | bool LLViewerTextEditor::hasEmbeddedInventory() | 1440 | bool LLViewerTextEditor::hasEmbeddedInventory() |