diff options
author | Jacek Antonelli | 2008-09-06 18:24:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-09-06 18:25:07 -0500 |
commit | 798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch) | |
tree | 1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/lltexturectrl.cpp | |
parent | Second Life viewer sources 1.20.15 (diff) | |
download | meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2 meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz |
Second Life viewer sources 1.21.0-RC
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/lltexturectrl.cpp | 86 |
1 files changed, 58 insertions, 28 deletions
diff --git a/linden/indra/newview/lltexturectrl.cpp b/linden/indra/newview/lltexturectrl.cpp index 9a02c5a..48cacf8 100644 --- a/linden/indra/newview/lltexturectrl.cpp +++ b/linden/indra/newview/lltexturectrl.cpp | |||
@@ -65,6 +65,7 @@ | |||
65 | #include "llviewercontrol.h" | 65 | #include "llviewercontrol.h" |
66 | #include "llglheaders.h" | 66 | #include "llglheaders.h" |
67 | #include "lluictrlfactory.h" | 67 | #include "lluictrlfactory.h" |
68 | #include "lltrans.h" | ||
68 | 69 | ||
69 | 70 | ||
70 | static const S32 CLOSE_BTN_WIDTH = 100; | 71 | static const S32 CLOSE_BTN_WIDTH = 100; |
@@ -117,7 +118,7 @@ public: | |||
117 | virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, | 118 | virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, |
118 | BOOL drop, EDragAndDropType cargo_type, void *cargo_data, | 119 | BOOL drop, EDragAndDropType cargo_type, void *cargo_data, |
119 | EAcceptance *accept, | 120 | EAcceptance *accept, |
120 | LLString& tooltip_msg); | 121 | std::string& tooltip_msg); |
121 | virtual void draw(); | 122 | virtual void draw(); |
122 | virtual BOOL handleKeyHere(KEY key, MASK mask); | 123 | virtual BOOL handleKeyHere(KEY key, MASK mask); |
123 | 124 | ||
@@ -155,7 +156,7 @@ public: | |||
155 | static void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data); | 156 | static void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data); |
156 | static void onShowFolders(LLUICtrl* ctrl, void* userdata); | 157 | static void onShowFolders(LLUICtrl* ctrl, void* userdata); |
157 | static void onApplyImmediateCheck(LLUICtrl* ctrl, void* userdata); | 158 | static void onApplyImmediateCheck(LLUICtrl* ctrl, void* userdata); |
158 | static void onSearchEdit(const LLString& search_string, void* user_data ); | 159 | static void onSearchEdit(const std::string& search_string, void* user_data ); |
159 | static void onTextureSelect( const LLTextureEntry& te, void *data ); | 160 | static void onTextureSelect( const LLTextureEntry& te, void *data ); |
160 | 161 | ||
161 | protected: | 162 | protected: |
@@ -173,7 +174,7 @@ protected: | |||
173 | LLTextBox* mTentativeLabel; | 174 | LLTextBox* mTentativeLabel; |
174 | LLTextBox* mResolutionLabel; | 175 | LLTextBox* mResolutionLabel; |
175 | 176 | ||
176 | LLString mPendingName; | 177 | std::string mPendingName; |
177 | BOOL mIsDirty; | 178 | BOOL mIsDirty; |
178 | BOOL mActive; | 179 | BOOL mActive; |
179 | 180 | ||
@@ -195,9 +196,9 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( | |||
195 | PermissionMask non_immediate_filter_perm_mask, | 196 | PermissionMask non_immediate_filter_perm_mask, |
196 | BOOL can_apply_immediately) | 197 | BOOL can_apply_immediately) |
197 | : | 198 | : |
198 | LLFloater( "texture picker", | 199 | LLFloater( std::string("texture picker"), |
199 | rect, | 200 | rect, |
200 | LLString( "Pick: " ) + label, | 201 | std::string( "Pick: " ) + label, |
201 | TRUE, | 202 | TRUE, |
202 | TEX_PICKER_MIN_WIDTH, TEX_PICKER_MIN_HEIGHT ), | 203 | TEX_PICKER_MIN_WIDTH, TEX_PICKER_MIN_HEIGHT ), |
203 | mOwner( owner ), | 204 | mOwner( owner ), |
@@ -345,12 +346,12 @@ void LLFloaterTexturePicker::updateImageStats() | |||
345 | //RN: have we received header data for this image? | 346 | //RN: have we received header data for this image? |
346 | if (mTexturep->getWidth(0) > 0 && mTexturep->getHeight(0) > 0) | 347 | if (mTexturep->getWidth(0) > 0 && mTexturep->getHeight(0) > 0) |
347 | { | 348 | { |
348 | LLString formatted_dims = llformat("%d x %d", mTexturep->getWidth(0),mTexturep->getHeight(0)); | 349 | std::string formatted_dims = llformat("%d x %d", mTexturep->getWidth(0),mTexturep->getHeight(0)); |
349 | mResolutionLabel->setTextArg("[DIMENSIONS]", formatted_dims); | 350 | mResolutionLabel->setTextArg("[DIMENSIONS]", formatted_dims); |
350 | } | 351 | } |
351 | else | 352 | else |
352 | { | 353 | { |
353 | mResolutionLabel->setTextArg("[DIMENSIONS]", LLString("[? x ?]")); | 354 | mResolutionLabel->setTextArg("[DIMENSIONS]", std::string("[? x ?]")); |
354 | } | 355 | } |
355 | } | 356 | } |
356 | } | 357 | } |
@@ -361,7 +362,7 @@ BOOL LLFloaterTexturePicker::handleDragAndDrop( | |||
361 | BOOL drop, | 362 | BOOL drop, |
362 | EDragAndDropType cargo_type, void *cargo_data, | 363 | EDragAndDropType cargo_type, void *cargo_data, |
363 | EAcceptance *accept, | 364 | EAcceptance *accept, |
364 | LLString& tooltip_msg) | 365 | std::string& tooltip_msg) |
365 | { | 366 | { |
366 | BOOL handled = FALSE; | 367 | BOOL handled = FALSE; |
367 | 368 | ||
@@ -815,12 +816,12 @@ void LLFloaterTexturePicker::updateFilterPermMask() | |||
815 | //mInventoryPanel->setFilterPermMask( getFilterPermMask() ); Commented out due to no-copy texture loss. | 816 | //mInventoryPanel->setFilterPermMask( getFilterPermMask() ); Commented out due to no-copy texture loss. |
816 | } | 817 | } |
817 | 818 | ||
818 | void LLFloaterTexturePicker::onSearchEdit(const LLString& search_string, void* user_data ) | 819 | void LLFloaterTexturePicker::onSearchEdit(const std::string& search_string, void* user_data ) |
819 | { | 820 | { |
820 | LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data; | 821 | LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data; |
821 | 822 | ||
822 | std::string upper_case_search_string = search_string; | 823 | std::string upper_case_search_string = search_string; |
823 | LLString::toUpper(upper_case_search_string); | 824 | LLStringUtil::toUpper(upper_case_search_string); |
824 | 825 | ||
825 | if (upper_case_search_string.empty()) | 826 | if (upper_case_search_string.empty()) |
826 | { | 827 | { |
@@ -908,7 +909,8 @@ LLTextureCtrl::LLTextureCtrl( | |||
908 | mCanApplyImmediately( FALSE ), | 909 | mCanApplyImmediately( FALSE ), |
909 | mNeedsRawImageData( FALSE ), | 910 | mNeedsRawImageData( FALSE ), |
910 | mValid( TRUE ), | 911 | mValid( TRUE ), |
911 | mDirty( FALSE ) | 912 | mDirty( FALSE ), |
913 | mShowLoadingPlaceholder( TRUE ) | ||
912 | { | 914 | { |
913 | mCaption = new LLTextBox( label, | 915 | mCaption = new LLTextBox( label, |
914 | LLRect( 0, BTN_HEIGHT_SMALL, getRect().getWidth(), 0 ), | 916 | LLRect( 0, BTN_HEIGHT_SMALL, getRect().getWidth(), 0 ), |
@@ -922,11 +924,11 @@ LLTextureCtrl::LLTextureCtrl( | |||
922 | S32 image_middle = (image_top + image_bottom) / 2; | 924 | S32 image_middle = (image_top + image_bottom) / 2; |
923 | S32 line_height = llround(LLFontGL::sSansSerifSmall->getLineHeight()); | 925 | S32 line_height = llround(LLFontGL::sSansSerifSmall->getLineHeight()); |
924 | 926 | ||
925 | mTentativeLabel = new LLTextBox( "Multiple", | 927 | mTentativeLabel = new LLTextBox( std::string("Multiple"), |
926 | LLRect( | 928 | LLRect( |
927 | 0, image_middle + line_height / 2, | 929 | 0, image_middle + line_height / 2, |
928 | getRect().getWidth(), image_middle - line_height / 2 ), | 930 | getRect().getWidth(), image_middle - line_height / 2 ), |
929 | "Multiple", | 931 | std::string("Multiple"), |
930 | LLFontGL::sSansSerifSmall ); | 932 | LLFontGL::sSansSerifSmall ); |
931 | mTentativeLabel->setHAlign( LLFontGL::HCENTER ); | 933 | mTentativeLabel->setHAlign( LLFontGL::HCENTER ); |
932 | mTentativeLabel->setFollowsAll(); | 934 | mTentativeLabel->setFollowsAll(); |
@@ -934,11 +936,12 @@ LLTextureCtrl::LLTextureCtrl( | |||
934 | 936 | ||
935 | LLRect border_rect(0, getRect().getHeight(), getRect().getWidth(), 0); | 937 | LLRect border_rect(0, getRect().getHeight(), getRect().getWidth(), 0); |
936 | border_rect.mBottom += BTN_HEIGHT_SMALL; | 938 | border_rect.mBottom += BTN_HEIGHT_SMALL; |
937 | mBorder = new LLViewBorder("border", border_rect, LLViewBorder::BEVEL_IN); | 939 | mBorder = new LLViewBorder(std::string("border"), border_rect, LLViewBorder::BEVEL_IN); |
938 | mBorder->setFollowsAll(); | 940 | mBorder->setFollowsAll(); |
939 | addChild(mBorder); | 941 | addChild(mBorder); |
940 | 942 | ||
941 | setEnabled(TRUE); // for the tooltip | 943 | setEnabled(TRUE); // for the tooltip |
944 | mLoadingPlaceholderString = LLTrans::getString("texture_loading"); | ||
942 | } | 945 | } |
943 | 946 | ||
944 | 947 | ||
@@ -965,22 +968,22 @@ LLXMLNodePtr LLTextureCtrl::getXML(bool save_children) const | |||
965 | 968 | ||
966 | LLView* LLTextureCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) | 969 | LLView* LLTextureCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) |
967 | { | 970 | { |
968 | LLString name("texture_picker"); | 971 | std::string name("texture_picker"); |
969 | node->getAttributeString("name", name); | 972 | node->getAttributeString("name", name); |
970 | 973 | ||
971 | LLRect rect; | 974 | LLRect rect; |
972 | createRect(node, rect, parent); | 975 | createRect(node, rect, parent); |
973 | 976 | ||
974 | LLString label; | 977 | std::string label; |
975 | node->getAttributeString("label", label); | 978 | node->getAttributeString("label", label); |
976 | 979 | ||
977 | LLString image_id(""); | 980 | std::string image_id(""); |
978 | node->getAttributeString("image", image_id); | 981 | node->getAttributeString("image", image_id); |
979 | 982 | ||
980 | LLString default_image_id(""); | 983 | std::string default_image_id(""); |
981 | node->getAttributeString("default_image", default_image_id); | 984 | node->getAttributeString("default_image", default_image_id); |
982 | 985 | ||
983 | LLString default_image_name("Default"); | 986 | std::string default_image_name("Default"); |
984 | node->getAttributeString("default_image_name", default_image_name); | 987 | node->getAttributeString("default_image_name", default_image_name); |
985 | 988 | ||
986 | BOOL allow_no_texture = FALSE; | 989 | BOOL allow_no_texture = FALSE; |
@@ -1009,7 +1012,12 @@ LLView* LLTextureCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactor | |||
1009 | return texture_picker; | 1012 | return texture_picker; |
1010 | } | 1013 | } |
1011 | 1014 | ||
1012 | void LLTextureCtrl::setCaption(const LLString& caption) | 1015 | void LLTextureCtrl::setShowLoadingPlaceholder(BOOL showLoadingPlaceholder) |
1016 | { | ||
1017 | mShowLoadingPlaceholder = showLoadingPlaceholder; | ||
1018 | } | ||
1019 | |||
1020 | void LLTextureCtrl::setCaption(const std::string& caption) | ||
1013 | { | 1021 | { |
1014 | mCaption->setText( caption ); | 1022 | mCaption->setText( caption ); |
1015 | } | 1023 | } |
@@ -1038,13 +1046,13 @@ void LLTextureCtrl::setEnabled( BOOL enabled ) | |||
1038 | LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); | 1046 | LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); |
1039 | if( enabled ) | 1047 | if( enabled ) |
1040 | { | 1048 | { |
1041 | LLString tooltip; | 1049 | std::string tooltip; |
1042 | if (floaterp) tooltip = floaterp->getUIString("choose_picture"); | 1050 | if (floaterp) tooltip = floaterp->getUIString("choose_picture"); |
1043 | setToolTip( tooltip ); | 1051 | setToolTip( tooltip ); |
1044 | } | 1052 | } |
1045 | else | 1053 | else |
1046 | { | 1054 | { |
1047 | setToolTip( LLString() ); | 1055 | setToolTip( std::string() ); |
1048 | // *TODO: would be better to keep floater open and show | 1056 | // *TODO: would be better to keep floater open and show |
1049 | // disabled state. | 1057 | // disabled state. |
1050 | closeFloater(); | 1058 | closeFloater(); |
@@ -1092,7 +1100,7 @@ void LLTextureCtrl::clear() | |||
1092 | setImageAssetID(LLUUID::null); | 1100 | setImageAssetID(LLUUID::null); |
1093 | } | 1101 | } |
1094 | 1102 | ||
1095 | void LLTextureCtrl::setLabel(const LLString& label) | 1103 | void LLTextureCtrl::setLabel(const std::string& label) |
1096 | { | 1104 | { |
1097 | mLabel = label; | 1105 | mLabel = label; |
1098 | mCaption->setText(label); | 1106 | mCaption->setText(label); |
@@ -1243,7 +1251,7 @@ void LLTextureCtrl::setImageAssetID( const LLUUID& asset_id ) | |||
1243 | BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, | 1251 | BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, |
1244 | BOOL drop, EDragAndDropType cargo_type, void *cargo_data, | 1252 | BOOL drop, EDragAndDropType cargo_type, void *cargo_data, |
1245 | EAcceptance *accept, | 1253 | EAcceptance *accept, |
1246 | LLString& tooltip_msg) | 1254 | std::string& tooltip_msg) |
1247 | { | 1255 | { |
1248 | BOOL handled = FALSE; | 1256 | BOOL handled = FALSE; |
1249 | 1257 | ||
@@ -1318,6 +1326,26 @@ void LLTextureCtrl::draw() | |||
1318 | } | 1326 | } |
1319 | 1327 | ||
1320 | mTentativeLabel->setVisible( !mTexturep.isNull() && getTentative() ); | 1328 | mTentativeLabel->setVisible( !mTexturep.isNull() && getTentative() ); |
1329 | |||
1330 | |||
1331 | // Show "Loading..." string on the top left corner while this texture is loading. | ||
1332 | // Using the discard level, do not show the string if the texture is almost but not | ||
1333 | // fully loaded. | ||
1334 | if ( mTexturep.notNull() && | ||
1335 | (mShowLoadingPlaceholder == TRUE) && | ||
1336 | (mTexturep->getDiscardLevel() != 1) && | ||
1337 | (mTexturep->getDiscardLevel() != 0)) | ||
1338 | { | ||
1339 | LLFontGL* font = LLFontGL::sSansSerifBig; | ||
1340 | font->renderUTF8( | ||
1341 | mLoadingPlaceholderString, 0, | ||
1342 | llfloor(interior.mLeft+10), | ||
1343 | llfloor(interior.mTop-20), | ||
1344 | LLColor4::white, | ||
1345 | LLFontGL::LEFT, | ||
1346 | LLFontGL::BASELINE, | ||
1347 | LLFontGL::DROP_SHADOW); | ||
1348 | } | ||
1321 | 1349 | ||
1322 | LLUICtrl::draw(); | 1350 | LLUICtrl::draw(); |
1323 | } | 1351 | } |
@@ -1411,7 +1439,7 @@ protected: | |||
1411 | LLToolTexEyedropper::LLToolTexEyedropper( | 1439 | LLToolTexEyedropper::LLToolTexEyedropper( |
1412 | void (*callback)(const LLUUID& obj_id, const LLUUID& image_id, void* userdata ), | 1440 | void (*callback)(const LLUUID& obj_id, const LLUUID& image_id, void* userdata ), |
1413 | void* userdata ) | 1441 | void* userdata ) |
1414 | : LLTool("texeyedropper"), | 1442 | : LLTool(std::string("texeyedropper")), |
1415 | mCallback( callback ), | 1443 | mCallback( callback ), |
1416 | mCallbackUserData( userdata ) | 1444 | mCallbackUserData( userdata ) |
1417 | { | 1445 | { |
@@ -1424,13 +1452,15 @@ LLToolTexEyedropper::~LLToolTexEyedropper() | |||
1424 | 1452 | ||
1425 | BOOL LLToolTexEyedropper::handleMouseDown(S32 x, S32 y, MASK mask) | 1453 | BOOL LLToolTexEyedropper::handleMouseDown(S32 x, S32 y, MASK mask) |
1426 | { | 1454 | { |
1427 | LLViewerObject* hit_obj = gViewerWindow->lastObjectHit(); | 1455 | // this will affect framerate on mouse down |
1456 | const LLPickInfo& pick = gViewerWindow->pickImmediate(x, y, FALSE); | ||
1457 | LLViewerObject* hit_obj = pick.getObject(); | ||
1428 | if (hit_obj && | 1458 | if (hit_obj && |
1429 | !hit_obj->isAvatar()) | 1459 | !hit_obj->isAvatar()) |
1430 | { | 1460 | { |
1431 | if( (0 <= gLastHitObjectFace) && (gLastHitObjectFace < hit_obj->getNumTEs()) ) | 1461 | if( (0 <= pick.mObjectFace) && (pick.mObjectFace < hit_obj->getNumTEs()) ) |
1432 | { | 1462 | { |
1433 | LLViewerImage* image = hit_obj->getTEImage( gLastHitObjectFace ); | 1463 | LLViewerImage* image = hit_obj->getTEImage( pick.mObjectFace ); |
1434 | if( image ) | 1464 | if( image ) |
1435 | { | 1465 | { |
1436 | if( mCallback ) | 1466 | if( mCallback ) |