diff options
author | Steven Bennetts <steve@lindenlab.com> | 2009-05-08 07:43:08 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2009-05-08 07:43:08 +0000 |
commit | a4000c3744e42fcbb638e742f3b63fa31a0dee15 (patch) | |
tree | 7f472c30e65bbfa04ee9bc06631a1af305cc31fb /indra/newview/llpreviewnotecard.cpp | |
parent | 6c4cadbb04d633ad7b762058bdeba6e1f650dafd (diff) |
merge trunk@116587 skinning-7@119389 -> viewer-2.0.0-skinning-7
Diffstat (limited to 'indra/newview/llpreviewnotecard.cpp')
-rw-r--r-- | indra/newview/llpreviewnotecard.cpp | 172 |
1 files changed, 50 insertions, 122 deletions
diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index 4abe390bc5..f3d0dc538d 100644 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -40,6 +40,7 @@ #include "llassetuploadresponders.h" #include "llviewerwindow.h" #include "llbutton.h" +#include "llfloaterreg.h" #include "llinventorymodel.h" #include "lllineeditor.h" #include "llnotify.h" @@ -62,121 +63,70 @@ #include "lluictrlfactory.h" ///---------------------------------------------------------------------------- -/// Local function declarations, constants, enums, and typedefs -///---------------------------------------------------------------------------- - -const S32 PREVIEW_MIN_WIDTH = - 2 * PREVIEW_BORDER + - 2 * PREVIEW_BUTTON_WIDTH + - PREVIEW_PAD + RESIZE_HANDLE_WIDTH + - PREVIEW_PAD; -const S32 PREVIEW_MIN_HEIGHT = - 2 * PREVIEW_BORDER + - 3*(20 + PREVIEW_PAD) + - 2 * SCROLLBAR_SIZE + 128; - -///---------------------------------------------------------------------------- /// Class LLPreviewNotecard ///---------------------------------------------------------------------------- // Default constructor -LLPreviewNotecard::LLPreviewNotecard(const std::string& name, - const LLRect& rect, - const std::string& title, - const LLUUID& item_id, - const LLUUID& object_id, - const LLUUID& asset_id, - BOOL show_keep_discard, - LLPointer<LLViewerInventoryItem> inv_item) : - LLPreview(name, rect, title, item_id, object_id, TRUE, - PREVIEW_MIN_WIDTH, - PREVIEW_MIN_HEIGHT, - inv_item), - mAssetID( asset_id ), - mNotecardItemID(item_id), - mObjectID(object_id) +LLPreviewNotecard::LLPreviewNotecard(const LLSD& key) //const LLUUID& item_id, + : LLPreview( key ) +{ + const LLInventoryItem *item = getItem(); + if (item) + { + mShowKeepDiscard = item->getPermissions().getCreator() != gAgent.getID(); + //Called from floater reg: LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard.xml", FALSE); + mAssetID = item->getAssetUUID(); + } +} + +LLPreviewNotecard::~LLPreviewNotecard() { - LLRect curRect = rect; +} - if (show_keep_discard) +BOOL LLPreviewNotecard::postBuild() +{ + LLViewerTextEditor *ed = getChild<LLViewerTextEditor>("Notecard Editor"); + if (ed) + { + ed->setNotecardInfo(mItemUUID, mObjectID, getKey()); + ed->makePristine(); + } + if (mShowKeepDiscard) { - LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard_keep_discard.xml"); childSetAction("Keep",onKeepBtn,this); childSetAction("Discard",onDiscardBtn,this); } else { - LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard.xml"); - childSetAction("Save",onClickSave,this); - - if( mAssetID.isNull() ) - { - const LLInventoryItem* item = getItem(); - if( item ) - { - mAssetID = item->getAssetUUID(); - } - } - } - - // only assert shape if not hosted in a multifloater - if (!getHost()) - { - reshape(curRect.getWidth(), curRect.getHeight(), TRUE); - setRect(curRect); + getChild<LLButton>("Keep")->setLabel(getString("Save")); + childSetAction("Keep",onClickSave,this); + childSetVisible("Discard", false); } - + childSetVisible("lock", FALSE); - + const LLInventoryItem* item = getItem(); - + childSetCommitCallback("desc", LLPreview::onText, this); if (item) childSetText("desc", item->getDescription()); childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe); - setTitle(title); - LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor"); if (editor) { editor->setWordWrap(TRUE); - editor->setSourceID(item_id); editor->setHandleEditKeysDirectly(TRUE); } - - gAgent.changeCameraToDefault(); -} - -LLPreviewNotecard::~LLPreviewNotecard() -{ -} - -BOOL LLPreviewNotecard::postBuild() -{ - LLViewerTextEditor *ed = getChild<LLViewerTextEditor>("Notecard Editor"); - if (ed) - { - ed->setNotecardInfo(mNotecardItemID, mObjectID); - ed->makePristine(); - } - return TRUE; + + return LLPreview::postBuild(); } -bool LLPreviewNotecard::saveItem(LLPointer<LLInventoryItem>* itemptr) +bool LLPreviewNotecard::saveItem() { - LLInventoryItem* item = NULL; - if (itemptr && itemptr->notNull()) - { - item = (LLInventoryItem*)(*itemptr); - } - bool res = saveIfNeeded(item); - if (res) - { - delete itemptr; - } - return res; + LLInventoryItem* item = gInventory.getItem(mItemUUID); + return saveIfNeeded(item); } void LLPreviewNotecard::setEnabled( BOOL enabled ) @@ -187,7 +137,7 @@ void LLPreviewNotecard::setEnabled( BOOL enabled ) childSetEnabled("Notecard Editor", enabled); childSetVisible("lock", !enabled); childSetEnabled("desc", enabled); - childSetEnabled("Save", enabled && editor && (!editor->isPristine())); + childSetEnabled("Keep", enabled && editor && (!editor->isPristine())); } @@ -195,13 +145,10 @@ void LLPreviewNotecard::setEnabled( BOOL enabled ) void LLPreviewNotecard::draw() { - - //childSetFocus("Save", FALSE); - LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor"); BOOL script_changed = !editor->isPristine(); - childSetEnabled("Save", script_changed && getEnabled()); + childSetEnabled("Keep", script_changed && getEnabled()); LLPreview::draw(); } @@ -255,8 +202,13 @@ bool LLPreviewNotecard::hasEmbeddedInventory() return editor->hasEmbeddedInventory(); } -void LLPreviewNotecard::refreshFromInventory() +void LLPreviewNotecard::refreshFromInventory(const LLUUID& new_item_id) { + if (new_item_id.notNull()) + { + mItemUUID = new_item_id; + setKey(LLSD(new_item_id)); + } lldebugs << "LLPreviewNotecard::refreshFromInventory()" << llendl; loadAsset(); } @@ -287,7 +239,6 @@ void LLPreviewNotecard::loadAsset() } else { - LLUUID* new_uuid = new LLUUID(mItemUUID); LLHost source_sim = LLHost::invalid; if (mObjectUUID.notNull()) { @@ -305,7 +256,6 @@ void LLPreviewNotecard::loadAsset() editor->makePristine(); editor->setEnabled(FALSE); mAssetStatus = PREVIEW_ASSET_LOADED; - delete new_uuid; return; } } @@ -318,7 +268,7 @@ void LLPreviewNotecard::loadAsset() item->getAssetUUID(), item->getType(), &onLoadComplete, - (void*)new_uuid, + (void*)new LLUUID(mItemUUID), TRUE); mAssetStatus = PREVIEW_ASSET_LOADING; } @@ -355,7 +305,8 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs, { llinfos << "LLPreviewNotecard::onLoadComplete()" << llendl; LLUUID* item_id = (LLUUID*)user_data; - LLPreviewNotecard* preview = LLPreviewNotecard::getInstance(*item_id); + + LLPreviewNotecard* preview = LLFloaterReg::findTypedInstance<LLPreviewNotecard>("preview_notecard", LLSD(*item_id)); if( preview ) { if(0 == status) @@ -420,18 +371,6 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs, } // static -LLPreviewNotecard* LLPreviewNotecard::getInstance(const LLUUID& item_id) -{ - LLPreview* instance = NULL; - preview_map_t::iterator found_it = LLPreview::sInstances.find(item_id); - if(found_it != LLPreview::sInstances.end()) - { - instance = found_it->second; - } - return (LLPreviewNotecard*)instance; -} - -// static void LLPreviewNotecard::onClickSave(void* user_data) { //llinfos << "LLPreviewNotecard::onBtnSave()" << llendl; @@ -590,10 +529,11 @@ void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data } // Find our window and close it if requested. - LLPreviewNotecard* previewp = (LLPreviewNotecard*)LLPreview::find(info->mItemUUID); + + LLPreviewNotecard* previewp = LLFloaterReg::findTypedInstance<LLPreviewNotecard>("preview_notecard", info->mItemUUID); if (previewp && previewp->mCloseAfterSave) { - previewp->close(); + previewp->closeFloater(); } } else @@ -624,7 +564,7 @@ bool LLPreviewNotecard::handleSaveChangesDialog(const LLSD& notification, const case 1: // "No" mForceClose = TRUE; - close(); + closeFloater(); break; case 2: // "Cancel" @@ -636,16 +576,4 @@ bool LLPreviewNotecard::handleSaveChangesDialog(const LLSD& notification, const return false; } -void LLPreviewNotecard::reshape(S32 width, S32 height, BOOL called_from_parent) -{ - LLPreview::reshape( width, height, called_from_parent ); - - if( !isMinimized() ) - { - // So that next time you open a script it will have the same height and width - // (although not the same position). - gSavedSettings.setRect("NotecardEditorRect", getRect()); - } -} - // EOF |