diff options
153 files changed, 3264 insertions, 3466 deletions
diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h index 0ed22f81f7..44fb6d0833 100644 --- a/indra/llcharacter/llcharacter.h +++ b/indra/llcharacter/llcharacter.h @@ -108,7 +108,7 @@ public: // updates all visual parameters for this character virtual void updateVisualParams(); - virtual void addDebugText( const char* text ) = 0; + virtual void addDebugText( const std::string& text ) = 0; virtual const LLUUID& getID() = 0; //------------------------------------------------------------------------- diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index 0aeefb1a21..7c8a7160e7 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -29,7 +29,7 @@ // Static Definitions //----------------------------------------------------------------------------- LLVFS* LLKeyframeMotion::sVFS = NULL; -LLKeyframeDataCache::LLKeyframeDataMap LLKeyframeDataCache::sKeyframeDataMap; +LLKeyframeDataCache::keyframe_data_map_t LLKeyframeDataCache::sKeyframeDataMap; //----------------------------------------------------------------------------- // Globals @@ -45,8 +45,20 @@ static F32 MIN_ACCELERATION_SQUARED = 0.0005f * 0.0005f; static F32 MAX_CONSTRAINTS = 10; //----------------------------------------------------------------------------- -// JointMotionList::dumpDiagInfo() +// JointMotionList //----------------------------------------------------------------------------- +LLKeyframeMotion::JointMotionList::JointMotionList() + : mNumJointMotions(0), + mJointMotionArray(NULL) +{ +} + +LLKeyframeMotion::JointMotionList::~JointMotionList() +{ + for_each(mConstraints.begin(), mConstraints.end(), DeletePointer()); + delete [] mJointMotionArray; +} + U32 LLKeyframeMotion::JointMotionList::dumpDiagInfo() { S32 total_size = sizeof(JointMotionList); @@ -415,7 +427,7 @@ LLKeyframeMotion::~LLKeyframeMotion() { delete [] mJointStates; } - mConstraints.deleteAllData(); + for_each(mConstraints.begin(), mConstraints.end(), DeletePointer()); } //----------------------------------------------------------------------------- @@ -550,8 +562,7 @@ LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *charact BOOL LLKeyframeMotion::setupPose() { // add all valid joint states to the pose - U32 jm; - for (jm=0; jm<mJointMotionList->mNumJointMotions; jm++) + for (U32 jm=0; jm<mJointMotionList->mNumJointMotions; jm++) { if ( mJointStates[jm].getJoint() ) { @@ -560,16 +571,16 @@ BOOL LLKeyframeMotion::setupPose() } // initialize joint constraints - for (JointConstraintSharedData* shared_constraintp = mJointMotionList->mConstraints.getFirstData(); - shared_constraintp; - shared_constraintp = mJointMotionList->mConstraints.getNextData()) - { - JointConstraint* constraintp = new JointConstraint(shared_constraintp); - initializeConstraint(constraintp); - mConstraints.addData(constraintp); - } + for (JointMotionList::constraint_list_t::iterator iter = mJointMotionList->mConstraints.begin(); + iter != mJointMotionList->mConstraints.end(); ++iter) + { + JointConstraintSharedData* shared_constraintp = *iter; + JointConstraint* constraintp = new JointConstraint(shared_constraintp); + initializeConstraint(constraintp); + mConstraints.push_front(constraintp); + } - if (mJointMotionList->mConstraints.getLength()) + if (mJointMotionList->mConstraints.size()) { mPelvisp = mCharacter->getJoint("mPelvis"); if (!mPelvisp) @@ -692,21 +703,21 @@ void LLKeyframeMotion::applyConstraints(F32 time, U8* joint_mask) if (mCharacter->getSkeletonSerialNum() != mLastSkeletonSerialNum) { mLastSkeletonSerialNum = mCharacter->getSkeletonSerialNum(); - for (JointConstraint* constraintp = mConstraints.getFirstData(); - constraintp; - constraintp = mConstraints.getNextData()) - { - initializeConstraint(constraintp); - } + for (constraint_list_t::iterator iter = mConstraints.begin(); + iter != mConstraints.end(); ++iter) + { + JointConstraint* constraintp = *iter; + initializeConstraint(constraintp); + } } // apply constraints - for (JointConstraint* constraintp = mConstraints.getFirstData(); - constraintp; - constraintp = mConstraints.getNextData()) - { - applyConstraint(constraintp, time, joint_mask); - } + for (constraint_list_t::iterator iter = mConstraints.begin(); + iter != mConstraints.end(); ++iter) + { + JointConstraint* constraintp = *iter; + applyConstraint(constraintp, time, joint_mask); + } } //----------------------------------------------------------------------------- @@ -714,12 +725,12 @@ void LLKeyframeMotion::applyConstraints(F32 time, U8* joint_mask) //----------------------------------------------------------------------------- void LLKeyframeMotion::onDeactivate() { - for (JointConstraint* constraintp = mConstraints.getFirstData(); - constraintp; - constraintp = mConstraints.getNextData()) - { - deactivateConstraint(constraintp); - } + for (constraint_list_t::iterator iter = mConstraints.begin(); + iter != mConstraints.end(); ++iter) + { + JointConstraint* constraintp = *iter; + deactivateConstraint(constraintp); + } } //----------------------------------------------------------------------------- @@ -1586,7 +1597,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) return FALSE; } - mJointMotionList->mConstraints.addData(constraintp); + mJointMotionList->mConstraints.push_front(constraintp); constraintp->mJointStateIndices = new S32[constraintp->mChainLength + 1]; @@ -1694,10 +1705,19 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const } } - success &= dp.packS32(mJointMotionList->mConstraints.getLength(), "num_constraints"); - for (JointConstraintSharedData* shared_constraintp = mJointMotionList->mConstraints.getFirstData(); - shared_constraintp; - shared_constraintp = mJointMotionList->mConstraints.getNextData()) + success &= dp.packS32(mJointMotionList->mConstraints.size(), "num_constraints"); + for (JointMotionList::constraint_list_t::iterator iter = mJointMotionList->mConstraints.begin(); + iter != mJointMotionList->mConstraints.end(); ++iter) + { + JointConstraintSharedData* shared_constraintp = *iter; + success &= dp.packU8(shared_constraintp->mChainLength, "chain_length"); + success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type"); + char volume_name[16]; /* Flawfinder: ignore */ + snprintf(volume_name, sizeof(volume_name), "%s", /* Flawfinder: ignore */ + mCharacter->findCollisionVolume(shared_constraintp->mSourceConstraintVolume)->getName().c_str()); + success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "source_volume"); + success &= dp.packVector3(shared_constraintp->mSourceConstraintOffset, "source_offset"); + if (shared_constraintp->mConstraintTargetType == TYPE_GROUND) { success &= dp.packU8(shared_constraintp->mChainLength, "chain_length"); success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type"); @@ -1708,7 +1728,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const success &= dp.packVector3(shared_constraintp->mSourceConstraintOffset, "source_offset"); if (shared_constraintp->mConstraintTargetType == TYPE_GROUND) { - snprintf(volume_name,sizeof(volume_name), "%s", "GROUND"); /* Flawfinder: ignore */ + snprintf(volume_name,sizeof(volume_name), "%s", "GROUND"); /* Flawfinder: ignore */ } else { @@ -1723,6 +1743,19 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const success &= dp.packF32(shared_constraintp->mEaseOutStartTime, "ease_out_start"); success &= dp.packF32(shared_constraintp->mEaseOutStopTime, "ease_out_stop"); } + else + { + snprintf(volume_name, sizeof(volume_name),"%s", /* Flawfinder: ignore */ + mCharacter->findCollisionVolume(shared_constraintp->mTargetConstraintVolume)->getName().c_str()); + } + success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "target_volume"); + success &= dp.packVector3(shared_constraintp->mTargetConstraintOffset, "target_offset"); + success &= dp.packVector3(shared_constraintp->mTargetConstraintDir, "target_dir"); + success &= dp.packF32(shared_constraintp->mEaseInStartTime, "ease_in_start"); + success &= dp.packF32(shared_constraintp->mEaseInStopTime, "ease_in_stop"); + success &= dp.packF32(shared_constraintp->mEaseOutStartTime, "ease_out_start"); + success &= dp.packF32(shared_constraintp->mEaseOutStopTime, "ease_out_stop"); + } return success; } @@ -1813,7 +1846,8 @@ void LLKeyframeMotion::setEaseOut(F32 ease_in) //----------------------------------------------------------------------------- void LLKeyframeMotion::flushKeyframeCache() { - LLKeyframeDataCache::clear(); + // TODO: Make this safe to do +// LLKeyframeDataCache::clear(); } //----------------------------------------------------------------------------- @@ -2022,8 +2056,8 @@ void LLKeyframeDataCache::dumpDiagInfo() llinfos << "-----------------------------------------------------" << llendl; // print each loaded mesh, and it's memory usage - LLKeyframeDataMap::iterator map_it; - for (map_it = sKeyframeDataMap.begin(); map_it != sKeyframeDataMap.end(); ++map_it) + for (keyframe_data_map_t::iterator map_it = sKeyframeDataMap.begin(); + map_it != sKeyframeDataMap.end(); ++map_it) { U32 joint_motion_kb; @@ -2057,12 +2091,12 @@ void LLKeyframeDataCache::addKeyframeData(const LLUUID& id, LLKeyframeMotion::Jo //-------------------------------------------------------------------- void LLKeyframeDataCache::removeKeyframeData(const LLUUID& id) { - LLKeyframeMotion::JointMotionList* joint_motion_listp = getKeyframeData(id); - if (joint_motion_listp) + keyframe_data_map_t::iterator found_data = sKeyframeDataMap.find(id); + if (found_data != sKeyframeDataMap.end()) { - delete joint_motion_listp; + delete found_data->second; + sKeyframeDataMap.erase(found_data); } - sKeyframeDataMap.erase(id); } //-------------------------------------------------------------------- @@ -2070,7 +2104,7 @@ void LLKeyframeDataCache::removeKeyframeData(const LLUUID& id) //-------------------------------------------------------------------- LLKeyframeMotion::JointMotionList* LLKeyframeDataCache::getKeyframeData(const LLUUID& id) { - LLKeyframeDataMap::iterator found_data = sKeyframeDataMap.find(id); + keyframe_data_map_t::iterator found_data = sKeyframeDataMap.find(id); if (found_data == sKeyframeDataMap.end()) { return NULL; diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index daa501af89..9b8c04ac92 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -16,7 +16,6 @@ #include <string> #include "llassetstorage.h" -#include "llassoclist.h" #include "llbboxlocal.h" #include "llhandmotion.h" #include "lljointstate.h" @@ -386,11 +385,12 @@ public: LLJoint::JointPriority mBasePriority; LLHandMotion::eHandPose mHandPose; LLJoint::JointPriority mMaxPriority; - LLLinkedList<JointConstraintSharedData> mConstraints; + typedef std::list<JointConstraintSharedData*> constraint_list_t; + constraint_list_t mConstraints; LLBBoxLocal mPelvisBBox; public: - JointMotionList() : mNumJointMotions(0), mJointMotionArray(NULL) {}; - ~JointMotionList() { mConstraints.deleteAllData(); delete [] mJointMotionArray; } + JointMotionList(); + ~JointMotionList(); U32 dumpDiagInfo(); }; @@ -406,7 +406,8 @@ protected: LLJoint* mPelvisp; LLCharacter* mCharacter; std::string mEmoteName; - LLLinkedList<JointConstraint> mConstraints; + typedef std::list<JointConstraint*> constraint_list_t; + constraint_list_t mConstraints; U32 mLastSkeletonSerialNum; F32 mLastUpdateTime; F32 mLastLoopedTime; @@ -420,8 +421,8 @@ public: LLKeyframeDataCache(){}; ~LLKeyframeDataCache(); - typedef std::map<LLUUID, class LLKeyframeMotion::JointMotionList*> LLKeyframeDataMap; - static LLKeyframeDataMap sKeyframeDataMap; + typedef std::map<LLUUID, class LLKeyframeMotion::JointMotionList*> keyframe_data_map_t; + static keyframe_data_map_t sKeyframeDataMap; static void addKeyframeData(const LLUUID& id, LLKeyframeMotion::JointMotionList*); static LLKeyframeMotion::JointMotionList* getKeyframeData(const LLUUID& id); diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp index 2856803c4b..c0b072c357 100644 --- a/indra/llcharacter/llmotioncontroller.cpp +++ b/indra/llcharacter/llmotioncontroller.cpp @@ -161,9 +161,9 @@ LLMotionController::~LLMotionController() //----------------------------------------------------------------------------- void LLMotionController::deleteAllMotions() { - mLoadingMotions.removeAllNodes(); + mLoadingMotions.clear(); mLoadedMotions.clear(); - mActiveMotions.removeAllNodes(); + mActiveMotions.clear(); for_each(mAllMotions.begin(), mAllMotions.end(), DeletePairedPointer()); mAllMotions.clear(); @@ -215,16 +215,16 @@ void LLMotionController::setTimeStep(F32 step) if (step != 0.f) { // make sure timestamps conform to new quantum - for( LLMotion* motionp = mActiveMotions.getFirstData(); - motionp != NULL; - motionp = mActiveMotions.getNextData() ) - { - motionp->mActivationTimestamp = (F32)llfloor(motionp->mActivationTimestamp / step) * step; - BOOL stopped = motionp->isStopped(); - motionp->setStopTime((F32)llfloor(motionp->getStopTime() / step) * step); - motionp->setStopped(stopped); - motionp->mSendStopTimestamp = (F32)llfloor(motionp->mSendStopTimestamp / step) * step; - } + for (motion_list_t::iterator iter = mActiveMotions.begin(); + iter != mActiveMotions.end(); ++iter) + { + LLMotion* motionp = *iter; + motionp->mActivationTimestamp = (F32)llfloor(motionp->mActivationTimestamp / step) * step; + BOOL stopped = motionp->isStopped(); + motionp->setStopTime((F32)llfloor(motionp->getStopTime() / step) * step); + motionp->setStopped(stopped); + motionp->mSendStopTimestamp = (F32)llfloor(motionp->mSendStopTimestamp / step) * step; + } } } @@ -238,23 +238,6 @@ void LLMotionController::setTimeFactor(F32 time_factor) } //----------------------------------------------------------------------------- -// getFirstActiveMotion() -//----------------------------------------------------------------------------- -LLMotion* LLMotionController::getFirstActiveMotion() -{ - return mActiveMotions.getFirstData(); -} - -//----------------------------------------------------------------------------- -// getNextActiveMotion() -//----------------------------------------------------------------------------- -LLMotion* LLMotionController::getNextActiveMotion() -{ - return mActiveMotions.getNextData(); -} - - -//----------------------------------------------------------------------------- // setCharacter() //----------------------------------------------------------------------------- void LLMotionController::setCharacter(LLCharacter *character) @@ -281,17 +264,9 @@ void LLMotionController::removeMotion( const LLUUID& id) { stopMotionLocally(id, TRUE); - mLoadingMotions.deleteData(motionp); - std::deque<LLMotion*>::iterator motion_it; - for (motion_it = mLoadedMotions.begin(); motion_it != mLoadedMotions.end(); ++motion_it) - { - if(*motion_it == motionp) - { - mLoadedMotions.erase(motion_it); - break; - } - } - mActiveMotions.deleteData(motionp); + mLoadingMotions.erase(motionp); + mLoadedMotions.remove(motionp); + mActiveMotions.remove(motionp); mAllMotions.erase(id); delete motionp; } @@ -332,7 +307,7 @@ LLMotion* LLMotionController::createMotion( const LLUUID &id ) delete motion; return NULL; case LLMotion::STATUS_HOLD: - mLoadingMotions.addData(motion); + mLoadingMotions.insert(motion); break; case LLMotion::STATUS_SUCCESS: // add motion to our list @@ -451,10 +426,10 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty memset(&last_joint_signature, 0, sizeof(U8) * LL_CHARACTER_MAX_JOINTS); // iterate through active motions in chronological order - for(LLMotion* motionp = mActiveMotions.getFirstData(); - motionp != NULL; - motionp = mActiveMotions.getNextData()) + for (motion_list_t::iterator iter = mActiveMotions.begin(); + iter != mActiveMotions.end(); ++iter) { + LLMotion* motionp = *iter; if (motionp->getBlendType() != anim_type) { continue; @@ -468,9 +443,8 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty } else { - S32 i; // NUM_JOINT_SIGNATURE_STRIDES should be multiple of 4 - for (i = 0; i < NUM_JOINT_SIGNATURE_STRIDES; i++) + for (S32 i = 0; i < NUM_JOINT_SIGNATURE_STRIDES; i++) { U32 *current_signature = (U32*)&(mJointSignature[0][i * 4]); U32 test_signature = *(U32*)&(motionp->mJointSignature[0][i * 4]); @@ -726,16 +700,15 @@ void LLMotionController::updateMotion() } // query pending motions for completion - LLMotion* motionp; - - for ( motionp = mLoadingMotions.getFirstData(); - motionp != NULL; - motionp = mLoadingMotions.getNextData() ) + for (motion_set_t::iterator iter = mLoadingMotions.begin(); + iter != mLoadingMotions.end(); ) { + motion_set_t::iterator curiter = iter++; + LLMotion* motionp = *curiter; LLMotion::LLMotionInitStatus status = motionp->onInitialize(mCharacter); if (status == LLMotion::STATUS_SUCCESS) { - mLoadingMotions.removeCurrentData(); + mLoadingMotions.erase(curiter); // add motion to our loaded motion list addLoadedMotion(motionp); // this motion should be playing @@ -748,7 +721,7 @@ void LLMotionController::updateMotion() { llinfos << "Motion " << motionp->getID() << " init failed." << llendl; sRegistry.markBad(motionp->getID()); - mLoadingMotions.removeCurrentData(); + mLoadingMotions.erase(curiter); mAllMotions.erase(motionp->getID()); delete motionp; } @@ -785,7 +758,7 @@ void LLMotionController::updateMotion() //----------------------------------------------------------------------------- BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) { - if (mLoadingMotions.checkData(motion)) + if (mLoadingMotions.find(motion) != mLoadingMotions.end()) { // we want to start this motion, but we can't yet, so flag it as started motion->setStopped(FALSE); @@ -816,7 +789,7 @@ BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) motion->mSendStopTimestamp = F32_MAX; } - mActiveMotions.addData(motion); + mActiveMotions.push_front(motion); motion->activate(); motion->onUpdate(0.f, mJointSignature[1]); @@ -830,7 +803,7 @@ BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) BOOL LLMotionController::deactivateMotion(LLMotion *motion) { motion->deactivate(); - mActiveMotions.removeData(motion); + mActiveMotions.remove(motion); return TRUE; } @@ -838,22 +811,17 @@ BOOL LLMotionController::deactivateMotion(LLMotion *motion) //----------------------------------------------------------------------------- // isMotionActive() //----------------------------------------------------------------------------- -BOOL LLMotionController::isMotionActive(LLMotion *motion) +bool LLMotionController::isMotionActive(LLMotion *motion) { - if (motion && motion->isActive()) - { - return TRUE; - } - - return FALSE; + return (motion && motion->isActive()); } //----------------------------------------------------------------------------- // isMotionLoading() //----------------------------------------------------------------------------- -BOOL LLMotionController::isMotionLoading(LLMotion* motion) +bool LLMotionController::isMotionLoading(LLMotion* motion) { - return mLoadingMotions.checkData(motion); + return (mLoadingMotions.find(motion) != mLoadingMotions.end()); } @@ -871,15 +839,14 @@ LLMotion *LLMotionController::findMotion(const LLUUID& id) //----------------------------------------------------------------------------- void LLMotionController::flushAllMotions() { - LLDynamicArray<LLUUID> active_motions; - LLDynamicArray<F32> active_motion_times; - - for (LLMotion* motionp = mActiveMotions.getFirstData(); - motionp; - motionp = mActiveMotions.getNextData()) + std::vector<std::pair<LLUUID,F32> > active_motions; + active_motions.reserve(mActiveMotions.size()); + for (motion_list_t::iterator iter = mActiveMotions.begin(); + iter != mActiveMotions.end(); ++iter) { - active_motions.put(motionp->getID()); - active_motion_times.put(mTime - motionp->mActivationTimestamp); + LLMotion* motionp = *iter; + F32 dtime = mTime - motionp->mActivationTimestamp; + active_motions.push_back(std::make_pair(motionp->getID(),dtime)); motionp->deactivate(); } @@ -891,9 +858,10 @@ void LLMotionController::flushAllMotions() mCharacter->removeAnimationData("Hand Pose"); // restart motions - for (S32 i = 0; i < active_motions.count(); i++) + for (std::vector<std::pair<LLUUID,F32> >::iterator iter = active_motions.begin(); + iter != active_motions.end(); ++iter) { - startMotion(active_motions[i], active_motion_times[i]); + startMotion(iter->first, iter->second); } } diff --git a/indra/llcharacter/llmotioncontroller.h b/indra/llcharacter/llmotioncontroller.h index d43d6d9a8f..a19e704643 100644 --- a/indra/llcharacter/llmotioncontroller.h +++ b/indra/llcharacter/llmotioncontroller.h @@ -16,7 +16,6 @@ #include <map> #include <deque> -#include "linked_lists.h" #include "lluuidhashmap.h" #include "llmotion.h" #include "llpose.h" @@ -90,6 +89,10 @@ protected: class LLMotionController { public: + typedef std::list<LLMotion*> motion_list_t; + typedef std::set<LLMotion*> motion_set_t; + +public: // Constructor LLMotionController(); @@ -145,12 +148,11 @@ public: void setTimeFactor(F32 time_factor); F32 getTimeFactor() { return mTimeFactor; } - LLMotion* getFirstActiveMotion(); - LLMotion* getNextActiveMotion(); + motion_list_t& getActiveMotions() { return mActiveMotions; } //protected: - BOOL isMotionActive( LLMotion *motion ); - BOOL isMotionLoading( LLMotion *motion ); + bool isMotionActive( LLMotion *motion ); + bool isMotionLoading( LLMotion *motion ); LLMotion *findMotion( const LLUUID& id ); protected: @@ -180,9 +182,9 @@ protected: std::map<LLUUID, LLMotion*> mAllMotions; - LLLinkedList<LLMotion> mLoadingMotions; - std::deque<LLMotion*> mLoadedMotions; - LLLinkedList<LLMotion> mActiveMotions; + motion_set_t mLoadingMotions; + motion_list_t mLoadedMotions; + motion_list_t mActiveMotions; LLFrameTimer mTimer; F32 mTime; diff --git a/indra/llcharacter/llpose.cpp b/indra/llcharacter/llpose.cpp index ff56dba585..e1b24d62cb 100644 --- a/indra/llcharacter/llpose.cpp +++ b/indra/llcharacter/llpose.cpp @@ -15,6 +15,7 @@ #include "llmotion.h" #include "llmath.h" +#include "llstl.h" //----------------------------------------------------------------------------- // Static @@ -438,7 +439,7 @@ LLPoseBlender::LLPoseBlender() LLPoseBlender::~LLPoseBlender() { - mJointStateBlenderPool.deleteAllData(); + for_each(mJointStateBlenderPool.begin(), mJointStateBlenderPool.end(), DeletePairedPointer()); } //----------------------------------------------------------------------------- @@ -452,15 +453,16 @@ BOOL LLPoseBlender::addMotion(LLMotion* motion) { LLJoint *jointp = jsp->getJoint(); LLJointStateBlender* joint_blender; - if (!mJointStateBlenderPool.checkData(jointp)) + if (mJointStateBlenderPool.find(jointp) == mJointStateBlenderPool.end()) { // this is the first time we are animating this joint // so create new jointblender and add it to our pool joint_blender = new LLJointStateBlender(); - mJointStateBlenderPool.addData(jointp, joint_blender); - } else + mJointStateBlenderPool[jointp] = joint_blender; + } + else { - joint_blender = mJointStateBlenderPool.getData(jointp); + joint_blender = mJointStateBlenderPool[jointp]; } if (jsp->getPriority() == LLJoint::USE_MOTION_PRIORITY) @@ -473,9 +475,9 @@ BOOL LLPoseBlender::addMotion(LLMotion* motion) } // add it to our list of active blenders - if(!mActiveBlenders.checkData(joint_blender)) + if (std::find(mActiveBlenders.begin(), mActiveBlenders.end(), joint_blender) == mActiveBlenders.end()) { - mActiveBlenders.addData(joint_blender); + mActiveBlenders.push_front(joint_blender); } } return TRUE; @@ -486,15 +488,15 @@ BOOL LLPoseBlender::addMotion(LLMotion* motion) //----------------------------------------------------------------------------- void LLPoseBlender::blendAndApply() { - for (LLJointStateBlender* jsbp = mActiveBlenders.getFirstData(); - jsbp; - jsbp = mActiveBlenders.getNextData()) + for (blender_list_t::iterator iter = mActiveBlenders.begin(); + iter != mActiveBlenders.end(); ++iter) { + LLJointStateBlender* jsbp = *iter; jsbp->blendJointStates(); } // we're done now so there are no more active blenders for this frame - mActiveBlenders.removeAllNodes(); + mActiveBlenders.clear(); } //----------------------------------------------------------------------------- @@ -502,10 +504,10 @@ void LLPoseBlender::blendAndApply() //----------------------------------------------------------------------------- void LLPoseBlender::blendAndCache(BOOL reset_cached_joints) { - for (LLJointStateBlender* jsbp = mActiveBlenders.getFirstData(); - jsbp; - jsbp = mActiveBlenders.getNextData()) + for (blender_list_t::iterator iter = mActiveBlenders.begin(); + iter != mActiveBlenders.end(); ++iter) { + LLJointStateBlender* jsbp = *iter; if (reset_cached_joints) { jsbp->resetCachedJoint(); @@ -519,10 +521,10 @@ void LLPoseBlender::blendAndCache(BOOL reset_cached_joints) //----------------------------------------------------------------------------- void LLPoseBlender::interpolate(F32 u) { - for (LLJointStateBlender* jsbp = mActiveBlenders.getFirstData(); - jsbp; - jsbp = mActiveBlenders.getNextData()) + for (blender_list_t::iterator iter = mActiveBlenders.begin(); + iter != mActiveBlenders.end(); ++iter) { + LLJointStateBlender* jsbp = *iter; jsbp->interpolate(u); } } @@ -532,13 +534,13 @@ void LLPoseBlender::interpolate(F32 u) //----------------------------------------------------------------------------- void LLPoseBlender::clearBlenders() { - for (LLJointStateBlender* jsbp = mActiveBlenders.getFirstData(); - jsbp; - jsbp = mActiveBlenders.getNextData()) + for (blender_list_t::iterator iter = mActiveBlenders.begin(); + iter != mActiveBlenders.end(); ++iter) { + LLJointStateBlender* jsbp = *iter; jsbp->clear(); } - mActiveBlenders.removeAllNodes(); + mActiveBlenders.clear(); } diff --git a/indra/llcharacter/llpose.h b/indra/llcharacter/llpose.h index e286c14e21..5d17bd8458 100644 --- a/indra/llcharacter/llpose.h +++ b/indra/llcharacter/llpose.h @@ -87,8 +87,10 @@ class LLMotion; class LLPoseBlender { protected: - LLMap<LLJoint*,LLJointStateBlender*> mJointStateBlenderPool; - LLLinkedList<LLJointStateBlender> mActiveBlenders; + typedef std::list<LLJointStateBlender*> blender_list_t; + typedef std::map<LLJoint*,LLJointStateBlender*> blender_map_t; + blender_map_t mJointStateBlenderPool; + blender_list_t mActiveBlenders; S32 mNextPoseSlot; LLPose mBlendedPose; diff --git a/indra/llcommon/llframetimer.cpp b/indra/llcommon/llframetimer.cpp index c66410651f..fca2bd2e85 100644 --- a/indra/llcommon/llframetimer.cpp +++ b/indra/llcommon/llframetimer.cpp @@ -33,6 +33,50 @@ void LLFrameTimer::updateFrameTime() sFrameCount++; } +void LLFrameTimer::start() +{ + reset(); + mStarted = TRUE; +} + +void LLFrameTimer::stop() +{ + mStarted = FALSE; +} + +void LLFrameTimer::reset() +{ + mStartTime = sFrameTime; + mExpiry = sFrameTime; +} + +// Don't combine pause/unpause with start/stop +// Useage: +// LLFrameTime foo; // starts automatically +// foo.unpause(); // noop but safe +// foo.pause(); // pauses timer +// foo.unpause() // unpauses +// F32 elapsed = foo.getElapsedTimeF32() // does not include time between pause() and unpause() +// Note: elapsed would also be valid with no unpause() call (= time run until pause() called) +void LLFrameTimer::pause() +{ + if (mStarted) + mStartTime = sFrameTime - mStartTime; // save dtime + mStarted = FALSE; +} + +void LLFrameTimer::unpause() +{ + if (!mStarted) + mStartTime = sFrameTime - mStartTime; // restore dtime + mStarted = TRUE; +} + +void LLFrameTimer::setTimerExpirySec(F32 expiration) +{ + mExpiry = expiration + mStartTime; +} + void LLFrameTimer::setExpiryAt(F64 seconds_since_epoch) { mStartTime = sFrameTime; diff --git a/indra/llcommon/llframetimer.h b/indra/llcommon/llframetimer.h index 05b01e6a72..c7c1c50c7b 100644 --- a/indra/llcommon/llframetimer.h +++ b/indra/llcommon/llframetimer.h @@ -44,8 +44,7 @@ public: return sTotalSeconds; } - // Call this method once per frame to update the current frame - // time. + // Call this method once per frame to update the current frame time. static void updateFrameTime(); static S32 getFrameCount() { return sFrameCount; } @@ -53,10 +52,12 @@ public: static F32 getFrameDeltaTimeF32(); // MANIPULATORS - void start() { reset(); mStarted = TRUE; } - void stop() { mStarted = FALSE; } - void reset() { mStartTime = sFrameTime; mExpiry = sFrameTime; } - void setTimerExpirySec(F32 expiration) { mExpiry = expiration + mStartTime; } + void start(); + void stop(); + void reset(); + void pause(); + void unpause(); + void setTimerExpirySec(F32 expiration); void setExpiryAt(F64 seconds_since_epoch); BOOL checkExpirationAndReset(F32 expiration); F32 getElapsedTimeAndResetF32() { F32 t = F32(sFrameTime - mStartTime); reset(); return t; } @@ -66,7 +67,7 @@ public: // ACCESSORS BOOL hasExpired() const { return (sFrameTime >= mExpiry); } F32 getTimeToExpireF32() const { return (F32)(mExpiry - sFrameTime); } - F32 getElapsedTimeF32() const { return (F32)(sFrameTime - mStartTime); } + F32 getElapsedTimeF32() const { return mStarted ? (F32)(sFrameTime - mStartTime) : (F32)mStartTime; } BOOL getStarted() const { return mStarted; } // return the seconds since epoch when this timer will expire. diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 1063de5a8c..addda19775 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -11,11 +11,6 @@ #include "llmemory.h" #include "llmemtype.h" -// not defining nullfunc will currently crash when trying to use a LLHandle -template< typename _Ty > - const typename LLHandle< _Ty >::NullFunc - LLHandle< _Ty >::sNullFunc = LLHandle< _Ty >::defaultNullFunc; - //---------------------------------------------------------------------------- //static diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index f7f4818740..2a58db659e 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -220,29 +220,28 @@ class LLHandle { public: LLHandle() : - mPointer(sNullFunc()) + mPointer(NULL) { - ref(); } LLHandle(Type* ptr) : - mPointer(nonNull(ptr)) + mPointer(NULL) { - ref(); + assign(ptr); } LLHandle(const LLHandle<Type>& ptr) : - mPointer(ptr.mPointer) + mPointer(NULL) { - ref(); + assign(ptr.mPointer); } // support conversion up the type hierarchy. See Item 45 in Effective C++, 3rd Ed. template<typename Subclass> LLHandle(const LLHandle<Subclass>& ptr) : - mPointer(ptr.get()) + mPointer(NULL) { - ref(); + assign(ptr.get()); } ~LLHandle() @@ -250,47 +249,39 @@ public: unref(); } + const Type* operator->() const { return nonNull(mPointer); } + Type* operator->() { return nonNull(mPointer); } + Type* get() const { return mPointer; } - const Type* operator->() const { return mPointer; } - Type* operator->() { return mPointer; } - const Type& operator*() const { return *mPointer; } - Type& operator*() { return *mPointer; } + // we disallow these operations as they expose our null objects to direct manipulation + // and bypass the reference counting semantics + //const Type& operator*() const { return *nonNull(mPointer); } + //Type& operator*() { return *nonNull(mPointer); } - operator BOOL() const { return (mPointer != sNullFunc()); } - operator bool() const { return (mPointer != sNullFunc()); } - bool operator!() const { return (mPointer == sNullFunc()); } - bool isNull() const { return (mPointer == sNullFunc()); } - bool notNull() const { return (mPointer != sNullFunc()); } + operator BOOL() const { return mPointer != NULL; } + operator bool() const { return mPointer != NULL; } + bool operator!() const { return mPointer == NULL; } + bool isNull() const { return mPointer == NULL; } + bool notNull() const { return mPointer != NULL; } operator Type*() const { return mPointer; } operator const Type*() const { return mPointer; } - bool operator !=(Type* ptr) const { return (mPointer != nonNull(ptr)); } - bool operator ==(Type* ptr) const { return (mPointer == nonNull(ptr)); } + bool operator !=(Type* ptr) const { return (mPointer != ptr); } + bool operator ==(Type* ptr) const { return (mPointer == ptr); } bool operator ==(const LLHandle<Type>& ptr) const { return (mPointer == ptr.mPointer); } bool operator < (const LLHandle<Type>& ptr) const { return (mPointer < ptr.mPointer); } bool operator > (const LLHandle<Type>& ptr) const { return (mPointer > ptr.mPointer); } LLHandle<Type>& operator =(Type* ptr) { - if( mPointer != ptr ) - { - unref(); - mPointer = nonNull(ptr); - ref(); - } - + assign(ptr); return *this; } LLHandle<Type>& operator =(const LLHandle<Type>& ptr) { - if( mPointer != ptr.mPointer ) - { - unref(); - mPointer = ptr.mPointer; - ref(); - } + assign(ptr.mPointer); return *this; } @@ -298,12 +289,7 @@ public: template<typename Subclass> LLHandle<Type>& operator =(const LLHandle<Subclass>& ptr) { - if( mPointer != ptr.get() ) - { - unref(); - mPointer = ptr.get(); - ref(); - } + assign(ptr.get()); return *this; } @@ -325,9 +311,9 @@ protected: if (mPointer) { Type *tempp = mPointer; - mPointer = sNullFunc(); + mPointer = NULL; tempp->unref(); - if (mPointer != sNullFunc()) + if (mPointer != NULL) { llwarns << "Unreference did assignment to non-NULL because of destructor" << llendl; unref(); @@ -335,19 +321,22 @@ protected: } } - static Type* nonNull(Type* ptr) + void assign(Type* ptr) { - return ptr == NULL ? sNullFunc() : ptr; + if( mPointer != ptr ) + { + unref(); + mPointer = ptr; + ref(); + } } - static Type* defaultNullFunc() + static Type* nonNull(Type* ptr) { - llerrs << "No null value provided for LLHandle" << llendl; - return NULL; + return ptr == NULL ? sNullFunc() : ptr; } protected: - Type* mPointer; }; diff --git a/indra/llimage/llimagejpeg.h b/indra/llimage/llimagejpeg.h index 5684e3720f..b068090882 100644 --- a/indra/llimage/llimagejpeg.h +++ b/indra/llimage/llimagejpeg.h @@ -14,7 +14,6 @@ #include "llimage.h" extern "C" { -#include "jpeglib/jinclude.h" #include "jpeglib/jpeglib.h" #include "jpeglib/jerror.h" } diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp index 52549e5d11..1587b6a21c 100644 --- a/indra/llimagej2coj/llimagej2coj.cpp +++ b/indra/llimagej2coj/llimagej2coj.cpp @@ -30,22 +30,23 @@ void fallbackDestroyLLImageJ2CImpl(LLImageJ2CImpl* impl) /** sample error callback expecting a FILE* client object */ -void error_callback(const char *msg, void *client_data) { - FILE *stream = (FILE*)client_data; - fprintf(stream, "[ERROR] %s", msg); +void error_callback(const char* msg, void*) +{ + llwarns << "LLImageJ2CImpl: " << msg << llendl; } /** sample warning callback expecting a FILE* client object */ -void warning_callback(const char *msg, void *client_data) { - FILE *stream = (FILE*)client_data; - fprintf(stream, "[WARNING] %s", msg); +void warning_callback(const char* msg, void*) +{ + llinfos << "LLImageJ2CImpl: " << msg << llendl; } /** sample debug callback expecting no client object */ -void info_callback(const char *msg, void *client_data) { - fprintf(stdout, "[INFO] %s", msg); +void info_callback(const char* msg, void*) +{ + lldebugs << "LLImageJ2CImpl: " << msg << llendl; } diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 9a49f32b7d..b85a0b65e6 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -677,7 +677,7 @@ S32 LLFontGL::render(const LLWString &wstr, if (use_ellipses && halign == LEFT) { // check for too long of a string - if (getWidthF32(wstr.c_str(), 0, max_chars) > scaled_max_pixels) + if (getWidthF32(wstr.c_str(), 0, max_chars) * sScaleX > scaled_max_pixels) { // use four dots for ellipsis width to generate padding const LLWString dots(utf8str_to_wstring(LLString("...."))); diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index ffa9262e21..8e81fec33b 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -46,7 +46,9 @@ LLButton::LLButton( const LLString& name, const LLRect& rect, const LLString& co mMouseUpCallback( NULL ), mHeldDownCallback( NULL ), mGLFont( NULL ), + mMouseDownFrame( 0 ), mHeldDownDelay( 0.5f ), // seconds until held-down callback is called + mHeldDownFrameDelay( 0 ), mImageUnselected( NULL ), mImageSelected( NULL ), mImageHoverSelected( NULL ), @@ -99,7 +101,9 @@ LLButton::LLButton(const LLString& name, const LLRect& rect, mMouseUpCallback( NULL ), mHeldDownCallback( NULL ), mGLFont( NULL ), + mMouseDownFrame( 0 ), mHeldDownDelay( 0.5f ), // seconds until held-down callback is called + mHeldDownFrameDelay( 0 ), mImageUnselected( NULL ), mImageSelected( NULL ), mImageHoverSelected( NULL ), @@ -196,9 +200,9 @@ void LLButton::init(void (*click_callback)(void*), void *callback_data, const LL LLButton::~LLButton() { - if( this == gFocusMgr.getMouseCapture() ) + if( hasMouseCapture() ) { - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); } } @@ -284,7 +288,7 @@ BOOL LLButton::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent ) BOOL LLButton::handleMouseDown(S32 x, S32 y, MASK mask) { // Route future Mouse messages here preemptively. (Release on mouse up.) - gFocusMgr.setMouseCapture( this, &LLButton::onMouseCaptureLost ); + gFocusMgr.setMouseCapture( this ); if (hasTabStop() && !getIsChrome()) { @@ -297,6 +301,7 @@ BOOL LLButton::handleMouseDown(S32 x, S32 y, MASK mask) } mMouseDownTimer.start(); + mMouseDownFrame = LLFrameTimer::getFrameCount(); if (mSoundFlags & MOUSE_DOWN) { @@ -310,19 +315,17 @@ BOOL LLButton::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask) { // We only handle the click if the click both started and ended within us - if( this == gFocusMgr.getMouseCapture() ) + if( hasMouseCapture() ) { + // Always release the mouse + gFocusMgr.setMouseCapture( NULL ); + // Regardless of where mouseup occurs, handle callback if (mMouseUpCallback) { (*mMouseUpCallback)(mCallbackUserData); } - mMouseDownTimer.stop(); - - // Always release the mouse - gFocusMgr.setMouseCapture( NULL, NULL ); - // DO THIS AT THE VERY END to allow the button to be destroyed as a result of being clicked. // If mouseup in the widget, it's been clicked if (pointInView(x, y)) @@ -337,6 +340,9 @@ BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask) (*mClickedCallback)( mCallbackUserData ); } } + + mMouseDownTimer.stop(); + mMouseDownTimer.reset(); } return TRUE; @@ -356,14 +362,14 @@ BOOL LLButton::handleHover(S32 x, S32 y, MASK mask) if (mMouseDownTimer.getStarted() && NULL != mHeldDownCallback) { F32 elapsed = mMouseDownTimer.getElapsedTimeF32(); - if( mHeldDownDelay < elapsed ) + if( mHeldDownDelay <= elapsed && mHeldDownFrameDelay <= LLFrameTimer::getFrameCount() - mMouseDownFrame) { mHeldDownCallback( mCallbackUserData ); } } // We only handle the click if the click both started and ended within us - if( this == gFocusMgr.getMouseCapture() ) + if( hasMouseCapture() ) { handled = TRUE; } @@ -412,7 +418,7 @@ void LLButton::draw() cursor_pos_gl.mY = llround((F32)cursor_pos_gl.mY / LLUI::sGLScaleFactor.mV[VY]); screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &local_mouse_x, &local_mouse_y); - BOOL pressed = pressed_by_keyboard || (this == gFocusMgr.getMouseCapture() && pointInView(local_mouse_x, local_mouse_y)); + BOOL pressed = pressed_by_keyboard || (hasMouseCapture() && pointInView(local_mouse_x, local_mouse_y)); BOOL display_state = FALSE; if( pressed ) @@ -800,11 +806,10 @@ void LLButton::setHoverImages( const LLString& image_name, const LLString& selec setImageHoverSelected(selected_name); } -// static -void LLButton::onMouseCaptureLost( LLMouseHandler* old_captor ) +void LLButton::onMouseCaptureLost() { - LLButton* self = (LLButton*) old_captor; - self->mMouseDownTimer.stop(); + mMouseDownTimer.stop(); + mMouseDownTimer.reset(); } //------------------------------------------------------------------------- diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 1982c2e36f..3dea4434a9 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -75,6 +75,8 @@ public: virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual void draw(); + virtual void onMouseCaptureLost(); + // HACK: "committing" a button is the same as clicking on it. virtual void onCommit(); @@ -85,7 +87,7 @@ public: void setMouseDownCallback( void (*cb)(void *data) ) { mMouseDownCallback = cb; } // mouse down within button void setMouseUpCallback( void (*cb)(void *data) ) { mMouseUpCallback = cb; } // mouse up, EVEN IF NOT IN BUTTON void setHeldDownCallback( void (*cb)(void *data) ) { mHeldDownCallback = cb; } // Mouse button held down and in button - void setHeldDownDelay( F32 seconds) { mHeldDownDelay = seconds; } + void setHeldDownDelay( F32 seconds, S32 frames = 0) { mHeldDownDelay = seconds; mHeldDownFrameDelay = frames; } F32 getHeldDownTime() const { return mMouseDownTimer.getElapsedTimeF32(); } @@ -140,7 +142,6 @@ public: void setBorderEnabled(BOOL b) { mBorderEnabled = b; } static void onHeldDown(void *userdata); // to be called by gIdleCallbacks - static void onMouseCaptureLost(LLMouseHandler* old_captor); void setFixedBorder(S32 width, S32 height) { mFixedWidth = width; mFixedHeight = height; } void setHoverGlowStrength(F32 strength) { mHoverGlowStrength = strength; } @@ -175,7 +176,9 @@ protected: const LLFontGL *mGLFont; LLFrameTimer mMouseDownTimer; + S32 mMouseDownFrame; F32 mHeldDownDelay; // seconds, after which held-down callbacks get called + S32 mHeldDownFrameDelay; // frames, after which held-down callbacks get called LLPointer<LLImageGL> mImageUnselected; LLUIString mUnselectedLabel; diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index 667985c699..e439cd0acc 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -40,7 +40,7 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString ) : LLUICtrl(name, rect, TRUE, commit_callback, callback_userdata, FOLLOWS_LEFT | FOLLOWS_TOP), - mDrawButton(TRUE), + mDrawArrow(TRUE), mTextEntry(NULL), mArrowImage(NULL), mArrowImageWidth(8), @@ -48,8 +48,8 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString mMaxChars(20), mTextEntryTentative(TRUE), mPrearrangeCallback( NULL ), - mTextEntryCallback( NULL ), - mListWidth(list_width) + mListPosition(BELOW), + mTextEntryCallback( NULL ) { // For now, all comboboxes don't take keyboard focus when clicked. // This might change if it is part of a modal dialog. @@ -57,7 +57,7 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString // Revert to standard behavior. When this control's parent is hidden, it needs to // hide this ctrl--which won't just happen automatically since when LLComboBox is - // showing its list, it's also set to TopView. When keyboard focus is cleared all + // showing its list, it's also set to TopCtrl. When keyboard focus is cleared all // controls (including this one) know that they are no longer editing. mKeyboardFocusOnClick = TRUE; @@ -68,7 +68,8 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString // Text label button mButton = new LLSquareButton("comboxbox button", r, label, NULL, LLString::null, - &LLComboBox::onButtonClick, this); + NULL, this); + mButton->setMouseDownCallback(onButtonDown); mButton->setFont(LLFontGL::sSansSerifSmall); mButton->setFollows(FOLLOWS_LEFT | FOLLOWS_BOTTOM | FOLLOWS_RIGHT); mButton->setHAlign( LLFontGL::LEFT ); @@ -91,6 +92,7 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString mList->setVisible(FALSE); mList->setBgWriteableColor( LLColor4(1,1,1,1) ); mList->setCommitOnKeyboardMovement(FALSE); + mList->setFocusChangedCallback(onListFocusChanged); addChild(mList); LLRect border_rect(0, mRect.getHeight(), mRect.getWidth(), 0); @@ -204,111 +206,6 @@ void LLComboBox::setEnabled(BOOL enabled) mButton->setEnabled(enabled); } -// *HACK: these are all hacks to support the fact that the combobox -// has mouse capture so we can hide the list when we don't handle the -// mouse up event -BOOL LLComboBox::handleHover(S32 x, S32 y, MASK mask) -{ - if (mList->getVisible()) - { - S32 local_x, local_y; - LLView::localPointToOtherView(x, y, &local_x, &local_y, mList); - if (mList->pointInView(local_x, local_y)) - { - return mList->handleHover(local_x, local_y, mask); - } - } - return LLUICtrl::handleHover(x, y, mask); -} - -BOOL LLComboBox::handleMouseDown(S32 x, S32 y, MASK mask) -{ - if (mList->getVisible()) - { - S32 local_x, local_y; - LLView::localPointToOtherView(x, y, &local_x, &local_y, mList); - if (mList->pointInView(local_x, local_y)) - { - return mList->handleMouseDown(local_x, local_y, mask); - } - } - BOOL has_focus_now = hasFocus(); - BOOL handled = LLUICtrl::handleMouseDown(x, y, mask); - if (handled && !has_focus_now) - { - onFocusReceived(); - } - - return handled; -} - -BOOL LLComboBox::handleRightMouseDown(S32 x, S32 y, MASK mask) -{ - if (mList->getVisible()) - { - S32 local_x, local_y; - LLView::localPointToOtherView(x, y, &local_x, &local_y, mList); - if (mList->pointInView(local_x, local_y)) - { - return mList->handleRightMouseDown(local_x, local_y, mask); - } - } - return LLUICtrl::handleRightMouseDown(x, y, mask); -} - -BOOL LLComboBox::handleRightMouseUp(S32 x, S32 y, MASK mask) -{ - if (mList->getVisible()) - { - S32 local_x, local_y; - LLView::localPointToOtherView(x, y, &local_x, &local_y, mList); - if (mList->pointInView(local_x, local_y)) - { - return mList->handleRightMouseUp(local_x, local_y, mask); - } - } - return LLUICtrl::handleRightMouseUp(x, y, mask); -} - -BOOL LLComboBox::handleDoubleClick(S32 x, S32 y, MASK mask) -{ - if (mList->getVisible()) - { - S32 local_x, local_y; - LLView::localPointToOtherView(x, y, &local_x, &local_y, mList); - if (mList->pointInView(local_x, local_y)) - { - return mList->handleDoubleClick(local_x, local_y, mask); - } - } - return LLUICtrl::handleDoubleClick(x, y, mask); -} - -BOOL LLComboBox::handleMouseUp(S32 x, S32 y, MASK mask) -{ - BOOL handled = childrenHandleMouseUp(x, y, mask) != NULL; - - if (!handled && mList->getVisible()) - { - S32 local_x, local_y; - LLView::localPointToOtherView(x, y, &local_x, &local_y, mList); - if (mList->pointInView(local_x, local_y)) - { - handled = mList->handleMouseUp(local_x, local_y, mask); - } - } - - if( !handled && gFocusMgr.getMouseCapture() == this ) - { - // Mouse events that we didn't handle cause the list to be hidden. - // Eat mouse event, regardless of where on the screen it happens. - hideList(); - handled = TRUE; - } - - return handled; -} - void LLComboBox::clear() { if (mTextEntry) @@ -493,12 +390,13 @@ void LLComboBox::onFocusLost() { mTextEntry->selectAll(); } + LLUICtrl::onFocusLost(); } void LLComboBox::setButtonVisible(BOOL visible) { mButton->setVisible(visible); - mDrawButton = visible; + mDrawArrow = visible; if (mTextEntry) { LLRect text_entry_rect(0, mRect.getHeight(), mRect.getWidth(), 0); @@ -522,15 +420,17 @@ void LLComboBox::draw() // Draw children LLUICtrl::draw(); - if (mDrawButton) + if (mDrawArrow) { // Paste the graphic on the right edge if (!mArrowImage.isNull()) { - S32 left = mRect.getWidth() - mArrowImageWidth - LLUI::sConfigGroup->getS32("DropShadowButton"); + S32 arrow_height = llmin(mRect.getHeight(), mArrowImage->getHeight()); + S32 arrow_width = llround((F32)mArrowImage->getWidth() * ((F32)arrow_height / (F32)mArrowImage->getHeight())); + + S32 left = mRect.getWidth() - mArrowImage->getWidth() - LLUI::sConfigGroup->getS32("DropShadowButton"); - gl_draw_image( left, 0, mArrowImage, - LLColor4::white); + gl_draw_scaled_image( left, 0, arrow_width, arrow_height, mArrowImage, LLColor4::white); } } } @@ -576,18 +476,60 @@ void LLComboBox::showList() //HACK: shouldn't have to know about scale here mList->arrange( 192, llfloor((F32)window_size.mY / LLUI::sGLScaleFactor.mV[VY]) - 50 ); - // Move rect so it hangs off the bottom of this view + // Make sure that we can see the whole list + LLRect floater_area_local; + gFloaterView->localRectToOtherView(gFloaterView->getLocalSnapRect(), &floater_area_local, this); + LLRect rect = mList->getRect(); - rect.setLeftTopAndSize(0, 0, rect.getWidth(), rect.getHeight() ); - mList->setRect(rect); + if (mListPosition == BELOW) + { + if (rect.getHeight() <= -floater_area_local.mBottom) + { + // Move rect so it hangs off the bottom of this view + rect.setLeftTopAndSize(0, 0, rect.getWidth(), rect.getHeight() ); + } + else + { + // stack on top or bottom, depending on which has more room + if (-floater_area_local.mBottom > floater_area_local.mTop - mRect.getHeight()) + { + // Move rect so it hangs off the bottom of this view + rect.setLeftTopAndSize(0, 0, rect.getWidth(), llmin(-floater_area_local.mBottom, rect.getHeight())); + } + else + { + // move rect so it stacks on top of this view (clipped to size of screen) + rect.setOriginAndSize(0, mRect.getHeight(), rect.getWidth(), llmin(floater_area_local.mTop - mRect.getHeight(), rect.getHeight())); + } + } + } + else // ABOVE + { + if (rect.getHeight() <= floater_area_local.mTop - mRect.getHeight()) + { + // move rect so it stacks on top of this view (clipped to size of screen) + rect.setOriginAndSize(0, mRect.getHeight(), rect.getWidth(), llmin(floater_area_local.mTop - mRect.getHeight(), rect.getHeight())); + } + else + { + // stack on top or bottom, depending on which has more room + if (-floater_area_local.mBottom > floater_area_local.mTop - mRect.getHeight()) + { + // Move rect so it hangs off the bottom of this view + rect.setLeftTopAndSize(0, 0, rect.getWidth(), llmin(-floater_area_local.mBottom, rect.getHeight())); + } + else + { + // move rect so it stacks on top of this view (clipped to size of screen) + rect.setOriginAndSize(0, mRect.getHeight(), rect.getWidth(), llmin(floater_area_local.mTop - mRect.getHeight(), rect.getHeight())); + } + } - // Make sure that we can see the whole list - LLRect floater_area_screen; - LLRect floater_area_local; - gFloaterView->getParent()->localRectToScreen( gFloaterView->getRect(), &floater_area_screen ); - screenRectToLocal( floater_area_screen, &floater_area_local ); - mList->translateIntoRect( floater_area_local, FALSE ); + } + mList->setOrigin(rect.mLeft, rect.mBottom); + mList->reshape(rect.getWidth(), rect.getHeight()); + mList->translateIntoRect(floater_area_local, FALSE); // Make sure we didn't go off bottom of screen S32 x, y; @@ -598,7 +540,12 @@ void LLComboBox::showList() mList->translate(0, -y); } - gFocusMgr.setMouseCapture( this, LLComboBox::onMouseCaptureLost ); + // pass mouse capture on to list if button is depressed + if (mButton->hasMouseCapture()) + { + gFocusMgr.setMouseCapture(mList); + } + // NB: this call will trigger the focuslost callback which will hide the list, so do it first // before finally showing the list @@ -608,14 +555,13 @@ void LLComboBox::showList() // so that the callback is not immediately triggered on setFocus() mList->selectFirstItem(); } - gFocusMgr.setKeyboardFocus(mList, onListFocusLost); + mList->setFocus(TRUE); // Show the list and push the button down mButton->setToggleState(TRUE); mList->setVisible(TRUE); - gFocusMgr.setTopView(mList, LLComboBox::onTopViewLost ); - + gFocusMgr.setTopCtrl(mList); } void LLComboBox::hideList() @@ -624,37 +570,21 @@ void LLComboBox::hideList() mList->setVisible(FALSE); mList->highlightNthItem(-1); - if( gFocusMgr.getTopView() == mList ) + if( gFocusMgr.getTopCtrl() == mList ) { - gFocusMgr.setTopView(NULL, NULL); + gFocusMgr.setTopCtrl(NULL); } - if( gFocusMgr.getMouseCapture() == this ) - { - gFocusMgr.setMouseCapture( NULL, NULL ); - } - - if( gFocusMgr.getKeyboardFocus() == mList ) - { - if (mAllowTextEntry) - { - mTextEntry->setFocus(TRUE); - } - else - { - setFocus(TRUE); - } - } + //mList->setFocus(FALSE); } - //------------------------------------------------------------------ // static functions //------------------------------------------------------------------ // static -void LLComboBox::onButtonClick(void *userdata) +void LLComboBox::onButtonDown(void *userdata) { LLComboBox *self = (LLComboBox *)userdata; @@ -701,50 +631,46 @@ void LLComboBox::onItemSelected(LLUICtrl* item, void *userdata) const LLString& name = self->mList->getSimpleSelectedItem(); - self->hideList(); - S32 cur_id = self->getCurrentIndex(); if (cur_id != -1) { - self->setLabel(self->mList->getSimpleSelectedItem()); + self->setLabel(name); if (self->mAllowTextEntry) { - self->mTextEntry->setText(name); - self->mTextEntry->setTentative(FALSE); gFocusMgr.setKeyboardFocus(self->mTextEntry, NULL); self->mTextEntry->selectAll(); } - else - { - self->mButton->setLabelUnselected( name ); - self->mButton->setLabelSelected( name ); - self->mButton->setDisabledLabel( name ); - self->mButton->setDisabledSelectedLabel( name ); - } + } + else + { + // invalid selection, just restore existing value + self->mList->selectSimpleItem(self->mButton->getLabelSelected()); } self->onCommit(); -} -// static -void LLComboBox::onTopViewLost(LLView* old_focus) -{ - LLComboBox *self = (LLComboBox *) old_focus->getParent(); self->hideList(); } - // static -void LLComboBox::onMouseCaptureLost(LLMouseHandler*) +void LLComboBox::onListFocusChanged(LLUICtrl* list, void* user_data) { - // Can't hide the list here. If the list scrolls off the screen, - // and you click in the arrow buttons of the scroll bar, they must capture - // the mouse to handle scrolling-while-mouse-down. + LLComboBox *self = (LLComboBox *) list->getParent(); + if (!list->hasFocus()) + { + //*HACK: store the original value explicitly somewhere, not just in label + LLString orig_selection = self->mAllowTextEntry ? self->mTextEntry->getText() : self->mButton->getLabelSelected(); + + self->hideList(); + + // reassert original selection + self->mList->selectSimpleItem(orig_selection, FALSE); + } } BOOL LLComboBox::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) { - + LLString tool_tip; if (LLUI::sShowXUINames) @@ -1122,15 +1048,3 @@ BOOL LLComboBox::operateOnAll(EOperation op) } return FALSE; } - -//static -void LLComboBox::onListFocusLost(LLUICtrl* old_focus) -{ - // if focus is going to nothing (user hit ESC), take it back - LLComboBox* combo = (LLComboBox*)old_focus->getParent(); - combo->hideList(); - if (gFocusMgr.getKeyboardFocus() == NULL) - { - combo->focusFirstItem(); - } -} diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index faf99937c9..2b19c3c2e5 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -34,6 +34,12 @@ class LLComboBox : public LLUICtrl, public LLCtrlListInterface { public: + typedef enum e_preferred_position + { + ABOVE, + BELOW + } EPreferredPosition; + LLComboBox( const LLString& name, const LLRect &rect, @@ -58,12 +64,6 @@ public: virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect); virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent); - virtual BOOL handleHover(S32 x, S32 y, MASK mask); - virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); - virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); - virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); - virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); - virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); // LLUICtrl interface virtual void clear(); // select nothing @@ -146,34 +146,31 @@ public: void setButtonVisible(BOOL visible); - static void onButtonClick(void *userdata); + static void onButtonDown(void *userdata); static void onItemSelected(LLUICtrl* item, void *userdata); - static void onTopViewLost(LLView* old_focus); - static void onMouseCaptureLost(LLMouseHandler* old_captor); + static void onListFocusChanged(LLUICtrl* item, void *userdata); static void onTextEntry(LLLineEditor* line_editor, void* user_data); static void onTextCommit(LLUICtrl* caller, void* user_data); void updateSelection(); - void showList(); - void hideList(); - - static void onListFocusLost(LLUICtrl* old_focus); - + virtual void showList(); + virtual void hideList(); + protected: LLButton* mButton; LLScrollListCtrl* mList; LLViewBorder* mBorder; BOOL mKeyboardFocusOnClick; - BOOL mDrawButton; + BOOL mDrawArrow; LLLineEditor* mTextEntry; LLPointer<LLImageGL> mArrowImage; S32 mArrowImageWidth; BOOL mAllowTextEntry; S32 mMaxChars; BOOL mTextEntryTentative; + EPreferredPosition mListPosition; void (*mPrearrangeCallback)(LLUICtrl*,void*); void (*mTextEntryCallback)(LLLineEditor*, void*); - S32 mListWidth; // width of pop-up list, 0 = use combobox width }; #endif diff --git a/indra/llui/lldraghandle.cpp b/indra/llui/lldraghandle.cpp index a88fbb7744..599a85021b 100644 --- a/indra/llui/lldraghandle.cpp +++ b/indra/llui/lldraghandle.cpp @@ -269,7 +269,7 @@ BOOL LLDragHandle::handleMouseDown(S32 x, S32 y, MASK mask) { // Route future Mouse messages here preemptively. (Release on mouse up.) // No handler needed for focus lost since this clas has no state that depends on it. - gFocusMgr.setMouseCapture(this, NULL ); + gFocusMgr.setMouseCapture(this); localPointToScreen(x, y, &mDragLastScreenX, &mDragLastScreenY); mLastMouseScreenX = mDragLastScreenX; @@ -282,10 +282,10 @@ BOOL LLDragHandle::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLDragHandle::handleMouseUp(S32 x, S32 y, MASK mask) { - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { // Release the mouse - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); } // Note: don't pass on to children @@ -298,7 +298,7 @@ BOOL LLDragHandle::handleHover(S32 x, S32 y, MASK mask) BOOL handled = FALSE; // We only handle the click if the click both started and ended within us - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { S32 screen_x; S32 screen_y; diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 0922de70af..1f71de1c87 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -279,7 +279,6 @@ void LLFloater::init(const LLString& title, mRect.getHeight() - LLPANEL_BORDER_WIDTH - close_box_size); mDragHandle = new LLDragHandleLeft("drag", drag_handle_rect, title ); } - mDragHandle->setSaveToXML(false); addChild(mDragHandle); // Resize Handle @@ -295,28 +294,24 @@ void LLFloater::init(const LLString& title, "resizebar_left", LLRect( 0, mRect.getHeight(), RESIZE_BAR_THICKNESS, 0), min_width, min_height, LLResizeBar::LEFT ); - mResizeBar[0]->setSaveToXML(false); addChild( mResizeBar[0] ); mResizeBar[1] = new LLResizeBar( "resizebar_top", LLRect( 0, mRect.getHeight(), mRect.getWidth(), mRect.getHeight() - RESIZE_BAR_THICKNESS), min_width, min_height, LLResizeBar::TOP ); - mResizeBar[1]->setSaveToXML(false); addChild( mResizeBar[1] ); mResizeBar[2] = new LLResizeBar( "resizebar_right", LLRect( mRect.getWidth() - RESIZE_BAR_THICKNESS, mRect.getHeight(), mRect.getWidth(), 0), min_width, min_height, LLResizeBar::RIGHT ); - mResizeBar[2]->setSaveToXML(false); addChild( mResizeBar[2] ); mResizeBar[3] = new LLResizeBar( "resizebar_bottom", LLRect( 0, RESIZE_BAR_THICKNESS, mRect.getWidth(), 0), min_width, min_height, LLResizeBar::BOTTOM ); - mResizeBar[3]->setSaveToXML(false); addChild( mResizeBar[3] ); @@ -327,7 +322,6 @@ void LLFloater::init(const LLString& title, min_width, min_height, LLResizeHandle::RIGHT_BOTTOM); - mResizeHandle[0]->setSaveToXML(false); addChild(mResizeHandle[0]); mResizeHandle[1] = new LLResizeHandle( "resize", @@ -335,7 +329,6 @@ void LLFloater::init(const LLString& title, min_width, min_height, LLResizeHandle::RIGHT_TOP ); - mResizeHandle[1]->setSaveToXML(false); addChild(mResizeHandle[1]); mResizeHandle[2] = new LLResizeHandle( "resize", @@ -343,7 +336,6 @@ void LLFloater::init(const LLString& title, min_width, min_height, LLResizeHandle::LEFT_BOTTOM ); - mResizeHandle[2]->setSaveToXML(false); addChild(mResizeHandle[2]); mResizeHandle[3] = new LLResizeHandle( "resize", @@ -351,7 +343,6 @@ void LLFloater::init(const LLString& title, min_width, min_height, LLResizeHandle::LEFT_TOP ); - mResizeHandle[3]->setSaveToXML(false); addChild(mResizeHandle[3]); } else @@ -463,14 +454,14 @@ void LLFloater::setVisible( BOOL visible ) if( !visible ) { - if( gFocusMgr.childIsTopView( this ) ) + if( gFocusMgr.childIsTopCtrl( this ) ) { - gFocusMgr.setTopView(NULL, NULL); + gFocusMgr.setTopCtrl(NULL); } if( gFocusMgr.childHasMouseCapture( this ) ) { - gFocusMgr.setMouseCapture(NULL, NULL); + gFocusMgr.setMouseCapture(NULL); } } @@ -584,9 +575,9 @@ void LLFloater::close(bool app_quitting) void LLFloater::releaseFocus() { - if( gFocusMgr.childIsTopView( this ) ) + if( gFocusMgr.childIsTopCtrl( this ) ) { - gFocusMgr.setTopView(NULL, NULL); + gFocusMgr.setTopCtrl(NULL); } if( gFocusMgr.childHasKeyboardFocus( this ) ) @@ -596,7 +587,7 @@ void LLFloater::releaseFocus() if( gFocusMgr.childHasMouseCapture( this ) ) { - gFocusMgr.setMouseCapture(NULL, NULL); + gFocusMgr.setMouseCapture(NULL); } } @@ -1464,28 +1455,24 @@ void LLFloater::setCanResize(BOOL can_resize) "resizebar_left", LLRect( 0, mRect.getHeight(), RESIZE_BAR_THICKNESS, 0), mMinWidth, mMinHeight, LLResizeBar::LEFT ); - mResizeBar[0]->setSaveToXML(false); addChild( mResizeBar[0] ); mResizeBar[1] = new LLResizeBar( "resizebar_top", LLRect( 0, mRect.getHeight(), mRect.getWidth(), mRect.getHeight() - RESIZE_BAR_THICKNESS), mMinWidth, mMinHeight, LLResizeBar::TOP ); - mResizeBar[1]->setSaveToXML(false); addChild( mResizeBar[1] ); mResizeBar[2] = new LLResizeBar( "resizebar_right", LLRect( mRect.getWidth() - RESIZE_BAR_THICKNESS, mRect.getHeight(), mRect.getWidth(), 0), mMinWidth, mMinHeight, LLResizeBar::RIGHT ); - mResizeBar[2]->setSaveToXML(false); addChild( mResizeBar[2] ); mResizeBar[3] = new LLResizeBar( "resizebar_bottom", LLRect( 0, RESIZE_BAR_THICKNESS, mRect.getWidth(), 0), mMinWidth, mMinHeight, LLResizeBar::BOTTOM ); - mResizeBar[3]->setSaveToXML(false); addChild( mResizeBar[3] ); @@ -1496,7 +1483,6 @@ void LLFloater::setCanResize(BOOL can_resize) mMinWidth, mMinHeight, LLResizeHandle::RIGHT_BOTTOM); - mResizeHandle[0]->setSaveToXML(false); addChild(mResizeHandle[0]); mResizeHandle[1] = new LLResizeHandle( "resize", @@ -1504,7 +1490,6 @@ void LLFloater::setCanResize(BOOL can_resize) mMinWidth, mMinHeight, LLResizeHandle::RIGHT_TOP ); - mResizeHandle[1]->setSaveToXML(false); addChild(mResizeHandle[1]); mResizeHandle[2] = new LLResizeHandle( "resize", @@ -1512,7 +1497,6 @@ void LLFloater::setCanResize(BOOL can_resize) mMinWidth, mMinHeight, LLResizeHandle::LEFT_BOTTOM ); - mResizeHandle[2]->setSaveToXML(false); addChild(mResizeHandle[2]); mResizeHandle[3] = new LLResizeHandle( "resize", @@ -1520,7 +1504,6 @@ void LLFloater::setCanResize(BOOL can_resize) mMinWidth, mMinHeight, LLResizeHandle::LEFT_TOP ); - mResizeHandle[3]->setSaveToXML(false); addChild(mResizeHandle[3]); } mResizable = can_resize; @@ -2022,8 +2005,7 @@ void LLFloaterView::focusFrontFloater() void LLFloaterView::getMinimizePosition(S32 *left, S32 *bottom) { S32 col = 0; - LLRect snap_rect_local = getSnapRect(); - snap_rect_local.translate(-mRect.mLeft, -mRect.mBottom); + LLRect snap_rect_local = getLocalSnapRect(); for(S32 row = snap_rect_local.mBottom; row < snap_rect_local.getHeight() - LLFLOATER_HEADER_SIZE; row += LLFLOATER_HEADER_SIZE ) //loop rows @@ -2146,8 +2128,7 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out S32 screen_width = getSnapRect().getWidth(); S32 screen_height = getSnapRect().getHeight(); // convert to local coordinate frame - LLRect snap_rect_local = getSnapRect(); - snap_rect_local.translate(-mRect.mLeft, -mRect.mBottom); + LLRect snap_rect_local = getLocalSnapRect(); if( floater->isResizable() ) { diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index 030fbf0653..da53e3d104 100644 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -21,18 +21,16 @@ LLFocusMgr::LLFocusMgr() mLockedView( NULL ), mKeyboardLockedFocusLostCallback( NULL ), mMouseCaptor( NULL ), - mMouseCaptureLostCallback( NULL ), mKeyboardFocus( NULL ), mDefaultKeyboardFocus( NULL ), mKeyboardFocusLostCallback( NULL ), - mTopView( NULL ), - mTopViewLostCallback( NULL ), + mTopCtrl( NULL ), mFocusWeight(0.f), mAppHasFocus(TRUE) // Macs don't seem to notify us that we've gotten focus, so default to true #ifdef _DEBUG , mMouseCaptorName("none") , mKeyboardFocusName("none") - , mTopViewName("none") + , mTopCtrlName("none") #endif { } @@ -46,7 +44,7 @@ void LLFocusMgr::releaseFocusIfNeeded( LLView* view ) { if( childHasMouseCapture( view ) ) { - setMouseCapture( NULL, NULL ); + setMouseCapture( NULL ); } if( childHasKeyboardFocus( view )) @@ -63,9 +61,9 @@ void LLFocusMgr::releaseFocusIfNeeded( LLView* view ) } } - if( childIsTopView( view ) ) + if( childIsTopCtrl( view ) ) { - setTopView( NULL, NULL ); + setTopCtrl( NULL ); } } @@ -108,13 +106,13 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, FocusLostCallback on_focu // If we've got a default keyboard focus, and the caller is // releasing keyboard focus, move to the default. - if (mDefaultKeyboardFocus != NULL && new_focus == NULL) + if (mDefaultKeyboardFocus != NULL && mKeyboardFocus == NULL) { mDefaultKeyboardFocus->setFocus(TRUE); } - LLView* focus_subtree = new_focus; - LLView* viewp = new_focus; + LLView* focus_subtree = mKeyboardFocus; + LLView* viewp = mKeyboardFocus; // find root-most focus root while(viewp) { @@ -128,13 +126,13 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, FocusLostCallback on_focu if (focus_subtree) { - mFocusHistory[focus_subtree->mViewHandle] = new_focus ? new_focus->mViewHandle : LLViewHandle::sDeadHandle; + mFocusHistory[focus_subtree->mViewHandle] = mKeyboardFocus ? mKeyboardFocus->mViewHandle : LLViewHandle::sDeadHandle; } } if (lock) { - mLockedView = new_focus; + mLockedView = mKeyboardFocus; mKeyboardLockedFocusLostCallback = on_focus_lost; } } @@ -198,16 +196,13 @@ void LLFocusMgr::removeKeyboardFocusWithoutCallback( LLView* focus ) } -void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor, void (*on_capture_lost)(LLMouseHandler* old_captor) ) +void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor ) { //if (mFocusLocked) //{ // return; //} - void (*old_callback)(LLMouseHandler*) = mMouseCaptureLostCallback; - mMouseCaptureLostCallback = on_capture_lost; - if( new_captor != mMouseCaptor ) { LLMouseHandler* old_captor = mMouseCaptor; @@ -230,9 +225,9 @@ void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor, void (*on_capture_ } */ - if( old_callback ) + if( old_captor ) { - old_callback( old_captor ); + old_captor->onMouseCaptureLost(); } #ifdef _DEBUG @@ -250,7 +245,6 @@ void LLFocusMgr::removeMouseCaptureWithoutCallback( LLMouseHandler* captor ) if( mMouseCaptor == captor ) { mMouseCaptor = NULL; - mMouseCaptureLostCallback = NULL; #ifdef _DEBUG mMouseCaptorName = "none"; #endif @@ -258,9 +252,9 @@ void LLFocusMgr::removeMouseCaptureWithoutCallback( LLMouseHandler* captor ) } -BOOL LLFocusMgr::childIsTopView( LLView* parent ) +BOOL LLFocusMgr::childIsTopCtrl( LLView* parent ) { - LLView* top_view = mTopView; + LLView* top_view = (LLView*)mTopCtrl; while( top_view ) { if( top_view == parent ) @@ -275,36 +269,25 @@ BOOL LLFocusMgr::childIsTopView( LLView* parent ) // set new_top = NULL to release top_view. -void LLFocusMgr::setTopView( LLView* new_top, void (*on_top_lost)(LLView* old_top) ) +void LLFocusMgr::setTopCtrl( LLUICtrl* new_top ) { - void (*old_callback)(LLView*) = mTopViewLostCallback; - mTopViewLostCallback = on_top_lost; - - if( new_top != mTopView ) + if( new_top != mTopCtrl ) { - LLView* old_top = mTopView; - mTopView = new_top; - if( old_callback ) - { - old_callback( old_top ); - } - - mTopView = new_top; + mTopCtrl = new_top; #ifdef _DEBUG - mTopViewName = new_top ? new_top->getName() : "none"; + mTopCtrlName = new_top ? new_top->getName() : "none"; #endif } } -void LLFocusMgr::removeTopViewWithoutCallback( LLView* top_view ) +void LLFocusMgr::removeTopCtrlWithoutCallback( LLUICtrl* top_view ) { - if( mTopView == top_view ) + if( mTopCtrl == top_view ) { - mTopView = NULL; - mTopViewLostCallback = NULL; + mTopCtrl = NULL; #ifdef _DEBUG - mTopViewName = "none"; + mTopCtrlName = "none"; #endif } } @@ -343,6 +326,12 @@ void LLFocusMgr::setAppHasFocus(BOOL focus) { triggerFocusFlash(); } + + // release focus from "top ctrl"s, which generally hides them + if (!focus && mTopCtrl && mTopCtrl->hasFocus()) + { + mTopCtrl->setFocus(FALSE); + } mAppHasFocus = focus; } diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h index cb555fca91..dc8025d4c0 100644 --- a/indra/llui/llfocusmgr.h +++ b/indra/llui/llfocusmgr.h @@ -27,7 +27,7 @@ public: ~LLFocusMgr(); // Mouse Captor - void setMouseCapture(LLMouseHandler* new_captor,void (*on_capture_lost)(LLMouseHandler* old_captor)); // new_captor = NULL to release the mouse. + void setMouseCapture(LLMouseHandler* new_captor); // new_captor = NULL to release the mouse. LLMouseHandler* getMouseCapture() { return mMouseCaptor; } void removeMouseCaptureWithoutCallback( LLMouseHandler* captor ); BOOL childHasMouseCapture( LLView* parent ); @@ -54,10 +54,10 @@ public: // Top View - void setTopView(LLView* new_top, void (*on_top_lost)(LLView* old_top)); - LLView* getTopView() const { return mTopView; } - void removeTopViewWithoutCallback( LLView* top_view ); - BOOL childIsTopView( LLView* parent ); + void setTopCtrl(LLUICtrl* new_top); + LLUICtrl* getTopCtrl() const { return mTopCtrl; } + void removeTopCtrlWithoutCallback( LLUICtrl* top_view ); + BOOL childIsTopCtrl( LLView* parent ); // All Three void releaseFocusIfNeeded( LLView* top_view ); @@ -70,7 +70,6 @@ protected: // Mouse Captor LLMouseHandler* mMouseCaptor; // Mouse events are premptively routed to this object - void (*mMouseCaptureLostCallback)(LLMouseHandler*); // The object to which mouse events are routed is called before another object takes its place // Keyboard Focus LLUICtrl* mKeyboardFocus; // Keyboard events are preemptively routed to this object @@ -78,8 +77,7 @@ protected: FocusLostCallback mKeyboardFocusLostCallback; // The object to which keyboard events are routed is called before another object takes its place // Top View - LLView* mTopView; - void (*mTopViewLostCallback)(LLView*); + LLUICtrl* mTopCtrl; LLFrameTimer mFocusTimer; F32 mFocusWeight; @@ -92,7 +90,7 @@ protected: #ifdef _DEBUG LLString mMouseCaptorName; LLString mKeyboardFocusName; - LLString mTopViewName; + LLString mTopCtrlName; #endif }; diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 46d66b3cd4..7422a039dd 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -96,7 +96,7 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, S32 max_length_bytes, void (*commit_callback)(LLUICtrl* caller, void* user_data ), void (*keystroke_callback)(LLLineEditor* caller, void* user_data ), - void (*focus_lost_callback)(LLLineEditor* caller, void* user_data ), + void (*focus_lost_callback)(LLUICtrl* caller, void* user_data ), void* userdata, LLLinePrevalidateFunc prevalidate_func, LLViewBorder::EBevel border_bevel, @@ -113,7 +113,6 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, mCommitOnFocusLost( TRUE ), mRevertOnEsc( TRUE ), mKeystrokeCallback( keystroke_callback ), - mFocusLostCallback( focus_lost_callback ), mIsSelecting( FALSE ), mSelectionStart( 0 ), mSelectionEnd( 0 ), @@ -147,6 +146,8 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, mGLFont = LLFontGL::sSansSerifSmall; } + setFocusLostCallback(focus_lost_callback); + mMinHPixels = mBorderThickness + UI_LINEEDITOR_H_PAD + mBorderLeft; mMaxHPixels = mRect.getWidth() - mMinHPixels - mBorderThickness - mBorderRight; @@ -167,7 +168,6 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, LLLineEditor::~LLLineEditor() { - mFocusLostCallback = NULL; mCommitOnFocusLost = FALSE; gFocusMgr.releaseFocusIfNeeded( this ); @@ -192,11 +192,8 @@ LLString LLLineEditor::getWidgetTag() const void LLLineEditor::onFocusLost() { - if( mFocusLostCallback ) - { - mFocusLostCallback( this, mCallbackUserData ); - } - + LLUICtrl::onFocusLost(); + if( mCommitOnFocusLost && mText.getString() != mPrevText) { onCommit(); @@ -483,7 +480,7 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) startSelection(); } - gFocusMgr.setMouseCapture( this, &LLLineEditor::onMouseCaptureLost ); + gFocusMgr.setMouseCapture( this ); } // delay cursor flashing @@ -496,14 +493,14 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; - if (gFocusMgr.getMouseCapture() != this && (x < mBorderLeft || x > (mRect.getWidth() - mBorderRight))) + if (!hasMouseCapture() && (x < mBorderLeft || x > (mRect.getWidth() - mBorderRight))) { return LLUICtrl::handleHover(x, y, mask); } if( getVisible() ) { - if( (gFocusMgr.getMouseCapture() == this) && mIsSelecting ) + if( (hasMouseCapture()) && mIsSelecting ) { if (x != mLastSelectionX || y != mLastSelectionY) { @@ -561,9 +558,9 @@ BOOL LLLineEditor::handleMouseUp(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); handled = TRUE; } @@ -1897,11 +1894,9 @@ BOOL LLLineEditor::prevalidateASCII(const LLWString &str) return rv; } -//static -void LLLineEditor::onMouseCaptureLost( LLMouseHandler* old_captor ) +void LLLineEditor::onMouseCaptureLost() { - LLLineEditor* self = (LLLineEditor*) old_captor; - self->endSelection(); + endSelection(); } @@ -1916,11 +1911,6 @@ void LLLineEditor::setKeystrokeCallback(void (*keystroke_callback)(LLLineEditor* mKeystrokeCallback = keystroke_callback; } -void LLLineEditor::setFocusLostCallback(void (*keystroke_callback)(LLLineEditor* caller, void* user_data)) -{ - mFocusLostCallback = keystroke_callback; -} - // virtual LLXMLNodePtr LLLineEditor::getXML(bool save_children) const { diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index ef2f43a1d3..27ae351d1f 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -51,7 +51,7 @@ public: S32 max_length_bytes = 254, void (*commit_callback)(LLUICtrl* caller, void* user_data) = NULL, void (*keystroke_callback)(LLLineEditor* caller, void* user_data) = NULL, - void (*focus_lost_callback)(LLLineEditor* caller, void* user_data) = NULL, + void (*focus_lost_callback)(LLUICtrl* caller, void* user_data) = NULL, void* userdata = NULL, LLLinePrevalidateFunc prevalidate_func = NULL, LLViewBorder::EBevel border_bevel = LLViewBorder::BEVEL_IN, @@ -72,6 +72,7 @@ public: /*virtual*/ BOOL handleDoubleClick(S32 x,S32 y,MASK mask); /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent ); /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent); + /*virtual*/ void onMouseCaptureLost(); // LLEditMenuHandler overrides virtual void cut(); @@ -166,7 +167,6 @@ public: void setSelectAllonFocusReceived(BOOL b); void setKeystrokeCallback(void (*keystroke_callback)(LLLineEditor* caller, void* user_data)); - void setFocusLostCallback(void (*keystroke_callback)(LLLineEditor* caller, void* user_data)); void setMaxTextLength(S32 max_text_length); void setBorderWidth(S32 left, S32 right); @@ -186,8 +186,6 @@ public: static BOOL postvalidateFloat(const LLString &str); - static void onMouseCaptureLost( LLMouseHandler* old_captor ); - protected: void removeChar(); void addChar(const llwchar c); @@ -222,7 +220,6 @@ protected: BOOL mRevertOnEsc; void (*mKeystrokeCallback)( LLLineEditor* caller, void* userdata ); - void (*mFocusLostCallback)( LLLineEditor* caller, void* userdata ); BOOL mIsSelecting; // Selection for clipboard operations S32 mSelectionStart; diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index d46a866e2b..79c38a87c0 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -3235,6 +3235,7 @@ LLPieMenu::LLPieMenu(const LLString& name, const LLString& label) mUseInfiniteRadius(FALSE), mHoverItem(NULL), mHoverThisFrame(FALSE), + mHoveredAnyItem(FALSE), mOuterRingAlpha(1.f), mCurRadius(0.f), mRightMouseDown(FALSE) @@ -3249,6 +3250,7 @@ LLPieMenu::LLPieMenu(const LLString& name) mUseInfiniteRadius(FALSE), mHoverItem(NULL), mHoverThisFrame(FALSE), + mHoveredAnyItem(FALSE), mOuterRingAlpha(1.f), mCurRadius(0.f), mRightMouseDown(FALSE) @@ -3319,12 +3321,12 @@ BOOL LLPieMenu::handleHover( S32 x, S32 y, MASK mask ) // release mouse capture after short period of visibility if we're using a finite boundary // so that right click outside of boundary will trigger new pie menu - if (gFocusMgr.getMouseCapture() == this && + if (hasMouseCapture() && !mRightMouseDown && mShrinkBorderTimer.getStarted() && mShrinkBorderTimer.getElapsedTimeF32() >= PIE_SHRINK_TIME) { - gFocusMgr.setMouseCapture(NULL, NULL); + gFocusMgr.setMouseCapture(NULL); mUseInfiniteRadius = FALSE; } @@ -3376,6 +3378,7 @@ BOOL LLPieMenu::handleHover( S32 x, S32 y, MASK mask ) break; } } + mHoveredAnyItem = TRUE; } else { @@ -3437,7 +3440,7 @@ BOOL LLPieMenu::handleRightMouseDown(S32 x, S32 y, MASK mask) if (clicked_in_pie) { // capture mouse cursor as if on initial menu show - gFocusMgr.setMouseCapture(this, NULL); + gFocusMgr.setMouseCapture(this); mShrinkBorderTimer.stop(); mUseInfiniteRadius = TRUE; handled = TRUE; @@ -3463,11 +3466,22 @@ BOOL LLPieMenu::handleRightMouseUp( S32 x, S32 y, MASK mask ) mShrinkBorderTimer.getElapsedTimeF32() > PIE_SHRINK_TIME) { mUseInfiniteRadius = FALSE; - gFocusMgr.setMouseCapture(NULL, NULL); + gFocusMgr.setMouseCapture(NULL); } + S32 delta_x = x /*+ mShiftHoriz*/ - getLocalRect().getCenterX(); + S32 delta_y = y /*+ mShiftVert*/ - getLocalRect().getCenterY(); + if (!mHoveredAnyItem && !mFirstMouseDown && (delta_x * delta_x) + (delta_y * delta_y) < PIE_CENTER_SIZE * PIE_CENTER_SIZE) + { + // user released right mouse button in middle of pie, interpret this as closing the menu + sMenuContainer->hideMenus(); + return TRUE; + } + + BOOL result = handleMouseUp( x, y, mask ); mRightMouseDown = FALSE; + mHoveredAnyItem = FALSE; return result; } @@ -3874,6 +3888,8 @@ void LLPieMenu::show(S32 x, S32 y, BOOL mouse_down) mRightMouseDown = mouse_down; mFirstMouseDown = mouse_down; mUseInfiniteRadius = TRUE; + mHoveredAnyItem = FALSE; + if (!mFirstMouseDown) { make_ui_sound("UISndPieMenuAppear"); @@ -3883,7 +3899,7 @@ void LLPieMenu::show(S32 x, S32 y, BOOL mouse_down) // we want all mouse events in case user does quick right click again off of pie menu // rectangle, to support gestural menu traversal - gFocusMgr.setMouseCapture(this, NULL); + gFocusMgr.setMouseCapture(this); if (mouse_down) { @@ -3910,10 +3926,11 @@ void LLPieMenu::hide(BOOL item_selected) mFirstMouseDown = FALSE; mRightMouseDown = FALSE; mUseInfiniteRadius = FALSE; + mHoveredAnyItem = FALSE; LLView::setVisible(FALSE); - gFocusMgr.setMouseCapture(NULL, NULL); + gFocusMgr.setMouseCapture(NULL); } ///============================================================================ @@ -4510,6 +4527,7 @@ void LLTearOffMenu::onFocusLost() { // remove highlight from parent item and our own menu mMenu->clearHoverItem(); + LLFloater::onFocusLost(); } BOOL LLTearOffMenu::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent) diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index e60f267702..36ca815ef3 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -672,6 +672,7 @@ private: BOOL mUseInfiniteRadius; // allow picking pie menu items anywhere outside of center circle LLMenuItemGL* mHoverItem; BOOL mHoverThisFrame; + BOOL mHoveredAnyItem; LLFrameTimer mShrinkBorderTimer; F32 mOuterRingAlpha; // for rendering pie menus as both bounded and unbounded F32 mCurRadius; diff --git a/indra/llui/llmodaldialog.cpp b/indra/llui/llmodaldialog.cpp index 4eaf6b7559..4453767f92 100644 --- a/indra/llui/llmodaldialog.cpp +++ b/indra/llui/llmodaldialog.cpp @@ -65,8 +65,8 @@ void LLModalDialog::startModal() } // This is a modal dialog. It sucks up all mouse and keyboard operations. - gFocusMgr.setMouseCapture( this, NULL ); - gFocusMgr.setTopView( this, NULL ); + gFocusMgr.setMouseCapture( this ); + gFocusMgr.setTopCtrl( this ); setFocus(TRUE); sModalStack.push_front( this ); @@ -107,10 +107,10 @@ void LLModalDialog::setVisible( BOOL visible ) if( visible ) { // This is a modal dialog. It sucks up all mouse and keyboard operations. - gFocusMgr.setMouseCapture( this, NULL ); + gFocusMgr.setMouseCapture( this ); // The dialog view is a root view - gFocusMgr.setTopView( this, NULL ); + gFocusMgr.setTopCtrl( this ); setFocus( TRUE ); } else @@ -222,9 +222,9 @@ void LLModalDialog::draw() if (mModal) { // If we've lost focus to a non-child, get it back ASAP. - if( gFocusMgr.getTopView() != this ) + if( gFocusMgr.getTopCtrl() != this ) { - gFocusMgr.setTopView( this, NULL); + gFocusMgr.setTopCtrl( this ); } if( !gFocusMgr.childHasKeyboardFocus( this ) ) @@ -234,7 +234,7 @@ void LLModalDialog::draw() if( !gFocusMgr.childHasMouseCapture( this ) ) { - gFocusMgr.setMouseCapture( this, NULL ); + gFocusMgr.setMouseCapture( this ); } } } @@ -259,7 +259,7 @@ void LLModalDialog::onAppFocusLost() LLModalDialog* instance = LLModalDialog::sModalStack.front(); if( gFocusMgr.childHasMouseCapture( instance ) ) { - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); } if( gFocusMgr.childHasKeyboardFocus( instance ) ) @@ -277,9 +277,9 @@ void LLModalDialog::onAppFocusGained() LLModalDialog* instance = LLModalDialog::sModalStack.front(); // This is a modal dialog. It sucks up all mouse and keyboard operations. - gFocusMgr.setMouseCapture( instance, NULL ); + gFocusMgr.setMouseCapture( instance ); instance->setFocus(TRUE); - gFocusMgr.setTopView( instance, NULL ); + gFocusMgr.setTopCtrl( instance ); instance->centerOnScreen(); } diff --git a/indra/llui/llresizebar.cpp b/indra/llui/llresizebar.cpp index c6bc7fb355..0128b4ebbc 100644 --- a/indra/llui/llresizebar.cpp +++ b/indra/llui/llresizebar.cpp @@ -21,8 +21,8 @@ LLResizeBar::LLResizeBar( const LLString& name, const LLRect& rect, S32 min_width, S32 min_height, Side side ) : LLView( name, rect, TRUE ), - mDragStartScreenX( 0 ), - mDragStartScreenY( 0 ), + mDragLastScreenX( 0 ), + mDragLastScreenY( 0 ), mLastMouseScreenX( 0 ), mLastMouseScreenY( 0 ), mMinWidth( min_width ), @@ -55,6 +55,8 @@ LLResizeBar::LLResizeBar( const LLString& name, const LLRect& rect, S32 min_widt default: break; } + // this is just a decorator + setSaveToXML(FALSE); } @@ -64,12 +66,11 @@ BOOL LLResizeBar::handleMouseDown(S32 x, S32 y, MASK mask) { // Route future Mouse messages here preemptively. (Release on mouse up.) // No handler needed for focus lost since this clas has no state that depends on it. - gFocusMgr.setMouseCapture( this, NULL ); + gFocusMgr.setMouseCapture( this ); - //localPointToScreen(x, y, &mDragStartScreenX, &mDragStartScreenX); - localPointToOtherView(x, y, &mDragStartScreenX, &mDragStartScreenY, getParent()->getParent()); - mLastMouseScreenX = mDragStartScreenX; - mLastMouseScreenY = mDragStartScreenY; + localPointToScreen(x, y, &mDragLastScreenX, &mDragLastScreenY); + mLastMouseScreenX = mDragLastScreenX; + mLastMouseScreenY = mDragLastScreenY; } return TRUE; @@ -80,10 +81,10 @@ BOOL LLResizeBar::handleMouseUp(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { // Release the mouse - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); handled = TRUE; } else @@ -108,74 +109,73 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask) BOOL handled = FALSE; // We only handle the click if the click both started and ended within us - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { - // *NOTE: this, of course, is fragile - LLView* floater_view = getParent()->getParent(); - S32 floater_view_x; - S32 floater_view_y; - localPointToOtherView(x, y, &floater_view_x, &floater_view_y, floater_view); + S32 screen_x; + S32 screen_y; + localPointToScreen(x, y, &screen_x, &screen_y); - S32 delta_x = floater_view_x - mDragStartScreenX; - S32 delta_y = floater_view_y - mDragStartScreenY; + S32 delta_x = screen_x - mDragLastScreenX; + S32 delta_y = screen_y - mDragLastScreenY; LLCoordGL mouse_dir; // use hysteresis on mouse motion to preserve user intent when mouse stops moving - mouse_dir.mX = (floater_view_x == mLastMouseScreenX) ? mLastMouseDir.mX : floater_view_x - mLastMouseScreenX; - mouse_dir.mY = (floater_view_y == mLastMouseScreenY) ? mLastMouseDir.mY : floater_view_y - mLastMouseScreenY; + mouse_dir.mX = (screen_x == mLastMouseScreenX) ? mLastMouseDir.mX : screen_x - mLastMouseScreenX; + mouse_dir.mY = (screen_y == mLastMouseScreenY) ? mLastMouseDir.mY : screen_y - mLastMouseScreenY; mLastMouseDir = mouse_dir; - mLastMouseScreenX = floater_view_x; - mLastMouseScreenY = floater_view_y; + mLastMouseScreenX = screen_x; + mLastMouseScreenY = screen_y; // Make sure the mouse in still over the application. We don't want to make the parent // so big that we can't see the resize handle any more. - LLRect valid_rect = floater_view->getRect(); - LLView* parentView = getParent(); - if( valid_rect.localPointInRect( floater_view_x, floater_view_y ) && parentView ) + LLRect valid_rect = getRootView()->getRect(); + LLView* resizing_view = getParent(); + + if( valid_rect.localPointInRect( screen_x, screen_y ) && resizing_view ) { // Resize the parent - LLRect parent_rect = parentView->getRect(); - LLRect scaled_rect = parent_rect; + LLRect orig_rect = resizing_view->getRect(); + LLRect scaled_rect = orig_rect; - S32 new_width = parent_rect.getWidth(); - S32 new_height = parent_rect.getHeight(); + S32 new_width = orig_rect.getWidth(); + S32 new_height = orig_rect.getHeight(); switch( mSide ) { case LEFT: - new_width = parent_rect.getWidth() - delta_x; + new_width = orig_rect.getWidth() - delta_x; if( new_width < mMinWidth ) { new_width = mMinWidth; - delta_x = parent_rect.getWidth() - mMinWidth; + delta_x = orig_rect.getWidth() - mMinWidth; } scaled_rect.translate(delta_x, 0); break; case TOP: - new_height = parent_rect.getHeight() + delta_y; + new_height = orig_rect.getHeight() + delta_y; if( new_height < mMinHeight ) { new_height = mMinHeight; - delta_y = mMinHeight - parent_rect.getHeight(); + delta_y = mMinHeight - orig_rect.getHeight(); } break; case RIGHT: - new_width = parent_rect.getWidth() + delta_x; + new_width = orig_rect.getWidth() + delta_x; if( new_width < mMinWidth ) { new_width = mMinWidth; - delta_x = mMinWidth - parent_rect.getWidth(); + delta_x = mMinWidth - orig_rect.getWidth(); } break; case BOTTOM: - new_height = parent_rect.getHeight() - delta_y; + new_height = orig_rect.getHeight() - delta_y; if( new_height < mMinHeight ) { new_height = mMinHeight; - delta_y = parent_rect.getHeight() - mMinHeight; + delta_y = orig_rect.getHeight() - mMinHeight; } scaled_rect.translate(0, delta_y); break; @@ -183,56 +183,59 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask) scaled_rect.mTop = scaled_rect.mBottom + new_height; scaled_rect.mRight = scaled_rect.mLeft + new_width; - parentView->setRect(scaled_rect); - - S32 snap_delta_x = 0; - S32 snap_delta_y = 0; + resizing_view->setRect(scaled_rect); LLView* snap_view = NULL; switch( mSide ) { case LEFT: - snap_view = parentView->findSnapEdge(snap_delta_x, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_x -= scaled_rect.mLeft; - scaled_rect.mLeft += snap_delta_x; + snap_view = resizing_view->findSnapEdge(scaled_rect.mLeft, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); break; case TOP: - snap_view = parentView->findSnapEdge(snap_delta_y, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_y -= scaled_rect.mTop; - scaled_rect.mTop += snap_delta_y; + snap_view = resizing_view->findSnapEdge(scaled_rect.mTop, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); break; case RIGHT: - snap_view = parentView->findSnapEdge(snap_delta_x, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_x -= scaled_rect.mRight; - scaled_rect.mRight += snap_delta_x; + snap_view = resizing_view->findSnapEdge(scaled_rect.mRight, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); break; case BOTTOM: - snap_view = parentView->findSnapEdge(snap_delta_y, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_y -= scaled_rect.mBottom; - scaled_rect.mBottom += snap_delta_y; + snap_view = resizing_view->findSnapEdge(scaled_rect.mBottom, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); break; } - parentView->snappedTo(snap_view); + // register "snap" behavior with snapped view + resizing_view->snappedTo(snap_view); - parentView->setRect(parent_rect); + // restore original rectangle so the appropriate changes are detected + resizing_view->setRect(orig_rect); + // change view shape as user operation + resizing_view->userSetShape(scaled_rect); - parentView->reshape(scaled_rect.getWidth(), scaled_rect.getHeight(), FALSE); - parentView->translate(scaled_rect.mLeft - parentView->getRect().mLeft, scaled_rect.mBottom - parentView->getRect().mBottom); - - floater_view_x = mDragStartScreenX + delta_x; - floater_view_y = mDragStartScreenY + delta_y; - mDragStartScreenX = floater_view_x + snap_delta_x; - mDragStartScreenY = floater_view_y + snap_delta_y; + // update last valid mouse cursor position based on resized view's actual size + LLRect new_rect = resizing_view->getRect(); + switch(mSide) + { + case LEFT: + mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft; + break; + case RIGHT: + mDragLastScreenX += new_rect.mRight - orig_rect.mRight; + break; + case TOP: + mDragLastScreenY += new_rect.mTop - orig_rect.mTop; + break; + case BOTTOM: + mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom; + break; + default: + break; + } } - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; handled = TRUE; } else { - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; handled = TRUE; } diff --git a/indra/llui/llresizebar.h b/indra/llui/llresizebar.h index c2a07fd3e3..7a77cce8a6 100644 --- a/indra/llui/llresizebar.h +++ b/indra/llui/llresizebar.h @@ -30,8 +30,8 @@ public: void setResizeLimits( S32 min_width, S32 min_height ) { mMinWidth = min_width; mMinHeight = min_height; } protected: - S32 mDragStartScreenX; - S32 mDragStartScreenY; + S32 mDragLastScreenX; + S32 mDragLastScreenY; S32 mLastMouseScreenX; S32 mLastMouseScreenY; LLCoordGL mLastMouseDir; diff --git a/indra/llui/llresizehandle.cpp b/indra/llui/llresizehandle.cpp index 77101fa296..e4035b3ab2 100644 --- a/indra/llui/llresizehandle.cpp +++ b/indra/llui/llresizehandle.cpp @@ -23,8 +23,8 @@ const S32 RESIZE_BORDER_WIDTH = 3; LLResizeHandle::LLResizeHandle( const LLString& name, const LLRect& rect, S32 min_width, S32 min_height, ECorner corner ) : LLView( name, rect, TRUE ), - mDragStartScreenX( 0 ), - mDragStartScreenY( 0 ), + mDragLastScreenX( 0 ), + mDragLastScreenY( 0 ), mLastMouseScreenX( 0 ), mLastMouseScreenY( 0 ), mImage( NULL ), @@ -47,6 +47,9 @@ LLResizeHandle::LLResizeHandle( const LLString& name, const LLRect& rect, S32 mi case RIGHT_TOP: setFollows( FOLLOWS_RIGHT | FOLLOWS_TOP ); break; case RIGHT_BOTTOM: setFollows( FOLLOWS_RIGHT | FOLLOWS_BOTTOM ); break; } + + // decorator object, don't serialize + setSaveToXML(FALSE); } EWidgetType LLResizeHandle::getWidgetType() const @@ -69,11 +72,11 @@ BOOL LLResizeHandle::handleMouseDown(S32 x, S32 y, MASK mask) { // Route future Mouse messages here preemptively. (Release on mouse up.) // No handler needed for focus lost since this clas has no state that depends on it. - gFocusMgr.setMouseCapture( this, NULL ); + gFocusMgr.setMouseCapture( this ); - localPointToScreen(x, y, &mDragStartScreenX, &mDragStartScreenY); - mLastMouseScreenX = mDragStartScreenX; - mLastMouseScreenY = mDragStartScreenY; + localPointToScreen(x, y, &mDragLastScreenX, &mDragLastScreenY); + mLastMouseScreenX = mDragLastScreenX; + mLastMouseScreenY = mDragLastScreenY; } } @@ -85,10 +88,10 @@ BOOL LLResizeHandle::handleMouseUp(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { // Release the mouse - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); handled = TRUE; } else @@ -106,7 +109,7 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) BOOL handled = FALSE; // We only handle the click if the click both started and ended within us - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { // Make sure the mouse in still over the application. We don't want to make the parent // so big that we can't see the resize handle any more. @@ -114,18 +117,18 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) S32 screen_x; S32 screen_y; localPointToScreen(x, y, &screen_x, &screen_y); - const LLRect& valid_rect = gFloaterView->getRect(); // Assumes that the parent is a floater. + const LLRect valid_rect = getRootView()->getRect(); screen_x = llclamp( screen_x, valid_rect.mLeft, valid_rect.mRight ); screen_y = llclamp( screen_y, valid_rect.mBottom, valid_rect.mTop ); - LLView* parentView = getParent(); - if( parentView ) + LLView* resizing_view = getParent(); + if( resizing_view ) { // Resize the parent - LLRect parent_rect = parentView->getRect(); - LLRect scaled_rect = parent_rect; - S32 delta_x = screen_x - mDragStartScreenX; - S32 delta_y = screen_y - mDragStartScreenY; + LLRect orig_rect = resizing_view->getRect(); + LLRect scaled_rect = orig_rect; + S32 delta_x = screen_x - mDragLastScreenX; + S32 delta_y = screen_y - mDragLastScreenY; LLCoordGL mouse_dir; // use hysteresis on mouse motion to preserve user intent when mouse stops moving mouse_dir.mX = (screen_x == mLastMouseScreenX) ? mLastMouseDir.mX : screen_x - mLastMouseScreenX; @@ -156,18 +159,18 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) break; } - S32 new_width = parent_rect.getWidth() + x_multiple * delta_x; + S32 new_width = orig_rect.getWidth() + x_multiple * delta_x; if( new_width < mMinWidth ) { new_width = mMinWidth; - delta_x = x_multiple * (mMinWidth - parent_rect.getWidth()); + delta_x = x_multiple * (mMinWidth - orig_rect.getWidth()); } - S32 new_height = parent_rect.getHeight() + y_multiple * delta_y; + S32 new_height = orig_rect.getHeight() + y_multiple * delta_y; if( new_height < mMinHeight ) { new_height = mMinHeight; - delta_y = y_multiple * (mMinHeight - parent_rect.getHeight()); + delta_y = y_multiple * (mMinHeight - orig_rect.getHeight()); } switch( mCorner ) @@ -188,10 +191,7 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) // temporarily set new parent rect scaled_rect.mRight = scaled_rect.mLeft + new_width; scaled_rect.mTop = scaled_rect.mBottom + new_height; - parentView->setRect(scaled_rect); - - S32 snap_delta_x = 0; - S32 snap_delta_y = 0; + resizing_view->setRect(scaled_rect); LLView* snap_view = NULL; LLView* test_view = NULL; @@ -200,77 +200,78 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) switch(mCorner) { case LEFT_TOP: - snap_view = parentView->findSnapEdge(snap_delta_x, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_x -= scaled_rect.mLeft; - test_view = parentView->findSnapEdge(snap_delta_y, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_y -= scaled_rect.mTop; + snap_view = resizing_view->findSnapEdge(scaled_rect.mLeft, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); + test_view = resizing_view->findSnapEdge(scaled_rect.mTop, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); if (!snap_view) { snap_view = test_view; } - scaled_rect.mLeft += snap_delta_x; - scaled_rect.mTop += snap_delta_y; break; case LEFT_BOTTOM: - snap_view = parentView->findSnapEdge(snap_delta_x, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_x -= scaled_rect.mLeft; - test_view = parentView->findSnapEdge(snap_delta_y, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_y -= scaled_rect.mBottom; + snap_view = resizing_view->findSnapEdge(scaled_rect.mLeft, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); + test_view = resizing_view->findSnapEdge(scaled_rect.mBottom, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); if (!snap_view) { snap_view = test_view; } - scaled_rect.mLeft += snap_delta_x; - scaled_rect.mBottom += snap_delta_y; break; case RIGHT_TOP: - snap_view = parentView->findSnapEdge(snap_delta_x, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_x -= scaled_rect.mRight; - test_view = parentView->findSnapEdge(snap_delta_y, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_y -= scaled_rect.mTop; + snap_view = resizing_view->findSnapEdge(scaled_rect.mRight, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); + test_view = resizing_view->findSnapEdge(scaled_rect.mTop, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); if (!snap_view) { snap_view = test_view; } - scaled_rect.mRight += snap_delta_x; - scaled_rect.mTop += snap_delta_y; break; case RIGHT_BOTTOM: - snap_view = parentView->findSnapEdge(snap_delta_x, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_x -= scaled_rect.mRight; - test_view = parentView->findSnapEdge(snap_delta_y, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); - snap_delta_y -= scaled_rect.mBottom; + snap_view = resizing_view->findSnapEdge(scaled_rect.mRight, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); + test_view = resizing_view->findSnapEdge(scaled_rect.mBottom, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); if (!snap_view) { snap_view = test_view; } - scaled_rect.mRight += snap_delta_x; - scaled_rect.mBottom += snap_delta_y; break; } - parentView->snappedTo(snap_view); + // register "snap" behavior with snapped view + resizing_view->snappedTo(snap_view); // reset parent rect - parentView->setRect(parent_rect); + resizing_view->setRect(orig_rect); // translate and scale to new shape - parentView->reshape(scaled_rect.getWidth(), scaled_rect.getHeight(), FALSE); - parentView->translate(scaled_rect.mLeft - parentView->getRect().mLeft, scaled_rect.mBottom - parentView->getRect().mBottom); + resizing_view->userSetShape(scaled_rect); - screen_x = mDragStartScreenX + delta_x + snap_delta_x; - screen_y = mDragStartScreenY + delta_y + snap_delta_y; - mDragStartScreenX = screen_x; - mDragStartScreenY = screen_y; + // update last valid mouse cursor position based on resized view's actual size + LLRect new_rect = resizing_view->getRect(); + switch(mCorner) + { + case LEFT_TOP: + mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft; + mDragLastScreenY += new_rect.mTop - orig_rect.mTop; + break; + case LEFT_BOTTOM: + mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft; + mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom; + break; + case RIGHT_TOP: + mDragLastScreenX += new_rect.mRight - orig_rect.mRight; + mDragLastScreenY += new_rect.mTop - orig_rect.mTop; + break; + case RIGHT_BOTTOM: + mDragLastScreenX += new_rect.mRight - orig_rect.mRight; + mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom; + break; + default: + break; + } } - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active) " << llendl; handled = TRUE; } else if( getVisible() && pointInHandle( x, y ) ) { - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive) " << llendl; handled = TRUE; } diff --git a/indra/llui/llresizehandle.h b/indra/llui/llresizehandle.h index 1350d1af20..cf383a33cc 100644 --- a/indra/llui/llresizehandle.h +++ b/indra/llui/llresizehandle.h @@ -37,8 +37,8 @@ protected: BOOL pointInHandle( S32 x, S32 y ); protected: - S32 mDragStartScreenX; - S32 mDragStartScreenY; + S32 mDragLastScreenX; + S32 mDragLastScreenY; S32 mLastMouseScreenX; S32 mLastMouseScreenY; LLCoordGL mLastMouseDir; diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index c21bbdcc75..f4aea3fa11 100644 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -214,7 +214,7 @@ BOOL LLScrollbar::handleMouseDown(S32 x, S32 y, MASK mask) { // Start dragging the thumb // No handler needed for focus lost since this clas has no state that depends on it. - gFocusMgr.setMouseCapture( this, NULL ); + gFocusMgr.setMouseCapture( this ); mDragStartX = x; mDragStartY = y; mOrigRect.mTop = mThumbRect.mTop; @@ -255,7 +255,7 @@ BOOL LLScrollbar::handleHover(S32 x, S32 y, MASK mask) // because they'll capture the mouse whenever they need hover events. BOOL handled = FALSE; - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { S32 height = mRect.getHeight(); S32 width = mRect.getWidth(); @@ -408,9 +408,9 @@ BOOL LLScrollbar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, BOOL LLScrollbar::handleMouseUp(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); handled = TRUE; } else @@ -442,7 +442,7 @@ void LLScrollbar::draw() screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &local_mouse_x, &local_mouse_y); BOOL other_captor = gFocusMgr.getMouseCapture() && gFocusMgr.getMouseCapture() != this; - BOOL hovered = mEnabled && !other_captor && (gFocusMgr.getMouseCapture() == this || mThumbRect.pointInRect(local_mouse_x, local_mouse_y)); + BOOL hovered = mEnabled && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y)); if (hovered) { mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f)); diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp index 15bb8e3f24..e5e31e45a9 100644 --- a/indra/llui/llscrollcontainer.cpp +++ b/indra/llui/llscrollcontainer.cpp @@ -437,7 +437,7 @@ void LLScrollableContainerView::draw() // auto-focus when scrollbar active // this allows us to capture user intent (i.e. stop automatically scrolling the view/etc) if (!gFocusMgr.childHasKeyboardFocus(this) && - (gFocusMgr.getMouseCapture() == mScrollbar[VERTICAL] || gFocusMgr.getMouseCapture() == mScrollbar[HORIZONTAL])) + (mScrollbar[VERTICAL]->hasMouseCapture() || mScrollbar[HORIZONTAL]->hasMouseCapture())) { focusFirstItem(); } diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 35d5affa5d..98dddfb542 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -29,8 +29,11 @@ #include "llwindow.h" #include "llcontrol.h" #include "llkeyboard.h" +#include "llresizebar.h" const S32 LIST_BORDER_PAD = 2; // white space inside the border and to the left of the scrollbar +const S32 MIN_COLUMN_WIDTH = 20; +const S32 LIST_SNAP_PADDING = 5; // local structures & classes. struct SortScrollListItem @@ -254,7 +257,7 @@ LLScrollListItem::~LLScrollListItem() std::for_each(mColumns.begin(), mColumns.end(), DeletePointer()); } -BOOL LLScrollListItem::handleMouseDown(S32 x, S32 y, MASK mask) +BOOL LLScrollListItem::handleClick(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; @@ -355,14 +358,13 @@ LLScrollListCtrl::LLScrollListCtrl(const LLString& name, const LLRect& rect, mPageLines(0), mHeadingHeight(20), mMaxSelectable(0), - mHeadingFont(NULL), mAllowMultipleSelection( allow_multiple_selection ), mAllowKeyboardMovement(TRUE), mCommitOnKeyboardMovement(TRUE), mCommitOnSelectionChange(FALSE), mSelectionChanged(FALSE), mCanSelect(TRUE), - mDisplayColumnButtons(FALSE), + mDisplayColumnHeaders(FALSE), mCollapseEmptyColumns(FALSE), mIsPopup(FALSE), mMaxItemCount(INT_MAX), @@ -377,21 +379,20 @@ LLScrollListCtrl::LLScrollListCtrl(const LLString& name, const LLRect& rect, mFgUnselectedColor( LLUI::sColorsGroup->getColor("ScrollUnselectedColor") ), mFgDisabledColor( LLUI::sColorsGroup->getColor("ScrollDisabledColor") ), mHighlightedColor( LLUI::sColorsGroup->getColor("ScrollHighlightedColor") ), + mHighlightedItem(-1), mBorderThickness( 2 ), mOnDoubleClickCallback( NULL ), mOnMaximumSelectCallback( NULL ), mOnSortChangedCallback( NULL ), - mHighlightedItem(-1), + mDrewSelected(FALSE), mBorder(NULL), - mDefaultColumn("SIMPLE"), mSearchColumn(0), + mDefaultColumn("SIMPLE"), mNumDynamicWidthColumns(0), mTotalStaticColumnWidth(0), - mSortColumn(0), - mSortAscending(TRUE), - - mDrewSelected(FALSE) + mSortColumn(-1), + mSortAscending(TRUE) { mItemListRect.setOriginAndSize( mBorderThickness + LIST_BORDER_PAD, @@ -478,6 +479,7 @@ void LLScrollListCtrl::clearRows() mScrollLines = 0; mLastSelected = NULL; + updateMaxContentWidth(NULL); } @@ -527,7 +529,6 @@ S32 LLScrollListCtrl::getFirstSelectedIndex() return -1; } - LLScrollListItem* LLScrollListCtrl::getFirstData() const { if (mItemList.size() == 0) @@ -537,6 +538,15 @@ LLScrollListItem* LLScrollListCtrl::getFirstData() const return mItemList[0]; } +LLScrollListItem* LLScrollListCtrl::getLastData() const +{ + if (mItemList.size() == 0) + { + return NULL; + } + return mItemList[mItemList.size() - 1]; +} + std::vector<LLScrollListItem*> LLScrollListCtrl::getAllData() const { std::vector<LLScrollListItem*> ret; @@ -554,7 +564,7 @@ void LLScrollListCtrl::reshape( S32 width, S32 height, BOOL called_from_parent ) { LLUICtrl::reshape( width, height, called_from_parent ); - S32 heading_size = (mDisplayColumnButtons ? mHeadingHeight : 0); + S32 heading_size = (mDisplayColumnHeaders ? mHeadingHeight : 0); mItemListRect.setOriginAndSize( mBorderThickness + LIST_BORDER_PAD, @@ -567,10 +577,8 @@ void LLScrollListCtrl::reshape( S32 width, S32 height, BOOL called_from_parent ) mScrollbar->setPageSize( mPageLines ); updateColumns(); - updateColumnButtons(); } - // Attempt to size the control to show all items. // Do not make larger than width or height. void LLScrollListCtrl::arrange(S32 max_width, S32 max_height) @@ -623,14 +631,56 @@ BOOL LLScrollListCtrl::addItem( LLScrollListItem* item, EAddPosition pos ) updateLineHeight(); mPageLines = mLineHeight ? mItemListRect.getHeight() / mLineHeight : 0; - mScrollbar->setVisible(mPageLines < getItemCount()); + BOOL scrollbar_visible = mPageLines < getItemCount(); + + if (scrollbar_visible != mScrollbar->getVisible()) + { + mScrollbar->setVisible(mPageLines < getItemCount()); + updateColumns(); + } mScrollbar->setPageSize( mPageLines ); mScrollbar->setDocSize( getItemCount() ); + + updateMaxContentWidth(item); } + return not_too_big; } +void LLScrollListCtrl::updateMaxContentWidth(LLScrollListItem* added_item) +{ + const S32 HEADING_TEXT_PADDING = 30; + const S32 COLUMN_TEXT_PADDING = 20; + + std::map<LLString, LLScrollListColumn>::iterator column_itor; + for (column_itor = mColumns.begin(); column_itor != mColumns.end(); ++column_itor) + { + LLScrollListColumn* column = &column_itor->second; + + if (!added_item) + { + // update on all items + column->mMaxContentWidth = column->mHeader ? LLFontGL::sSansSerifSmall->getWidth(column->mLabel) + mColumnPadding + HEADING_TEXT_PADDING : 0; + item_list::iterator iter; + for (iter = mItemList.begin(); iter != mItemList.end(); iter++) + { + LLScrollListCell* cellp = (*iter)->getColumn(column->mIndex); + if (!cellp) continue; + + column->mMaxContentWidth = llmax(LLFontGL::sSansSerifSmall->getWidth(cellp->getText()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth); + } + } + else + { + LLScrollListCell* cellp = added_item->getColumn(column->mIndex); + if (!cellp) continue; + + column->mMaxContentWidth = llmax(LLFontGL::sSansSerifSmall->getWidth(cellp->getText()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth); + } + } +} + // Line height is the max height of all the cells in all the items. void LLScrollListCtrl::updateLineHeight() @@ -659,60 +709,82 @@ void LLScrollListCtrl::updateColumns() for (column_itor = mColumns.begin(); column_itor != mColumns.end(); ++column_itor) { LLScrollListColumn *column = &column_itor->second; + S32 new_width = column->mWidth; if (column->mRelWidth >= 0) { - column->mWidth = (S32)llround(column->mRelWidth*mItemListRect.getWidth()); + new_width = (S32)llround(column->mRelWidth*mItemListRect.getWidth()); } else if (column->mDynamicWidth) { - column->mWidth = (mItemListRect.getWidth() - mTotalStaticColumnWidth) / mNumDynamicWidthColumns; - + new_width = (mItemListRect.getWidth() - mTotalStaticColumnWidth) / mNumDynamicWidthColumns; + } + + if (new_width != column->mWidth) + { + column->mWidth = new_width; } mColumnsIndexed[column_itor->second.mIndex] = column; } -} -void LLScrollListCtrl::updateColumnButtons() -{ - std::map<LLString, LLScrollListColumn>::iterator column_itor; - for (column_itor = mColumns.begin(); column_itor != mColumns.end(); ++column_itor) + item_list::iterator iter; + for (iter = mItemList.begin(); iter != mItemList.end(); iter++) { - LLScrollListColumn* column = &column_itor->second; - LLButton *button = column->mButton; - - if (button) + LLScrollListItem *itemp = *iter; + S32 num_cols = itemp->getNumColumns(); + S32 i = 0; + for (LLScrollListCell* cell = itemp->getColumn(i); i < num_cols; cell = itemp->getColumn(++i)) { - mColumnsIndexed[column->mIndex] = column; + if (i >= (S32)mColumnsIndexed.size()) break; + + cell->setWidth(mColumnsIndexed[i]->mWidth); + } + } + // update headers + std::vector<LLScrollListColumn*>::iterator column_ordered_it; + S32 left = mItemListRect.mLeft; + LLColumnHeader* last_header = NULL; + for (column_ordered_it = mColumnsIndexed.begin(); column_ordered_it != mColumnsIndexed.end(); ++column_ordered_it) + { + if ((*column_ordered_it)->mWidth <= 0) + { + // skip hidden columns + } + LLScrollListColumn* column = *column_ordered_it; + + if (column->mHeader) + { + last_header = column->mHeader; S32 top = mItemListRect.mTop; - S32 left = mItemListRect.mLeft; - { - std::map<LLString, LLScrollListColumn>::iterator itor; - for (itor = mColumns.begin(); itor != mColumns.end(); ++itor) - { - if (itor->second.mIndex < column->mIndex && - itor->second.mWidth > 0) - { - left += itor->second.mWidth + mColumnPadding; - } - } - } - S32 right = left+column->mWidth; - if (column->mIndex != (S32)mColumns.size()-1) + S32 right = left + column->mWidth; + + if (column->mIndex != (S32)mColumnsIndexed.size()-1) { right += mColumnPadding; } - LLRect temp_rect = LLRect(left,top+mHeadingHeight,right,top); - button->setRect(temp_rect); - button->setFont(mHeadingFont); - button->setVisible(mDisplayColumnButtons); + right = llmax(left, llmin(mItemListRect.getWidth(), right)); + + S32 header_width = right - left; + + last_header->reshape(header_width, mHeadingHeight); + last_header->translate(left - last_header->getRect().mLeft, top - last_header->getRect().mBottom); + last_header->setVisible(mDisplayColumnHeaders && header_width > 0); + left = right; } } + + // expand last column header we encountered to full list width + if (last_header) + { + S32 header_strip_width = mItemListRect.getWidth() + (mScrollbar->getVisible() ? 0 : SCROLLBAR_SIZE); + S32 new_width = llmax(0, mItemListRect.mLeft + header_strip_width - last_header->getRect().mLeft); + last_header->reshape(new_width, last_header->getRect().getHeight()); + } } void LLScrollListCtrl::setDisplayHeading(BOOL display) { - mDisplayColumnButtons = display; + mDisplayColumnHeaders = display; updateColumns(); @@ -726,15 +798,7 @@ void LLScrollListCtrl::setHeadingHeight(S32 heading_height) reshape(mRect.getWidth(), mRect.getHeight()); // Resize - mScrollbar->reshape(SCROLLBAR_SIZE, mItemListRect.getHeight()); - - updateColumnButtons(); -} - -void LLScrollListCtrl::setHeadingFont(const LLFontGL* heading_font) -{ - mHeadingFont = heading_font; - updateColumnButtons(); + mScrollbar->reshape(SCROLLBAR_SIZE, mItemListRect.getHeight() + (mDisplayColumnHeaders ? mHeadingHeight : 0)); } void LLScrollListCtrl::setCollapseEmptyColumns(BOOL collapse) @@ -854,6 +918,7 @@ void LLScrollListCtrl::deleteSingleItem(S32 target_index) } delete itemp; mItemList.erase(mItemList.begin() + target_index); + updateMaxContentWidth(NULL); } void LLScrollListCtrl::deleteSelectedItems() @@ -873,6 +938,7 @@ void LLScrollListCtrl::deleteSelectedItems() } } mLastSelected = NULL; + updateMaxContentWidth(NULL); } void LLScrollListCtrl::highlightNthItem(S32 target_index) @@ -880,6 +946,7 @@ void LLScrollListCtrl::highlightNthItem(S32 target_index) if (mHighlightedItem != target_index) { mHighlightedItem = target_index; + llinfos << "Highlighting item " << target_index << llendl; } } @@ -1467,109 +1534,154 @@ BOOL LLScrollListCtrl::handleScrollWheel(S32 x, S32 y, S32 clicks) return handled; } - -BOOL LLScrollListCtrl::handleMouseDown(S32 x, S32 y, MASK mask) +BOOL LLScrollListCtrl::selectItemAt(S32 x, S32 y, MASK mask) { - BOOL handled = LLView::childrenHandleMouseDown(x, y, mask) != NULL; + if (!mCanSelect) return FALSE; - // set keyboard focus first, in case click action wants to move focus elsewhere - setFocus(TRUE); + BOOL selection_changed = FALSE; - if( !handled && mCanSelect) + LLScrollListItem* hit_item = hitItem(x, y); + if( hit_item ) { - LLScrollListItem* hit_item = hitItem(x, y); - if( hit_item ) + if( mAllowMultipleSelection ) { - if( mAllowMultipleSelection ) + if (mask & MASK_SHIFT) { - if (mask & MASK_SHIFT) + if (mLastSelected == NULL) { - if (mLastSelected == NULL) - { - selectItem(hit_item); - } - else + selectItem(hit_item); + } + else + { + // Select everthing between mLastSelected and hit_item + bool selecting = false; + item_list::iterator itor; + // If we multiselect backwards, we'll stomp on mLastSelected, + // meaning that we never stop selecting until hitting max or + // the end of the list. + LLScrollListItem* lastSelected = mLastSelected; + for (itor = mItemList.begin(); itor != mItemList.end(); ++itor) { - // Select everthing between mLastSelected and hit_item - bool selecting = false; - item_list::iterator itor; - // If we multiselect backwards, we'll stomp on mLastSelected, - // meaning that we never stop selecting until hitting max or - // the end of the list. - LLScrollListItem* lastSelected = mLastSelected; - for (itor = mItemList.begin(); itor != mItemList.end(); ++itor) + if(mMaxSelectable > 0 && getAllSelected().size() >= mMaxSelectable) { - if(mMaxSelectable > 0 && getAllSelected().size() >= mMaxSelectable) - { - if(mOnMaximumSelectCallback) - { - mOnMaximumSelectCallback(mCallbackUserData); - } - break; - } - LLScrollListItem *item = *itor; - if (item == hit_item || item == lastSelected) - { - selectItem(item, FALSE); - selecting = !selecting; - } - if (selecting) + if(mOnMaximumSelectCallback) { - selectItem(item, FALSE); + mOnMaximumSelectCallback(mCallbackUserData); } + break; + } + LLScrollListItem *item = *itor; + if (item == hit_item || item == lastSelected) + { + selectItem(item, FALSE); + selecting = !selecting; + } + if (selecting) + { + selectItem(item, FALSE); } } } - else if (mask & MASK_CONTROL) + } + else if (mask & MASK_CONTROL) + { + if (hit_item->getSelected()) { - if (hit_item->getSelected()) + deselectItem(hit_item); + } + else + { + if(!(mMaxSelectable > 0 && getAllSelected().size() >= mMaxSelectable)) { - deselectItem(hit_item); + selectItem(hit_item, FALSE); } else { - if(!(mMaxSelectable > 0 && getAllSelected().size() >= mMaxSelectable)) + if(mOnMaximumSelectCallback) { - selectItem(hit_item, FALSE); - } - else - { - if(mOnMaximumSelectCallback) - { - mOnMaximumSelectCallback(mCallbackUserData); - } + mOnMaximumSelectCallback(mCallbackUserData); } } } - else - { - deselectAllItems(TRUE); - selectItem(hit_item); - } } else { + deselectAllItems(TRUE); selectItem(hit_item); } - - hit_item->handleMouseDown(x - mBorderThickness - LIST_BORDER_PAD, - 1, mask); - // always commit on mousedown - onCommit(); - mSelectionChanged = FALSE; - - // clear search string on mouse operations - mSearchString.clear(); } else { - mLastSelected = NULL; + selectItem(hit_item); } + + hit_item->handleClick(x - mBorderThickness - LIST_BORDER_PAD, + 1, mask); + + selection_changed = mSelectionChanged; + if (mCommitOnSelectionChange) + { + commitIfChanged(); + } + + // clear search string on mouse operations + mSearchString.clear(); + } + else + { + //mLastSelected = NULL; + //deselectAllItems(TRUE); + } + + return selection_changed; +} + + +BOOL LLScrollListCtrl::handleMouseDown(S32 x, S32 y, MASK mask) +{ + BOOL handled = LLView::childrenHandleMouseDown(x, y, mask) != NULL; + + if( !handled ) + { + // set keyboard focus first, in case click action wants to move focus elsewhere + setFocus(TRUE); + + // clear selection changed flag so because user is starting a selection operation + mSelectionChanged = FALSE; + + gFocusMgr.setMouseCapture(this); + selectItemAt(x, y, mask); } return TRUE; } +BOOL LLScrollListCtrl::handleMouseUp(S32 x, S32 y, MASK mask) +{ + if (hasMouseCapture()) + { + if(mask == MASK_NONE) + { + selectItemAt(x, y, mask); + } + } + + if (hasMouseCapture()) + { + gFocusMgr.setMouseCapture(NULL); + } + + // always commit when mouse operation is completed inside list + // this only needs to be done for lists that don't commit on selection change + if (!mCommitOnSelectionChange && pointInView(x,y)) + { + mSelectionChanged = FALSE; + onCommit(); + } + + return LLUICtrl::handleMouseUp(x, y, mask); +} + BOOL LLScrollListCtrl::handleDoubleClick(S32 x, S32 y, MASK mask) { //BOOL handled = FALSE; @@ -1628,31 +1740,35 @@ BOOL LLScrollListCtrl::handleHover(S32 x,S32 y,MASK mask) { BOOL handled = FALSE; - if(getVisible()) + if (hasMouseCapture()) { - if (mCanSelect) + if(mask == MASK_NONE) { - LLScrollListItem* item = hitItem(x, y); - if (item) - { - highlightNthItem(getItemIndex(item)); - } - else - { - highlightNthItem(-1); - } + selectItemAt(x, y, mask); } - - handled = LLView::handleHover( x, y, mask ); - - if( !handled ) + } + else if (mCanSelect) + { + LLScrollListItem* item = hitItem(x, y); + if (item) + { + highlightNthItem(getItemIndex(item)); + } + else { - // Opaque - getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << llendl; - handled = TRUE; + highlightNthItem(-1); } } + + handled = LLUICtrl::handleHover( x, y, mask ); + + //if( !handled ) + //{ + // // Opaque + // getWindow()->setCursor(UI_CURSOR_ARROW); + // lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << llendl; + // handled = TRUE; + //} return handled; } @@ -1954,7 +2070,7 @@ void LLScrollListCtrl::deselectItem(LLScrollListItem* itemp) void LLScrollListCtrl::commitIfChanged() { - if (mSelectionChanged) + if (mSelectionChanged && !hasMouseCapture()) { mSelectionChanged = FALSE; onCommit(); @@ -1973,9 +2089,18 @@ void LLScrollListCtrl::onScrollChange( S32 new_pos, LLScrollbar* scrollbar, void // First column is column 0 void LLScrollListCtrl::sortByColumn(U32 column, BOOL ascending) { - mSortColumn = column; - mSortAscending = ascending; - std::sort(mItemList.begin(), mItemList.end(), SortScrollListItem(mSortColumn, mSortAscending)); + if (mSortColumn != column) + { + mSortColumn = column; + std::sort(mItemList.begin(), mItemList.end(), SortScrollListItem(mSortColumn, mSortAscending)); + } + + // just reverse the list if changing sort order + if(mSortAscending != ascending) + { + std::reverse(mItemList.begin(), mItemList.end()); + mSortAscending = ascending; + } } void LLScrollListCtrl::sortByColumn(LLString name, BOOL ascending) @@ -2047,7 +2172,7 @@ LLXMLNodePtr LLScrollListCtrl::getXML(bool save_children) const node->createChild("draw_border", TRUE)->setBoolValue((mBorder != NULL)); - node->createChild("draw_heading", TRUE)->setBoolValue(mDisplayColumnButtons); + node->createChild("draw_heading", TRUE)->setBoolValue(mDisplayColumnHeaders); node->createChild("background_visible", TRUE)->setBoolValue(mBackgroundVisible); @@ -2196,13 +2321,6 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac node->getAttributeS32("heading_height", heading_height); scroll_list->setHeadingHeight(heading_height); } - if (node->hasAttribute("heading_font")) - { - LLString heading_font(""); - node->getAttributeString("heading_font", heading_font); - LLFontGL* gl_font = LLFontGL::fontFromName(heading_font.c_str()); - scroll_list->setHeadingFont(gl_font); - } scroll_list->setCollapseEmptyColumns(collapse_empty_columns); scroll_list->setScrollListParameters(node); @@ -2408,7 +2526,7 @@ BOOL LLScrollListCtrl::canDeselect() void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos) { LLString name = column["name"].asString(); - if (mColumns.size() == 0) + if (mColumns.empty()) { mDefaultColumn = 0; } @@ -2451,30 +2569,28 @@ void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos) right += mColumnPadding; } LLRect temp_rect = LLRect(left,top+mHeadingHeight,right,top); - new_column->mButton = new LLSquareButton(button_name, temp_rect, "", mHeadingFont, "", onClickColumn, NULL); + new_column->mHeader = new LLColumnHeader(button_name, temp_rect, new_column); if(column["image"].asString() != "") { - //new_column->mButton->setScaleImage(false); - new_column->mButton->setImageSelected(column["image"].asString()); - new_column->mButton->setImageUnselected(column["image"].asString()); + //new_column->mHeader->setScaleImage(false); + new_column->mHeader->setImage(column["image"].asString()); } else { - new_column->mButton->setLabelSelected(new_column->mLabel); - new_column->mButton->setLabelUnselected(new_column->mLabel); + new_column->mHeader->setLabel(new_column->mLabel); + //new_column->mHeader->setLabel(new_column->mLabel); } //RN: although it might be useful to change sort order with the keyboard, // mixing tab stops on child items along with the parent item is not supported yet - new_column->mButton->setTabStop(FALSE); - addChild(new_column->mButton); - new_column->mButton->setVisible(mDisplayColumnButtons); + new_column->mHeader->setTabStop(FALSE); + addChild(new_column->mHeader); + new_column->mHeader->setVisible(mDisplayColumnHeaders); // Move scroll to front removeChild(mScrollbar); addChild(mScrollbar); - - new_column->mButton->setCallbackUserData(new_column); + } } updateColumns(); @@ -2517,7 +2633,7 @@ void LLScrollListCtrl::onClickColumn(void *userdata) std::string LLScrollListCtrl::getSortColumnName() { - LLScrollListColumn* column = mColumnsIndexed[mSortColumn]; + LLScrollListColumn* column = mSortColumn >= 0 ? mColumnsIndexed[mSortColumn] : NULL; if (column) return column->mName; else return ""; @@ -2528,11 +2644,11 @@ void LLScrollListCtrl::clearColumns() std::map<LLString, LLScrollListColumn>::iterator itor; for (itor = mColumns.begin(); itor != mColumns.end(); ++itor) { - LLButton *button = itor->second.mButton; - if (button) + LLColumnHeader *header = itor->second.mHeader; + if (header) { - removeChild(button); - delete button; + removeChild(header); + delete header; } } mColumns.clear(); @@ -2544,14 +2660,22 @@ void LLScrollListCtrl::setColumnLabel(const LLString& column, const LLString& la if (itor != mColumns.end()) { itor->second.mLabel = label; - if (itor->second.mButton) + if (itor->second.mHeader) { - itor->second.mButton->setLabelSelected(label); - itor->second.mButton->setLabelUnselected(label); + itor->second.mHeader->setLabel(label); } } } +LLScrollListColumn* LLScrollListCtrl::getColumn(S32 index) +{ + if (index < 0 || index >= (S32)mColumnsIndexed.size()) + { + return NULL; + } + return mColumnsIndexed[index]; +} + void LLScrollListCtrl::setColumnHeadings(LLSD headings) { mColumns.clear(); @@ -2629,6 +2753,10 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p else { new_item->setColumn(index, new LLScrollListText(value.asString(), font, width, font_style, font_alignment)); + if (column_itor->second.mHeader && !value.asString().empty()) + { + column_itor->second.mHeader->setHasResizableElement(TRUE); + } } } @@ -2725,6 +2853,14 @@ void LLScrollListCtrl::setFocus(BOOL b) } LLUICtrl::setFocus(b); } + +//virtual +void LLScrollListCtrl::onFocusReceived() +{ + // forget latent selection changes when getting focus + mSelectionChanged = FALSE; +} + //virtual void LLScrollListCtrl::onFocusLost() { @@ -2735,5 +2871,433 @@ void LLScrollListCtrl::onFocusLost() getParent()->onFocusLost(); } } + if (hasMouseCapture()) + { + gFocusMgr.setMouseCapture(NULL); + } + LLUICtrl::onFocusLost(); +} + +LLColumnHeader::LLColumnHeader(const LLString& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL* fontp) : + LLComboBox(label, rect, label, NULL, NULL), + mColumn(column), + mOrigLabel(label), + mShowSortOptions(FALSE), + mHasResizableElement(FALSE) +{ + mListPosition = LLComboBox::ABOVE; + setCommitCallback(onSelectSort); + setCallbackUserData(this); + mButton->setTabStop(FALSE); + // require at least two frames between mouse down and mouse up event to capture intentional "hold" not just bad framerate + mButton->setHeldDownDelay(LLUI::sConfigGroup->getF32("ColumnHeaderDropDownDelay"), 2); + mButton->setHeldDownCallback(onHeldDown); + mButton->setClickedCallback(onClick); + mButton->setMouseDownCallback(onMouseDown); + + mButton->setCallbackUserData(this); + + mAscendingText = "[LOW]...[HIGH](Ascending)"; + mDescendingText = "[HIGH]...[LOW](Descending)"; + + LLSD row; + row["columns"][0]["column"] = "label"; + row["columns"][0]["value"] = mAscendingText.getString(); + row["columns"][0]["font"] = "SANSSERIF_SMALL"; + row["columns"][0]["width"] = 80; + + row["columns"][1]["column"] = "arrow"; + row["columns"][1]["type"] = "icon"; + row["columns"][1]["value"] = LLUI::sAssetsGroup->getString("up_arrow.tga"); + row["columns"][1]["width"] = 20; + + mList->addElement(row); + + row["columns"][0]["column"] = "label"; + row["columns"][0]["type"] = "text"; + row["columns"][0]["value"] = mDescendingText.getString(); + row["columns"][0]["font"] = "SANSSERIF_SMALL"; + row["columns"][0]["width"] = 80; + + row["columns"][1]["column"] = "arrow"; + row["columns"][1]["type"] = "icon"; + row["columns"][1]["value"] = LLUI::sAssetsGroup->getString("down_arrow.tga"); + row["columns"][1]["width"] = 20; + + mList->addElement(row); + + mList->reshape(llmax(mList->getRect().getWidth(), 110, mRect.getWidth()), mList->getRect().getHeight()); + + // resize handles on left and right + const S32 RESIZE_BAR_THICKNESS = 3; + mResizeBar = new LLResizeBar( + "resizebar", + LLRect( mRect.getWidth() - RESIZE_BAR_THICKNESS, mRect.getHeight(), mRect.getWidth(), 0), + MIN_COLUMN_WIDTH, mRect.getHeight(), LLResizeBar::RIGHT ); + addChild(mResizeBar); + + mResizeBar->setEnabled(FALSE); +} + +LLColumnHeader::~LLColumnHeader() +{ +} + +void LLColumnHeader::draw() +{ + if( getVisible() ) + { + mDrawArrow = !mColumn->mLabel.empty() && mColumn->mParentCtrl->getSortColumnName() == mColumn->mSortingColumn; + + BOOL is_ascending = mColumn->mParentCtrl->getSortAscending(); + mArrowImage = is_ascending ? LLUI::sImageProvider->getUIImageByID(LLUUID(LLUI::sAssetsGroup->getString("up_arrow.tga"))) + : LLUI::sImageProvider->getUIImageByID(LLUUID(LLUI::sAssetsGroup->getString("down_arrow.tga"))); + + //BOOL clip = mRect.mRight > mColumn->mParentCtrl->getItemListRect().getWidth(); + //LLGLEnable scissor_test(clip ? GL_SCISSOR_TEST : GL_FALSE); + + //LLRect column_header_local_rect(-mRect.mLeft, mRect.getHeight(), mColumn->mParentCtrl->getItemListRect().getWidth() - mRect.mLeft, 0); + //LLUI::setScissorRegionLocal(column_header_local_rect); + + // Draw children + LLComboBox::draw(); + + if (mList->getVisible()) + { + // sync sort order with list selection every frame + mColumn->mParentCtrl->sortByColumn(mColumn->mSortingColumn, getCurrentIndex() == 0); + } + + } +} + +BOOL LLColumnHeader::handleDoubleClick(S32 x, S32 y, MASK mask) +{ + if (canResize() && mResizeBar->getRect().pointInRect(x, y)) + { + // reshape column to max content width + LLRect column_rect = getRect(); + column_rect.mRight = column_rect.mLeft + mColumn->mMaxContentWidth; + userSetShape(column_rect); + } + else + { + onClick(this); + } + return TRUE; +} + +void LLColumnHeader::setImage(const LLString &image_name) +{ + if (mButton) + { + mButton->setImageSelected(image_name); + mButton->setImageUnselected(image_name); + } +} + +//static +void LLColumnHeader::onClick(void* user_data) +{ + LLColumnHeader* headerp = (LLColumnHeader*)user_data; + if (!headerp) return; + + LLScrollListColumn* column = headerp->mColumn; + if (!column) return; + + if (headerp->mList->getVisible()) + { + headerp->hideList(); + } + + LLScrollListCtrl::onClickColumn(column); + + // propage new sort order to sort order list + headerp->mList->selectNthItem(column->mParentCtrl->getSortAscending() ? 0 : 1); +} + +//static +void LLColumnHeader::onMouseDown(void* user_data) +{ + // for now, do nothing but block the normal showList() behavior + return; +} + +//static +void LLColumnHeader::onHeldDown(void* user_data) +{ + LLColumnHeader* headerp = (LLColumnHeader*)user_data; + headerp->showList(); +} + +void LLColumnHeader::showList() +{ + if (mShowSortOptions) + { + //LLSD item_val = mColumn->mParentCtrl->getFirstData()->getValue(); + mOrigLabel = mButton->getLabelSelected(); + + // move sort column over to this column and do initial sort + mColumn->mParentCtrl->sortByColumn(mColumn->mSortingColumn, mColumn->mParentCtrl->getSortAscending()); + + LLString low_item_text; + LLString high_item_text; + + LLScrollListItem* itemp = mColumn->mParentCtrl->getFirstData(); + if (itemp) + { + LLScrollListCell* cell = itemp->getColumn(mColumn->mIndex); + if (cell && cell->isText()) + { + if (mColumn->mParentCtrl->getSortAscending()) + { + low_item_text = cell->getText(); + } + else + { + high_item_text = cell->getText(); + } + } + } + + itemp = mColumn->mParentCtrl->getLastData(); + if (itemp) + { + LLScrollListCell* cell = itemp->getColumn(mColumn->mIndex); + if (cell && cell->isText()) + { + if (mColumn->mParentCtrl->getSortAscending()) + { + high_item_text = cell->getText(); + } + else + { + low_item_text = cell->getText(); + } + } + } + + LLString::truncate(low_item_text, 3); + LLString::truncate(high_item_text, 3); + + LLString ascending_string; + LLString descending_string; + + if (low_item_text.empty() || high_item_text.empty()) + { + ascending_string = "Ascending"; + descending_string = "Descending"; + } + else + { + mAscendingText.setArg("[LOW]", low_item_text); + mAscendingText.setArg("[HIGH]", high_item_text); + mDescendingText.setArg("[LOW]", low_item_text); + mDescendingText.setArg("[HIGH]", high_item_text); + ascending_string = mAscendingText.getString(); + descending_string = mDescendingText.getString(); + } + + S32 text_width = LLFontGL::sSansSerifSmall->getWidth(ascending_string); + text_width = llmax(text_width, LLFontGL::sSansSerifSmall->getWidth(descending_string)) + 10; + text_width = llmax(text_width, mRect.getWidth() - 30); + + mList->getColumn(0)->mWidth = text_width; + ((LLScrollListText*)mList->getFirstData()->getColumn(0))->setText(ascending_string); + ((LLScrollListText*)mList->getLastData()->getColumn(0))->setText(descending_string); + + mList->reshape(llmax(text_width + 30, 110, mRect.getWidth()), mList->getRect().getHeight()); + + LLComboBox::showList(); + } } +//static +void LLColumnHeader::onSelectSort(LLUICtrl* ctrl, void* user_data) +{ + LLColumnHeader* headerp = (LLColumnHeader*)user_data; + if (!headerp) return; + + LLScrollListColumn* column = headerp->mColumn; + if (!column) return; + LLScrollListCtrl *parent = column->mParentCtrl; + if (!parent) return; + + if (headerp->getCurrentIndex() == 0) + { + // ascending + parent->sortByColumn(column->mSortingColumn, TRUE); + } + else + { + // descending + parent->sortByColumn(column->mSortingColumn, FALSE); + } + + // restore original column header + headerp->setLabel(headerp->mOrigLabel); +} + +LLView* LLColumnHeader::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding) +{ + // this logic assumes dragging on right + llassert(snap_edge == SNAP_RIGHT); + + // use higher snap threshold for column headers + threshold = llmin(threshold, 15); + + LLRect snap_rect = getSnapRect(); + + S32 snap_delta = mColumn->mMaxContentWidth - snap_rect.getWidth(); + + // x coord growing means column growing, so same signs mean we're going in right direction + if (llabs(snap_delta) <= threshold && mouse_dir.mX * snap_delta > 0 ) + { + new_edge_val = snap_rect.mRight + snap_delta; + } + else + { + LLScrollListColumn* next_column = mColumn->mParentCtrl->getColumn(mColumn->mIndex + 1); + while (next_column) + { + if (next_column->mHeader) + { + snap_delta = (next_column->mHeader->getSnapRect().mRight - next_column->mMaxContentWidth) - snap_rect.mRight; + if (llabs(snap_delta) <= threshold && mouse_dir.mX * snap_delta > 0 ) + { + new_edge_val = snap_rect.mRight + snap_delta; + } + break; + } + next_column = mColumn->mParentCtrl->getColumn(next_column->mIndex + 1); + } + } + + return this; +} + +void LLColumnHeader::userSetShape(const LLRect& new_rect) +{ + S32 new_width = new_rect.getWidth(); + S32 delta_width = new_width - (mRect.getWidth() + mColumn->mParentCtrl->getColumnPadding()); + + if (delta_width != 0) + { + S32 remaining_width = delta_width; + S32 col; + for (col = mColumn->mIndex + 1; col < mColumn->mParentCtrl->getNumColumns(); col++) + { + LLScrollListColumn* columnp = mColumn->mParentCtrl->getColumn(col); + if (!columnp) break; + + if (columnp->mHeader && columnp->mHeader->canResize()) + { + // how many pixels in width can this column afford to give up? + S32 resize_buffer_amt = llmax(0, columnp->mWidth - MIN_COLUMN_WIDTH); + + // user shrinking column, need to add width to other columns + if (delta_width < 0) + { + if (!columnp->mDynamicWidth && columnp->mWidth > 0) + { + // statically sized column, give all remaining width to this column + columnp->mWidth -= remaining_width; + if (columnp->mRelWidth > 0.f) + { + columnp->mRelWidth = (F32)columnp->mWidth / (F32)mColumn->mParentCtrl->getItemListRect().getWidth(); + } + } + break; + } + else + { + // user growing column, need to take width from other columns + remaining_width -= resize_buffer_amt; + + if (!columnp->mDynamicWidth && columnp->mWidth > 0) + { + columnp->mWidth -= llmin(columnp->mWidth - MIN_COLUMN_WIDTH, delta_width); + if (columnp->mRelWidth > 0.f) + { + columnp->mRelWidth = (F32)columnp->mWidth / (F32)mColumn->mParentCtrl->getItemListRect().getWidth(); + } + } + + if (remaining_width <= 0) + { + // width sucked up from neighboring columns, done + break; + } + } + } + } + + // clamp resize amount to maximum that can be absorbed by other columns + if (delta_width > 0) + { + delta_width -= llmax(remaining_width, 0); + } + + // propagate constrained delta_width to new width for this column + new_width = mRect.getWidth() + delta_width - mColumn->mParentCtrl->getColumnPadding(); + + // use requested width + mColumn->mWidth = new_width; + + // update proportional spacing + if (mColumn->mRelWidth > 0.f) + { + mColumn->mRelWidth = (F32)new_width / (F32)mColumn->mParentCtrl->getItemListRect().getWidth(); + } + + // tell scroll list to layout columns again + mColumn->mParentCtrl->updateColumns(); + } +} + +void LLColumnHeader::setHasResizableElement(BOOL resizable) +{ + // for now, dynamically spaced columns can't be resized + if (mColumn->mDynamicWidth) return; + + if (resizable != mHasResizableElement) + { + mHasResizableElement = resizable; + + S32 num_resizable_columns = 0; + S32 col; + for (col = 0; col < mColumn->mParentCtrl->getNumColumns(); col++) + { + LLScrollListColumn* columnp = mColumn->mParentCtrl->getColumn(col); + if (columnp->mHeader && columnp->mHeader->canResize()) + { + num_resizable_columns++; + } + } + + S32 num_resizers_enabled = 0; + + // now enable/disable resize handles on resizable columns if we have at least two + for (col = 0; col < mColumn->mParentCtrl->getNumColumns(); col++) + { + LLScrollListColumn* columnp = mColumn->mParentCtrl->getColumn(col); + if (!columnp->mHeader) continue; + BOOL enable = num_resizable_columns >= 2 && num_resizers_enabled < (num_resizable_columns - 1) && columnp->mHeader->canResize(); + columnp->mHeader->enableResizeBar(enable); + if (enable) + { + num_resizers_enabled++; + } + } + } +} + +void LLColumnHeader::enableResizeBar(BOOL enable) +{ + mResizeBar->setEnabled(enable); +} + +BOOL LLColumnHeader::canResize() +{ + return getVisible() && (mHasResizableElement || mColumn->mDynamicWidth); +} diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index 9c16e4dff9..99218ab3c4 100644 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -23,9 +23,12 @@ #include "llviewborder.h" #include "llframetimer.h" #include "llcheckboxctrl.h" +#include "llcombobox.h" class LLScrollbar; class LLScrollListCtrl; +class LLColumnHeader; +class LLResizeBar; class LLScrollListCell { @@ -39,6 +42,7 @@ public: virtual const BOOL getVisible() const { return TRUE; } virtual void setWidth(S32 width) = 0; virtual void highlightText(S32 offset, S32 num_chars) {} + virtual BOOL isText() = 0; virtual BOOL handleClick() { return FALSE; } virtual void setEnabled(BOOL enable) { } @@ -58,6 +62,7 @@ public: virtual const BOOL getVisible() const { return mVisible; } virtual void highlightText(S32 offset, S32 num_chars) {mHighlightOffset = offset; mHighlightCount = num_chars;} void setText(const LLString& text); + virtual BOOL isText() { return TRUE; } private: LLUIString mText; @@ -86,6 +91,7 @@ public: virtual const LLString& getText() const { return mImageUUID; } virtual const LLString& getTextLower() const { return mImageUUID; } virtual void setWidth(S32 width) { mWidth = width; } + virtual BOOL isText() { return FALSE; } private: LLPointer<LLImageGL> mIcon; @@ -107,6 +113,7 @@ public: virtual void setEnabled(BOOL enable) { if (mCheckBox) mCheckBox->setEnabled(enable); } LLCheckBoxCtrl* getCheckBox() { return mCheckBox; } + virtual BOOL isText() { return FALSE; } private: LLCheckBoxCtrl* mCheckBox; @@ -117,14 +124,37 @@ class LLScrollListColumn { public: // Default constructor - LLScrollListColumn() : mName(""), mSortingColumn(""), mLabel(""), mWidth(-1), mRelWidth(-1.0), mDynamicWidth(FALSE), mIndex(-1), mParentCtrl(NULL), mButton(NULL), mFontAlignment(LLFontGL::LEFT) + LLScrollListColumn() : + mName(""), + mSortingColumn(""), + mLabel(""), + mWidth(-1), + mRelWidth(-1.0), + mDynamicWidth(FALSE), + mMaxContentWidth(0), + mIndex(-1), + mParentCtrl(NULL), + mHeader(NULL), + mFontAlignment(LLFontGL::LEFT) { } - LLScrollListColumn(LLString name, LLString label, S32 width, F32 relwidth) - : mName(name), mSortingColumn(name), mLabel(label), mWidth(width), mRelWidth(relwidth), mDynamicWidth(FALSE), mIndex(-1), mParentCtrl(NULL), mButton(NULL) { } + LLScrollListColumn(LLString name, LLString label, S32 width, F32 relwidth) : + mName(name), + mSortingColumn(name), + mLabel(label), + mWidth(width), + mRelWidth(relwidth), + mDynamicWidth(FALSE), + mMaxContentWidth(0), + mIndex(-1), + mParentCtrl(NULL), + mHeader(NULL) + { } LLScrollListColumn(const LLSD &sd) { + mMaxContentWidth = 0; + mName = sd.get("name").asString(); mSortingColumn = mName; if (sd.has("sort")) @@ -160,7 +190,7 @@ public: mIndex = -1; mParentCtrl = NULL; - mButton = NULL; + mHeader = NULL; } LLString mName; @@ -169,12 +199,47 @@ public: S32 mWidth; F32 mRelWidth; BOOL mDynamicWidth; + S32 mMaxContentWidth; S32 mIndex; LLScrollListCtrl* mParentCtrl; - LLButton* mButton; + LLColumnHeader* mHeader; LLFontGL::HAlign mFontAlignment; }; +class LLColumnHeader : public LLComboBox +{ +public: + LLColumnHeader(const LLString& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL *font = NULL); + ~LLColumnHeader(); + + /*virtual*/ void draw(); + /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); + /*virtual*/ void showList(); + /*virtual*/ LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding); + /*virtual*/ void userSetShape(const LLRect& new_rect); + + void setImage(const LLString &image_name); + LLScrollListColumn* getColumn() { return mColumn; } + void setHasResizableElement(BOOL resizable); + BOOL canResize(); + void enableResizeBar(BOOL enable); + LLString getLabel() { return mOrigLabel; } + + static void onSelectSort(LLUICtrl* ctrl, void* user_data); + static void onClick(void* user_data); + static void onMouseDown(void* user_data); + static void onHeldDown(void* user_data); + +protected: + LLScrollListColumn* mColumn; + LLResizeBar* mResizeBar; + LLString mOrigLabel; + LLUIString mAscendingText; + LLUIString mDescendingText; + BOOL mShowSortOptions; + BOOL mHasResizableElement; +}; + class LLScrollListItem { public: @@ -216,7 +281,7 @@ public: LLScrollListCell *getColumn(const S32 i) const { if (i < (S32)mColumns.size()) { return mColumns[i]; } return NULL; } - virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); + virtual BOOL handleClick(S32 x, S32 y, MASK mask); LLString getContentsCSV(); @@ -263,6 +328,10 @@ public: virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM); virtual void clearColumns(); virtual void setColumnLabel(const LLString& column, const LLString& label); + + virtual LLScrollListColumn* getColumn(S32 index); + virtual S32 getNumColumns() const { return mColumnsIndexed.size(); } + // Adds a single element, from an array of: // "columns" => [ "column" => column name, "value" => value, "type" => type, "font" => font, "font-style" => style ], "id" => uuid // Creates missing columns automatically. @@ -301,7 +370,8 @@ public: BOOL selectFirstItem(); BOOL selectNthItem( S32 index ); - + BOOL selectItemAt(S32 x, S32 y, MASK mask); + void deleteSingleItem( S32 index ) ; void deleteSelectedItems(); void deselectAllItems(BOOL no_commit_on_change = FALSE); // by default, go ahead and commit on selection change @@ -338,23 +408,6 @@ public: LLScrollListItem* addStringUUIDItem(const LLString& item_text, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0); LLUUID getStringUUIDSelectedItem(); - // "Full" interface: use this when you're creating a list that has one or more of the following: - // * contains icons - // * contains multiple columns - // * allows multiple selection - // * has items that are not guarenteed to have unique names - // * has additional per-item data (e.g. a UUID or void* userdata) - // - // To add items using this approach, create new LLScrollListItems and LLScrollListCells. Add the - // cells (column entries) to each item, and add the item to the LLScrollListCtrl. - // - // The LLScrollListCtrl owns its items and is responsible for deleting them - // (except in the case that the addItem() call fails, in which case it is up - // to the caller to delete the item) - - // returns FALSE if item faile to be added to list, does NOT delete 'item' - // TomY TODO - Deprecate this API and remove it - BOOL addItem( LLScrollListItem* item, EAddPosition pos = ADD_BOTTOM ); LLScrollListItem* getFirstSelected() const; virtual S32 getFirstSelectedIndex(); std::vector<LLScrollListItem*> getAllSelected() const; @@ -363,6 +416,7 @@ public: // iterate over all items LLScrollListItem* getFirstData() const; + LLScrollListItem* getLastData() const; std::vector<LLScrollListItem*> getAllData() const; void setAllowMultipleSelection(BOOL mult ) { mAllowMultipleSelection = mult; } @@ -379,6 +433,7 @@ public: void setBackgroundVisible(BOOL b) { mBackgroundVisible = b; } void setDrawStripes(BOOL b) { mDrawStripes = b; } void setColumnPadding(const S32 c) { mColumnPadding = c; } + S32 getColumnPadding() { return mColumnPadding; } void setCommitOnKeyboardMovement(BOOL b) { mCommitOnKeyboardMovement = b; } void setCommitOnSelectionChange(BOOL b) { mCommitOnSelectionChange = b; } void setAllowKeyboardMovement(BOOL b) { mAllowKeyboardMovement = b; } @@ -398,6 +453,7 @@ public: // Overridden from LLView virtual void draw(); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); + virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); @@ -405,6 +461,7 @@ public: virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); virtual void setEnabled(BOOL enabled); virtual void setFocus( BOOL b ); + virtual void onFocusReceived(); virtual void onFocusLost(); virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); @@ -412,17 +469,18 @@ public: virtual LLRect getRequiredRect(); static BOOL rowPreceeds(LLScrollListItem *new_row, LLScrollListItem *test_row); + LLRect getItemListRect() { return mItemListRect; } + // Used "internally" by the scroll bar. static void onScrollChange( S32 new_pos, LLScrollbar* src, void* userdata ); static void onClickColumn(void *userdata); void updateColumns(); - void updateColumnButtons(); + void updateMaxContentWidth(LLScrollListItem* changed_item); void setDisplayHeading(BOOL display); void setHeadingHeight(S32 heading_height); - void setHeadingFont(const LLFontGL* heading_font); void setCollapseEmptyColumns(BOOL collapse); void setIsPopup(BOOL is_popup) { mIsPopup = is_popup; } @@ -454,6 +512,22 @@ public: S32 selectMultiple( LLDynamicArray<LLUUID> ids ); protected: + // "Full" interface: use this when you're creating a list that has one or more of the following: + // * contains icons + // * contains multiple columns + // * allows multiple selection + // * has items that are not guarenteed to have unique names + // * has additional per-item data (e.g. a UUID or void* userdata) + // + // To add items using this approach, create new LLScrollListItems and LLScrollListCells. Add the + // cells (column entries) to each item, and add the item to the LLScrollListCtrl. + // + // The LLScrollListCtrl owns its items and is responsible for deleting them + // (except in the case that the addItem() call fails, in which case it is up + // to the caller to delete the item) + + // returns FALSE if item faile to be added to list, does NOT delete 'item' + BOOL addItem( LLScrollListItem* item, EAddPosition pos = ADD_BOTTOM ); void selectPrevItem(BOOL extend_selection); void selectNextItem(BOOL extend_selection); void drawItems(); @@ -473,7 +547,6 @@ protected: S32 mPageLines; // max number of lines is it possible to see on the screen given mRect and mLineHeight S32 mHeadingHeight; // the height of the column header buttons, if visible U32 mMaxSelectable; - const LLFontGL* mHeadingFont; // the font to use for column head buttons, if visible LLScrollbar* mScrollbar; BOOL mAllowMultipleSelection; BOOL mAllowKeyboardMovement; @@ -481,7 +554,7 @@ protected: BOOL mCommitOnSelectionChange; BOOL mSelectionChanged; BOOL mCanSelect; - BOOL mDisplayColumnButtons; + BOOL mDisplayColumnHeaders; BOOL mCollapseEmptyColumns; BOOL mIsPopup; @@ -525,8 +598,8 @@ protected: S32 mNumDynamicWidthColumns; S32 mTotalStaticColumnWidth; - U32 mSortColumn; - BOOL mSortAscending; + S32 mSortColumn; + BOOL mSortAscending; std::map<LLString, LLScrollListColumn> mColumns; std::vector<LLScrollListColumn*> mColumnsIndexed; diff --git a/indra/llui/llslider.cpp b/indra/llui/llslider.cpp index 2a1c2f7845..3a01013943 100644 --- a/indra/llui/llslider.cpp +++ b/indra/llui/llslider.cpp @@ -98,7 +98,7 @@ F32 LLSlider::getValueF32() const BOOL LLSlider::handleHover(S32 x, S32 y, MASK mask) { - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { S32 left_edge = THUMB_WIDTH/2; S32 right_edge = mRect.getWidth() - (THUMB_WIDTH/2); @@ -125,9 +125,9 @@ BOOL LLSlider::handleMouseUp(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); if( mMouseUpCallback ) { @@ -175,7 +175,7 @@ BOOL LLSlider::handleMouseDown(S32 x, S32 y, MASK mask) // Start dragging the thumb // No handler needed for focus lost since this class has no state that depends on it. - gFocusMgr.setMouseCapture( this, NULL ); + gFocusMgr.setMouseCapture( this ); mDragStartThumbRect = mThumbRect; } make_ui_sound("UISndClick"); @@ -242,12 +242,12 @@ void LLSlider::draw() if (!thumb_imagep) { gl_rect_2d(mThumbRect, mThumbCenterColor, TRUE); - if (gFocusMgr.getMouseCapture() == this) + if (hasMouseCapture()) { gl_rect_2d(mDragStartThumbRect, mThumbCenterColor % opacity, FALSE); } } - else if( gFocusMgr.getMouseCapture() == this ) + else if( hasMouseCapture() ) { gl_draw_scaled_image_with_border(mDragStartThumbRect.mLeft, mDragStartThumbRect.mBottom, 16, 16, mDragStartThumbRect.getWidth(), mDragStartThumbRect.getHeight(), thumb_imagep, mThumbCenterColor % 0.3f, TRUE); diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp index 3079726434..b3c49e81f1 100644 --- a/indra/llui/llsliderctrl.cpp +++ b/indra/llui/llsliderctrl.cpp @@ -186,7 +186,7 @@ void LLSliderCtrl::clear() BOOL LLSliderCtrl::isMouseHeldDown() { - return gFocusMgr.getMouseCapture() == mSlider; + return mSlider->hasMouseCapture(); } void LLSliderCtrl::updateText() diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp index 4c1700175b..fbd8335e6c 100644 --- a/indra/llui/llspinctrl.cpp +++ b/indra/llui/llspinctrl.cpp @@ -316,8 +316,8 @@ void LLSpinCtrl::setTentative(BOOL b) BOOL LLSpinCtrl::isMouseHeldDown() { return - gFocusMgr.getMouseCapture() == mDownBtn || - gFocusMgr.getMouseCapture() == mUpBtn; + mDownBtn->hasMouseCapture() + || mUpBtn->hasMouseCapture(); } void LLSpinCtrl::onCommit() diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 1ba991f916..c412d77922 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -983,7 +983,7 @@ void LLTabContainer::updateMaxScrollPos() void LLTabContainer::commitHoveredButton(S32 x, S32 y) { - if (gFocusMgr.getMouseCapture() == this) + if (hasMouseCapture()) { for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) { @@ -1244,7 +1244,7 @@ BOOL LLTabContainer::handleMouseDown( S32 x, S32 y, MASK mask ) if( tab_rect.pointInRect( x, y ) ) { LLButton* tab_button = mTabList[getCurrentPanelIndex()]->mButton; - gFocusMgr.setMouseCapture(this, NULL); + gFocusMgr.setMouseCapture(this); gFocusMgr.setKeyboardFocus(tab_button, NULL); } } @@ -1307,7 +1307,7 @@ BOOL LLTabContainer::handleMouseUp( S32 x, S32 y, MASK mask ) commitHoveredButton(x, y); LLPanel* cur_panel = getCurrentPanel(); - if (gFocusMgr.getMouseCapture() == this) + if (hasMouseCapture()) { if (cur_panel) { @@ -1318,7 +1318,7 @@ BOOL LLTabContainer::handleMouseUp( S32 x, S32 y, MASK mask ) mTabList[getCurrentPanelIndex()]->mButton->setFocus(TRUE); } } - gFocusMgr.setMouseCapture(NULL, NULL); + gFocusMgr.setMouseCapture(NULL); } return handled; } diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 0cd2e98514..f6f7067540 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -94,7 +94,7 @@ BOOL LLTextBox::handleMouseDown(S32 x, S32 y, MASK mask) handled = TRUE; // Route future Mouse messages here preemptively. (Release on mouse up.) - gFocusMgr.setMouseCapture( this, NULL ); + gFocusMgr.setMouseCapture( this ); if (mSoundFlags & MOUSE_DOWN) { @@ -115,12 +115,12 @@ BOOL LLTextBox::handleMouseUp(S32 x, S32 y, MASK mask) // HACK: Only do this if there actually is a click callback, so that // overly large text boxes in the older UI won't start eating clicks. if (mClickedCallback - && this == gFocusMgr.getMouseCapture()) + && hasMouseCapture()) { handled = TRUE; // Release the mouse - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); if (mSoundFlags & MOUSE_UP) { diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index de34aabb1f..366b1956c4 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -1182,7 +1182,7 @@ BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) setCursorAtLocalPos( x, y, TRUE ); startSelection(); } - gFocusMgr.setMouseCapture( this, &LLTextEditor::onMouseCaptureLost ); + gFocusMgr.setMouseCapture( this ); } handled = TRUE; @@ -1208,7 +1208,7 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) mHoverSegment = NULL; if( getVisible() ) { - if(gFocusMgr.getMouseCapture() == this ) + if(hasMouseCapture() ) { if( mIsSelecting ) { @@ -1341,9 +1341,9 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) // Delay cursor flashing mKeystrokeTimer.reset(); - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); handled = TRUE; } @@ -2454,6 +2454,8 @@ void LLTextEditor::onFocusLost() // Make sure cursor is shown again getWindow()->showCursorFromMouseMove(); + + LLUICtrl::onFocusLost(); } void LLTextEditor::setEnabled(BOOL enabled) @@ -3734,11 +3736,9 @@ S32 LLTextEditor::getSegmentIdxAtOffset(S32 offset) } } -//static -void LLTextEditor::onMouseCaptureLost( LLMouseHandler* old_captor ) +void LLTextEditor::onMouseCaptureLost() { - LLTextEditor* self = (LLTextEditor*) old_captor; - self->endSelection(); + endSelection(); } void LLTextEditor::setOnScrollEndCallback(void (*callback)(void*), void* userdata) diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index ce85e35fe3..21db32b33f 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -75,6 +75,8 @@ public: virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, LLString& tooltip_msg); + virtual void onMouseCaptureLost(); + // view overrides virtual void reshape(S32 width, S32 height, BOOL called_from_parent); @@ -190,7 +192,6 @@ public: void setHandleEditKeysDirectly( BOOL b ) { mHandleEditKeysDirectly = b; } // Callbacks - static void onMouseCaptureLost( LLMouseHandler* old_captor ); static void setLinkColor(LLColor4 color) { mLinkColor = color; } static void setURLCallbacks( void (*callback1) (const char* url), BOOL (*callback2) (LLString url) ) diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index e8e3f271a0..f32266faa8 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -1723,6 +1723,10 @@ LLString LLUI::locateSkin(const LLString& filename) if (!gDirUtilp->fileExists(found_file)) { LLString localization(sConfigGroup->getString("Language")); + if(localization == "default") + { + localization = sConfigGroup->getString("SystemLanguage"); + } LLString local_skin = "xui" + slash + localization + slash + filename; found_file = gDirUtilp->getExpandedFilename(LL_PATH_SKINS, local_skin); } diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 0d9791c660..abf796fde0 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -26,6 +26,7 @@ const U32 MAX_STRING_LENGTH = 10; LLUICtrl::LLUICtrl() : mCommitCallback(NULL), + mFocusLostCallback(NULL), mFocusReceivedCallback(NULL), mFocusChangedCallback(NULL), mValidateCallback(NULL), @@ -44,6 +45,7 @@ LLUICtrl::LLUICtrl(const LLString& name, const LLRect& rect, BOOL mouse_opaque, // of buttons in the UI. JC 7/20/2002 LLView( name, rect, mouse_opaque, reshape ), mCommitCallback( on_commit_callback) , + mFocusLostCallback( NULL ), mFocusReceivedCallback( NULL ), mFocusChangedCallback( NULL ), mValidateCallback( NULL ), @@ -57,6 +59,12 @@ LLUICtrl::LLUICtrl(const LLString& name, const LLRect& rect, BOOL mouse_opaque, LLUICtrl::~LLUICtrl() { gFocusMgr.releaseFocusIfNeeded( this ); // calls onCommit() + + if( gFocusMgr.getTopCtrl() == this ) + { + llwarns << "UI Control holding top ctrl deleted: " << getName() << ". Top view removed." << llendl; + gFocusMgr.removeTopCtrlWithoutCallback( this ); + } } void LLUICtrl::onCommit() @@ -151,6 +159,11 @@ void LLUICtrl::onFocusReceived() void LLUICtrl::onFocusLost() { + if( mFocusLostCallback ) + { + mFocusLostCallback( this, mCallbackUserData ); + } + if( mFocusChangedCallback ) { mFocusChangedCallback( this, mCallbackUserData ); diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 1418151201..1c2ac677df 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -104,6 +104,7 @@ public: virtual void setMaxValue(LLSD max_value); // In general, only LLPanel uses these. + void setFocusLostCallback(void (*cb)(LLUICtrl* caller, void* user_data)) { mFocusLostCallback = cb; } void setFocusReceivedCallback( void (*cb)(LLUICtrl*, void*) ) { mFocusReceivedCallback = cb; } void setFocusChangedCallback( void (*cb)(LLUICtrl*, void*) ) { mFocusChangedCallback = cb; } @@ -135,6 +136,7 @@ protected: protected: void (*mCommitCallback)( LLUICtrl* ctrl, void* userdata ); + void (*mFocusLostCallback)( LLUICtrl* caller, void* userdata ); void (*mFocusReceivedCallback)( LLUICtrl* ctrl, void* userdata ); void (*mFocusChangedCallback)( LLUICtrl* ctrl, void* userdata ); BOOL (*mValidateCallback)( LLUICtrl* ctrl, void* userdata ); diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index 21278455da..6410208189 100644 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -222,6 +222,10 @@ void LLUICtrlFactory::setupPaths() if (LLUI::sConfigGroup) { language = LLUI::sConfigGroup->getString("Language"); + if(language == "default") + { + language = LLUI::sConfigGroup->getString("SystemLanguage"); + } } path_val_ui.setArg("[Language]", language); LLString fullpath = app_dir + path_val_ui.getString(); diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 02a99b00cd..da5c77fc94 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -155,18 +155,12 @@ LLView::~LLView() gFocusMgr.removeKeyboardFocusWithoutCallback( this ); } - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { llwarns << "View holding mouse capture deleted: " << getName() << ". Mouse capture removed." << llendl; gFocusMgr.removeMouseCaptureWithoutCallback( this ); } - if( gFocusMgr.getTopView() == this ) - { - llwarns << "View holding top view deleted: " << getName() << ". Top view removed." << llendl; - gFocusMgr.removeTopViewWithoutCallback( this ); - } - sViewHandleMap.erase(mViewHandle); deleteAllChildren(); @@ -733,9 +727,9 @@ void LLView::setEnabled(BOOL enabled) // virtual void LLView::setVisible(BOOL visible) { - if( !visible && (gFocusMgr.getTopView() == this) ) + if( !visible && (gFocusMgr.getTopCtrl() == this) ) { - gFocusMgr.setTopView( NULL, NULL ); + gFocusMgr.setTopCtrl( NULL ); } if ( mVisible != visible ) @@ -1034,7 +1028,14 @@ LLView* LLView::childrenHandleDragAndDrop(S32 x, S32 y, MASK mask, return handled_view; } +void LLView::onMouseCaptureLost() +{ +} +BOOL LLView::hasMouseCapture() +{ + return gFocusMgr.getMouseCapture() == this; +} BOOL LLView::handleMouseUp(S32 x, S32 y, MASK mask) { @@ -1591,6 +1592,13 @@ const LLRect LLView::getLocalRect() const return local_rect; } +const LLRect LLView::getLocalSnapRect() const +{ + LLRect local_snap_rect = getSnapRect(); + local_snap_rect.translate(-mRect.mLeft, -mRect.mBottom); + return local_snap_rect; +} + void LLView::updateRect() { if (mSpanChildren && mChildList.size()) @@ -2087,6 +2095,12 @@ const LLCtrlQuery & LLView::getFocusRootsQuery() } +void LLView::userSetShape(const LLRect& new_rect) +{ + reshape(new_rect.getWidth(), new_rect.getHeight()); + translate(new_rect.mLeft - mRect.mLeft, new_rect.mBottom - mRect.mBottom); +} + LLView* LLView::findSnapRect(LLRect& new_rect, const LLCoordGL& mouse_dir, LLView::ESnapType snap_type, S32 threshold, S32 padding) { @@ -2108,8 +2122,7 @@ LLView* LLView::findSnapRect(LLRect& new_rect, const LLCoordGL& mouse_dir, BOOL snapped_x = FALSE; BOOL snapped_y = FALSE; - LLRect parent_local_snap_rect = mParentView->getSnapRect(); - parent_local_snap_rect.translate(-mParentView->getRect().mLeft, -mParentView->getRect().mBottom); + LLRect parent_local_snap_rect = mParentView->getLocalSnapRect(); if (snap_type == SNAP_PARENT || snap_type == SNAP_PARENT_AND_SIBLINGS) { @@ -2284,8 +2297,7 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna BOOL snapped_x = FALSE; BOOL snapped_y = FALSE; - LLRect parent_local_snap_rect = mParentView->getSnapRect(); - parent_local_snap_rect.translate(-mParentView->getRect().mLeft, -mParentView->getRect().mBottom); + LLRect parent_local_snap_rect = mParentView->getLocalSnapRect(); if (snap_type == SNAP_PARENT || snap_type == SNAP_PARENT_AND_SIBLINGS) { diff --git a/indra/llui/llview.h b/indra/llui/llview.h index b794c087b5..504558a132 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -294,6 +294,7 @@ public: const LLRect getScreenRect() const; const LLRect getLocalRect() const; virtual const LLRect getSnapRect() const { return mRect; } + virtual const LLRect getLocalSnapRect() const; virtual LLRect getRequiredRect(); // Get required size for this object. 0 for width/height means don't care. virtual void updateRect(); // apply procedural updates to own rectangle @@ -315,12 +316,13 @@ public: // Default behavior is to use reshape flags to resize child views virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); - virtual void translate( S32 x, S32 y ); virtual void setOrigin( S32 x, S32 y ) { mRect.translate( x - mRect.mLeft, y - mRect.mBottom ); } BOOL translateIntoRect( const LLRect& constraint, BOOL allow_partial_outside ); - LLView* findSnapRect(LLRect& new_rect, const LLCoordGL& mouse_dir, LLView::ESnapType snap_type, S32 threshold, S32 padding = 0); - LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding = 0); + + virtual void userSetShape(const LLRect& new_rect); + virtual LLView* findSnapRect(LLRect& new_rect, const LLCoordGL& mouse_dir, LLView::ESnapType snap_type, S32 threshold, S32 padding = 0); + virtual LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding = 0); // Defaults to other_view->getVisible() virtual BOOL canSnapTo(LLView* other_view); @@ -345,6 +347,8 @@ public: /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); + /*virtual*/ void onMouseCaptureLost(); + /*virtual*/ BOOL hasMouseCapture(); // Default behavior is to pass the tooltip event to children, // then display mToolTipMsg if no child handled it. diff --git a/indra/llwindow/llmousehandler.h b/indra/llwindow/llmousehandler.h index e59b5845b0..1df1609451 100644 --- a/indra/llwindow/llmousehandler.h +++ b/indra/llwindow/llmousehandler.h @@ -15,8 +15,6 @@ // Intended for use via multiple inheritance. // A class may have as many interfaces as it likes, but never needs to inherit one more than once. -#include "llstring.h" - class LLMouseHandler { public: @@ -33,11 +31,15 @@ public: virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) = 0; virtual const LLString& getName() const = 0; + virtual void onMouseCaptureLost() = 0; + // Hack to support LLFocusMgr virtual BOOL isView() = 0; virtual void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const = 0; virtual void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const = 0; + + virtual BOOL hasMouseCapture() = 0; }; #endif diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index ccc100a861..f7df94c65c 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -217,6 +217,11 @@ LLWindow::LLWindow(BOOL fullscreen, U32 flags) { mJoyAxis[i] = 0; } + + for (U32 i = 0; i < 16; i++) + { + mJoyButtonState[i] = 0; + } } // virtual @@ -243,6 +248,15 @@ F32 LLWindow::getJoystickAxis(U32 axis) return 0.f; } +U8 LLWindow::getJoystickButton(U32 button) +{ + if (button < 16) + { + return mJoyButtonState[button]; + } + return 0; +} + void LLWindow::setCallbacks(LLWindowCallbacks *callbacks) { mCallbacks = callbacks; diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index f19178d7f5..5c5f712b32 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -183,6 +183,8 @@ public: virtual void setNativeAspectRatio(F32 aspect) = 0; F32 getJoystickAxis(U32 axis); + U8 getJoystickButton(U32 button); + void setCallbacks(LLWindowCallbacks *callbacks); virtual void beforeDialog() {}; // prepare to put up an OS dialog (if special measures are required, such as in fullscreen mode) @@ -221,7 +223,8 @@ protected: BOOL mHideCursorPermanent; U32 mFlags; F32 mJoyAxis[6]; - + U8 mJoyButtonState[16]; + friend class LLWindowManager; }; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index b8123096e6..697b8f2175 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -744,8 +744,6 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width, } SetTimer( mWindowHandle, 0, 1000 / 30, NULL ); // 30 fps timer - mJoyStickState = 0; - mJoyButtonState = 0; } @@ -2803,89 +2801,9 @@ void LLWindowWin32::updateJoystick( ) mJoyAxis[4] = js.lRy/1000.f; mJoyAxis[5] = js.lRz/1000.f; - if (js.lX <= -500) + for (U32 i = 0; i < 16; i++) { - if (!(mJoyStickState & 0x1)) - { - gKeyboard->handleTranslatedKeyDown(KEY_PAD_LEFT, 0); - mJoyStickState |= 0x1; - } - } - else - { - if (mJoyStickState & 0x1) - { - gKeyboard->handleTranslatedKeyUp(KEY_PAD_LEFT, 0); - mJoyStickState &= ~0x1; - } - } - if (js.lX >= 500) - { - if (!(mJoyStickState & 0x2)) - { - gKeyboard->handleTranslatedKeyDown(KEY_PAD_RIGHT, 0); - mJoyStickState |= 0x2; - } - } - else - { - if (mJoyStickState & 0x2) - { - gKeyboard->handleTranslatedKeyUp(KEY_PAD_RIGHT, 0); - mJoyStickState &= ~0x2; - } - } - if (js.lY <= -500) - { - if (!(mJoyStickState & 0x4)) - { - gKeyboard->handleTranslatedKeyDown(KEY_PAD_UP, 0); - mJoyStickState |= 0x4; - } - } - else - { - if (mJoyStickState & 0x4) - { - gKeyboard->handleTranslatedKeyUp(KEY_PAD_UP, 0); - mJoyStickState &= ~0x4; - } - } - if (js.lY >= 500) - { - if (!(mJoyStickState & 0x8)) - { - gKeyboard->handleTranslatedKeyDown(KEY_PAD_DOWN, 0); - mJoyStickState |= 0x8; - } - } - else - { - if (mJoyStickState & 0x8) - { - gKeyboard->handleTranslatedKeyUp(KEY_PAD_DOWN, 0); - mJoyStickState &= ~0x8; - } - } - - for( int i = 0; i < 15; i++ ) - { - if ( js.rgbButtons[i] & 0x80 ) - { - if (!(mJoyButtonState & (1<<i))) - { - gKeyboard->handleTranslatedKeyDown(KEY_BUTTON1+i, 0); - mJoyButtonState |= (1<<i); - } - } - else - { - if (mJoyButtonState & (1<<i)) - { - gKeyboard->handleTranslatedKeyUp(KEY_BUTTON1+i, 0); - mJoyButtonState &= ~(1<<i); - } - } + mJoyButtonState[i] = js.rgbButtons[i]; } } diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index ba944ca900..c4391ef41f 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -150,9 +150,6 @@ protected: WORD mPrevGammaRamp[256*3]; WORD mCurrentGammaRamp[256*3]; - U32 mJoyStickState; - U32 mJoyButtonState; - LPWSTR mIconResource; BOOL mMousePositionModified; BOOL mInputProcessingPaused; diff --git a/indra/newview/English.lproj/language.txt b/indra/newview/English.lproj/language.txt new file mode 100644 index 0000000000..bc0aa577f9 --- /dev/null +++ b/indra/newview/English.lproj/language.txt @@ -0,0 +1 @@ +en-us
\ No newline at end of file diff --git a/indra/newview/German.lproj/language.txt b/indra/newview/German.lproj/language.txt new file mode 100644 index 0000000000..c42e816f93 --- /dev/null +++ b/indra/newview/German.lproj/language.txt @@ -0,0 +1 @@ +de
\ No newline at end of file diff --git a/indra/newview/Japanese.lproj/language.txt b/indra/newview/Japanese.lproj/language.txt new file mode 100644 index 0000000000..c6e3ab6f3c --- /dev/null +++ b/indra/newview/Japanese.lproj/language.txt @@ -0,0 +1 @@ +ja
\ No newline at end of file diff --git a/indra/newview/Korean.lproj/language.txt b/indra/newview/Korean.lproj/language.txt new file mode 100644 index 0000000000..b03ec72ee0 --- /dev/null +++ b/indra/newview/Korean.lproj/language.txt @@ -0,0 +1 @@ +ko
\ No newline at end of file diff --git a/indra/newview/installers/windows/lang_de.nsi b/indra/newview/installers/windows/lang_de.nsi new file mode 100644 index 0000000000..71d2138313 --- /dev/null +++ b/indra/newview/installers/windows/lang_de.nsi @@ -0,0 +1,57 @@ +; First is default
+LoadLanguageFile "${NSISDIR}\Contrib\Language files\German.nlf"
+
+; subtitle on license text caption (setup new version or update current one
+LangString LicenseSubTitleUpdate ${LANG_GERMAN} " Update"
+LangString LicenseSubTitleSetup ${LANG_GERMAN} " Setup"
+
+; description on license page
+LangString LicenseDescUpdate ${LANG_GERMAN} "Dieses Paket wird Second Life auf Version ${VERSION_LONG}.updaten"
+LangString LicenseDescSetup ${LANG_GERMAN} "Dieses Paket installiert Second Life auf Ihrem Computer."
+LangString LicenseDescNext ${LANG_GERMAN} "Nächster Schritt"
+
+; installation directory text
+LangString DirectoryChooseTitle ${LANG_GERMAN} "Installations Ordner"
+LangString DirectoryChooseUpdate ${LANG_GERMAN} "Wählen Sie den Second Life Ordner für dieses Update:"
+LangString DirectoryChooseSetup ${LANG_GERMAN} "Wählen Sie den Pfad, in den Sie Second Life installieren möchten:"
+
+; CheckStartupParams message box
+LangString CheckStartupParamsMB ${LANG_GERMAN} "Konnte Programm '$INSTPROG' nicht finden. Stilles Update fehlgeschlagen."
+
+; installation success dialog
+LangString InstSuccesssQuestion ${LANG_GERMAN} "Second Life jetzt starten?"
+
+; remove old NSIS version
+LangString RemoveOldNSISVersion ${LANG_GERMAN} "Überprüfe alte Version..."
+
+; check windows version
+LangString CheckWindowsVersionDP ${LANG_GERMAN} "Überprüfe Windows Version..."
+LangString CheckWindowsVersionMB ${LANG_GERMAN} 'Second Life unterstützt nur Windows XP, Windows 2000 und Mac OS X.$\n$\nDer Versuch es auf Windows $R0 zu installieren, könnte in unvorhersehbaren Abstürtzen und zu Datenverlust führen.$\n$\nTrotzdem installieren?'
+
+; checkifadministrator function (install)
+LangString CheckAdministratorInstDP ${LANG_GERMAN} "Überprüfe nach Genehmigung zur Installation..."
+LangString CheckAdministratorInstMB ${LANG_GERMAN} 'Es scheint so, als würden Sie einen "limited" Account verwenden.$\nSie müssen ein"administrator" sein, um Second Life installieren zu können..'
+
+; checkifadministrator function (uninstall)
+LangString CheckAdministratorUnInstDP ${LANG_GERMAN} "Überprüfe Genehmigung zum Deinstallieren..."
+LangString CheckAdministratorUnInstMB ${LANG_GERMAN} 'Es scheint so, als würden Sie einen "limited" Account verwenden.$\nSie müssen ein"administrator" sein, um Second Life installieren zu können..'
+
+; checkifalreadycurrent
+LangString CheckIfCurrentMB ${LANG_GERMAN} "Es scheint so, als hätten Sie Second Life ${VERSION_LONG} bereits installiert.$\n$\nWürden Sie es gerne erneut installieren?"
+
+; closesecondlife function (install)
+LangString CloseSecondLifeInstDP ${LANG_GERMAN} "Warte darauf, dass Second Life beendet wird..."
+LangString CloseSecondLifeInstMB ${LANG_GERMAN} "Second Life kann nicht installiert werden, wenn es bereits läuft.$\n$\nBeenden Sie, was Sie gerade tun und wählen Sie OK, um Second Life zu beenden oder Continue .$\nSelect CANCEL, um abzubrechen."
+
+; closesecondlife function (uninstall)
+LangString CloseSecondLifeUnInstDP ${LANG_GERMAN} "Warte darauf, dass Second Life beendet wird..."
+LangString CloseSecondLifeUnInstMB ${LANG_GERMAN} "Second Life kann nicht installiert werden, wenn es bereits läuft.$\n$\nBeenden Sie, was Sie gerade tun und wählen Sie OK, um Second Life zu beenden oder Continue .$\nSelect CANCEL, um abzubrechen."
+
+; removecachefiles
+LangString RemoveCacheFilesDP ${LANG_GERMAN} "Lösche alle Cache Files in Dokumente und Einstellungen"
+
+; delete program files
+LangString DeleteProgramFilesMB ${LANG_GERMAN} "Es bestehen weiterhin Dateien in Ihrem SecondLife Programm Ordner.$\n$\nDies sind möglicherweise Dateien, die sie modifiziert oder bewegt haben:$\n$INSTDIR$\n$\nMöchten Sie diese ebenfalls löschen?"
+
+; uninstall text
+LangString UninstallTextMsg ${LANG_GERMAN} "Dies wird Second Life ${VERSION_LONG} von Ihrem System entfernen."
\ No newline at end of file diff --git a/indra/newview/installers/windows/lang_en-us.nsi b/indra/newview/installers/windows/lang_en-us.nsi new file mode 100644 index 0000000000..c26af12a9c --- /dev/null +++ b/indra/newview/installers/windows/lang_en-us.nsi @@ -0,0 +1,57 @@ +; First is default
+LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
+
+; subtitle on license text caption
+LangString LicenseSubTitleUpdate ${LANG_ENGLISH} " Update"
+LangString LicenseSubTitleSetup ${LANG_ENGLISH} " Setup"
+
+; description on license page
+LangString LicenseDescUpdate ${LANG_ENGLISH} "This package will update Second Life to version ${VERSION_LONG}.(XXX)"
+LangString LicenseDescSetup ${LANG_ENGLISH} "This package will install Second Life on your computer."
+LangString LicenseDescNext ${LANG_ENGLISH} "Next"
+
+; installation directory text
+LangString DirectoryChooseTitle ${LANG_ENGLISH} "Installation Directory"
+LangString DirectoryChooseUpdate ${LANG_ENGLISH} "Select the Second Life directory to update:"
+LangString DirectoryChooseSetup ${LANG_ENGLISH} "Select the directory to install Second Life in:"
+
+; CheckStartupParams message box
+LangString CheckStartupParamsMB ${LANG_ENGLISH} "Could not find the program '$INSTPROG'. Silent update failed."
+
+; installation success dialog
+LangString InstSuccesssQuestion ${LANG_ENGLISH} "Start Second Life now?"
+
+; remove old NSIS version
+LangString RemoveOldNSISVersion ${LANG_ENGLISH} "Checking for old version..."
+
+; check windows version
+LangString CheckWindowsVersionDP ${LANG_ENGLISH} "Checking Windows version..."
+LangString CheckWindowsVersionMB ${LANG_ENGLISH} 'Second Life only supports Windows XP, Windows 2000, and Mac OS X.$\n$\nAttempting to install on Windows $R0 can result in crashes and data loss.$\n$\nInstall anyway?'
+
+; checkifadministrator function (install)
+LangString CheckAdministratorInstDP ${LANG_ENGLISH} "Checking for permission to install..."
+LangString CheckAdministratorInstMB ${LANG_ENGLISH} 'You appear to be using a "limited" account.$\nYou must be an "administrator" to install Second Life.'
+
+; checkifadministrator function (uninstall)
+LangString CheckAdministratorUnInstDP ${LANG_ENGLISH} "Checking for permission to uninstall..."
+LangString CheckAdministratorUnInstMB ${LANG_ENGLISH} 'You appear to be using a "limited" account.$\nYou must be an "administrator" to uninstall Second Life.'
+
+; checkifalreadycurrent
+LangString CheckIfCurrentMB ${LANG_ENGLISH} "It appears that Second Life ${VERSION_LONG} is already installed.$\n$\nWould you like to install it again?"
+
+; closesecondlife function (install)
+LangString CloseSecondLifeInstDP ${LANG_ENGLISH} "Waiting for Second Life to shut down..."
+LangString CloseSecondLifeInstMB ${LANG_ENGLISH} "Second Life can't be installed while it is already running.$\n$\nFinish what you're doing then select OK to close Second Life and continue.$\nSelect CANCEL to cancel installation."
+
+; closesecondlife function (uninstall)
+LangString CloseSecondLifeUnInstDP ${LANG_ENGLISH} "Waiting for Second Life to shut down..."
+LangString CloseSecondLifeUnInstMB ${LANG_ENGLISH} "Second Life can't be uninstalled while it is already running.$\n$\nFinish what you're doing then select OK to close Second Life and continue.$\nSelect CANCEL to cancel."
+
+; removecachefiles
+LangString RemoveCacheFilesDP ${LANG_ENGLISH} "Deleting cache files in Documents and Settings folder"
+
+; delete program files
+LangString DeleteProgramFilesMB ${LANG_ENGLISH} "There are still files in your SecondLife program directory.$\n$\nThese are possibly files you created or moved to:$\n$INSTDIR$\n$\nDo you want to remove them?"
+
+; uninstall text
+LangString UninstallTextMsg ${LANG_ENGLISH} "This will uninstall Second Life ${VERSION_LONG} from your system."
diff --git a/indra/newview/installers/windows/lang_ja.nsi b/indra/newview/installers/windows/lang_ja.nsi new file mode 100644 index 0000000000..43cb492780 --- /dev/null +++ b/indra/newview/installers/windows/lang_ja.nsi @@ -0,0 +1,57 @@ +; First is default
+LoadLanguageFile "${NSISDIR}\Contrib\Language files\Japanese.nlf"
+
+; subtitle on license text caption
+LangString LicenseSubTitleUpdate ${LANG_JAPANESE} " ƒAƒbƒvƒf[ƒg"
+LangString LicenseSubTitleSetup ${LANG_JAPANESE} " ƒZƒbƒgƒAƒbƒv"
+
+; description on license page
+LangString LicenseDescUpdate ${LANG_JAPANESE} "‚±‚̃pƒbƒP[ƒW‚̓ZƒJƒ“ƒhƒ‰ƒCƒt‚ðƒo[ƒWƒ‡ƒ“${VERSION_LONG}.‚ɃAƒbƒvƒf[ƒg‚µ‚Ü‚·B"
+LangString LicenseDescSetup ${LANG_JAPANESE} "‚±‚̃pƒbƒP[ƒW‚Í‚ ‚È‚½‚̃Rƒ“ƒsƒ…[ƒ^‚ɃZƒJƒ“ƒhƒ‰ƒCƒt‚ðƒCƒ“ƒXƒg[ƒ‹‚µ‚Ü‚·B"
+LangString LicenseDescNext ${LANG_JAPANESE} "ŽŸ"
+
+; installation directory text
+LangString DirectoryChooseTitle ${LANG_JAPANESE} "ƒCƒ“ƒXƒg[ƒ‹EƒfƒBƒŒƒNƒgƒŠ"
+LangString DirectoryChooseUpdate ${LANG_JAPANESE} "ƒAƒbƒvƒf[ƒg‚·‚éƒZƒJƒ“ƒhƒ‰ƒCƒt‚̃fƒBƒŒƒNƒgƒŠ‚ð‘I‘ð‚µ‚Ä‚‚¾‚³‚¢B:"
+LangString DirectoryChooseSetup ${LANG_JAPANESE} "ƒZƒJƒ“ƒhƒ‰ƒCƒt‚ðƒCƒ“ƒXƒg[ƒ‹‚·‚éƒfƒBƒŒƒNƒgƒŠ‚ð‘I‘ð‚µ‚Ä‚‚¾‚³‚¢B: "
+
+; CheckStartupParams message box
+LangString CheckStartupParamsMB ${LANG_JAPANESE} "ƒvƒƒOƒ‰ƒ€–¼'$INSTPROG'‚ªŒ©‚‚©‚è‚Ü‚¹‚ñBƒTƒCƒŒƒ“ƒgEƒAƒbƒvƒf[ƒg‚ÉŽ¸”s‚µ‚Ü‚µ‚½B"
+
+; installation success dialog
+LangString InstSuccesssQuestion ${LANG_JAPANESE} "’¼‚¿‚ɃZƒJƒ“ƒhƒ‰ƒCƒt‚ðŠJŽn‚µ‚Ü‚·‚©H "
+
+; remove old NSIS version
+LangString RemoveOldNSISVersion ${LANG_JAPANESE} "ŒÃ‚¢ƒo[ƒWƒ‡ƒ“î•ñ‚ðƒ`ƒFƒbƒN’†‚Å‚·c"
+
+; check windows version
+LangString CheckWindowsVersionDP ${LANG_JAPANESE} "ƒEƒBƒ“ƒhƒEƒY‚̃o[ƒWƒ‡ƒ“î•ñ‚ðƒ`ƒFƒbƒN’†‚Å‚·..."
+LangString CheckWindowsVersionMB ${LANG_JAPANESE} "ƒZƒJƒ“ƒhƒ‰ƒCƒt‚ÍWindows XPAWindows 2000AMac OS X‚Ì‚Ý‚ðƒTƒ|[ƒg‚µ‚Ä‚¢‚Ü‚·BWindows $R0‚ðƒCƒ“ƒXƒg[ƒ‹‚·‚鎖‚ÍAƒf[ƒ^‚ÌÁŽ¸‚âƒNƒ‰ƒbƒVƒ…‚ÌŒ´ˆö‚É‚È‚é‰Â”\«‚ª‚ ‚è‚Ü‚·BƒCƒ“ƒXƒg[ƒ‹‚𑱂¯‚Ü‚·‚©H"
+
+; checkifadministrator function (install)
+LangString CheckAdministratorInstDP ${LANG_JAPANESE} "ƒCƒ“ƒXƒg[ƒ‹‚Ì‚½‚ß‚ÌŒ ŒÀ‚ðƒ`ƒFƒbƒN’†‚Å‚·..."
+LangString CheckAdministratorInstMB ${LANG_JAPANESE} "ƒZƒJƒ“ƒhƒ‰ƒCƒt‚ðƒCƒ“ƒXƒg[ƒ‹‚·‚é‚É‚ÍŠÇ—ŽÒŒ ŒÀ‚ª•K—v‚Å‚·B"
+
+; checkifadministrator function (uninstall)
+LangString CheckAdministratorUnInstDP ${LANG_JAPANESE} "ƒAƒ“ƒCƒ“ƒXƒg[ƒ‹‚Ì‚½‚ß‚ÌŒ ŒÀ‚ðƒ`ƒFƒbƒN’†‚Å‚·..."
+LangString CheckAdministratorUnInstMB ${LANG_JAPANESE} "ƒZƒJƒ“ƒhƒ‰ƒCƒt‚ðƒAƒ“ƒCƒ“ƒXƒg[ƒ‹‚·‚é‚É‚ÍŠÇ—ŽÒŒ ŒÀ‚ª•K—v‚Å‚·B"
+
+; checkifalreadycurrent
+LangString CheckIfCurrentMB ${LANG_JAPANESE} "ƒZƒJƒ“ƒhƒ‰ƒCƒt${VERSION_LONG} ‚̓Cƒ“ƒXƒg[ƒ‹Ï‚Ý‚Å‚·BÄ“xƒCƒ“ƒXƒg[ƒ‹‚µ‚Ü‚·‚©H "
+
+; closesecondlife function (install)
+LangString CloseSecondLifeInstDP ${LANG_JAPANESE} "ƒZƒJƒ“ƒhƒ‰ƒCƒt‚ðI—¹’†‚Å‚·..."
+LangString CloseSecondLifeInstMB ${LANG_JAPANESE} "ƒZƒJƒ“ƒhƒ‰ƒCƒt‚Ì‹N“®’†‚ɃCƒ“ƒXƒg[ƒ‹‚Ío—ˆ‚Ü‚¹‚ñB’¼‚¿‚ɃZƒJƒ“ƒhƒ‰ƒCƒt‚ðI—¹‚µ‚ăCƒ“ƒXƒg[ƒ‹‚ðŠJŽn‚·‚éꇂÍOKƒ{ƒ^ƒ“‚ð‰Ÿ‚µ‚Ä‚‚¾‚³‚¢BCANCEL‚ð‰Ÿ‚·‚Æ’†Ž~‚µ‚Ü‚·B"
+
+; closesecondlife function (uninstall)
+LangString CloseSecondLifeUnInstDP ${LANG_JAPANESE} "ƒZƒJƒ“ƒhƒ‰ƒCƒt‚ðI—¹’†‚Å‚·..."
+LangString CloseSecondLifeUnInstMB ${LANG_JAPANESE} "ƒZƒJƒ“ƒhƒ‰ƒCƒt‚Ì‹N“®’†‚ɃAƒ“ƒCƒ“ƒXƒg[ƒ‹‚Ío—ˆ‚Ü‚¹‚ñB’¼‚¿‚ɃZƒJƒ“ƒhƒ‰ƒCƒt‚ðI—¹‚µ‚ăAƒ“ƒCƒ“ƒXƒg[ƒ‹‚ðŠJŽn‚·‚éꇂÍOKƒ{ƒ^ƒ“‚ð‰Ÿ‚µ‚Ä‚‚¾‚³‚¢BCANCEL‚ð‰Ÿ‚·‚Æ’†Ž~‚µ‚Ü‚·B"
+
+; removecachefiles
+LangString RemoveCacheFilesDP ${LANG_JAPANESE} " Documents and Settings ƒtƒHƒ‹ƒ_‚̃LƒƒƒbƒVƒ…ƒtƒ@ƒCƒ‹‚ðƒfƒŠ[ƒg’†‚Å‚·B"
+
+; delete program files
+LangString DeleteProgramFilesMB ${LANG_JAPANESE} "ƒZƒJƒ“ƒhƒ‰ƒCƒt‚̃fƒBƒŒƒNƒgƒŠ‚É‚ÍA‚Ü‚¾ƒtƒ@ƒCƒ‹‚ªŽc‚³‚ê‚Ä‚¢‚Ü‚·B$\n$INSTDIR$\n‚É‚ ‚È‚½‚ªì¬A‚Ü‚½‚͈ړ®‚³‚¹‚½ƒtƒ@ƒCƒ‹‚ª‚ ‚é‰Â”\«‚ª‚ ‚è‚Ü‚·B‘S‚Ä휂µ‚Ü‚·‚©H "
+
+; uninstall text
+LangString UninstallTextMsg ${LANG_JAPANESE} "ƒZƒJƒ“ƒhƒ‰ƒCƒt${VERSION_LONG}‚ðƒAƒ“ƒCƒ“ƒXƒg[ƒ‹‚µ‚Ü‚·B"
diff --git a/indra/newview/installers/windows/lang_ko.nsi b/indra/newview/installers/windows/lang_ko.nsi new file mode 100644 index 0000000000..4e6b5ec0cd --- /dev/null +++ b/indra/newview/installers/windows/lang_ko.nsi @@ -0,0 +1,57 @@ +; First is default
+LoadLanguageFile "${NSISDIR}\Contrib\Language files\Korean.nlf"
+
+; subtitle on license text caption
+LangString LicenseSubTitleUpdate ${LANG_KOREAN} "¾÷µ¥ÀÌÆ®"
+LangString LicenseSubTitleSetup ${LANG_KOREAN} " ¼³Ä¡Çϱâ"
+
+; description on license page
+LangString LicenseDescUpdate ${LANG_KOREAN} "ÀÌ ÆÑÅ°Áö´Â ¼¼ÄÁµå¶óÀÌÇÁ¸¦ ¹öÀü${VERSION_LONG}.À¸·Î ¾÷µ¥ÀÌÆ® ÇÕ´Ï´Ù. "
+LangString LicenseDescSetup ${LANG_KOREAN} "ÀÌ ÆÑÅ°Áö´Â ¼¼ÄÁµå¶óÀÌÇÁ¸¦ ÄÄÇ»ÅÍ¿¡ ¼³Ä¡ÇÕ´Ï´Ù."
+LangString LicenseDescNext ${LANG_KOREAN} "´ÙÀ½"
+
+; installation directory text
+LangString DirectoryChooseTitle ${LANG_KOREAN} "¼³Ä¡ µð·ºÅ丮"
+LangString DirectoryChooseUpdate ${LANG_KOREAN} "¼¼ÄÁµå¶óÀÌÇÁ¸¦ ¾÷µ¥ÀÌÆ®ÇÒ µð·ºÅ丮¸¦ ¼±ÅÃÇϼ¼¿ä. "
+LangString DirectoryChooseSetup ${LANG_KOREAN} "¼¼ÄÁµå¶óÀÌÇÁ¸¦ ¼³Ä¡ÇÒ µð·ºÅ丮¸¦ ¼±ÅÃÇϼ¼¿ä:"
+
+; CheckStartupParams message box
+LangString CheckStartupParamsMB ${LANG_KOREAN} " ¡®$INSTPROG¡¯ ÇÁ·Î±×·¥À» ãÁö ¸øÇß½À´Ï´Ù. ÀÚµ¿ ¾÷µ¥ÀÌÆ®¿¡ ½ÇÆÐÇß½À´Ï´Ù."
+
+; installation success dialog
+LangString InstSuccesssQuestion ${LANG_KOREAN} "¼¼ÄÁµå¶óÀÌÇÁ¸¦ ½ÃÀÛÇÏ°Ú½À´Ï±î?"
+
+; remove old NSIS version
+LangString RemoveOldNSISVersion ${LANG_KOREAN} "ÀÌÀü ¹öÀüÀ» ã°í ÀÖ½À´Ï´Ù¡¦ "
+
+; check windows version
+LangString CheckWindowsVersionDP ${LANG_KOREAN} "À©µµ¿ì ¹öÀüÀ» È®ÀÎÇÏ°í ÀÖ½À´Ï´Ù."
+LangString CheckWindowsVersionMB ${LANG_KOREAN} "¼¼ÄÁµå¶óÀÌÇÁ´Â À©µµ¿ì XP, À©µµ¿ì 2000, ±×¸®°í ¸Æ OS X¸¦ Áö¿øÇÕ´Ï´Ù. À©µµ¿ì $R0¿¡ ¼³Ä¡¸¦ ½ÃµµÇÏ¸é ¿ÀÀÛµ¿°ú µ¥ÀÌÅÍ ºÐ½ÇÀÌ ÀϾ ¼ö ÀÖ½À´Ï´Ù. °è¼Ó ¼³Ä¡ÇÏ°Ú½À´Ï±î? "
+
+; checkifadministrator function (install)
+LangString CheckAdministratorInstDP ${LANG_KOREAN} "¼³Ä¡ ±ÇÇÑÀ» È®ÀÎ ÁßÀÔ´Ï´Ù... "
+LangString CheckAdministratorInstMB ${LANG_KOREAN} "ÇöÀç ¡®¼Õ´Ô¡¯°èÁ¤À» »ç¿ë ÁßÀÔ´Ï´Ù. ¼¼ÄÁµå¶óÀÌÇÁ¸¦ ¼³Ä¡Çϱâ À§Çؼ± ¡®¿î¿µÀÚ¡± °èÁ¤À» »ç¿ëÇØ¾ß ÇÕ´Ï´Ù."
+
+; checkifadministrator function (uninstall)
+LangString CheckAdministratorUnInstDP ${LANG_KOREAN} "Á¦°Å ±ÇÇÑÀ» È®ÀÎ ÁßÀÔ´Ï´Ù. "
+LangString CheckAdministratorUnInstMB ${LANG_KOREAN} " ÇöÀç ¡®¼Õ´Ô¡¯°èÁ¤À» »ç¿ë ÁßÀÔ´Ï´Ù. ¼¼ÄÁµå¶óÀÌÇÁ¸¦ Á¦°ÅÇϱâ À§Çؼ± ¡®¿î¿µÀÚ¡± °èÁ¤À» »ç¿ëÇØ¾ß ÇÕ´Ï´Ù. "
+
+; checkifalreadycurrent
+LangString CheckIfCurrentMB ${LANG_KOREAN} "¼¼ÄÁµå¶óÀÌÇÁ ¹öÀü ${VERSION_LONG}ÀÌ ÀÌ¹Ì ¼³Ä¡µÇ¾î ÀÖ½À´Ï´Ù. ´Ù½Ã ¼³Ä¡ÇϽðڽÀ´Ï±î? "
+
+; closesecondlife function (install)
+LangString CloseSecondLifeInstDP ${LANG_KOREAN} "¼¼ÄÁµå¶óÀÌÇÁ¸¦ Á¾·áÇÒ ¶§ ±îÁö ´ë±â Áß¡¦ "
+LangString CloseSecondLifeInstMB ${LANG_KOREAN} "¼¼ÄÁµå¶óÀÌÇÁ°¡ ÀÌ¹Ì ÀÛµ¿ ÁßÀÏ °æ¿ì ¼³Ä¡¸¦ °è¼Ó ÇÒ ¼ö ¾ø½À´Ï´Ù. ÇöÀç ÀÛ¾÷À» ¸ØÃß°í ¡®È®ÀΡ¯À» ´·¯ ¼¼ÄÁµå¶óÀÌÇÁ¸¦ Á¾·áÇÑ ´ÙÀ½ ÁøÇàÇϱ⠹ٶø´Ï´Ù. ¼³Ä¡¸¦ Ãë¼ÒÇÏ·Á¸é ¡®Ãë¼Ò¡¯¸¦ ´©¸£¼¼¿ä."
+
+; closesecondlife function (uninstall)
+LangString CloseSecondLifeUnInstDP ${LANG_KOREAN} "¼¼ÄÁµå¶óÀÌÇÁ¸¦ Á¾·áÇÒ ¶§ ±îÁö ´ë±â Áß¡¦¡±"
+LangString CloseSecondLifeUnInstMB ${LANG_KOREAN} " ¼¼ÄÁµå¶óÀÌÇÁ°¡ ÀÌ¹Ì ÀÛµ¿ ÁßÀÏ °æ¿ì Á¦°Å¸¦ °è¼Ó ÇÒ ¼ö ¾ø½À´Ï´Ù. ÇöÀç ÀÛ¾÷À» ¸ØÃß°í ¡®È®ÀΡ¯À» ´·¯ ¼¼ÄÁµå¶óÀÌÇÁ¸¦ Á¾·áÇÑ ´ÙÀ½ ÁøÇàÇϱ⠹ٶø´Ï´Ù. ¼³Ä¡¸¦ ÃëÇÏ·Á¸é ¡®Ãë¼Ò¡¯¸¦ ´©¸£¼¼¿ä. "
+
+; removecachefiles
+LangString RemoveCacheFilesDP ${LANG_KOREAN} " Documents and Settings Æú´õ ³»ÀÇ Ä³½Ã ÆÄÀϵéÀ» Áö¿ó´Ï´Ù."
+
+; delete program files
+LangString DeleteProgramFilesMB ${LANG_KOREAN} "¼¼ÄÁµå¶óÀÌÇÁ ÇÁ·Î±×·¥ µð·ºÅ丮¿¡ ¾ÆÁ÷ ÆÄÀϵéÀÌ ³²¾Æ ÀÖ½À´Ï´Ù. ÀÌ ÆÄÀϵéÀº »ç¿ëÀÚ°¡ ¸¸µç °ÍµéÀ̰ųª$\n$INSTDIR$\n$\n·Î À̵¿ÇÑ ÆÄÀϵéÀÏ ¼ö ÀÖ½À´Ï´Ù. ÀÌ ÆÄÀϵéÀ» Á¦°ÅÇÏ°Ú½À´Ï±î?"
+
+; uninstall text
+LangString UninstallTextMsg ${LANG_KOREAN} "¼¼ÄÁµå¶óÀÌÇÁ${VERSION_LONG}À» ½Ã½ºÅÛ¿¡¼ Á¦°ÅÇÕ´Ï´Ù."
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index c0ad9ffb03..15ab9bac1d 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -309,9 +309,6 @@ LLAgent::LLAgent() mbJump(FALSE), - mWanderTimer(), - mWanderTargetGlobal( LLVector3d::zero ), - mAutoPilot(FALSE), mAutoPilotFlyOnStop(FALSE), mAutoPilotTargetGlobal(), @@ -2097,36 +2094,6 @@ BOOL LLAgent::getBusy() const //----------------------------------------------------------------------------- -// updateWanderTarget() -//----------------------------------------------------------------------------- -void LLAgent::updateWanderTarget() -{ - S32 num_regions; - LLViewerRegion* rand_region; - F32 rand_x; - F32 rand_y; - - if (mWanderTimer.checkExpirationAndReset(ll_frand(MAX_WANDER_TIME))) - { - // Pick a random spot to wander towards - num_regions = gWorldPointer->mActiveRegionList.getLength(); - S32 region_num = llround(ll_frand() * num_regions); - rand_region = gWorldPointer->mActiveRegionList.getFirstData(); - S32 i = 0; - while (i < region_num) - { - rand_region = gWorldPointer->mActiveRegionList.getNextData(); - i++; - } - rand_x = ll_frand(rand_region->getWidth()); - rand_y = ll_frand(rand_region->getWidth()); - - stopAutoPilot(); - startAutoPilotGlobal(rand_region->getPosGlobalFromRegion(LLVector3(rand_x, rand_y, 0.f))); - } -} - -//----------------------------------------------------------------------------- // startAutoPilotGlobal() //----------------------------------------------------------------------------- void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::string& behavior_name, const LLQuaternion *target_rotation, void (*finish_callback)(BOOL, void *), void *callback_data, F32 stop_distance, F32 rot_threshold) @@ -4043,10 +4010,6 @@ void LLAgent::changeCameraToFollow(BOOL animate) mbFlagsDirty = TRUE; } - //RN: this doesn't seem to be necessary and destroys the UE for script-driven cameras - //gViewerWindow->setKeyboardFocus( NULL, NULL ); - //gViewerWindow->setMouseCapture( NULL, NULL ); - if (animate) { startCameraAnimation(); @@ -4110,9 +4073,6 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) mbFlagsDirty = TRUE; } - //RN: this doesn't seem to be necessary and destroys the UE for script-driven cameras - //gViewerWindow->setKeyboardFocus( NULL, NULL ); - //gViewerWindow->setMouseCapture( NULL, NULL ); } // Remove any pitch from the avatar @@ -4185,7 +4145,7 @@ void LLAgent::changeCameraToCustomizeAvatar(BOOL animate) } gViewerWindow->setKeyboardFocus( NULL, NULL ); - gViewerWindow->setMouseCapture( NULL, NULL ); + gViewerWindow->setMouseCapture( NULL ); LLVOAvatar::onCustomizeStart(); } diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index b86dc03807..d0bda5d46a 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -398,8 +398,6 @@ public: void propagate(const F32 dt); // BUG: should roll into updateAgentPosition - void updateWanderTarget(); // drones will pick points in the world to autopilot towards - void startAutoPilotGlobal(const LLVector3d &pos_global, const std::string& behavior_name = "", const LLQuaternion *target_rotation = NULL, void (*finish_callback)(BOOL, void *) = NULL, void *callback_data = NULL, F32 stop_distance = 0.f, F32 rotation_threshold = 0.03f); @@ -771,9 +769,6 @@ private: BOOL mbJump; - LLFrameTimer mWanderTimer; - LLVector3d mWanderTargetGlobal; - BOOL mAutoPilot; BOOL mAutoPilotFlyOnStop; LLVector3d mAutoPilotTargetGlobal; diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index 7c615dd159..821bb2a69f 100644 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -79,7 +79,7 @@ void LLAssetUploadResponder::error(U32 statusNum, const std::string& reason) default: args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); args["[REASON]"] = "The server is experiencing unexpected " - "difficulties. Please try again later."; + "difficulties."; gViewerWindow->alertXml("CannotUploadReason", args); break; } diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp index 19b6d80082..ddf0b83e73 100644 --- a/indra/newview/llchatbar.cpp +++ b/indra/newview/llchatbar.cpp @@ -583,7 +583,7 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) } // static -void LLChatBar::onInputEditorFocusLost( LLLineEditor* caller, void* userdata) +void LLChatBar::onInputEditorFocusLost( LLUICtrl* caller, void* userdata) { // stop typing animation gAgent.stopTyping(); diff --git a/indra/newview/llchatbar.h b/indra/newview/llchatbar.h index e0f31ae124..65724a1f45 100644 --- a/indra/newview/llchatbar.h +++ b/indra/newview/llchatbar.h @@ -67,7 +67,7 @@ public: static void onTabClick( void* userdata ); static void onInputEditorKeystroke(LLLineEditor* caller, void* userdata); - static void onInputEditorFocusLost(LLLineEditor* caller,void* userdata); + static void onInputEditorFocusLost(LLUICtrl* caller,void* userdata); static void onInputEditorGainFocus(LLUICtrl* caller,void* userdata); static void onCommitGesture(LLUICtrl* ctrl, void* data); diff --git a/indra/newview/llcolorswatch.cpp b/indra/newview/llcolorswatch.cpp index 4dade7f683..13e7fef4ec 100644 --- a/indra/newview/llcolorswatch.cpp +++ b/indra/newview/llcolorswatch.cpp @@ -148,7 +148,7 @@ BOOL LLColorSwatchCtrl::handleMouseDown(S32 x, S32 y, MASK mask) { // Route future Mouse messages here preemptively. (Release on mouse up.) // No handler is needed for capture lost since this object has no state that depends on it. - gViewerWindow->setMouseCapture( this, NULL ); + gViewerWindow->setMouseCapture( this ); return TRUE; } @@ -157,10 +157,10 @@ BOOL LLColorSwatchCtrl::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLColorSwatchCtrl::handleMouseUp(S32 x, S32 y, MASK mask) { // We only handle the click if the click both started and ended within us - if( gViewerWindow->hasMouseCapture( this ) ) + if( hasMouseCapture() ) { // Release the mouse - gViewerWindow->setMouseCapture( NULL, NULL ); + gViewerWindow->setMouseCapture( NULL ); // If mouseup in the widget, it's been clicked if ( pointInView(x, y) ) diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 3418007d41..77bbc1ca81 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -254,7 +254,8 @@ LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerImage *texturep) LLMemType mt(LLMemType::MTYPE_DRAWABLE); LLFace *face = new LLFace(this, mVObjp); - + if (!face) llerrs << "Allocating new Face: " << mFaces.size() << llendl; + if (face) { mFaces.push_back(face); diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 93af956466..de82dff95d 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -26,6 +26,7 @@ #include "llviewerwindow.h" #include "pipeline.h" #include "llviewerregion.h" +#include "llglslshader.h" BOOL LLDrawPoolAlpha::sShowDebugAlpha = FALSE; @@ -47,7 +48,7 @@ LLDrawPoolAlpha::~LLDrawPoolAlpha() void LLDrawPoolAlpha::prerender() { - mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_OBJECT); + mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_OBJECT); } void LLDrawPoolAlpha::beginRenderPass(S32 pass) diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 9b9825deff..a0cc189c46 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -21,6 +21,7 @@ #include "llviewerregion.h" #include "noise.h" #include "pipeline.h" +#include "llglslshader.h" static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK; static U32 sBufferUsage = GL_STREAM_DRAW_ARB; @@ -82,12 +83,12 @@ static LLMatrix4 sModelViewMatrix = LLMatrix4(); S32 LLDrawPoolAvatar::getVertexShaderLevel() const { - return (S32) gPipeline.getVertexShaderLevel(LLPipeline::SHADER_AVATAR); + return (S32) LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_AVATAR); } void LLDrawPoolAvatar::prerender() { - mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_AVATAR); + mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_AVATAR); sShaderLevel = mVertexShaderLevel; if (sShaderLevel > 0) @@ -171,15 +172,15 @@ void LLDrawPoolAvatar::endFootShadow() void LLDrawPoolAvatar::beginRigid() { - sVertexProgram = &gPipeline.mAvatarEyeballProgram; + sVertexProgram = &gAvatarEyeballProgram; glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); if (sShaderLevel > 0) { //eyeballs render with the specular shader - gPipeline.mAvatarEyeballProgram.bind(); - gPipeline.mMaterialIndex = gPipeline.mAvatarEyeballProgram.mAttribute[LLPipeline::GLSL_MATERIAL_COLOR]; - gPipeline.mSpecularIndex = gPipeline.mAvatarEyeballProgram.mAttribute[LLPipeline::GLSL_SPECULAR_COLOR]; + gAvatarEyeballProgram.bind(); + gMaterialIndex = gAvatarEyeballProgram.mAttribute[LLShaderMgr::MATERIAL_COLOR]; + gSpecularIndex = gAvatarEyeballProgram.mAttribute[LLShaderMgr::SPECULAR_COLOR]; } } @@ -194,7 +195,7 @@ void LLDrawPoolAvatar::beginSkinned() glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - sVertexProgram = &gPipeline.mAvatarProgram; + sVertexProgram = &gAvatarProgram; if (sShaderLevel > 0) // for hardware blending { @@ -202,22 +203,22 @@ void LLDrawPoolAvatar::beginSkinned() glClientActiveTextureARB(GL_TEXTURE1_ARB); if (sShaderLevel >= SHADER_LEVEL_BUMP) { - gPipeline.mMaterialIndex = sVertexProgram->mAttribute[LLPipeline::GLSL_MATERIAL_COLOR]; - gPipeline.mSpecularIndex = sVertexProgram->mAttribute[LLPipeline::GLSL_SPECULAR_COLOR]; + gMaterialIndex = sVertexProgram->mAttribute[LLShaderMgr::MATERIAL_COLOR]; + gSpecularIndex = sVertexProgram->mAttribute[LLShaderMgr::SPECULAR_COLOR]; } sVertexProgram->bind(); if (sShaderLevel >= SHADER_LEVEL_CLOTH) { - enable_cloth_weights(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_CLOTHING]); + enable_cloth_weights(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_CLOTHING]); } - enable_vertex_weighting(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_WEIGHT]); + enable_vertex_weighting(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_WEIGHT]); if (sShaderLevel >= SHADER_LEVEL_BUMP) { - enable_binormals(sVertexProgram->mAttribute[LLPipeline::GLSL_BINORMAL]); + enable_binormals(sVertexProgram->mAttribute[LLShaderMgr::BINORMAL]); } - sVertexProgram->enableTexture(LLPipeline::GLSL_BUMP_MAP); + sVertexProgram->enableTexture(LLShaderMgr::BUMP_MAP); glActiveTextureARB(GL_TEXTURE0_ARB); } } @@ -228,17 +229,17 @@ void LLDrawPoolAvatar::endSkinned() if (sShaderLevel > 0) { sRenderingSkinned = FALSE; - sVertexProgram->disableTexture(LLPipeline::GLSL_BUMP_MAP); + sVertexProgram->disableTexture(LLShaderMgr::BUMP_MAP); glActiveTextureARB(GL_TEXTURE0_ARB); glClientActiveTextureARB(GL_TEXTURE0_ARB); - disable_vertex_weighting(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_WEIGHT]); + disable_vertex_weighting(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_WEIGHT]); if (sShaderLevel >= SHADER_LEVEL_BUMP) { - disable_binormals(sVertexProgram->mAttribute[LLPipeline::GLSL_BINORMAL]); + disable_binormals(sVertexProgram->mAttribute[LLShaderMgr::BINORMAL]); } if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) { - disable_cloth_weights(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_CLOTHING]); + disable_cloth_weights(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_CLOTHING]); } sVertexProgram->unbind(); @@ -354,7 +355,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) if (sShaderLevel > 0) { - gPipeline.mAvatarMatrixParam = sVertexProgram->mUniform[LLPipeline::GLSL_AVATAR_MATRIX]; + gAvatarMatrixParam = sVertexProgram->mUniform[LLShaderMgr::AVATAR_MATRIX]; } if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) @@ -370,16 +371,16 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) wind = wind * rot_mat; wind.mV[VW] = avatarp->mWindVec.mV[VW]; - sVertexProgram->vertexAttrib4fv(LLPipeline::GLSL_AVATAR_WIND, wind.mV); + sVertexProgram->vertexAttrib4fv(LLShaderMgr::AVATAR_WIND, wind.mV); F32 phase = -1.f * (avatarp->mRipplePhase); F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); LLVector4 sin_params(freq, freq, freq, phase); - sVertexProgram->vertexAttrib4fv(LLPipeline::GLSL_AVATAR_SINWAVE, sin_params.mV); + sVertexProgram->vertexAttrib4fv(LLShaderMgr::AVATAR_SINWAVE, sin_params.mV); LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); gravity = gravity * rot_mat; - sVertexProgram->vertexAttrib4fv(LLPipeline::GLSL_AVATAR_GRAVITY, gravity.mV); + sVertexProgram->vertexAttrib4fv(LLShaderMgr::AVATAR_GRAVITY, gravity.mV); } if( !single_avatar || (avatarp == single_avatar) ) @@ -507,10 +508,10 @@ void LLDrawPoolAvatar::renderForSelect() glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glGetFloatv(GL_MODELVIEW_MATRIX, (F32*) sModelViewMatrix.mMatrix); - sVertexProgram = &gPipeline.mAvatarPickProgram; + sVertexProgram = &gAvatarPickProgram; if (sShaderLevel > 0) { - gPipeline.mAvatarMatrixParam = sVertexProgram->mUniform[LLPipeline::GLSL_AVATAR_MATRIX]; + gAvatarMatrixParam = sVertexProgram->mUniform[LLShaderMgr::AVATAR_MATRIX]; } glAlphaFunc(GL_GEQUAL, 0.2f); glBlendFunc(GL_ONE, GL_ZERO); @@ -527,7 +528,7 @@ void LLDrawPoolAvatar::renderForSelect() glClientActiveTextureARB(GL_TEXTURE0_ARB); sRenderingSkinned = TRUE; sVertexProgram->bind(); - enable_vertex_weighting(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_WEIGHT]); + enable_vertex_weighting(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_WEIGHT]); } mIndicesDrawn += avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); @@ -537,7 +538,7 @@ void LLDrawPoolAvatar::renderForSelect() { sRenderingSkinned = FALSE; sVertexProgram->unbind(); - disable_vertex_weighting(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_WEIGHT]); + disable_vertex_weighting(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_WEIGHT]); } glAlphaFunc(GL_GREATER, 0.01f); @@ -577,7 +578,7 @@ LLColor3 LLDrawPoolAvatar::getDebugColor() const LLVertexBufferAvatar::LLVertexBufferAvatar() : LLVertexBuffer(sDataMask, - gPipeline.getVertexShaderLevel(LLPipeline::SHADER_AVATAR) > 0 ? + LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_AVATAR) > 0 ? GL_STATIC_DRAW_ARB : GL_STREAM_DRAW_ARB) { @@ -599,16 +600,16 @@ void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const glClientActiveTextureARB(GL_TEXTURE0_ARB); glTexCoordPointer(2,GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_TEXCOORD])); - set_vertex_weights(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_WEIGHT], mStride, (F32*)(base + mOffsets[TYPE_WEIGHT])); + set_vertex_weights(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_WEIGHT], mStride, (F32*)(base + mOffsets[TYPE_WEIGHT])); if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_BUMP) { - set_binormals(sVertexProgram->mAttribute[LLPipeline::GLSL_BINORMAL], mStride, (LLVector3*)(base + mOffsets[TYPE_BINORMAL])); + set_binormals(sVertexProgram->mAttribute[LLShaderMgr::BINORMAL], mStride, (LLVector3*)(base + mOffsets[TYPE_BINORMAL])); } if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH) { - set_vertex_clothing_weights(sVertexProgram->mAttribute[LLPipeline::GLSL_AVATAR_CLOTHING], mStride, (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT])); + set_vertex_clothing_weights(sVertexProgram->mAttribute[LLShaderMgr::AVATAR_CLOTHING], mStride, (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT])); } } else diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 377dbea2d0..f0f7130e0b 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -27,7 +27,7 @@ #include "llviewercamera.h" #include "llviewerimagelist.h" #include "pipeline.h" - +#include "llglslshader.h" //#include "llimagebmp.h" //#include "../tools/imdebug/imdebug.h" @@ -141,7 +141,7 @@ LLDrawPoolBump::LLDrawPoolBump() void LLDrawPoolBump::prerender() { - mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_OBJECT); + mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_OBJECT); } // static @@ -234,14 +234,14 @@ void LLDrawPoolBump::beginShiny() cube_map->setMatrix(0); cube_map->bind(); - if (gPipeline.getVertexShaderLevel(LLPipeline::SHADER_OBJECT) > 0) + if (LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_OBJECT) > 0) { LLMatrix4 mat; glGetFloatv(GL_MODELVIEW_MATRIX, (F32*) mat.mMatrix); - gPipeline.mObjectShinyProgram.bind(); - LLVector3 vec = LLVector3(gPipeline.mShinyOrigin) * mat; - LLVector4 vec4(vec, gPipeline.mShinyOrigin.mV[3]); - glUniform4fvARB(gPipeline.mObjectShinyProgram.mUniform[LLPipeline::GLSL_SHINY_ORIGIN], 1, + gObjectShinyProgram.bind(); + LLVector3 vec = LLVector3(gShinyOrigin) * mat; + LLVector4 vec4(vec, gShinyOrigin.mV[3]); + glUniform4fvARB(gObjectShinyProgram.mUniform[LLShaderMgr::SHINY_ORIGIN], 1, vec4.mV); } else @@ -361,9 +361,9 @@ void LLDrawPoolBump::endShiny() cube_map->disable(); cube_map->restoreMatrix(); - if (gPipeline.getVertexShaderLevel(LLPipeline::SHADER_OBJECT) > 0) + if (LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_OBJECT) > 0) { - gPipeline.mObjectShinyProgram.unbind(); + gObjectShinyProgram.unbind(); } glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); diff --git a/indra/newview/lldrawpoolground.cpp b/indra/newview/lldrawpoolground.cpp index edbb11ad79..b6c3d638ea 100644 --- a/indra/newview/lldrawpoolground.cpp +++ b/indra/newview/lldrawpoolground.cpp @@ -21,6 +21,7 @@ #include "pipeline.h" #include "llagent.h" #include "llviewerregion.h" +#include "llglslshader.h" LLDrawPoolGround::LLDrawPoolGround() : LLFacePool(POOL_GROUND) @@ -34,7 +35,7 @@ LLDrawPool *LLDrawPoolGround::instancePool() void LLDrawPoolGround::prerender() { - mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_ENVIRONMENT); + mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_ENVIRONMENT); } void LLDrawPoolGround::render(S32 pass) diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index 4c09cd4095..26022e362a 100644 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -17,6 +17,7 @@ #include "llface.h" #include "llsky.h" #include "pipeline.h" +#include "llglslshader.h" class LLRenderShinyGlow : public LLDrawPoolBump { @@ -102,7 +103,7 @@ LLDrawPoolSimple::LLDrawPoolSimple() : void LLDrawPoolSimple::prerender() { - mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_OBJECT); + mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_OBJECT); } void LLDrawPoolSimple::beginRenderPass(S32 pass) diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 80340f63b9..6448576117 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -23,6 +23,7 @@ #include "llvosky.h" #include "llworld.h" // To get water height #include "pipeline.h" +#include "llglslshader.h" LLDrawPoolSky::LLDrawPoolSky() : LLFacePool(POOL_SKY) @@ -36,7 +37,7 @@ LLDrawPool *LLDrawPoolSky::instancePool() void LLDrawPoolSky::prerender() { - mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_ENVIRONMENT); + mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_ENVIRONMENT); } void LLDrawPoolSky::render(S32 pass) diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index 8c5c2e177a..787cd3167b 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -28,6 +28,7 @@ #include "llviewerimagelist.h" // To get alpha gradients #include "llworld.h" #include "pipeline.h" +#include "llglslshader.h" const F32 DETAIL_SCALE = 1.f/16.f; int DebugDetailMap = 0; @@ -149,10 +150,10 @@ void LLDrawPoolTerrain::render(S32 pass) gPipeline.disableLights(); if ((mVertexShaderLevel > 0)) { - gPipeline.mHighlightProgram.bind(); - gPipeline.mHighlightProgram.vertexAttrib4f(LLPipeline::GLSL_MATERIAL_COLOR,1,1,1,1); + gHighlightProgram.bind(); + gHighlightProgram.vertexAttrib4f(LLShaderMgr::MATERIAL_COLOR,1,1,1,1); renderOwnership(); - gPipeline.mTerrainProgram.bind(); + gTerrainProgram.bind(); } else { @@ -203,9 +204,9 @@ void LLDrawPoolTerrain::renderFull4TUShader() // Stage 0: detail texture 0 // - S32 detailTex0 = gPipeline.mTerrainProgram.enableTexture(LLPipeline::GLSL_TERRAIN_DETAIL0); - S32 detailTex1 = gPipeline.mTerrainProgram.enableTexture(LLPipeline::GLSL_TERRAIN_DETAIL1); - S32 rampTex = gPipeline.mTerrainProgram.enableTexture(LLPipeline::GLSL_TERRAIN_ALPHARAMP); + S32 detailTex0 = gTerrainProgram.enableTexture(LLShaderMgr::TERRAIN_DETAIL0); + S32 detailTex1 = gTerrainProgram.enableTexture(LLShaderMgr::TERRAIN_DETAIL1); + S32 rampTex = gTerrainProgram.enableTexture(LLShaderMgr::TERRAIN_ALPHARAMP); LLViewerImage::bindTexture(detail_texture0p,detailTex0); @@ -322,9 +323,9 @@ void LLDrawPoolTerrain::renderFull4TUShader() } // Disable multitexture - gPipeline.mTerrainProgram.disableTexture(LLPipeline::GLSL_TERRAIN_ALPHARAMP); - gPipeline.mTerrainProgram.disableTexture(LLPipeline::GLSL_TERRAIN_DETAIL0); - gPipeline.mTerrainProgram.disableTexture(LLPipeline::GLSL_TERRAIN_DETAIL1); + gTerrainProgram.disableTexture(LLShaderMgr::TERRAIN_ALPHARAMP); + gTerrainProgram.disableTexture(LLShaderMgr::TERRAIN_DETAIL0); + gTerrainProgram.disableTexture(LLShaderMgr::TERRAIN_DETAIL1); glClientActiveTextureARB(GL_TEXTURE3_ARB); glActiveTextureARB(GL_TEXTURE3_ARB); @@ -1061,5 +1062,5 @@ LLColor3 LLDrawPoolTerrain::getDebugColor() const S32 LLDrawPoolTerrain::getMaterialAttribIndex() { - return gPipeline.mTerrainProgram.mAttribute[LLPipeline::GLSL_MATERIAL_COLOR]; + return gTerrainProgram.mAttribute[LLShaderMgr::MATERIAL_COLOR]; } diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp index 170669955c..350ad6a652 100644 --- a/indra/newview/lldrawpooltree.cpp +++ b/indra/newview/lldrawpooltree.cpp @@ -17,6 +17,7 @@ #include "llvotree.h" #include "pipeline.h" #include "llviewercamera.h" +#include "llglslshader.h" S32 LLDrawPoolTree::sDiffTex = 0; @@ -267,5 +268,5 @@ LLColor3 LLDrawPoolTree::getDebugColor() const S32 LLDrawPoolTree::getMaterialAttribIndex() { - return gPipeline.mObjectSimpleProgram.mAttribute[LLPipeline::GLSL_MATERIAL_COLOR]; + return gObjectSimpleProgram.mAttribute[LLShaderMgr::MATERIAL_COLOR]; } diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 6e372b6f76..fd66d58851 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -28,6 +28,7 @@ #include "llworld.h" #include "pipeline.h" #include "viewer.h" // gSunTextureID, gMoonTextureID +#include "llglslshader.h" const LLUUID WATER_TEST("2bfd3884-7e27-69b9-ba3a-3e673f680004"); @@ -71,12 +72,9 @@ LLDrawPool *LLDrawPoolWater::instancePool() void LLDrawPoolWater::prerender() { -#if 1 // 1.9.1 mVertexShaderLevel = gSavedSettings.getBOOL("RenderRippleWater") ? - gPipeline.getVertexShaderLevel(LLPipeline::SHADER_ENVIRONMENT) : 0; -#else - mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_ENVIRONMENT); -#endif + LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_ENVIRONMENT) : 0; + } extern LLColor4U MAX_WATER_COLOR; @@ -319,7 +317,7 @@ void LLDrawPoolWater::renderShaderSimple() glEnableClientState(GL_NORMAL_ARRAY); // Set up second pass first - S32 bumpTex = gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_BUMP_MAP); + S32 bumpTex = gWaterProgram.enableTexture(LLShaderMgr::BUMP_MAP); mWaterImagep->addTextureStats(1024.f*1024.f); mWaterImagep->bind(bumpTex); @@ -368,7 +366,7 @@ void LLDrawPoolWater::renderShaderSimple() if (gSky.mVOSkyp->getCubeMap()) { - envTex = gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); + envTex = gWaterProgram.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); gSky.mVOSkyp->getCubeMap()->bind(); glMatrixMode(GL_TEXTURE); @@ -382,9 +380,9 @@ void LLDrawPoolWater::renderShaderSimple() glMatrixMode(GL_MODELVIEW); } - S32 diffTex = gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_DIFFUSE_MAP); + S32 diffTex = gWaterProgram.enableTexture(LLShaderMgr::DIFFUSE_MAP); - gPipeline.mWaterProgram.bind(); + gWaterProgram.bind(); for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); iter != mDrawFace.end(); iter++) @@ -401,21 +399,21 @@ void LLDrawPoolWater::renderShaderSimple() if (gSky.mVOSkyp->getCubeMap()) { - gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); + gWaterProgram.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); } // Now, disable texture coord generation on texture state 1 - gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_BUMP_MAP); + gWaterProgram.disableTexture(LLShaderMgr::BUMP_MAP); LLImageGL::unbindTexture(bumpTex, GL_TEXTURE_2D); glActiveTextureARB(GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_GEN_S); //texture unit 1 glDisable(GL_TEXTURE_GEN_T); //texture unit 1 - gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_DIFFUSE_MAP); + gWaterProgram.disableTexture(LLShaderMgr::DIFFUSE_MAP); // Disable texture coordinate and color arrays LLImageGL::unbindTexture(diffTex, GL_TEXTURE_2D); @@ -546,17 +544,17 @@ void LLDrawPoolWater::shade() LLCubeMap* skyMap = gSky.mVOSkyp->getCubeMap(); - gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); + gWaterProgram.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); skyMap->bind(); //bind normal map - S32 bumpTex = gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_BUMP_MAP); + S32 bumpTex = gWaterProgram.enableTexture(LLShaderMgr::BUMP_MAP); mWaterNormp->addTextureStats(1024.f*1024.f); mWaterNormp->bind(bumpTex); - gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_WATER_SCREENTEX); + gWaterProgram.enableTexture(LLShaderMgr::WATER_SCREENTEX); - gPipeline.mWaterProgram.bind(); + gWaterProgram.bind(); if (!sSkipScreenCopy) { @@ -567,20 +565,20 @@ void LLDrawPoolWater::shade() glBindTexture(GL_TEXTURE_2D, 0); } - glUniform2fvARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_FBSCALE], 1, + glUniform2fvARB(gWaterProgram.mUniform[LLShaderMgr::WATER_FBSCALE], 1, gPipeline.mScreenScale.mV); - S32 diffTex = gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_DIFFUSE_MAP); + S32 diffTex = gWaterProgram.enableTexture(LLShaderMgr::DIFFUSE_MAP); LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - glUniform1fARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_TIME], sTime); - glUniform3fvARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_SPECULAR], 1, light_diffuse.mV); - glUniform1fARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_SPECULAR_EXP], light_exp); - glUniform3fvARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_EYEVEC], 1, gCamera->getOrigin().mV); - glUniform2fvARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_WAVE_DIR1], 1, d1.mV); - glUniform2fvARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_WAVE_DIR2], 1, d2.mV); - glUniform3fvARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_LIGHT_DIR], 1, light_dir.mV); + glUniform1fARB(gWaterProgram.mUniform[LLShaderMgr::WATER_TIME], sTime); + glUniform3fvARB(gWaterProgram.mUniform[LLShaderMgr::WATER_SPECULAR], 1, light_diffuse.mV); + glUniform1fARB(gWaterProgram.mUniform[LLShaderMgr::WATER_SPECULAR_EXP], light_exp); + glUniform3fvARB(gWaterProgram.mUniform[LLShaderMgr::WATER_EYEVEC], 1, gCamera->getOrigin().mV); + glUniform2fvARB(gWaterProgram.mUniform[LLShaderMgr::WATER_WAVE_DIR1], 1, d1.mV); + glUniform2fvARB(gWaterProgram.mUniform[LLShaderMgr::WATER_WAVE_DIR2], 1, d2.mV); + glUniform3fvARB(gWaterProgram.mUniform[LLShaderMgr::WATER_LIGHT_DIR], 1, light_dir.mV); LLColor4 water_color; LLVector3 camera_up = gCamera->getUpAxis(); @@ -588,12 +586,12 @@ void LLDrawPoolWater::shade() if (gCamera->cameraUnderWater()) { water_color.setVec(1.f, 1.f, 1.f, 0.4f); - glUniform1fARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_REFSCALE], 0.25f); + glUniform1fARB(gWaterProgram.mUniform[LLShaderMgr::WATER_REFSCALE], 0.25f); } else { water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot)); - glUniform1fARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_REFSCALE], 0.01f); + glUniform1fARB(gWaterProgram.mUniform[LLShaderMgr::WATER_REFSCALE], 0.01f); } if (water_color.mV[3] > 0.9f) { @@ -620,10 +618,10 @@ void LLDrawPoolWater::shade() } } - gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); - gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_WATER_SCREENTEX); - gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_BUMP_MAP); - gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_DIFFUSE_MAP); + gWaterProgram.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); + gWaterProgram.disableTexture(LLShaderMgr::WATER_SCREENTEX); + gWaterProgram.disableTexture(LLShaderMgr::BUMP_MAP); + gWaterProgram.disableTexture(LLShaderMgr::DIFFUSE_MAP); glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 280abcd541..b3e68e24df 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -231,8 +231,6 @@ void LLFace::setDrawable(LLDrawable *drawable) void LLFace::setSize(const S32 num_vertices, const S32 num_indices) { - LLMemType mt1(LLMemType::MTYPE_DRAWABLE); - mGeomCount = num_vertices; mIndicesCount = num_indices; } @@ -950,17 +948,17 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } else { - if (mode & LLViewerTextureAnim::TRANSLATE) + //if (mode & LLViewerTextureAnim::TRANSLATE) { os = ot = 0.f; } - if (mode & LLViewerTextureAnim::ROTATE) + //if (mode & LLViewerTextureAnim::ROTATE) { r = 0.f; cos_ang = 1.f; sin_ang = 0.f; } - if (mode & LLViewerTextureAnim::SCALE) + //if (mode & LLViewerTextureAnim::SCALE) { ms = mt = 1.f; } diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp index 3c296615f6..22617a7fcc 100644 --- a/indra/newview/llfloateranimpreview.cpp +++ b/indra/newview/llfloateranimpreview.cpp @@ -390,7 +390,7 @@ BOOL LLFloaterAnimPreview::handleMouseDown(S32 x, S32 y, MASK mask) if (mPreviewRect.pointInRect(x, y)) { bringToFront( x, y ); - gViewerWindow->setMouseCapture(this, onMouseCaptureLost); + gViewerWindow->setMouseCapture(this); gViewerWindow->hideCursor(); mLastMouseX = x; mLastMouseY = y; @@ -405,7 +405,7 @@ BOOL LLFloaterAnimPreview::handleMouseDown(S32 x, S32 y, MASK mask) //----------------------------------------------------------------------------- BOOL LLFloaterAnimPreview::handleMouseUp(S32 x, S32 y, MASK mask) { - gViewerWindow->setMouseCapture(FALSE, NULL); + gViewerWindow->setMouseCapture(FALSE); gViewerWindow->showCursor(); return LLFloater::handleMouseUp(x, y, mask); } @@ -417,7 +417,7 @@ BOOL LLFloaterAnimPreview::handleHover(S32 x, S32 y, MASK mask) { MASK local_mask = mask & ~MASK_ALT; - if (mAnimPreview && gViewerWindow->hasMouseCapture(this)) + if (mAnimPreview && hasMouseCapture()) { if (local_mask == MASK_PAN) { @@ -479,7 +479,7 @@ BOOL LLFloaterAnimPreview::handleScrollWheel(S32 x, S32 y, S32 clicks) //----------------------------------------------------------------------------- // onMouseCaptureLost() //----------------------------------------------------------------------------- -void LLFloaterAnimPreview::onMouseCaptureLost(LLMouseHandler* handler) +void LLFloaterAnimPreview::onMouseCaptureLost() { gViewerWindow->showCursor(); } diff --git a/indra/newview/llfloateranimpreview.h b/indra/newview/llfloateranimpreview.h index 40ec96f73d..858d586274 100644 --- a/indra/newview/llfloateranimpreview.h +++ b/indra/newview/llfloateranimpreview.h @@ -56,10 +56,10 @@ public: BOOL handleMouseUp(S32 x, S32 y, MASK mask); BOOL handleHover(S32 x, S32 y, MASK mask); BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); + void onMouseCaptureLost(); void refresh(); - static void onMouseCaptureLost(LLMouseHandler*); static void onBtnPlay(void*); static void onBtnStop(void*); static void setUploadAmount(S32 amount) { sUploadAmount = amount; } diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index de9432ee73..559b29379c 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -24,7 +24,7 @@ const S32 MIN_WIDTH = 200; const S32 MIN_HEIGHT = 340; const LLRect FLOATER_RECT(0, 380, 240, 0); -const char FLOATER_TITLE[] = "Choose Person"; +const char FLOATER_TITLE[] = "Choose Resident"; // static LLFloaterAvatarPicker* LLFloaterAvatarPicker::sInstance = NULL; @@ -89,9 +89,7 @@ BOOL LLFloaterAvatarPicker::postBuild() if (mListNames) { - LLScrollListItem* row = new LLScrollListItem( TRUE, NULL, LLUUID::null ); - row->addColumn("No results", LLFontGL::sSansSerif); - mListNames->addItem(row); + mListNames->addSimpleElement("No results"); } mInventoryPanel = (LLInventoryPanel*)this->getCtrlByNameAndType("Inventory Panel", WIDGET_TYPE_INVENTORY_PANEL); @@ -237,10 +235,7 @@ void LLFloaterAvatarPicker::find() if (mListNames) { mListNames->deleteAllItems(); - - LLScrollListItem* row = new LLScrollListItem( TRUE, NULL, LLUUID::null ); - row->addColumn("Searching...", LLFontGL::sSansSerif); - mListNames->addItem(row); + mListNames->addSimpleElement("Searching..."); } childSetEnabled("Select", FALSE); @@ -305,23 +300,20 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* msg->getStringFast(_PREHASH_Data,_PREHASH_FirstName, DB_FIRST_NAME_BUF_SIZE, first_name, i); msg->getStringFast(_PREHASH_Data,_PREHASH_LastName, DB_LAST_NAME_BUF_SIZE, last_name, i); - LLScrollListItem* row = new LLScrollListItem( TRUE, NULL, avatar_id ); - + LLString avatar_name; if (avatar_id.isNull()) { self->childSetTextArg("NotFound", "[TEXT]", self->childGetText("Edit")); - LLString msg = self->childGetValue("NotFound").asString(); - row->addColumn(msg, LLFontGL::sSansSerif); + avatar_name = self->childGetValue("NotFound").asString(); self->mListNames->setEnabled(FALSE); } else { - LLString buffer = LLString(first_name) + " " + last_name; - row->addColumn(buffer, LLFontGL::sSansSerif); + avatar_name = LLString(first_name) + " " + last_name; self->mListNames->setEnabled(TRUE); found_one = TRUE; } - self->mListNames->addItem(row); + self->mListNames->addSimpleElement(avatar_name); } if (found_one) diff --git a/indra/newview/llfloaterbump.cpp b/indra/newview/llfloaterbump.cpp index 969124a81c..68f002f9d9 100644 --- a/indra/newview/llfloaterbump.cpp +++ b/indra/newview/llfloaterbump.cpp @@ -63,9 +63,10 @@ void LLFloaterBump::show(void *contents) if (gMeanCollisionList.isEmpty()) { LLString none_detected = sInstance->childGetText("none_detected"); - LLScrollListItem *item = new LLScrollListItem(); - item->addColumn(none_detected, LLFontGL::sSansSerifBold); - list->addItem(item); + LLSD row; + row["columns"][0]["value"] = none_detected; + row["columns"][0]["font-style"] = "BOLD"; + list->addElement(row); } else { @@ -132,7 +133,9 @@ void LLFloaterBump::add(LLScrollListCtrl* list, LLMeanCollisionData* mcd) text.setArg("[FIRST]", mcd->mFirstName); text.setArg("[LAST]", mcd->mLastName); - LLScrollListItem *item = new LLScrollListItem(TRUE, NULL, mcd->mPerp); - item->addColumn(text, LLFontGL::sSansSerifBold); - list->addItem(item); + LLSD row; + row["id"] = mcd->mPerp; + row["columns"][0]["value"] = text; + row["columns"][0]["font-style"] = "BOLD"; + list->addElement(row); } diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index 03a94aed63..1ee8cd62ab 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -1261,14 +1261,12 @@ void LLFloaterBuyLandUI::refreshUI() } - //remove_contribution not in XML - ?! childSetValue("remove_contribution", LLSD(groupContributionEnough)); childSetEnabled("remove_contribution", groupContributionEnough); bool showRemoveContribution = mParcelIsGroupLand && (mParcelGroupContribution > 0); - childSetText("remove_contribution", - llformat("Remove %d square meters of contribution from group", - minContribution)); + childSetLabelArg("remove_contribution", "[AMOUNT]", + llformat("%d", minContribution)); childSetVisible("remove_contribution", showRemoveContribution); childShow("step_3"); diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index 144833a3f5..8af0dd410f 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -554,11 +554,10 @@ void LLFloaterColorPicker::onColorSelect( const LLTextureEntry& te, void *data ) } } -void LLFloaterColorPicker::onMouseCaptureLost(LLMouseHandler *old_captor) +void LLFloaterColorPicker::onMouseCaptureLost() { - LLFloaterColorPicker* self = (LLFloaterColorPicker*)old_captor; - self->setMouseDownInHueRegion(FALSE); - self->setMouseDownInLumRegion(FALSE); + setMouseDownInHueRegion(FALSE); + setMouseDownInLumRegion(FALSE); } ////////////////////////////////////////////////////////////////////////////// @@ -942,7 +941,7 @@ handleMouseDown ( S32 x, S32 y, MASK mask ) if ( rgbAreaRect.pointInRect ( x, y ) ) { - gViewerWindow->setMouseCapture(this, onMouseCaptureLost); + gViewerWindow->setMouseCapture(this); // mouse button down setMouseDownInHueRegion ( TRUE ); @@ -961,7 +960,7 @@ handleMouseDown ( S32 x, S32 y, MASK mask ) if ( lumAreaRect.pointInRect ( x, y ) ) { - gViewerWindow->setMouseCapture(this, onMouseCaptureLost); + gViewerWindow->setMouseCapture(this); // mouse button down setMouseDownInLumRegion ( TRUE ); @@ -1174,9 +1173,9 @@ handleMouseUp ( S32 x, S32 y, MASK mask ) // mouse button not down in color swatch anymore mMouseDownInSwatch = false; - if (gViewerWindow->hasMouseCapture(this)) + if (hasMouseCapture()) { - gViewerWindow->setMouseCapture(NULL, NULL); + gViewerWindow->setMouseCapture(NULL); } // dispatch to base class for the rest of things diff --git a/indra/newview/llfloatercolorpicker.h b/indra/newview/llfloatercolorpicker.h index aa406c0dec..7660aa8c2d 100644 --- a/indra/newview/llfloatercolorpicker.h +++ b/indra/newview/llfloatercolorpicker.h @@ -36,6 +36,7 @@ class LLFloaterColorPicker virtual BOOL handleMouseDown ( S32 x, S32 y, MASK mask ); virtual BOOL handleMouseUp ( S32 x, S32 y, MASK mask ); virtual BOOL handleHover ( S32 x, S32 y, MASK mask ); + virtual void onMouseCaptureLost(); virtual void onClose(bool app_quitting); // implicit methods @@ -94,7 +95,6 @@ class LLFloaterColorPicker F32 hueToRgb ( F32 val1In, F32 val2In, F32 valHUeIn ); void setActive(BOOL active); - static void onMouseCaptureLost(LLMouseHandler* old_captor); protected: // callbacks diff --git a/indra/newview/llfloatergodtools.cpp b/indra/newview/llfloatergodtools.cpp index 3b7a868472..6065fc92c9 100644 --- a/indra/newview/llfloatergodtools.cpp +++ b/indra/newview/llfloatergodtools.cpp @@ -1325,11 +1325,10 @@ void LLPanelRequestTools::refresh() list->operateOnAll(LLCtrlListInterface::OP_DELETE); list->addSimpleElement(SELECTION); list->addSimpleElement(AGENT_REGION); - LLViewerRegion* regionp; - for(regionp = gWorldp->mActiveRegionList.getFirstData(); - regionp != NULL; - regionp = gWorldp->mActiveRegionList.getNextData()) + for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin(); + iter != gWorldp->mActiveRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; LLString name = regionp->getName(); if (!name.empty()) { @@ -1387,11 +1386,10 @@ void LLPanelRequestTools::onClickRequest(void* data) else { // find region by name - LLViewerRegion* regionp; - for(regionp = gWorldp->mActiveRegionList.getFirstData(); - regionp != NULL; - regionp = gWorldp->mActiveRegionList.getNextData()) + for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin(); + iter != gWorldp->mActiveRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; if(dest == regionp->getName()) { // found it diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index 2e77bbcfbd..f10abc4466 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -356,7 +356,7 @@ BOOL LLFloaterImagePreview::handleMouseDown(S32 x, S32 y, MASK mask) if (mPreviewRect.pointInRect(x, y)) { bringToFront( x, y ); - gViewerWindow->setMouseCapture(this, onMouseCaptureLost); + gViewerWindow->setMouseCapture(this); gViewerWindow->hideCursor(); mLastMouseX = x; mLastMouseY = y; @@ -371,7 +371,7 @@ BOOL LLFloaterImagePreview::handleMouseDown(S32 x, S32 y, MASK mask) //----------------------------------------------------------------------------- BOOL LLFloaterImagePreview::handleMouseUp(S32 x, S32 y, MASK mask) { - gViewerWindow->setMouseCapture(FALSE, NULL); + gViewerWindow->setMouseCapture(FALSE); gViewerWindow->showCursor(); return LLFloater::handleMouseUp(x, y, mask); } @@ -383,7 +383,7 @@ BOOL LLFloaterImagePreview::handleHover(S32 x, S32 y, MASK mask) { MASK local_mask = mask & ~MASK_ALT; - if (mAvatarPreview && gViewerWindow->hasMouseCapture(this)) + if (mAvatarPreview && hasMouseCapture()) { if (local_mask == MASK_PAN) { diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 77ebe88a09..45570f6aa2 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -392,8 +392,8 @@ BOOL LLPanelLandGeneral::postBuild() mBtnDeedToGroup->setClickedCallback(onClickDeed, this); - mCheckContributeWithDeed = LLUICtrlFactory::getCheckBoxByName(this, "check contib"); - childSetCommitCallback("check contib", onCommitAny, this); + mCheckContributeWithDeed = LLUICtrlFactory::getCheckBoxByName(this, "check contrib"); + childSetCommitCallback("check contrib", onCommitAny, this); @@ -1865,7 +1865,7 @@ void LLPanelLandObjects::onClickReturnOtherObjects(void* userdata) } // static -void LLPanelLandObjects::onLostFocus(LLLineEditor *caller, void* user_data) +void LLPanelLandObjects::onLostFocus(LLUICtrl *caller, void* user_data) { LLPanelLandObjects *lop = (LLPanelLandObjects *)user_data; LLParcel* parcel = lop->mParcel->getParcel(); diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h index b1aad89d7d..cfd009c335 100644 --- a/indra/newview/llfloaterland.h +++ b/indra/newview/llfloaterland.h @@ -234,7 +234,7 @@ public: static void onDoubleClickOwner(void*); static void onCommitList(LLUICtrl* ctrl, void* data); - static void onLostFocus(LLLineEditor* caller, void* user_data); + static void onLostFocus(LLUICtrl* caller, void* user_data); static void processParcelObjectOwnersReply(LLMessageSystem *msg, void **); diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index ac77b3c3f0..92e005c0bb 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -504,7 +504,7 @@ void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) previewp->mSnapshotDelayTimer.hasExpired()); // don't take snapshots while ALT-zoom active - if (gFocusMgr.getMouseCapture() == gToolCamera) + if (gToolCamera->hasMouseCapture()) { previewp->mSnapshotActive = FALSE; } diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp index 63b1734642..0529507c35 100644 --- a/indra/newview/llfloatertools.cpp +++ b/indra/newview/llfloatertools.cpp @@ -928,7 +928,7 @@ void LLFloaterTools::setObjectType( void* data ) LLPCode pcode = *(LLPCode*) data; LLToolPlacer::setObjectType( pcode ); gSavedSettings.setBOOL("CreateToolCopySelection", FALSE); - gViewerWindow->setMouseCapture(NULL, NULL); + gViewerWindow->setMouseCapture(NULL); } // static diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index e9fa4cc1dd..31668b6d80 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -71,7 +71,7 @@ void copy_selected_item(void* user_data); void open_selected_items(void* user_data); void properties_selected_items(void* user_data); void paste_items(void* user_data); -void top_view_lost( LLView* handler ); +void renamer_focus_lost( LLUICtrl* handler, void* user_data ); ///---------------------------------------------------------------------------- /// Class LLFolderViewItem @@ -588,7 +588,7 @@ BOOL LLFolderViewItem::handleMouseDown( S32 x, S32 y, MASK mask ) { // No handler needed for focus lost since this class has no // state that depends on it. - gViewerWindow->setMouseCapture( this, NULL ); + gViewerWindow->setMouseCapture( this ); if (!mIsSelected) { @@ -623,7 +623,7 @@ BOOL LLFolderViewItem::handleMouseDown( S32 x, S32 y, MASK mask ) BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask ) { - if( gViewerWindow->hasMouseCapture( this ) && isMovable() ) + if( hasMouseCapture() && isMovable() ) { S32 screen_x; S32 screen_y; @@ -723,10 +723,10 @@ BOOL LLFolderViewItem::handleMouseUp( S32 x, S32 y, MASK mask ) mSelectPending = FALSE; - if( gViewerWindow->hasMouseCapture( this ) ) + if( hasMouseCapture() ) { getRoot()->setShowSelectionContext(FALSE); - gViewerWindow->setMouseCapture( NULL, NULL ); + gViewerWindow->setMouseCapture( NULL ); } return TRUE; } @@ -1226,7 +1226,7 @@ void LLFolderViewFolder::filter( LLInventoryFilter& filter) } // when applying a filter, matching folders get their contents downloaded first - if (getRoot()->isFilterActive() && getFiltered(filter.getMinRequiredGeneration()) && !gInventory.isCategoryComplete(mListener->getUUID())) + if (filter.isNotDefault() && getFiltered(filter.getMinRequiredGeneration()) && !gInventory.isCategoryComplete(mListener->getUUID())) { gInventory.startBackgroundFetch(mListener->getUUID()); } @@ -2596,9 +2596,9 @@ LLFolderView::~LLFolderView( void ) LLView::deleteViewByHandle(mPopupMenuHandle); - if(gViewerWindow->hasTopView(mRenamer)) + if(gViewerWindow->hasTopCtrl(mRenamer)) { - gViewerWindow->setTopView(NULL, NULL); + gViewerWindow->setTopCtrl(NULL); } mAutoOpenItems.removeAllNodes(); @@ -3175,7 +3175,7 @@ void LLFolderView::finishRenamingItem( void ) mRenamer->setFocus( FALSE ); mRenamer->setVisible( FALSE ); mRenamer->setCommitOnFocusLost( TRUE ); - gViewerWindow->setTopView( NULL, NULL ); + gViewerWindow->setTopCtrl( NULL ); if( mRenameItem ) { @@ -3193,7 +3193,7 @@ void LLFolderView::revertRenamingItem( void ) mRenamer->setFocus( FALSE ); mRenamer->setVisible( FALSE ); mRenamer->setCommitOnFocusLost( TRUE ); - gViewerWindow->setTopView( NULL, NULL ); + gViewerWindow->setTopCtrl( NULL ); if( mRenameItem ) { @@ -3591,7 +3591,8 @@ void LLFolderView::startRenamingSelectedItem( void ) mRenamer->setVisible( TRUE ); // set focus will fail unless item is visible mRenamer->setFocus( TRUE ); - gViewerWindow->setTopView( mRenamer, top_view_lost ); + mRenamer->setFocusLostCallback(renamer_focus_lost); + gViewerWindow->setTopCtrl( mRenamer ); } } @@ -3920,6 +3921,7 @@ void LLFolderView::onFocusLost( ) { gEditMenuHandler = NULL; } + LLUICtrl::onFocusLost(); } BOOL LLFolderView::search(LLFolderViewItem* first_item, const LLString &search_string, BOOL backward) @@ -4077,9 +4079,9 @@ BOOL LLFolderView::handleScrollWheel(S32 x, S32 y, S32 clicks) void LLFolderView::deleteAllChildren() { - if(gViewerWindow->hasTopView(mRenamer)) + if(gViewerWindow->hasTopCtrl(mRenamer)) { - gViewerWindow->setTopView(NULL, NULL); + gViewerWindow->setTopCtrl(NULL); } LLView::deleteViewByHandle(mPopupMenuHandle); mPopupMenuHandle = LLViewHandle::sDeadHandle; @@ -4219,7 +4221,7 @@ void LLFolderView::idle(void* user_data) self->mFilter.clearModified(); BOOL filter_modified_and_active = self->mCompletedFilterGeneration < self->mFilter.getCurrentGeneration() && - self->mFilter.isActive(); + self->mFilter.isNotDefault(); self->mNeedsAutoSelect = filter_modified_and_active && !(gFocusMgr.childHasKeyboardFocus(self) || gFocusMgr.getMouseCapture()); @@ -4288,6 +4290,12 @@ void LLFolderView::dumpSelectionInformation() bool sort_item_name(LLFolderViewItem* a, LLFolderViewItem* b) { + // Sort 'system' / unmovable folders to the top. + if (a->isMovable() != b->isMovable()) + { + return b->isMovable(); + } + S32 compare = LLString::compareDict(a->getLabel(), b->getLabel()); if (0 == compare) { @@ -4303,6 +4311,12 @@ bool sort_item_name(LLFolderViewItem* a, LLFolderViewItem* b) // of inventory items. bool sort_item_date(LLFolderViewItem* a, LLFolderViewItem* b) { + // Sort 'system' / unmovable folders to the top. + if (a->isMovable() != b->isMovable()) + { + return b->isMovable(); + } + U32 first_create = a->getCreationDate(); U32 second_create = b->getCreationDate(); if (first_create == second_create) @@ -4315,9 +4329,12 @@ bool sort_item_date(LLFolderViewItem* a, LLFolderViewItem* b) } } -void top_view_lost( LLView* view ) +void renamer_focus_lost( LLUICtrl* ctrl, void* userdata) { - if( view ) view->setVisible( FALSE ); + if( ctrl ) + { + ctrl->setVisible( FALSE ); + } } void delete_selected_item(void* user_data) @@ -4453,7 +4470,7 @@ std::string::size_type LLInventoryFilter::getStringMatchOffset() const } // has user modified default filter params? -BOOL LLInventoryFilter::isActive() +BOOL LLInventoryFilter::isNotDefault() { return mFilterOps.mFilterTypes != mDefaultFilterOps.mFilterTypes || mFilterSubString.size() @@ -4463,6 +4480,16 @@ BOOL LLInventoryFilter::isActive() || mFilterOps.mHoursAgo != mDefaultFilterOps.mHoursAgo; } +BOOL LLInventoryFilter::isActive() +{ + return mFilterOps.mFilterTypes != 0xffffffff + || mFilterSubString.size() + || mFilterOps.mPermissions != PERM_NONE + || mFilterOps.mMinDate != 0 + || mFilterOps.mMaxDate != U32_MAX + || mFilterOps.mHoursAgo != 0; +} + BOOL LLInventoryFilter::isModified() { return mModified; @@ -4672,7 +4699,7 @@ void LLInventoryFilter::setModified(EFilterBehavior behavior) mFilterBehavior = FILTER_RESTART; } - if (isActive()) + if (isNotDefault()) { // if not keeping current filter results, update last valid as well switch(mFilterBehavior) diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index 84dcddedbb..76784f1ac9 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -191,6 +191,7 @@ public: BOOL check(LLFolderViewItem* item); std::string::size_type getStringMatchOffset() const; BOOL isActive(); + BOOL isNotDefault(); BOOL isModified(); BOOL isModifiedAndClear(); BOOL isSinceLogoff(); @@ -678,7 +679,7 @@ public: PermissionMask getFilterPermissions() const { return mFilter.getFilterPermissions(); } LLInventoryFilter::EFolderShow getShowFolderState() { return mFilter.getShowFolderState(); } U32 getSortOrder() const; - BOOL isFilterActive() { return mFilter.isActive(); } + BOOL isFilterModified() { return mFilter.isNotDefault(); } BOOL getAllowMultiSelect() { return mAllowMultiSelect; } // Close all folders in the view diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index 83c08ec602..9ab9a3f6bb 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -570,7 +570,7 @@ void LLFloaterIMPanel::onInputEditorFocusReceived( LLUICtrl* caller, void* userd } // static -void LLFloaterIMPanel::onInputEditorFocusLost(LLLineEditor* caller, void* userdata) +void LLFloaterIMPanel::onInputEditorFocusLost(LLUICtrl* caller, void* userdata) { LLFloaterIMPanel* self = (LLFloaterIMPanel*) userdata; self->setTyping(FALSE); diff --git a/indra/newview/llimpanel.h b/indra/newview/llimpanel.h index d54ac794b7..21a0cbcd41 100644 --- a/indra/newview/llimpanel.h +++ b/indra/newview/llimpanel.h @@ -59,7 +59,7 @@ public: LLString& tooltip_msg); static void onInputEditorFocusReceived( LLUICtrl* caller, void* userdata ); - static void onInputEditorFocusLost(LLLineEditor* caller, void* userdata); + static void onInputEditorFocusLost(LLUICtrl* caller, void* userdata); static void onInputEditorKeystroke(LLLineEditor* caller, void* userdata); static void onTabClick( void* userdata ); diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index a9b5e6e124..ce6c85d3fd 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -115,7 +115,7 @@ BOOL LLJoystick::handleMouseUp(S32 x, S32 y, MASK mask) { // llinfos << "joystick mouse up " << x << ", " << y << llendl; - if( gViewerWindow->hasMouseCapture( this ) ) + if( hasMouseCapture() ) { mLastMouse.set(x, y); mHeldDown = FALSE; @@ -128,7 +128,7 @@ BOOL LLJoystick::handleMouseUp(S32 x, S32 y, MASK mask) BOOL LLJoystick::handleHover(S32 x, S32 y, MASK mask) { - if( gViewerWindow->hasMouseCapture( this ) ) + if( hasMouseCapture() ) { mLastMouse.set(x, y); } @@ -153,7 +153,9 @@ void LLJoystick::onHeldDown(void *userdata) { LLJoystick *self = (LLJoystick *)userdata; - llassert( gViewerWindow->hasMouseCapture( self ) ); + // somebody removed this function without checking the + // build. Removed 2007-03-26. + //llassert( gViewerWindow->hasMouseCapture( self ) ); self->mHeldDown = TRUE; self->onHeldDown(); diff --git a/indra/newview/llnameeditor.cpp b/indra/newview/llnameeditor.cpp index ade4cf3473..923cd99d21 100644 --- a/indra/newview/llnameeditor.cpp +++ b/indra/newview/llnameeditor.cpp @@ -30,7 +30,7 @@ LLNameEditor::LLNameEditor(const std::string& name, const LLRect& rect, S32 max_text_length, void (*commit_callback)(LLUICtrl* caller, void* user_data), void (*keystroke_callback)(LLLineEditor* caller, void* user_data), - void (*focus_lost_callback)(LLLineEditor* caller, void* user_data), + void (*focus_lost_callback)(LLUICtrl* caller, void* user_data), void* userdata, LLLinePrevalidateFunc prevalidate_func, LLViewBorder::EBevel border_bevel, diff --git a/indra/newview/llnameeditor.h b/indra/newview/llnameeditor.h index b5e811fba4..b6ea2e7728 100644 --- a/indra/newview/llnameeditor.h +++ b/indra/newview/llnameeditor.h @@ -30,7 +30,7 @@ public: S32 max_text_length = 254, void (*commit_callback)(LLUICtrl* caller, void* user_data) = NULL, void (*keystroke_callback)(LLLineEditor* caller, void* user_data) = NULL, - void (*focus_lost_callback)(LLLineEditor* caller, void* user_data) = NULL, + void (*focus_lost_callback)(LLUICtrl* caller, void* user_data) = NULL, void* userdata = NULL, LLLinePrevalidateFunc prevalidate_func = NULL, LLViewBorder::EBevel border_bevel = LLViewBorder::BEVEL_IN, diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp index ddf88c94df..eabb9e0b23 100644 --- a/indra/newview/llnamelistctrl.cpp +++ b/indra/newview/llnamelistctrl.cpp @@ -158,6 +158,13 @@ BOOL LLNameListCtrl::addNameItem(LLScrollListItem* item, EAddPosition pos) addItem(item, pos); + // this column is resizable + LLScrollListColumn* columnp = getColumn(mNameColumnIndex); + if (columnp && columnp->mHeader) + { + columnp->mHeader->setHasResizableElement(TRUE); + } + return result; } @@ -178,6 +185,15 @@ LLScrollListItem* LLNameListCtrl::addElement(const LLSD& value, EAddPosition pos LLScrollListCell* cell = (LLScrollListCell*)item->getColumn(mNameColumnIndex); ((LLScrollListText*)cell)->setText( fullname ); + updateMaxContentWidth(item); + + // this column is resizable + LLScrollListColumn* columnp = getColumn(mNameColumnIndex); + if (columnp && columnp->mHeader) + { + columnp->mHeader->setHasResizableElement(TRUE); + } + return item; } @@ -222,6 +238,7 @@ void LLNameListCtrl::refresh(const LLUUID& id, const char* first, cell = (LLScrollListCell*)item->getColumn(mNameColumnIndex); ((LLScrollListText*)cell)->setText( fullname ); + updateMaxContentWidth(item); } } } @@ -299,13 +316,6 @@ LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto node->getAttributeS32("heading_height", heading_height); name_list->setHeadingHeight(heading_height); } - if (node->hasAttribute("heading_font")) - { - LLString heading_font(""); - node->getAttributeString("heading_font", heading_font); - LLFontGL* gl_font = LLFontGL::fontFromName(heading_font.c_str()); - name_list->setHeadingFont(gl_font); - } name_list->setCollapseEmptyColumns(collapse_empty_columns); BOOL allow_calling_card_drop = FALSE; @@ -344,8 +354,12 @@ LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto columns[index]["width"] = columnwidth; } + LLFontGL::HAlign h_align = LLFontGL::LEFT; + h_align = LLView::selectFontHAlign(child); + columns[index]["name"] = columnname; columns[index]["label"] = labelname; + columns[index]["halign"] = (S32)h_align; index++; } } diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index b03996d460..1050070f81 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -255,12 +255,10 @@ void LLNetMap::draw() // figure out where agent is S32 region_width = llround(gWorldPointer->getRegionWidthInMeters()); - LLViewerRegion *regionp; - - for (regionp = gWorldPointer->mActiveRegionList.getFirstData(); - regionp; - regionp = gWorldPointer->mActiveRegionList.getNextData()) + for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin(); + iter != gWorldp->mActiveRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; // Find x and y position relative to camera's center. LLVector3 origin_agent = regionp->getOriginAgent(); LLVector3 rel_region_pos = origin_agent - gAgent.getCameraPositionAgent(); @@ -374,10 +372,10 @@ void LLNetMap::draw() LLVector3 pos_map; // Draw avatars - for (regionp = gWorldPointer->mActiveRegionList.getFirstData(); - regionp; - regionp = gWorldPointer->mActiveRegionList.getNextData()) + for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin(); + iter != gWorldp->mActiveRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; const LLVector3d& origin_global = regionp->getOriginGlobal(); S32 count = regionp->mMapAvatars.count(); diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index ce9f6b18b2..05bd59593d 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -59,7 +59,7 @@ #include "llvieweruictrlfactory.h" // Statics -LLLinkedList<LLPanelAvatar> LLPanelAvatar::sAllPanels; +std::list<LLPanelAvatar*> LLPanelAvatar::sAllPanels; BOOL LLPanelAvatar::sAllowFirstLife = FALSE; //----------------------------------------------------------------------------- @@ -1220,7 +1220,7 @@ LLPanelAvatar::LLPanelAvatar( mDisableRate(FALSE) { - sAllPanels.addData(this); + sAllPanels.push_back(this); LLCallbackMap::map_t factory_map; @@ -1272,7 +1272,7 @@ BOOL LLPanelAvatar::postBuild(void) LLPanelAvatar::~LLPanelAvatar() { - sAllPanels.removeData(this); + sAllPanels.remove(this); } @@ -1503,7 +1503,6 @@ void LLPanelAvatar::resetGroupList() if (mPanelSecondLife && group_list) { group_list->deleteAllItems(); - LLScrollListItem* item; S32 count = gAgent.mGroups.count(); LLUUID id; @@ -1525,9 +1524,12 @@ void LLPanelAvatar::resetGroupList() */ group_string += group_data.mName; - item = new LLScrollListItem(TRUE, NULL, id); - item->addColumn(group_string, LLFontGL::sSansSerifSmall, 0, LLFontGL::NORMAL); - group_list->addItem(item); + + LLSD row; + row["columns"][0]["value"] = group_string; + row["columns"][0]["font"] = "SANSSERIF_SMALL"; + row["columns"][0]["width"] = 0; + group_list->addElement(row); } group_list->sortByColumn(0, TRUE); } @@ -1728,8 +1730,6 @@ void LLPanelAvatar::sendAvatarNotesUpdate() // static void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) { - LLPanelAvatar* self = NULL; - LLUUID agent_id; // your id LLUUID avatar_id; // target of this panel LLUUID image_id; @@ -1753,8 +1753,9 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id); msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AvatarID, avatar_id ); - for (self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) + for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter) { + LLPanelAvatar* self = *iter; if (self->mAvatarID != avatar_id) { continue; @@ -1876,8 +1877,6 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) // static void LLPanelAvatar::processAvatarInterestsReply(LLMessageSystem *msg, void**) { - LLPanelAvatar* self = NULL; - LLUUID agent_id; // your id LLUUID avatar_id; // target of this panel @@ -1892,8 +1891,9 @@ void LLPanelAvatar::processAvatarInterestsReply(LLMessageSystem *msg, void**) msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id); msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AvatarID, avatar_id ); - for (self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) + for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter) { + LLPanelAvatar* self = *iter; if (self->mAvatarID != avatar_id) { continue; @@ -1921,15 +1921,15 @@ void LLPanelAvatar::processAvatarGroupsReply(LLMessageSystem *msg, void**) LLUUID group_id; char group_name[DB_GROUP_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ LLUUID group_insignia_id; - const LLFontGL* FONT = LLFontGL::sSansSerifSmall; llinfos << "groups packet size " << msg->getReceiveSize() << llendl; msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id); msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AvatarID, avatar_id ); - for (LLPanelAvatar* self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) + for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter) { + LLPanelAvatar* self = *iter; if (self->mAvatarID != avatar_id) { continue; @@ -1977,9 +1977,15 @@ void LLPanelAvatar::processAvatarGroupsReply(LLMessageSystem *msg, void**) group_list->deleteSingleItem(index); } } - LLScrollListItem *group_item = new LLScrollListItem(TRUE, NULL, group_id); - group_item->addColumn(group_string, FONT); - if(group_list) group_list->addItem(group_item); + + LLSD row; + row["id"] = group_id; + row["columns"][0]["value"] = group_string; + row["columns"][0]["font"] = "SANSSERIF_SMALL"; + if (group_list) + { + group_list->addElement(row); + } } } if(group_list) group_list->sortByColumn(0, TRUE); @@ -2107,10 +2113,9 @@ void LLPanelAvatar::processAvatarStatisticsReply(LLMessageSystem *msg, void**) msg->getUUIDFast(_PREHASH_AvatarData, _PREHASH_AvatarID, avatar_id); // look up all panels which have this avatar - LLPanelAvatar *self = NULL; - - for (self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) + for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter) { + LLPanelAvatar* self = *iter; if (self->mAvatarID != avatar_id) { continue; @@ -2126,8 +2131,6 @@ void LLPanelAvatar::processAvatarStatisticsReply(LLMessageSystem *msg, void**) ratings_list->deleteAllItems(); } // build the item list - LLFontGL *font = LLFontGL::sSansSerifSmall; - S32 items = msg->getNumberOfBlocksFast(_PREHASH_StatisticsData); for (S32 i = 0; i < items; i++) { @@ -2141,18 +2144,22 @@ void LLPanelAvatar::processAvatarStatisticsReply(LLMessageSystem *msg, void**) msg->getS32( "StatisticsData", "Positive", positive, i); msg->getS32( "StatisticsData", "Negative", negative, i); - LLScrollListItem *item = NULL; - const S32 TEXT_WIDTH = 75; - item = new LLScrollListItem(); - item->addColumn( name, font, TEXT_WIDTH ); - - snprintf( value_string, sizeof(value_string), "+%d", positive); /* Flawfinder: ignore */ - item->addColumn( value_string, font, 50 ); - - item->addColumn("", font); // extra column to force striped appearance - if(ratings_list) ratings_list->addItem( item ); + LLSD row; + row["columns"][0]["value"] = name; + row["columns"][0]["font"] = "SANSSERIF_SMALL"; + row["columns"][0]["width"] = TEXT_WIDTH; + row["columns"][1]["value"] = value_string; + row["columns"][1]["font"] = "SANSSERIF_SMALL"; + row["columns"][1]["width"] = 50; + row["columns"][2]["value"] = ""; + row["columns"][2]["font"] = "SANSSERIF_SMALL"; + + if(ratings_list) + { + ratings_list->addElement( row ); + } } } } @@ -2168,10 +2175,9 @@ void LLPanelAvatar::processAvatarNotesReply(LLMessageSystem *msg, void**) msg->getUUID("Data", "TargetID", target_id); // look up all panels which have this avatar - LLPanelAvatar *self = NULL; - - for (self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) + for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter) { + LLPanelAvatar* self = *iter; if (self->mAvatarID != target_id) { continue; @@ -2187,7 +2193,6 @@ void LLPanelAvatar::processAvatarNotesReply(LLMessageSystem *msg, void**) void LLPanelAvatar::processAvatarClassifiedReply(LLMessageSystem *msg, void** userdata) { - LLPanelAvatar *self = NULL; LLUUID agent_id; LLUUID target_id; @@ -2195,8 +2200,9 @@ void LLPanelAvatar::processAvatarClassifiedReply(LLMessageSystem *msg, void** us msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_TargetID, target_id); // look up all panels which have this avatar target - for (self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) + for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter) { + LLPanelAvatar* self = *iter; if (self->mAvatarID != target_id) { continue; @@ -2208,7 +2214,6 @@ void LLPanelAvatar::processAvatarClassifiedReply(LLMessageSystem *msg, void** us void LLPanelAvatar::processAvatarPicksReply(LLMessageSystem *msg, void** userdata) { - LLPanelAvatar *self = NULL; LLUUID agent_id; LLUUID target_id; @@ -2216,8 +2221,9 @@ void LLPanelAvatar::processAvatarPicksReply(LLMessageSystem *msg, void** userdat msg->getUUID("AgentData", "TargetID", target_id); // look up all panels which have this avatar target - for (self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) + for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter) { + LLPanelAvatar* self = *iter; if (self->mAvatarID != target_id) { continue; diff --git a/indra/newview/llpanelavatar.h b/indra/newview/llpanelavatar.h index 9b1f6e23e1..be6feebc30 100644 --- a/indra/newview/llpanelavatar.h +++ b/indra/newview/llpanelavatar.h @@ -339,7 +339,8 @@ protected: BOOL mAllowEdit; BOOL mDisableRate; - static LLLinkedList<LLPanelAvatar> sAllPanels; + typedef std::list<LLPanelAvatar*> panel_list_t; + static panel_list_t sAllPanels; }; // helper funcs diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index f1aed81df1..5c5e0479d4 100644 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -72,7 +72,7 @@ public: static LLDispatchClassifiedClickThrough sClassifiedClickThrough; //static -LLLinkedList<LLPanelClassified> LLPanelClassified::sAllPanels; +std::list<LLPanelClassified*> LLPanelClassified::sAllPanels; LLPanelClassified::LLPanelClassified(BOOL in_finder) : LLPanel("Classified Panel"), @@ -99,7 +99,7 @@ LLPanelClassified::LLPanelClassified(BOOL in_finder) mSetBtn(NULL), mClickThroughText(NULL) { - sAllPanels.addData(this); + sAllPanels.push_back(this); std::string classified_def_file; if (mInFinder) @@ -119,7 +119,7 @@ LLPanelClassified::LLPanelClassified(BOOL in_finder) LLPanelClassified::~LLPanelClassified() { - sAllPanels.removeData(this); + sAllPanels.remove(this); } @@ -300,9 +300,9 @@ void LLPanelClassified::setClickThrough(const LLUUID& classified_id, S32 map, S32 profile) { - LLPanelClassified *self = NULL; - for (self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) - { + for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter) + { + LLPanelClassified* self = *iter; // For top picks, must match pick id if (self->mClassifiedID != classified_id) { @@ -483,9 +483,9 @@ void LLPanelClassified::processClassifiedInfoReply(LLMessageSystem *msg, void ** msg->getS32("Data", "PriceForListing", price_for_listing); // Look up the panel to fill in - LLPanelClassified *self = NULL; - for (self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) - { + for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter) + { + LLPanelClassified* self = *iter; // For top picks, must match pick id if (self->mClassifiedID != classified_id) { diff --git a/indra/newview/llpanelclassified.h b/indra/newview/llpanelclassified.h index 6d5be1df09..c959c0f82f 100644 --- a/indra/newview/llpanelclassified.h +++ b/indra/newview/llpanelclassified.h @@ -123,7 +123,8 @@ protected: LLTextBox* mClickThroughText; LLRect mSnapshotSize; - static LLLinkedList<LLPanelClassified> sAllPanels; + typedef std::list<LLPanelClassified*> panel_list_t; + static panel_list_t sAllPanels; }; diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp index 56c97d0689..9d40357544 100644 --- a/indra/newview/llpanelgroupgeneral.cpp +++ b/indra/newview/llpanelgroupgeneral.cpp @@ -683,12 +683,14 @@ void LLPanelGroupGeneral::update(LLGroupChange gc) } else { - LLScrollListItem* row = new LLScrollListItem( TRUE, NULL, LLUUID::null ); std::stringstream pending; pending << "Retrieving member list (" << gdatap->mMembers.size() << "\\" << gdatap->mMemberCount << ")"; - row->addColumn(pending.str(), LLFontGL::sSansSerif); + + LLSD row; + row["columns"][0]["value"] = pending.str(); + mListVisibleMembers->setEnabled(FALSE); - mListVisibleMembers->addItem(row); + mListVisibleMembers->addElement(row); } } } diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index 231551a756..12ac66e9fb 100644 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -99,11 +99,11 @@ void LLPanelGroupInvite::impl::addUsers(const std::vector<std::string>& names, } //add the name to the names list - const BOOL enabled = TRUE; - LLScrollListItem* row = new LLScrollListItem( - enabled, NULL, id); - row->addColumn(name.c_str(), LLFontGL::sSansSerif); - mInvitees->addItem(row); + LLSD row; + row["id"] = id; + row["columns"][0]["value"] = name; + + mInvitees->addElement(row); } } diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp index c60a69eb21..a05f7c54c6 100644 --- a/indra/newview/llpanelpick.cpp +++ b/indra/newview/llpanelpick.cpp @@ -36,7 +36,7 @@ #include "llviewerwindow.h" //static -LLLinkedList<LLPanelPick> LLPanelPick::sAllPanels; +std::list<LLPanelPick*> LLPanelPick::sAllPanels; LLPanelPick::LLPanelPick(BOOL top_pick) : LLPanel("Top Picks Panel"), @@ -59,7 +59,7 @@ LLPanelPick::LLPanelPick(BOOL top_pick) mEnabledCheck(NULL), mSetBtn(NULL) { - sAllPanels.addData(this); + sAllPanels.push_back(this); std::string pick_def_file; if (top_pick) @@ -75,7 +75,7 @@ LLPanelPick::LLPanelPick(BOOL top_pick) LLPanelPick::~LLPanelPick() { - sAllPanels.removeData(this); + sAllPanels.remove(this); } @@ -315,9 +315,9 @@ void LLPanelPick::processPickInfoReply(LLMessageSystem *msg, void **) msg->getBOOL("Data", "Enabled", enabled); // Look up the panel to fill in - LLPanelPick *self = NULL; - for (self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) - { + for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter) + { + LLPanelPick* self = *iter; // For top picks, must match pick id if (self->mPickID != pick_id) { diff --git a/indra/newview/llpanelpick.h b/indra/newview/llpanelpick.h index bdc7ef1f3e..a347133be6 100644 --- a/indra/newview/llpanelpick.h +++ b/indra/newview/llpanelpick.h @@ -93,7 +93,8 @@ protected: LLCheckBoxCtrl* mEnabledCheck; LLButton* mSetBtn; - static LLLinkedList<LLPanelPick> sAllPanels; + typedef std::list<LLPanelPick*> panel_list_t; + static panel_list_t sAllPanels; }; #endif // LL_LLPANELPICK_H diff --git a/indra/newview/llpanelplace.cpp b/indra/newview/llpanelplace.cpp index 905cc61560..d9c29fccdf 100644 --- a/indra/newview/llpanelplace.cpp +++ b/indra/newview/llpanelplace.cpp @@ -32,7 +32,7 @@ #include "llweb.h" //static -LLLinkedList<LLPanelPlace> LLPanelPlace::sAllPanels; +std::list<LLPanelPlace*> LLPanelPlace::sAllPanels; LLPanelPlace::LLPanelPlace() : LLPanel("Places Panel"), @@ -40,13 +40,13 @@ LLPanelPlace::LLPanelPlace() mPosGlobal(), mAuctionID(0) { - sAllPanels.addData(this); + sAllPanels.push_back(this); } LLPanelPlace::~LLPanelPlace() { - sAllPanels.removeData(this); + sAllPanels.remove(this); } @@ -139,10 +139,9 @@ void LLPanelPlace::processParcelInfoReply(LLMessageSystem *msg, void **) msg->getUUID("Data", "ParcelID", parcel_id); // look up all panels which have this avatar - LLPanelPlace *self = NULL; - - for (self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) + for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter) { + LLPanelPlace* self = *iter; if (self->mParcelID != parcel_id) { continue; diff --git a/indra/newview/llpanelplace.h b/indra/newview/llpanelplace.h index b45aef3e87..49dc518cc7 100644 --- a/indra/newview/llpanelplace.h +++ b/indra/newview/llpanelplace.h @@ -64,7 +64,8 @@ protected: //LLButton* mLandmarkBtn; LLButton* mAuctionBtn; - static LLLinkedList<LLPanelPlace> sAllPanels; + typedef std::list<LLPanelPlace*> panel_list_t; + static panel_list_t sAllPanels; }; #endif // LL_LLPANELPLACE_H diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp index 91df61ca91..52ce263e59 100644 --- a/indra/newview/llpreview.cpp +++ b/indra/newview/llpreview.cpp @@ -309,7 +309,7 @@ BOOL LLPreview::handleMouseDown(S32 x, S32 y, MASK mask) // No handler needed for focus lost since this class has no // state that depends on it. bringToFront(x, y); - gFocusMgr.setMouseCapture(this, NULL); + gFocusMgr.setMouseCapture(this); S32 screen_x; S32 screen_y; localPointToScreen(x, y, &screen_x, &screen_y ); @@ -321,9 +321,9 @@ BOOL LLPreview::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLPreview::handleMouseUp(S32 x, S32 y, MASK mask) { - if(gFocusMgr.getMouseCapture() == this) + if(hasMouseCapture()) { - gFocusMgr.setMouseCapture(NULL, NULL); + gFocusMgr.setMouseCapture(NULL); return TRUE; } return LLFloater::handleMouseUp(x, y, mask); @@ -331,7 +331,7 @@ BOOL LLPreview::handleMouseUp(S32 x, S32 y, MASK mask) BOOL LLPreview::handleHover(S32 x, S32 y, MASK mask) { - if(gFocusMgr.getMouseCapture() == this) + if(hasMouseCapture()) { S32 screen_x; S32 screen_y; diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index 6a6b07425f..39e32c31f5 100644 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -1023,11 +1023,11 @@ void LLPreviewGesture::loadUIFromGesture(LLMultiGesture* gesture) if (!new_step) continue; // Create an enabled item with this step - LLScrollListItem* item = new LLScrollListItem(TRUE, new_step); - item->addColumn(new_step->getLabel(), LLFontGL::sSansSerifSmall); - - // Add item to bottom of list - mStepList->addItem(item, ADD_BOTTOM); + LLSD row; + row["columns"][0]["value"] = new_step->getLabel(); + row["columns"][0]["font"] = "SANSSERIF_SMALL"; + LLScrollListItem* item = mStepList->addElement(row); + item->setUserdata(new_step); } } @@ -1572,12 +1572,11 @@ LLScrollListItem* LLPreviewGesture::addStep(const std::string& library_text) } // Create an enabled item with this step - LLScrollListItem* step_item = new LLScrollListItem(TRUE, step); - std::string label = step->getLabel(); - step_item->addColumn(label, LLFontGL::sSansSerifSmall); - - // Add item to bottom of list - mStepList->addItem(step_item, ADD_BOTTOM); + LLSD row; + row["columns"][0]["value"] = step->getLabel(); + row["columns"][0]["font"] = "SANSSERIF_SMALL"; + LLScrollListItem* step_item = mStepList->addElement(row); + step_item->setUserdata(step); // And move selection to the list on the right mLibraryList->deselectAllItems(); diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 51ca007d75..97b4a982d2 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -859,15 +859,14 @@ void LLPreviewLSL::callbackLSLCompileFailed(const LLSD& compile_errors) { llinfos << "Compile failed!" << llendl; - const LLFontGL* err_font = gResMgr->getRes(LLFONT_OCRA); - LLScrollListItem* item = NULL; for(LLSD::array_const_iterator line = compile_errors.beginArray(); line < compile_errors.endArray(); line++) { - item = new LLScrollListItem(); - item->addColumn(line->asString(), err_font); - mScriptEd->mErrorList->addItem(item); + LLSD row; + row["columns"][0]["value"] = line->asString(); + row["columns"][0]["font"] = "OCRA"; + mScriptEd->mErrorList->addElement(row); } mScriptEd->selectFirstError(); closeIfNeeded(); @@ -992,9 +991,11 @@ void LLPreviewLSL::saveIfNeeded() if(!fp) { llwarns << "Unable to write to " << filename << llendl; - LLScrollListItem* item = new LLScrollListItem(); - item->addColumn("Error writing to local file. Is your hard drive full?", LLFontGL::sSansSerifSmall); - mScriptEd->mErrorList->addItem(item); + + LLSD row; + row["columns"][0]["value"] = "Error writing to local file. Is your hard drive full?"; + row["columns"][0]["font"] = "SANSSERIF_SMALL"; + mScriptEd->mErrorList->addElement(row); return; } @@ -1049,8 +1050,6 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, std::string dst_filename = llformat("%s.lso", filepath.c_str()); std::string err_filename = llformat("%s.out", filepath.c_str()); - LLScrollListItem* item = NULL; - const LLFontGL* err_font = gResMgr->getRes(LLFONT_OCRA); if(!lscript_compile(filename.c_str(), dst_filename.c_str(), err_filename.c_str(), @@ -1082,9 +1081,11 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, { line.assign(buffer); LLString::stripNonprintable(line); - item = new LLScrollListItem(); - item->addColumn(line, err_font); - mScriptEd->mErrorList->addItem(item); + + LLSD row; + row["columns"][0]["value"] = line; + row["columns"][0]["font"] = "OCRA"; + mScriptEd->mErrorList->addElement(row); } } fclose(fp); @@ -1176,9 +1177,10 @@ void LLPreviewLSL::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_d { if (self) { - LLScrollListItem* item = new LLScrollListItem(); - item->addColumn("Compile successful!", LLFontGL::sSansSerifSmall); - self->mScriptEd->mErrorList->addItem(item); + LLSD row; + row["columns"][0]["value"] = "Compile successful!"; + row["columns"][0]["font"] = "SANSSERIF_SMALL"; + self->mScriptEd->mErrorList->addElement(row); // Find our window and close it if requested. self->getWindow()->decBusyCount(); @@ -1399,15 +1401,14 @@ void LLLiveLSLEditor::callbackLSLCompileSucceeded(const LLUUID& task_id, void LLLiveLSLEditor::callbackLSLCompileFailed(const LLSD& compile_errors) { lldebugs << "Compile failed!" << llendl; - const LLFontGL* err_font = gResMgr->getRes(LLFONT_OCRA); - LLScrollListItem* item = NULL; for(LLSD::array_const_iterator line = compile_errors.beginArray(); line < compile_errors.endArray(); line++) { - item = new LLScrollListItem(); - item->addColumn(line->asString(), err_font); - mScriptEd->mErrorList->addItem(item); + LLSD row; + row["columns"][0]["value"] = line->asString(); + row["columns"][0]["font"] = "OCRA"; + mScriptEd->mErrorList->addElement(row); } mScriptEd->selectFirstError(); closeIfNeeded(); @@ -1769,9 +1770,11 @@ void LLLiveLSLEditor::saveIfNeeded() if(!fp) { llwarns << "Unable to write to " << filename << llendl; - LLScrollListItem* item = new LLScrollListItem(); - item->addColumn("Error writing to local file. Is your hard drive full?", LLFontGL::sSansSerifSmall); - mScriptEd->mErrorList->addItem(item); + + LLSD row; + row["columns"][0]["value"] = "Error writing to local file. Is your hard drive full?"; + row["columns"][0]["font"] = "SANSSERIF_SMALL"; + mScriptEd->mErrorList->addElement(row); return; } LLString utf8text = mScriptEd->mEditor->getText(); @@ -1829,8 +1832,6 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, std::string dst_filename = llformat("%s.lso", filepath.c_str()); std::string err_filename = llformat("%s.out", filepath.c_str()); - LLScrollListItem* item = NULL; - const LLFontGL* err_font = gResMgr->getRes(LLFONT_OCRA); FILE *fp; if(!lscript_compile(filename.c_str(), dst_filename.c_str(), @@ -1859,9 +1860,11 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, { line.assign(buffer); LLString::stripNonprintable(line); - item = new LLScrollListItem(); - item->addColumn(line, err_font); - mScriptEd->mErrorList->addItem(item); + + LLSD row; + row["columns"][0]["value"] = line; + row["columns"][0]["font"] = "OCRA"; + mScriptEd->mErrorList->addElement(row); } } fclose(fp); diff --git a/indra/newview/llprogressview.cpp b/indra/newview/llprogressview.cpp index 1172bd8cf0..3bfe913ab4 100644 --- a/indra/newview/llprogressview.cpp +++ b/indra/newview/llprogressview.cpp @@ -42,7 +42,7 @@ const S32 ANIMATION_FRAMES = 1; //13; // XUI:translate LLProgressView::LLProgressView(const std::string& name, const LLRect &rect) -: LLView(name, rect, TRUE) +: LLPanel(name, rect, FALSE) { mPercentDone = 0.f; mDrawBackground = TRUE; @@ -119,7 +119,7 @@ void LLProgressView::setVisible(BOOL visible) } else if (!getVisible() && visible) { - gFocusMgr.setTopView(this, NULL); + gFocusMgr.setTopCtrl(this); mFadeTimer.stop(); mProgressTimer.start(); LLView::setVisible(visible); @@ -183,7 +183,7 @@ void LLProgressView::draw() LLView::draw(); if (mFadeTimer.getElapsedTimeF32() > FADE_IN_TIME) { - gFocusMgr.removeTopViewWithoutCallback(this); + gFocusMgr.removeTopCtrlWithoutCallback(this); LLView::setVisible(FALSE); gStartImageGL = NULL; } diff --git a/indra/newview/llprogressview.h b/indra/newview/llprogressview.h index 474a431b09..455256a665 100644 --- a/indra/newview/llprogressview.h +++ b/indra/newview/llprogressview.h @@ -9,13 +9,13 @@ #ifndef LL_LLPROGRESSVIEW_H #define LL_LLPROGRESSVIEW_H -#include "llview.h" +#include "llpanel.h" #include "llframetimer.h" class LLImageRaw; class LLButton; -class LLProgressView : public LLView +class LLProgressView : public LLPanel { public: LLProgressView(const std::string& name, const LLRect& rect); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index c14b4461d6..a38bfc3600 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -133,8 +133,8 @@ struct LLDeRezInfo LLObjectSelection* get_null_object_selection() { - static LLObjectSelectionHandle null_ptr(new LLObjectSelection()); - return (LLObjectSelection*)null_ptr; + static LLObjectSelection null_selection; + return &null_selection;; } diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 98b4c4ef42..d8d9f1c5d6 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -140,11 +140,6 @@ void LLSpatialGroup::clearDrawMap() mDrawMap.clear(); } -BOOL LLSpatialGroup::safeToDelete() -{ - return gQuit || !isState(IN_QUEUE | ACTIVE_OCCLUSION | RESHADOW_QUEUE); -} - class LLRelightPainter : public LLSpatialGroup::OctreeTraveler { public: @@ -330,7 +325,6 @@ BOOL LLSpatialGroup::updateInGroup(LLDrawable *drawablep, BOOL immediate) unbound(); setState(OBJECT_DIRTY); setState(GEOM_DIRTY); - gPipeline.markRebuild(this); validate_drawable(drawablep); return TRUE; } @@ -351,13 +345,15 @@ BOOL LLSpatialGroup::addObject(LLDrawable *drawablep, BOOL add_all, BOOL from_oc drawablep->setSpatialGroup(this, 0); validate_drawable(drawablep); setState(OBJECT_DIRTY | GEOM_DIRTY); - gPipeline.markRebuild(this); mLastAddTime = gFrameTimeSeconds; if (drawablep->isSpatialBridge()) { mBridgeList.push_back((LLSpatialBridge*) drawablep); } - setState(IMAGE_DIRTY); + if (drawablep->getRadius() > 1.f) + { + setState(IMAGE_DIRTY); + } } return TRUE; @@ -560,7 +556,6 @@ BOOL LLSpatialGroup::removeObject(LLDrawable *drawablep, BOOL from_octree) { drawablep->setSpatialGroup(NULL, -1); setState(GEOM_DIRTY); - gPipeline.markRebuild(this); if (drawablep->isSpatialBridge()) { for (bridge_list_t::iterator i = mBridgeList.begin(); i != mBridgeList.end(); ++i) @@ -589,7 +584,6 @@ void LLSpatialGroup::shift(const LLVector3 &offset) mObjectExtents[0] += offset; mObjectExtents[1] += offset; - gPipeline.markRebuild(this); setState(GEOM_DIRTY | MATRIX_DIRTY | OCCLUSION_DIRTY); } @@ -1610,66 +1604,6 @@ BOOL earlyFail(LLCamera* camera, LLSpatialGroup* group) return TRUE; } -void LLSpatialPartition::processGeometry(LLCamera* camera) -{ - if (!mRenderByGroup || mBufferUsage == GL_STREAM_DRAW_ARB) - { - return; - } - - U32 process_count = 8; - - LLSpatialGroup* root = (LLSpatialGroup*) mOctree->getListener(0); - if (mUpdateQueue.empty()) - { - root->setState(LLSpatialGroup::IN_GEOMETRY_QUEUE); - mUpdateQueue.push(root); - } - - while (process_count > 0 && !mUpdateQueue.empty()) - { - process_count--; - LLPointer<LLSpatialGroup> group = mUpdateQueue.front(); - mUpdateQueue.pop(); - - group->clearState(LLSpatialGroup::IN_GEOMETRY_QUEUE); - - if (group->isDead()) - { - continue; - } - - //push children onto queue - for (U32 i = 0; i < group->mOctreeNode->getChildCount(); i++) - { - LLSpatialGroup* child = (LLSpatialGroup*) group->mOctreeNode->getChild(i)->getListener(0); - - if (!child->isState(LLSpatialGroup::IN_GEOMETRY_QUEUE)) - { - child->setState(LLSpatialGroup::IN_GEOMETRY_QUEUE); - mUpdateQueue.push(child); - } - } - - if (!group->isDead() && !group->isVisible()) - { - if (!group->isState(LLSpatialGroup::OBJECT_DIRTY) && - group->mBufferUsage != GL_STREAM_DRAW_ARB) - { - group->updateDistance(*camera); - for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i) - { - LLDrawable* drawablep = *i; - if (!drawablep->isDead()) - { - drawablep->updateDistance(*camera); - } - } - } - } - } -} - void LLSpatialPartition::markReimage(LLSpatialGroup* group) { if (mImageEnabled && group->isState(LLSpatialGroup::IMAGE_DIRTY)) @@ -1731,7 +1665,6 @@ void LLSpatialPartition::processImagery(LLCamera* camera) gPipeline.blurReflectionMap(gPipeline.mCubeBuffer, cube_map, res); group->mReflectionMap = cube_map; group->setState(LLSpatialGroup::GEOM_DIRTY); - gPipeline.markRebuild(group); } group->clearState(LLSpatialGroup::IMAGE_DIRTY); diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 6a795d4c6c..c65f4063bf 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -134,9 +134,8 @@ public: SKIP_FRUSTUM_CHECK = 0x00040000, OCCLUSION_DIRTY = 0x00080000, BELOW_WATER = 0x00100000, - IN_GEOMETRY_QUEUE = 0x00200000, - IN_IMAGE_QUEUE = 0x00400000, - IMAGE_DIRTY = 0x00800000, + IN_IMAGE_QUEUE = 0x00200000, + IMAGE_DIRTY = 0x00400000, } eSpatialState; typedef enum @@ -147,7 +146,6 @@ public: } eSetStateMode; LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part); - BOOL safeToDelete(); virtual ~LLSpatialGroup(); BOOL isDead() { return isState(DEAD); } @@ -265,7 +263,6 @@ public: S32 cull(LLCamera &camera, std::vector<LLDrawable *>* results = NULL, BOOL for_select = FALSE); // Cull on arbitrary frustum BOOL checkOcclusion(LLSpatialGroup* group, LLCamera* camera); void markReimage(LLSpatialGroup* group); - void processGeometry(LLCamera* camera); void processImagery(LLCamera* camera); void processOcclusion(LLCamera* camera); void buildOcclusion(); @@ -293,9 +290,6 @@ protected: typedef std::queue<LLPointer<LLSpatialGroup> > spatial_group_queue_t; spatial_group_queue_t mOcclusionQueue; - //things that need a terse update - spatial_group_queue_t mUpdateQueue; - //things that need an image update spatial_group_queue_t mImageQueue; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 92f39f265e..f315869437 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -214,7 +214,7 @@ void callback_choose_gender(S32 option, void* userdata); void init_start_screen(S32 location_id); void release_start_screen(); void process_connect_to_userserver(LLMessageSystem* msg, void**); - +void reset_login(); // // exported functionality @@ -854,7 +854,7 @@ BOOL idle_startup() args["[HOST_NAME]"] = host_name; gViewerWindow->alertXml("UnableToConnect", args, login_alert_done ); - gStartupState = STATE_LOGIN_SHOW; + reset_login(); return FALSE; } break; @@ -891,7 +891,7 @@ BOOL idle_startup() login_alert_status, NULL); // Back up to login screen - gStartupState = STATE_LOGIN_SHOW; + reset_login(); gViewerStats->incStat(LLViewerStats::ST_LOGIN_TIMEOUT_COUNT); } ms_sleep(1); @@ -907,7 +907,7 @@ BOOL idle_startup() gViewerWindow->alertXml("PleaseSelectServer", args, login_alert_done ); - gStartupState = STATE_LOGIN_SHOW; + reset_login(); return FALSE; } @@ -1055,7 +1055,7 @@ BOOL idle_startup() NULL); // Back up to login screen - gStartupState = STATE_LOGIN_SHOW; + reset_login(); gViewerStats->incStat(LLViewerStats::ST_LOGIN_TIMEOUT_COUNT); } else @@ -1601,7 +1601,7 @@ BOOL idle_startup() LLStringBase<char>::format_map_t args; args["[ERROR_MESSAGE]"] = emsg.str(); gViewerWindow->alertXml("ErrorMessage", args, login_alert_done); - gStartupState = STATE_LOGIN_SHOW; + reset_login(); gAutoLogin = FALSE; show_connect_box = TRUE; } @@ -1618,7 +1618,7 @@ BOOL idle_startup() LLStringBase<char>::format_map_t args; args["[ERROR_MESSAGE]"] = emsg.str(); gViewerWindow->alertXml("ErrorMessage", args, login_alert_done); - gStartupState = STATE_LOGIN_SHOW; + reset_login(); gAutoLogin = FALSE; show_connect_box = TRUE; } @@ -2767,7 +2767,7 @@ void on_userserver_name_resolved( BOOL success, const LLString& host_name, U32 i LLStringBase<char>::format_map_t args; args["[HOST_NAME]"] = host_name; gViewerWindow->alertXml("SetByHostFail", args, login_alert_done ); - gStartupState = STATE_LOGIN_SHOW; + reset_login(); } } @@ -2869,7 +2869,7 @@ void update_dialog_callback(S32 option, void *userdata) { app_force_quit(); // Bump them back to the login screen. - //gStartupState = STATE_LOGIN_SHOW; + //reset_login(); } else { @@ -2997,7 +2997,7 @@ void use_circuit_callback(void**, S32 result) llinfos << "Backing up to login screen!" << llendl; gViewerWindow->alertXml("LoginPacketNeverReceived", login_alert_status, NULL); - gStartupState = STATE_LOGIN_SHOW; + reset_login(); } else { @@ -3918,4 +3918,9 @@ bool LLStartUp::canGoFullscreen() return gStartupState >= STATE_WORLD_INIT; } +void reset_login() +{ + gStartupState = STATE_LOGIN_SHOW; + // do cleanup here of in-world UI? +} diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 39feb40109..c732394b4e 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -802,7 +802,7 @@ void LLFloaterTexturePicker::onSearchEdit(const LLString& search_string, void* u else if (picker->mInventoryPanel->getFilterSubString().empty()) { // first letter in search term, save existing folder open state - if (!picker->mInventoryPanel->getRootFolder()->isFilterActive()) + if (!picker->mInventoryPanel->getRootFolder()->isFilterModified()) { picker->mSavedFolderState.setApply(FALSE); picker->mInventoryPanel->getRootFolder()->applyFunctorRecursively(picker->mSavedFolderState); diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index a9f660a0f5..e8dc281c6f 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -379,10 +379,7 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher, { calcWorkPriority(); mType = host.isOk() ? LLImageBase::TYPE_AVATAR_BAKE : LLImageBase::TYPE_NORMAL; - if (host == LLHost::invalid) - { - mHost = gAgent.getRegionHost(); - } +// llinfos << "Create: " << mID << " mHost:" << host << " Discard=" << discard << llendl; if (!mFetcher->mDebugPause) { U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH; @@ -393,6 +390,10 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher, LLTextureFetchWorker::~LLTextureFetchWorker() { +// llinfos << "Destroy: " << mID +// << " Decoded=" << mDecodedDiscard +// << " Requested=" << mRequestedDiscard +// << " Desired=" << mDesiredDiscard << llendl; llassert_always(!haveWork()); lockWorkData(); if (mCacheReadHandle != LLTextureCache::nullHandle()) @@ -423,6 +424,7 @@ void LLTextureFetchWorker::clearPackets() U32 LLTextureFetchWorker::calcWorkPriority() { +// llassert_always(mImagePriority >= 0 && mImagePriority <= LLViewerImage::maxDecodePriority()); F32 priority_scale = (F32)LLWorkerThread::PRIORITY_LOWBITS / LLViewerImage::maxDecodePriority(); mWorkPriority = (U32)(mImagePriority * priority_scale); return mWorkPriority; @@ -455,8 +457,9 @@ void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size) mDesiredSize = size; prioritize = true; } - if (prioritize && mState == INIT) + if ((prioritize && mState == INIT) || mState == DONE) { + mState = INIT; U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH; setPriority(work_priority); } @@ -464,8 +467,9 @@ void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size) void LLTextureFetchWorker::setImagePriority(F32 priority) { +// llassert_always(priority >= 0 && priority <= LLViewerImage::maxDecodePriority()); F32 delta = fabs(priority - mImagePriority); - if (delta > (mImagePriority * .05f)) // 5% + if (delta > (mImagePriority * .05f) || mState == DONE) { mImagePriority = priority; calcWorkPriority(); @@ -530,7 +534,7 @@ bool LLTextureFetchWorker::doWork(S32 param) mBuffer = NULL; mBufferSize = 0; mHaveAllData = FALSE; - clearPackets(); + clearPackets(); // TODO: Shouldn't be necessary mCacheReadHandle = LLTextureCache::nullHandle(); mCacheWriteHandle = LLTextureCache::nullHandle(); mURL.clear(); @@ -893,7 +897,11 @@ bool LLTextureFetchWorker::doWork(S32 param) setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); return false; } - return true; + else + { + setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); + return true; + } } return false; @@ -956,18 +964,14 @@ bool LLTextureFetchWorker::deleteOK() } } - const F32 MAX_IDLE_TIME = 5.f; - if ((mFetchTimer.getElapsedTimeF32() < MAX_IDLE_TIME)) - { - delete_ok = false; - } - else if ((haveWork() && - // not ok to delete from these states - ((mState >= LOAD_FROM_HTTP_GET_URL && mState <= LOAD_FROM_HTTP_GET_DATA) || - (mState >= WRITE_TO_CACHE && mState <= WAIT_ON_WRITE)))) + if ((haveWork() && + // not ok to delete from these states + ((mState >= LOAD_FROM_HTTP_GET_URL && mState <= LOAD_FROM_HTTP_GET_DATA) || + (mState >= WRITE_TO_CACHE && mState <= WAIT_ON_WRITE)))) { delete_ok = false; } + return delete_ok; } @@ -1246,20 +1250,24 @@ LLTextureFetch::~LLTextureFetch() bool LLTextureFetch::createRequest(const LLUUID& id, const LLHost& host, F32 priority, S32 w, S32 h, S32 c, S32 discard, bool needs_aux) { + if (mDebugPause) + { + return false; + } + LLTextureFetchWorker* worker = NULL; LLMutexLock lock(&mQueueMutex); map_t::iterator iter = mRequestMap.find(id); if (iter != mRequestMap.end()) { worker = iter->second; - LLHost host2 = host; - if (host2 == LLHost::invalid) host2 = gAgent.getRegionHost(); - if (worker->mHost != host2) + if (worker->mHost != host) { -// llwarns << "LLTextureFetch::createRequest " << id << " called with multiple hosts: " -// << host << " != " << host2 << llendl; + llwarns << "LLTextureFetch::createRequest " << id << " called with multiple hosts: " + << host << " != " << worker->mHost << llendl; removeRequest(worker, true); worker = NULL; + return false; } } // If the requester knows the dimentions of the image, @@ -1284,6 +1292,11 @@ bool LLTextureFetch::createRequest(const LLUUID& id, const LLHost& host, F32 pri worker->setImagePriority(priority); worker->setDesiredDiscard(discard, desired_size); worker->unlockWorkData(); + if (!worker->haveWork()) + { + worker->mState = LLTextureFetchWorker::INIT; + worker->addWork(0, LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority); + } } else { @@ -1317,7 +1330,11 @@ void LLTextureFetch::addToNetworkQueue(LLTextureFetchWorker* worker) // i.e. a delete has not been requested mNetworkQueue.insert(worker->mID); } - mCancelQueue[worker->mHost].erase(worker->mID); + for (cancel_queue_t::iterator iter1 = mCancelQueue.begin(); + iter1 != mCancelQueue.end(); ++iter1) + { + iter1->second.erase(worker->mID); + } } // call lockQueue() first! @@ -1368,6 +1385,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, // Should only happen if we set mDebugPause... if (!mDebugPause) { +// llwarns << "Adding work for inactive worker: " << id << llendl; worker->addWork(0, LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority); } } @@ -1451,9 +1469,15 @@ void LLTextureFetch::sendRequestListToSimulators() typedef std::set<LLTextureFetchWorker*,LLTextureFetchWorker::Compare> request_list_t; typedef std::map< LLHost, request_list_t > work_request_map_t; work_request_map_t requests; - for (queue_t::iterator iter = mNetworkQueue.begin(); iter != mNetworkQueue.end(); ++iter) + for (queue_t::iterator iter = mNetworkQueue.begin(); iter != mNetworkQueue.end(); ) { - LLTextureFetchWorker* req = getWorker(*iter); + queue_t::iterator curiter = iter++; + LLTextureFetchWorker* req = getWorker(*curiter); + if (!req) + { + mNetworkQueue.erase(curiter); + continue; // paranoia + } if (req->mID == mDebugID) { mDebugCount++; // for setting breakpoints @@ -1492,7 +1516,11 @@ void LLTextureFetch::sendRequestListToSimulators() bool use_http = http_url.empty() ? false : true; LLHost host = iter1->first; // invalid host = use agent host - if (host != gAgent.getRegionHost()) + if (host == LLHost::invalid) + { + host = gAgent.getRegionHost(); + } + else { use_http = false; } @@ -1521,8 +1549,7 @@ void LLTextureFetch::sendRequestListToSimulators() gMessageSystem->addS8Fast(_PREHASH_DiscardLevel, (S8)req->mSimRequestedDiscard); gMessageSystem->addF32Fast(_PREHASH_DownloadPriority, req->mImagePriority); gMessageSystem->addU32Fast(_PREHASH_Packet, packet); - U8 type = host.isOk() ? LLImageBase::TYPE_AVATAR_BAKE : LLImageBase::TYPE_NORMAL; - gMessageSystem->addU8Fast(_PREHASH_Type, type); + gMessageSystem->addU8Fast(_PREHASH_Type, req->mType); // llinfos << "IMAGE REQUEST: " << req->mID << " Discard: " << req->mDesiredDiscard // << " Packet: " << packet << " Priority: " << req->mImagePriority << llendl; @@ -1555,6 +1582,10 @@ void LLTextureFetch::sendRequestListToSimulators() iter1 != mCancelQueue.end(); ++iter1) { LLHost host = iter1->first; + if (host == LLHost::invalid) + { + host = gAgent.getRegionHost(); + } S32 request_count = 0; for (queue_t::iterator iter2 = iter1->second.begin(); iter2 != iter1->second.end(); ++iter2) @@ -1624,12 +1655,11 @@ bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size) return true; } -bool LLTextureFetch::receiveImageHeader(const LLHost& host_in, const LLUUID& id, U8 codec, U16 packets, U32 totalbytes, +bool LLTextureFetch::receiveImageHeader(const LLHost& host, const LLUUID& id, U8 codec, U16 packets, U32 totalbytes, U16 data_size, U8* data) { LLMutexLock lock(&mQueueMutex); LLTextureFetchWorker* worker = getWorker(id); - LLHost host = (host_in == LLHost::invalid) ? gAgent.getRegionHost() : host_in; bool res = true; ++mPacketCount; @@ -1639,17 +1669,12 @@ bool LLTextureFetch::receiveImageHeader(const LLHost& host_in, const LLUUID& id, // llwarns << "Received header for non active worker: " << id << llendl; res = false; } - else if (host != worker->mHost) - { -// llwarns << "Received header from wrong host for: " << id << llendl; - res = false; - } else if (worker->mState != LLTextureFetchWorker::LOAD_FROM_NETWORK || worker->mSentRequest != LLTextureFetchWorker::SENT_SIM) { - llwarns << "receiveImageHeader for worker: " << id - << " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState] - << " sent: " << worker->mSentRequest << llendl; +// llwarns << "receiveImageHeader for worker: " << id +// << " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState] +// << " sent: " << worker->mSentRequest << llendl; res = false; } else if (worker->mLastPacket != -1) @@ -1685,11 +1710,10 @@ bool LLTextureFetch::receiveImageHeader(const LLHost& host_in, const LLUUID& id, return res; } -bool LLTextureFetch::receiveImagePacket(const LLHost& host_in, const LLUUID& id, U16 packet_num, U16 data_size, U8* data) +bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U16 packet_num, U16 data_size, U8* data) { LLMutexLock lock(&mQueueMutex); LLTextureFetchWorker* worker = getWorker(id); - LLHost host = (host_in == LLHost::invalid) ? gAgent.getRegionHost() : host_in; bool res = true; ++mPacketCount; @@ -1699,11 +1723,6 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host_in, const LLUUID& id, // llwarns << "Received packet " << packet_num << " for non active worker: " << id << llendl; res = false; } - else if (host != worker->mHost) - { -// llwarns << "Received packet from wrong host for: " << id << llendl; - res = false; - } else if (worker->mLastPacket == -1) { // llwarns << "Received packet " << packet_num << " before header for: " << id << llendl; @@ -1735,6 +1754,8 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host_in, const LLUUID& id, { // llwarns << "receiveImagePacket " << packet_num << "/" << worker->mLastPacket << " for worker: " << id // << " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState] << llendl; + removeFromNetworkQueue(worker); // failsafe + mCancelQueue[host].insert(id); } worker->unlockWorkData(); diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index b75e379755..683f8b56cf 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -129,21 +129,18 @@ void LLTextureBar::draw() } else if (mHilite) { - S32 idx = llclamp(mHilite,1,4); - if (idx==1) color = LLColor4::yellow; - else color = LLColor4::orange; - } - else if (mImagep->getBoostLevel()) - { - color = LLColor4::magenta; + S32 idx = llclamp(mHilite,1,3); + if (idx==1) color = LLColor4::orange; + else if (idx==2) color = LLColor4::yellow; + else color = LLColor4::pink2; } else if (mImagep->mDontDiscard) { - color = LLColor4::pink2; + color = LLColor4::green4; } - else if (!mImagep->getUseMipMaps()) + else if (mImagep->getBoostLevel()) { - color = LLColor4::green4; + color = LLColor4::magenta; } else if (mImagep->getDecodePriority() == 0.0f) { @@ -577,6 +574,9 @@ void LLTextureView::draw() { LLPointer<LLViewerImage> imagep = *iter++; + S32 cur_discard = imagep->getDiscardLevel(); + S32 desired_discard = imagep->mDesiredDiscardLevel; + if (mPrintList) { llinfos << imagep->getID() @@ -585,7 +585,7 @@ void LLTextureView::draw() << "\t" << imagep->getDecodePriority() << "\t" << imagep->getWidth() << "\t" << imagep->getHeight() - << "\t" << imagep->getDiscardLevel() + << "\t" << cur_discard << llendl; } @@ -614,7 +614,7 @@ void LLTextureView::draw() if (sDebugImages.find(imagep) != sDebugImages.end()) { - pri += 3*HIGH_PRIORITY; + pri += 4*HIGH_PRIORITY; } if (!mOrderFetch) @@ -629,14 +629,14 @@ void LLTextureView::draw() { if (imagep == objectp->getTEImage(te)) { - pri += 2*HIGH_PRIORITY; + pri += 3*HIGH_PRIORITY; break; } } } #endif #if 1 - if (pri < HIGH_PRIORITY) + if (pri < HIGH_PRIORITY && (cur_discard< 0 || desired_discard < cur_discard)) { LLViewerObject *objectp = gHoverView->getLastHoverObject(); if (objectp) @@ -653,15 +653,6 @@ void LLTextureView::draw() } } #endif -#if 0 - if (pri < HIGH_PRIORITY) - { - if (imagep->mBoostPriority) - { - pri += 4*HIGH_PRIORITY; - } - } -#endif #if 1 if (pri > 0.f && pri < HIGH_PRIORITY) { diff --git a/indra/newview/lltool.cpp b/indra/newview/lltool.cpp index 1053e4a569..b31a70e917 100644 --- a/indra/newview/lltool.cpp +++ b/indra/newview/lltool.cpp @@ -34,7 +34,7 @@ LLTool::LLTool( const LLString& name, LLToolComposite* composite ) : LLTool::~LLTool() { - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { llwarns << "Tool deleted holding mouse capture. Mouse capture removed." << llendl; gFocusMgr.removeMouseCaptureWithoutCallback( this ); @@ -113,12 +113,12 @@ void LLTool::setMouseCapture( BOOL b ) { if( b ) { - gViewerWindow->setMouseCapture(mComposite ? mComposite : this, &LLTool::onMouseCaptureLost ); + gViewerWindow->setMouseCapture(mComposite ? mComposite : this ); } else if( hasMouseCapture() ) { - gViewerWindow->setMouseCapture( NULL, NULL ); + gViewerWindow->setMouseCapture( NULL ); } } @@ -128,7 +128,7 @@ void LLTool::draw() BOOL LLTool::hasMouseCapture() { - return gViewerWindow->hasMouseCapture(mComposite ? mComposite : this); + return gFocusMgr.getMouseCapture() == (mComposite ? mComposite : this); } BOOL LLTool::handleKey(KEY key, MASK mask) @@ -144,17 +144,3 @@ LLTool* LLTool::getOverrideTool(MASK mask) } return NULL; } - -// static -void LLTool::onMouseCaptureLost( LLMouseHandler* old_captor ) -{ - LLTool* self = (LLTool*) old_captor; - if( self->mComposite ) - { - self->mComposite->onMouseCaptureLost(); - } - else - { - self->onMouseCaptureLost(); - } -} diff --git a/indra/newview/lltool.h b/indra/newview/lltool.h index d67a0d7d24..0cdeae6bd9 100644 --- a/indra/newview/lltool.h +++ b/indra/newview/lltool.h @@ -72,7 +72,6 @@ public: // Note: NOT virtual. Subclasses should call this version. void setMouseCapture(BOOL b); BOOL hasMouseCapture(); - static void onMouseCaptureLost(LLMouseHandler* old_captor); virtual void onMouseCaptureLost() {} // override this one as needed. protected: diff --git a/indra/newview/lltoolcomp.cpp b/indra/newview/lltoolcomp.cpp index 5d803b4c52..a1c51cfe44 100644 --- a/indra/newview/lltoolcomp.cpp +++ b/indra/newview/lltoolcomp.cpp @@ -736,6 +736,11 @@ BOOL LLToolCompGun::handleMouseUp(S32 x, S32 y, MASK mask) void LLToolCompGun::onMouseCaptureLost() { + if (mComposite) + { + mComposite->onMouseCaptureLost(); + return; + } mCur->onMouseCaptureLost(); // JC - I don't know if this is necessary. Maybe we could lose capture diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 1eb27f9165..b4aee4e2e1 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -859,7 +859,7 @@ void LLToolDragAndDrop::dragOrDrop( S32 x, S32 y, MASK mask, BOOL drop, BOOL handled = FALSE; - LLView* top_view = gViewerWindow->getTopView(); + LLView* top_view = gViewerWindow->getTopCtrl(); LLViewerInventoryItem* item; LLViewerInventoryCategory* cat; @@ -2308,7 +2308,7 @@ EAcceptance LLToolDragAndDrop::dad3dTextureObject( } if(!obj->permModify()) { - return ACCEPT_NO_LOCKED; + return ACCEPT_NO_LOCKED; } //If texture !copyable don't texture or you'll never get it back. if(!item->getPermissions().allowCopyBy(gAgent.getID())) diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 68d9ddbd54..f9511f72a5 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -44,6 +44,7 @@ LLToolPie *gToolPie = NULL; LLViewerObject* LLToolPie::sClickActionObject = NULL; LLHandle<LLObjectSelection> LLToolPie::sLeftClickSelection = NULL; +U8 LLToolPie::sClickAction = 0; extern void handle_buy(void*); @@ -145,17 +146,17 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show) // If it's a left-click, and we have a special action, do it. if (useClickAction(always_show, mask, object, parent)) { - U8 click_action = 0; + sClickAction = 0; if (object && object->getClickAction()) { - click_action = object->getClickAction(); + sClickAction = object->getClickAction(); } else if (parent && parent->getClickAction()) { - click_action = parent->getClickAction(); + sClickAction = parent->getClickAction(); } - switch(click_action) + switch(sClickAction) { case CLICK_ACTION_TOUCH: default: @@ -168,8 +169,9 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show) if (object && object->flagTakesMoney() || parent && parent->flagTakesMoney()) { - sClickActionObject = parent; - sLeftClickSelection = LLToolSelect::handleObjectSelection(parent, MASK_NONE, FALSE, TRUE); + // pay event goes to object actually clicked on + sClickActionObject = object; + sLeftClickSelection = LLToolSelect::handleObjectSelection(object, MASK_NONE, FALSE, TRUE); return TRUE; } break; @@ -398,13 +400,12 @@ void LLToolPie::selectionPropertiesReceived() if (!sLeftClickSelection->isEmpty()) { - LLViewerObject* root = sLeftClickSelection->getFirstRootObject(); + LLViewerObject* selected_object = sLeftClickSelection->getPrimaryObject(); // since we don't currently have a way to lock a selection, it could have changed // after we initially clicked on the object - if (root == sClickActionObject) + if (selected_object == sClickActionObject) { - U8 action = root->getClickAction(); - switch (action) + switch (sClickAction) { case CLICK_ACTION_BUY: handle_buy(NULL); @@ -422,6 +423,7 @@ void LLToolPie::selectionPropertiesReceived() } sLeftClickSelection = NULL; sClickActionObject = NULL; + sClickAction = 0; } BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index 2ae125c76e..6c3a200dbc 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -54,6 +54,7 @@ protected: LLUUID mHitObjectID; BOOL mMouseOutsideSlop; // for this drag, has mouse moved outside slop region static LLViewerObject* sClickActionObject; + static U8 sClickAction; static LLHandle<LLObjectSelection> sLeftClickSelection; }; diff --git a/indra/newview/lluploaddialog.cpp b/indra/newview/lluploaddialog.cpp index 9bcc123eb5..f8c54fd6c7 100644 --- a/indra/newview/lluploaddialog.cpp +++ b/indra/newview/lluploaddialog.cpp @@ -62,7 +62,7 @@ LLUploadDialog::LLUploadDialog( const std::string& msg) setMessage(msg); // The dialog view is a root view - gViewerWindow->setTopView( this, NULL ); + gViewerWindow->setTopCtrl( this ); } void LLUploadDialog::setMessage( const std::string& msg) diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index 512ddc8565..123dcc8eb4 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -34,6 +34,7 @@ #include "llvoavatar.h" #include "llsky.h" #include "pipeline.h" +#include "llglslshader.h" #if !LL_DARWIN && !LL_LINUX extern PFNGLWEIGHTPOINTERARBPROC glWeightPointerARB; @@ -479,7 +480,7 @@ void LLViewerJointMesh::uploadJointMatrices() //cgGLSetParameterArray4f(gPipeline.mAvatarMatrix, offset, 1, vector); } } - glUniform4fvARB(gPipeline.mAvatarMatrixParam, 45, mat); + glUniform4fvARB(gAvatarMatrixParam, 45, mat); } } @@ -554,14 +555,14 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass) { glColor4f(0,0,0,1); - if (gPipeline.mMaterialIndex > 0) + if (gMaterialIndex > 0) { - glVertexAttrib4fvARB(gPipeline.mMaterialIndex, mColor.mV); + glVertexAttrib4fvARB(gMaterialIndex, mColor.mV); } - if (mShiny && gPipeline.mSpecularIndex > 0) + if (mShiny && gSpecularIndex > 0) { - glVertexAttrib4fARB(gPipeline.mSpecularIndex, 1,1,1,1); + glVertexAttrib4fARB(gSpecularIndex, 1,1,1,1); } } else @@ -888,7 +889,7 @@ void LLViewerJointMesh::updateGeometry() if (mValid && mMesh && mFace && mMesh->hasWeights() && mFace->mVertexBuffer.notNull() && - gPipeline.getVertexShaderLevel(LLPipeline::SHADER_AVATAR) == 0) + LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_AVATAR) == 0) { uploadJointMatrices(); LLStrider<LLVector3> o_vertices; diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp new file mode 100644 index 0000000000..ae51726b5e --- /dev/null +++ b/indra/newview/llviewerjoystick.cpp @@ -0,0 +1,252 @@ +/** + * @file llviewerjoystick.cpp + * @brief Joystick functionality. + * + * Copyright (c) 2002-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llviewercontrol.h" +#include "llviewerwindow.h" +#include "llviewercamera.h" +#include "llviewerjoystick.h" +#include "viewer.h" +#include "llkeyboard.h" + +static LLQuaternion sFlycamRotation; +static LLVector3 sFlycamPosition; +static F32 sFlycamZoom; + +BOOL LLViewerJoystick::sOverrideCamera = FALSE; + +void LLViewerJoystick::updateCamera(BOOL reset) +{ + static F32 last_delta[] = {0,0,0,0,0,0,0}; + static F32 delta[] = { 0,0,0,0,0,0,0 }; + + LLWindow* window = gViewerWindow->getWindow(); + + F32 time = gFrameIntervalSeconds; + + S32 axis[] = + { + gSavedSettings.getS32("FlycamAxis0"), + gSavedSettings.getS32("FlycamAxis1"), + gSavedSettings.getS32("FlycamAxis2"), + gSavedSettings.getS32("FlycamAxis3"), + gSavedSettings.getS32("FlycamAxis4"), + gSavedSettings.getS32("FlycamAxis5"), + gSavedSettings.getS32("FlycamAxis6") + }; + + F32 axis_scale[] = + { + gSavedSettings.getF32("FlycamAxisScale0"), + gSavedSettings.getF32("FlycamAxisScale1"), + gSavedSettings.getF32("FlycamAxisScale2"), + gSavedSettings.getF32("FlycamAxisScale3"), + gSavedSettings.getF32("FlycamAxisScale4"), + gSavedSettings.getF32("FlycamAxisScale5"), + gSavedSettings.getF32("FlycamAxisScale6") + }; + + F32 dead_zone[] = + { + gSavedSettings.getF32("FlycamAxisDeadZone0"), + gSavedSettings.getF32("FlycamAxisDeadZone1"), + gSavedSettings.getF32("FlycamAxisDeadZone2"), + gSavedSettings.getF32("FlycamAxisDeadZone3"), + gSavedSettings.getF32("FlycamAxisDeadZone4"), + gSavedSettings.getF32("FlycamAxisDeadZone5"), + gSavedSettings.getF32("FlycamAxisDeadZone6") + }; + + if (reset) + { + sFlycamPosition = gCamera->getOrigin(); + sFlycamRotation = gCamera->getQuaternion(); + sFlycamZoom = gCamera->getView(); + + for (U32 i = 0; i < 7; i++) + { + last_delta[i] = -window->getJoystickAxis(axis[i]); + delta[i] = 0.f; + } + return; + } + + F32 cur_delta[7]; + F32 feather = gSavedSettings.getF32("FlycamFeathering"); + BOOL absolute = gSavedSettings.getBOOL("FlycamAbsolute"); + + for (U32 i = 0; i < 7; i++) + { + cur_delta[i] = -window->getJoystickAxis(axis[i]); + F32 tmp = cur_delta[i]; + if (absolute) + { + cur_delta[i] = cur_delta[i] - last_delta[i]; + } + last_delta[i] = tmp; + + if (cur_delta[i] > 0) + { + cur_delta[i] = llmax(cur_delta[i]-dead_zone[i], 0.f); + } + else + { + cur_delta[i] = llmin(cur_delta[i]+dead_zone[i], 0.f); + } + cur_delta[i] *= axis_scale[i]; + + if (!absolute) + { + cur_delta[i] *= time; + } + + delta[i] = delta[i] + (cur_delta[i]-delta[i])*time*feather; + } + + sFlycamPosition += LLVector3(delta) * sFlycamRotation; + + LLMatrix3 rot_mat(delta[3], + delta[4], + delta[5]); + + sFlycamRotation = LLQuaternion(rot_mat)*sFlycamRotation; + + if (gSavedSettings.getBOOL("FlycamAutoLeveling")) + { + LLMatrix3 level(sFlycamRotation); + + LLVector3 x = LLVector3(level.mMatrix[0]); + LLVector3 y = LLVector3(level.mMatrix[1]); + LLVector3 z = LLVector3(level.mMatrix[2]); + + y.mV[2] = 0.f; + y.normVec(); + + level.setRows(x,y,z); + level.orthogonalize(); + + LLQuaternion quat = LLQuaternion(level); + sFlycamRotation = nlerp(llmin(feather*time,1.f), sFlycamRotation, quat); + } + + if (gSavedSettings.getBOOL("FlycamZoomDirect")) + { + sFlycamZoom = last_delta[6]*axis_scale[6]+dead_zone[6]; + } + else + { + sFlycamZoom += delta[6]; + } + + LLMatrix3 mat(sFlycamRotation); + + gCamera->setView(sFlycamZoom); + gCamera->setOrigin(sFlycamPosition); + gCamera->mXAxis = LLVector3(mat.mMatrix[0]); + gCamera->mYAxis = LLVector3(mat.mMatrix[1]); + gCamera->mZAxis = LLVector3(mat.mMatrix[2]); +} + + +void LLViewerJoystick::scanJoystick() +{ + if (!sOverrideCamera) + { + static U32 joystick_state = 0; + static U32 button_state = 0; + + F32 xval = gViewerWindow->getWindow()->getJoystickAxis(0); + F32 yval = gViewerWindow->getWindow()->getJoystickAxis(1); + + if (xval <= -0.5f) + { + if (!(joystick_state & 0x1)) + { + gKeyboard->handleTranslatedKeyDown(KEY_PAD_LEFT, 0); + joystick_state |= 0x1; + } + } + else + { + if (joystick_state & 0x1) + { + gKeyboard->handleTranslatedKeyUp(KEY_PAD_LEFT, 0); + joystick_state &= ~0x1; + } + } + if (xval >= 0.5f) + { + if (!(joystick_state & 0x2)) + { + gKeyboard->handleTranslatedKeyDown(KEY_PAD_RIGHT, 0); + joystick_state |= 0x2; + } + } + else + { + if (joystick_state & 0x2) + { + gKeyboard->handleTranslatedKeyUp(KEY_PAD_RIGHT, 0); + joystick_state &= ~0x2; + } + } + if (yval <= -0.5f) + { + if (!(joystick_state & 0x4)) + { + gKeyboard->handleTranslatedKeyDown(KEY_PAD_UP, 0); + joystick_state |= 0x4; + } + } + else + { + if (joystick_state & 0x4) + { + gKeyboard->handleTranslatedKeyUp(KEY_PAD_UP, 0); + joystick_state &= ~0x4; + } + } + if (yval >= 0.5f) + { + if (!(joystick_state & 0x8)) + { + gKeyboard->handleTranslatedKeyDown(KEY_PAD_DOWN, 0); + joystick_state |= 0x8; + } + } + else + { + if (joystick_state & 0x8) + { + gKeyboard->handleTranslatedKeyUp(KEY_PAD_DOWN, 0); + joystick_state &= ~0x8; + } + } + + for( int i = 0; i < 15; i++ ) + { + if ( gViewerWindow->getWindow()->getJoystickButton(i) & 0x80 ) + { + if (!(button_state & (1<<i))) + { + gKeyboard->handleTranslatedKeyDown(KEY_BUTTON1+i, 0); + button_state |= (1<<i); + } + } + else + { + if (button_state & (1<<i)) + { + gKeyboard->handleTranslatedKeyUp(KEY_BUTTON1+i, 0); + button_state &= ~(1<<i); + } + } + } + } +} + diff --git a/indra/newview/llviewerjoystick.h b/indra/newview/llviewerjoystick.h new file mode 100644 index 0000000000..bc2186c992 --- /dev/null +++ b/indra/newview/llviewerjoystick.h @@ -0,0 +1,20 @@ +/** + * @file llviewerjoystick.h + * @brief Viewer joystick functionality. + * + * Copyright (c) 2001-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +#ifndef LL_LLVIEWERJOYSTICK_H +#define LL_LLVIEWERJOYSTICK_H + +class LLViewerJoystick +{ +public: + static BOOL sOverrideCamera; + static void scanJoystick(); + static void updateCamera(BOOL reset = FALSE); +}; + +#endif diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 9a43729195..89665171c9 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -174,6 +174,7 @@ #include "pipeline.h" #include "viewer.h" #include "roles_constants.h" +#include "llviewerjoystick.h" #include "lltexlayer.h" @@ -994,6 +995,10 @@ void init_debug_ui_menu(LLMenuGL* menu) menu->append(new LLMenuItemToggleGL("Debug Keys", &LLView::sDebugKeys)); menu->append(new LLMenuItemToggleGL("Debug WindowProc", &gDebugWindowProc)); menu->append(new LLMenuItemToggleGL("Debug Text Editor Tips", &gDebugTextEditorTips)); + menu->appendSeparator(); + menu->append(new LLMenuItemCheckGL("Show Time", menu_toggle_control, NULL, menu_check_control, (void*)"DebugShowTime")); + menu->append(new LLMenuItemCheckGL("Show Render Info", menu_toggle_control, NULL, menu_check_control, (void*)"DebugShowRenderInfo")); + menu->createJumpKeys(); } @@ -3145,6 +3150,11 @@ void reset_view_final( BOOL proceed, void* ) gAgent.changeCameraToDefault(); + if (LLViewerJoystick::sOverrideCamera) + { + handle_toggle_flycam(NULL); + } + gAgent.resetView(!gFloaterTools->getVisible()); gFloaterTools->close(); @@ -6331,14 +6341,15 @@ void handle_dump_followcam(void*) BOOL check_flycam(void*) { - return LLPipeline::sOverrideAgentCamera; + return LLViewerJoystick::sOverrideCamera; } void handle_toggle_flycam(void*) { - LLPipeline::sOverrideAgentCamera = !LLPipeline::sOverrideAgentCamera; - if (LLPipeline::sOverrideAgentCamera) + LLViewerJoystick::sOverrideCamera = !LLViewerJoystick::sOverrideCamera; + if (LLViewerJoystick::sOverrideCamera) { + LLViewerJoystick::updateCamera(TRUE); LLFloaterJoystick::show(NULL); } } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index ed13f6dbe9..55256a6f23 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3884,7 +3884,16 @@ void process_alert_core(const char* buffer, BOOL modal) } // Translate system messages here. - if (buffer[0] == '/') + const char ALERT_PREFIX[] = "ALERT: "; + const size_t ALERT_PREFIX_LEN = sizeof(ALERT_PREFIX) - 1; + if (!strncmp(buffer, ALERT_PREFIX, ALERT_PREFIX_LEN)) + { + // Allow the server to spawn a named alert so that server alerts can be + // translated out of English. JC + std::string alert_name(buffer + ALERT_PREFIX_LEN); + LLAlertDialog::showXml(alert_name); + } + else if (buffer[0] == '/') { // System message is important, show in upper-right box not tip LLString text(buffer+1); diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index ee29876274..c3f2b2d2f6 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -2568,6 +2568,6 @@ bool LLParcelSelection::hasOthersSelected() const LLParcelSelection* get_null_parcel_selection() { - static LLParcelSelectionHandle null_ptr = new LLParcelSelection(); - return null_ptr; + static LLParcelSelection null_selection; + return &null_selection; } diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index a6895aff2f..bf09c54100 100644 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -461,7 +461,7 @@ LLViewerPartGroup *LLViewerPartSim::put(LLViewerPart* part) const F32 MAX_MAG = 1000000.f*1000000.f; // 1 million if (part->mPosAgent.magVecSquared() > MAX_MAG || !part->mPosAgent.isFinite()) { -#if !LL_RELEASE_FOR_DOWNLOAD +#if 0 && !LL_RELEASE_FOR_DOWNLOAD llwarns << "LLViewerPartSim::put Part out of range!" << llendl; llwarns << part->mPosAgent << llendl; #endif diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 262c7d8ed7..3bc529a9e3 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -422,7 +422,6 @@ LLVector3 LLViewerRegion::getCenterAgent() const return gAgent.getPosAgentFromGlobal(mCenterGlobal); } - void LLViewerRegion::setRegionNameAndZone(const char* name_and_zone) { LLString name_zone(name_and_zone); @@ -705,21 +704,6 @@ F32 LLViewerRegion::getCompositionXY(const S32 x, const S32 y) const return getComposition()->getValueScaled((F32)x, (F32)y); } - -// ---------------- Friends ---------------- - -std::ostream& operator<<(std::ostream &s, const LLViewerRegion ®ion) -{ - s << "{ "; - s << region.mHost; - s << " mOriginGlobal = " << region.getOriginGlobal()<< "\n"; - s << "}"; - return s; -} - - -// ---------------- Protected Member Functions ---------------- - void LLViewerRegion::calculateCenterGlobal() { mCenterGlobal = mOriginGlobal; @@ -735,7 +719,24 @@ void LLViewerRegion::calculateCenterGlobal() } } +void LLViewerRegion::calculateCameraDistance() +{ + mCameraDistanceSquared = (F32)(gAgent.getCameraPositionGlobal() - getCenterGlobal()).magVecSquared(); +} + +// ---------------- Friends ---------------- +std::ostream& operator<<(std::ostream &s, const LLViewerRegion ®ion) +{ + s << "{ "; + s << region.mHost; + s << " mOriginGlobal = " << region.getOriginGlobal()<< "\n"; + s << "}"; + return s; +} + + +// ---------------- Protected Member Functions ---------------- void LLViewerRegion::updateNetStats() { diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 1dc1b3af20..05c37fe08f 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -208,9 +208,19 @@ public: void unpackRegionHandshake(); void calculateCenterGlobal(); + void calculateCameraDistance(); friend std::ostream& operator<<(std::ostream &s, const LLViewerRegion ®ion); +public: + struct CompareDistance + { + bool operator()(const LLViewerRegion* const& lhs, const LLViewerRegion* const& rhs) + { + return lhs->mCameraDistanceSquared < rhs->mCameraDistanceSquared; + } + }; + protected: void disconnectAllNeighbors(); void initStats(); @@ -265,13 +275,15 @@ protected: U32 mPingDelay; F32 mDeltaTime; // Time since last measurement of lastPackets, Bits, etc + // Misc LLVLComposition *mCompositionp; // Composition layer for the surface U32 mRegionFlags; // includes damage flags U8 mSimAccess; F32 mBillableFactor; U32 mMaxTasks; // max prim count - + F32 mCameraDistanceSquared; // updated once per frame + // Maps local ids to cache entries. // Regions can have order 10,000 objects, so assume // a structure of size 2^14 = 16,000 diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index f9e74f31e6..4ebfef3a9b 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -584,7 +584,7 @@ BOOL LLViewerTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) { mDragItem = item_at_pos; mDragItemSaved = LLEmbeddedItems::getEmbeddedItemSaved(wc); - gFocusMgr.setMouseCapture( this, NULL ); + gFocusMgr.setMouseCapture( this ); mMouseDownX = x; mMouseDownY = y; S32 screen_x; @@ -646,7 +646,7 @@ BOOL LLViewerTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) setCursorAtLocalPos( x, y, TRUE ); startSelection(); } - gFocusMgr.setMouseCapture( this, &LLTextEditor::onMouseCaptureLost ); + gFocusMgr.setMouseCapture( this ); } handled = TRUE; @@ -676,7 +676,7 @@ BOOL LLViewerTextEditor::handleHover(S32 x, S32 y, MASK mask) } if( getVisible() ) { - if(gFocusMgr.getMouseCapture() == this ) + if(hasMouseCapture() ) { if( mIsSelecting ) { @@ -829,7 +829,7 @@ BOOL LLViewerTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) // Delay cursor flashing mKeystrokeTimer.reset(); - if( gFocusMgr.getMouseCapture() == this ) + if( hasMouseCapture() ) { if (mDragItem) { @@ -842,7 +842,7 @@ BOOL LLViewerTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) } } mDragItem = NULL; - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); handled = TRUE; } diff --git a/indra/newview/llviewertextureanim.cpp b/indra/newview/llviewertextureanim.cpp index b40320ad2d..67b0901162 100644 --- a/indra/newview/llviewertextureanim.cpp +++ b/indra/newview/llviewertextureanim.cpp @@ -17,6 +17,9 @@ LLViewerTextureAnim::LLViewerTextureAnim() : LLTextureAnim() { mLastFrame = -1.f; // Force an update initially mLastTime = 0.f; + mOffS = mOffT = 0; + mScaleS = mScaleT = 1; + mRot = 0; } LLViewerTextureAnim::~LLViewerTextureAnim() @@ -148,13 +151,13 @@ S32 LLViewerTextureAnim::animateTextures(F32 &off_s, F32 &off_t, if (mMode & ROTATE) { result |= ROTATE; - rot = frame_counter; + mRot = rot = frame_counter; } else if (mMode & SCALE) { result |= SCALE; - scale_s = frame_counter; - scale_t = frame_counter; + mScaleS = scale_s = frame_counter; + mScaleT = scale_t = frame_counter; } else { @@ -168,22 +171,22 @@ S32 LLViewerTextureAnim::animateTextures(F32 &off_s, F32 &off_t, &&(mSizeY)) { result |= SCALE; - scale_s = 1.f/mSizeX; - scale_t = 1.f/mSizeY; + mScaleS = scale_s = 1.f/mSizeX; + mScaleT = scale_t = 1.f/mSizeY; x_frame = fmod(frame_counter, mSizeX); y_frame = (S32)(frame_counter / mSizeX); x_pos = x_frame * scale_s; y_pos = y_frame * scale_t; - off_s = (-0.5f + 0.5f*scale_s)+ x_pos; - off_t = (0.5f - 0.5f*scale_t) - y_pos; + mOffS = off_s = (-0.5f + 0.5f*scale_s)+ x_pos; + mOffT = off_t = (0.5f - 0.5f*scale_t) - y_pos; } else { - scale_s = 1.f; - scale_t = 1.f; + mScaleS = scale_s = 1.f; + mScaleT = scale_t = 1.f; x_pos = frame_counter * scale_s; - off_s = (-0.5f + 0.5f*scale_s)+ x_pos; - off_t = 0.f; + mOffS = off_s = (-0.5f + 0.5f*scale_s)+ x_pos; + mOffT = off_t = 0.f; } } } diff --git a/indra/newview/llviewertextureanim.h b/indra/newview/llviewertextureanim.h index c7e75c565c..a5488be4eb 100644 --- a/indra/newview/llviewertextureanim.h +++ b/indra/newview/llviewertextureanim.h @@ -25,6 +25,13 @@ public: { TRANSLATE = 0x01 // Result code JUST for animateTextures }; + + F32 mOffS; + F32 mOffT; + F32 mScaleS; + F32 mScaleT; + F32 mRot; + protected: LLFrameTimer mTimer; F64 mLastTime; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 41f937efd5..732568f652 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -43,7 +43,6 @@ #include "llxfermanager.h" #include "message.h" #include "object_flags.h" -#include "text_out.h" #include "lltimer.h" #include "timing.h" #include "llviewermenu.h" @@ -334,7 +333,216 @@ void LLViewerWindow::printFeedback() } #endif //SABINRIG +//////////////////////////////////////////////////////////////////////////// +// +// LLDebugText +// + +class LLDebugText +{ +private: + struct Line + { + Line(const std::string& in_text, S32 in_x, S32 in_y) : text(in_text), x(in_x), y(in_y) {} + std::string text; + S32 x,y; + }; + + LLViewerWindow *mWindow; + + typedef std::vector<Line> line_list_t; + line_list_t mLineList; + LLColor4 mTextColor; + +public: + LLDebugText(LLViewerWindow* window) : mWindow(window) {} + + void addText(S32 x, S32 y, const std::string &text) + { + mLineList.push_back(Line(text, x, y)); + } + + void update() + { + std::string wind_vel_text; + std::string wind_vector_text; + std::string rwind_vel_text; + std::string rwind_vector_text; + std::string audio_text; + + // Draw the statistics in a light gray + // and in a thin font + mTextColor = LLColor4( 0.86f, 0.86f, 0.86f, 1.f ); + + // Draw stuff growing up from right lower corner of screen + U32 xpos = mWindow->getWindowWidth() - 350; + U32 ypos = 64; + const U32 y_inc = 20; + + if (gSavedSettings.getBOOL("DebugShowTime")) + { + const U32 y_inc2 = 15; + for (std::map<S32,LLFrameTimer>::reverse_iterator iter = gDebugTimers.rbegin(); + iter != gDebugTimers.rend(); ++iter) + { + S32 idx = iter->first; + LLFrameTimer& timer = iter->second; + F32 time = timer.getElapsedTimeF32(); + S32 hours = (S32)(time / (60*60)); + S32 mins = (S32)((time - hours*(60*60)) / 60); + S32 secs = (S32)((time - hours*(60*60) - mins*60)); + addText(xpos, ypos, llformat(" Debug %d: %d:%02d:%02d", idx, hours,mins,secs)); ypos += y_inc2; + } + + F32 time = gFrameTimeSeconds; + S32 hours = (S32)(time / (60*60)); + S32 mins = (S32)((time - hours*(60*60)) / 60); + S32 secs = (S32)((time - hours*(60*60) - mins*60)); + addText(xpos, ypos, llformat("Time: %d:%02d:%02d", hours,mins,secs)); ypos += y_inc; + } + + if (gDisplayCameraPos) + { + std::string camera_view_text; + std::string camera_center_text; + std::string agent_view_text; + std::string agent_left_text; + std::string agent_center_text; + std::string agent_root_center_text; + + LLVector3d tvector; // Temporary vector to hold data for printing. + + // Update camera center, camera view, wind info every other frame + tvector = gAgent.getPositionGlobal(); + agent_center_text = llformat("AgentCenter %f %f %f", + (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); + + if (gAgent.getAvatarObject()) + { + tvector = gAgent.getPosGlobalFromAgent(gAgent.getAvatarObject()->mRoot.getWorldPosition()); + agent_root_center_text = llformat("AgentRootCenter %f %f %f", + (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); + } + else + { + agent_root_center_text = "---"; + } + + + tvector = LLVector4(gAgent.getFrameAgent().getAtAxis()); + agent_view_text = llformat("AgentAtAxis %f %f %f", + (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); + + tvector = LLVector4(gAgent.getFrameAgent().getLeftAxis()); + agent_left_text = llformat("AgentLeftAxis %f %f %f", + (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); + + tvector = gAgent.getCameraPositionGlobal(); + camera_center_text = llformat("CameraCenter %f %f %f", + (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); + + tvector = LLVector4(gCamera->getAtAxis()); + camera_view_text = llformat("CameraAtAxis %f %f %f", + (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); + + addText(xpos, ypos, agent_center_text); ypos += y_inc; + addText(xpos, ypos, agent_root_center_text); ypos += y_inc; + addText(xpos, ypos, agent_view_text); ypos += y_inc; + addText(xpos, ypos, agent_left_text); ypos += y_inc; + addText(xpos, ypos, camera_center_text); ypos += y_inc; + addText(xpos, ypos, camera_view_text); ypos += y_inc; + } + + if (gDisplayWindInfo) + { + wind_vel_text = llformat("Wind velocity %.2f m/s", gWindVec.magVec()); + wind_vector_text = llformat("Wind vector %.2f %.2f %.2f", gWindVec.mV[0], gWindVec.mV[1], gWindVec.mV[2]); + rwind_vel_text = llformat("RWind vel %.2f m/s", gRelativeWindVec.magVec()); + rwind_vector_text = llformat("RWind vec %.2f %.2f %.2f", gRelativeWindVec.mV[0], gRelativeWindVec.mV[1], gRelativeWindVec.mV[2]); + + addText(xpos, ypos, wind_vel_text); ypos += y_inc; + addText(xpos, ypos, wind_vector_text); ypos += y_inc; + addText(xpos, ypos, rwind_vel_text); ypos += y_inc; + addText(xpos, ypos, rwind_vector_text); ypos += y_inc; + } + if (gDisplayWindInfo) + { + if (gAudiop) + { + audio_text= llformat("Audio for wind: %d", gAudiop->isWindEnabled()); + } + addText(xpos, ypos, audio_text); ypos += y_inc; + } + if (gDisplayFOV) + { + addText(xpos, ypos, llformat("FOV: %2.1f deg", RAD_TO_DEG * gCamera->getView())); + ypos += y_inc; + } + if (gSavedSettings.getBOOL("DebugShowRenderInfo")) + { + if (gPipeline.getUseVertexShaders() == 0) + { + addText(xpos, ypos, "Shaders Disabled"); + ypos += y_inc; + } + addText(xpos, ypos, llformat("%d MB Vertex Data", LLVertexBuffer::sAllocatedBytes/(1024*1024))); + ypos += y_inc; + + addText(xpos, ypos, llformat("%d Pending Lock", LLVertexBuffer::sLockedList.size())); + ypos += y_inc; + + addText(xpos, ypos, llformat("%d Vertex Buffers", LLVertexBuffer::sGLCount)); + ypos += y_inc; + } + if (LLPipeline::getRenderParticleBeacons(NULL)) + { + addText(xpos, ypos, "Viewing particle beacons (blue)"); + ypos += y_inc; + } + if (LLPipeline::toggleRenderTypeControlNegated((void*)LLPipeline::RENDER_TYPE_PARTICLES)) + { + addText(xpos, ypos, "Hiding particles"); + ypos += y_inc; + } + if (LLPipeline::getRenderPhysicalBeacons(NULL)) + { + addText(xpos, ypos, "Viewing physical object beacons (green)"); + ypos += y_inc; + } + if (LLPipeline::getRenderScriptedBeacons(NULL)) + { + addText(xpos, ypos, "Viewing scripted object beacons (red)"); + ypos += y_inc; + } + if (LLPipeline::getRenderSoundBeacons(NULL)) + { + addText(xpos, ypos, "Viewing sound beacons (yellow)"); + ypos += y_inc; + } + } + + void draw() + { + for (line_list_t::iterator iter = mLineList.begin(); + iter != mLineList.end(); ++iter) + { + const Line& line = *iter; + LLFontGL::sMonospace->renderUTF8(line.text, 0, (F32)line.x, (F32)line.y, mTextColor, + LLFontGL::LEFT, LLFontGL::TOP, + LLFontGL::NORMAL, S32_MAX, S32_MAX, NULL, FALSE); + } + mLineList.clear(); + } + +}; + +void LLViewerWindow::updateDebugText() +{ + mDebugText->update(); +} + +//////////////////////////////////////////////////////////////////////////// // // LLViewerWindow // @@ -401,12 +609,23 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask } // Topmost view gets a chance before the hierarchy - LLView* top_view = gFocusMgr.getTopView(); - if (top_view) + LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); + if (top_ctrl) { S32 local_x, local_y; - top_view->screenPointToLocal( x, y, &local_x, &local_y ); - if (top_view->pointInView(local_x, local_y) && top_view->handleMouseDown(local_x, local_y, mask)) return TRUE; + top_ctrl->screenPointToLocal( x, y, &local_x, &local_y ); + if (top_ctrl->pointInView(local_x, local_y)) + { + if(top_ctrl->handleMouseDown(local_x, local_y, mask)) + { + return TRUE; + } + } + else if (top_ctrl->hasFocus()) + { + // always defocus top view if we click off of it + top_ctrl->setFocus(FALSE); + } } // Give the UI views a chance to process the click @@ -479,12 +698,25 @@ BOOL LLViewerWindow::handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK ma } // Check for hit on UI. - LLView* top_view = gFocusMgr.getTopView(); - if (top_view) + LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); + if (top_ctrl) { S32 local_x, local_y; - top_view->screenPointToLocal( x, y, &local_x, &local_y ); - if (top_view->pointInView(local_x, local_y) && top_view->handleDoubleClick(local_x, local_y, mask)) return TRUE; + top_ctrl->screenPointToLocal( x, y, &local_x, &local_y ); + if (top_ctrl->pointInView(local_x, local_y)) + { + if(top_ctrl->handleDoubleClick(local_x, local_y, mask)) + { + return TRUE; + } + } + else + { + if (top_ctrl->hasFocus()) + { + top_ctrl->setFocus(FALSE); + } + } } if (mRootView->handleDoubleClick(x, y, mask)) @@ -574,12 +806,12 @@ BOOL LLViewerWindow::handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask) return mouse_captor->handleMouseUp(local_x, local_y, mask); } - LLView* top_view = gFocusMgr.getTopView(); - if (top_view) + LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); + if (top_ctrl) { S32 local_x, local_y; - top_view->screenPointToLocal( x, y, &local_x, &local_y ); - handled = top_view->pointInView(local_x, local_y) && top_view->handleMouseUp(local_x, local_y, mask); + top_ctrl->screenPointToLocal( x, y, &local_x, &local_y ); + handled = top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleMouseUp(local_x, local_y, mask); } if( !handled ) @@ -670,12 +902,25 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK return mouse_captor->handleRightMouseDown(local_x, local_y, mask); } - LLView* top_view = gFocusMgr.getTopView(); - if (top_view) + LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); + if (top_ctrl) { S32 local_x, local_y; - top_view->screenPointToLocal( x, y, &local_x, &local_y ); - if (top_view->pointInView(local_x, local_y) && top_view->handleRightMouseDown(local_x, local_y, mask)) return TRUE; + top_ctrl->screenPointToLocal( x, y, &local_x, &local_y ); + if (top_ctrl->pointInView(local_x, local_y)) + { + if(top_ctrl->handleRightMouseDown(local_x, local_y, mask)) + { + return TRUE; + } + } + else + { + if (top_ctrl->hasFocus()) + { + top_ctrl->setFocus(FALSE); + } + } } if( mRootView->handleRightMouseDown(x, y, mask) ) @@ -773,12 +1018,12 @@ BOOL LLViewerWindow::handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK m return mouse_captor->handleRightMouseUp(local_x, local_y, mask); } - LLView* top_view = gFocusMgr.getTopView(); - if (top_view) + LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); + if (top_ctrl) { S32 local_x, local_y; - top_view->screenPointToLocal( x, y, &local_x, &local_y ); - handled = top_view->pointInView(local_x, local_y) && top_view->handleRightMouseUp(local_x, local_y, mask); + top_ctrl->screenPointToLocal( x, y, &local_x, &local_y ); + handled = top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleRightMouseUp(local_x, local_y, mask); } if( !handled ) @@ -912,7 +1157,7 @@ void LLViewerWindow::handleFocusLost(LLWindow *window) { gToolMgr->onAppFocusLost(); } - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); if (gMenuBarView) { @@ -1284,6 +1529,8 @@ LLViewerWindow::LLViewerWindow( // sync the keyboard's setting with the saved setting gSavedSettings.getControl("NumpadControl")->firePropertyChanged(); + + mDebugText = new LLDebugText(this); } void LLViewerWindow::initGLDefaults() @@ -1632,6 +1879,8 @@ void LLViewerWindow::initWorldUI() LLViewerWindow::~LLViewerWindow() { + delete mDebugText; + gSavedSettings.setS32("FloaterViewBottom", gFloaterView->getRect().mBottom); // Cleanup global views @@ -1845,6 +2094,10 @@ void LLViewerWindow::reshape(S32 width, S32 height) } } +void LLViewerWindow::drawDebugText() +{ + mDebugText->draw(); +} void LLViewerWindow::draw() { @@ -1916,7 +2169,7 @@ void LLViewerWindow::draw() { LLGLSTexture gls_texture; - show_text_gl(); + drawDebugText(); } if (gToolMgr) @@ -1928,7 +2181,7 @@ void LLViewerWindow::draw() if( gAgent.cameraMouselook() ) { drawMouselookInstructions(); - stop_glerror(); + stop_glerror(); } // Draw all nested UI views. @@ -1936,16 +2189,16 @@ void LLViewerWindow::draw() mRootView->draw(); // Draw optional on-top-of-everyone view - LLView* top_view = gFocusMgr.getTopView(); - if (top_view && top_view->getVisible()) + LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); + if (top_ctrl && top_ctrl->getVisible()) { S32 screen_x, screen_y; - top_view->localPointToScreen(0, 0, &screen_x, &screen_y); + top_ctrl->localPointToScreen(0, 0, &screen_x, &screen_y); glMatrixMode(GL_MODELVIEW); LLUI::pushMatrix(); LLUI::translate( (F32) screen_x, (F32) screen_y, 0.f); - top_view->draw(); + top_ctrl->draw(); LLUI::popMatrix(); } @@ -2065,7 +2318,7 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) // cursor modes, etc, and re-enable. //if (gFocusMgr.getMouseCapture()) //{ - // gFocusMgr.setMouseCapture(NULL, NULL); + // gFocusMgr.setMouseCapture(NULL); // return TRUE; //} } @@ -2131,10 +2384,10 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) // Topmost view gets a chance before the hierarchy // *FIX: get rid of this? - LLView* top_view = gFocusMgr.getTopView(); - if (top_view) + LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); + if (top_ctrl) { - if( top_view->handleKey( key, mask, TRUE ) ) + if( top_ctrl->handleKey( key, mask, TRUE ) ) { return TRUE; } @@ -2207,8 +2460,8 @@ BOOL LLViewerWindow::handleUnicodeChar(llwchar uni_char, MASK mask) } // Topmost view gets a chance before the hierarchy - LLView* top_view = gFocusMgr.getTopView(); - if (top_view && top_view->handleUnicodeChar( uni_char, FALSE ) ) + LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); + if (top_ctrl && top_ctrl->handleUnicodeChar( uni_char, FALSE ) ) { return TRUE; } @@ -2244,13 +2497,13 @@ void LLViewerWindow::handleScrollWheel(S32 clicks) return; } - LLView* top_view = gFocusMgr.getTopView(); - if (top_view) + LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); + if (top_ctrl) { S32 local_x; S32 local_y; - top_view->screenPointToLocal( mCurrentMousePoint.mX, mCurrentMousePoint.mY, &local_x, &local_y ); - if (top_view->handleScrollWheel(local_x, local_y, clicks)) return; + top_ctrl->screenPointToLocal( mCurrentMousePoint.mX, mCurrentMousePoint.mY, &local_x, &local_y ); + if (top_ctrl->handleScrollWheel(local_x, local_y, clicks)) return; } if (mRootView->handleScrollWheel(mCurrentMousePoint.mX, mCurrentMousePoint.mY, clicks) ) @@ -2396,8 +2649,8 @@ BOOL LLViewerWindow::handlePerFrameHover() BOOL handled = FALSE; - BOOL handled_by_top_view = FALSE; - LLView* top_view = gFocusMgr.getTopView(); + BOOL handled_by_top_ctrl = FALSE; + LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture(); if( mouse_captor ) @@ -2419,12 +2672,12 @@ BOOL LLViewerWindow::handlePerFrameHover() } else { - if (top_view) + if (top_ctrl) { S32 local_x, local_y; - top_view->screenPointToLocal( x, y, &local_x, &local_y ); - handled = top_view->pointInView(local_x, local_y) && top_view->handleHover(local_x, local_y, mask); - handled_by_top_view = TRUE; + top_ctrl->screenPointToLocal( x, y, &local_x, &local_y ); + handled = top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleHover(local_x, local_y, mask); + handled_by_top_ctrl = TRUE; } if ( !handled ) @@ -2511,11 +2764,11 @@ BOOL LLViewerWindow::handlePerFrameHover() mouse_captor->screenPointToLocal( x, y, &local_x, &local_y ); tool_tip_handled = mouse_captor->handleToolTip( local_x, local_y, tool_tip_msg, &screen_sticky_rect ); } - else if (handled_by_top_view) + else if (handled_by_top_ctrl) { S32 local_x, local_y; - top_view->screenPointToLocal( x, y, &local_x, &local_y ); - tool_tip_handled = top_view->handleToolTip( local_x, local_y, tool_tip_msg, &screen_sticky_rect ); + top_ctrl->screenPointToLocal( x, y, &local_x, &local_y ); + tool_tip_handled = top_ctrl->handleToolTip( local_x, local_y, tool_tip_msg, &screen_sticky_rect ); } else { @@ -4155,9 +4408,9 @@ BOOL LLViewerWindow::childHasKeyboardFocus(const LLView* parent) const return gFocusMgr.childHasKeyboardFocus( parent ); } -void LLViewerWindow::setMouseCapture(LLMouseHandler* new_captor,void (*on_capture_lost)(LLMouseHandler* old_captor)) +void LLViewerWindow::setMouseCapture(LLMouseHandler* new_captor) { - gFocusMgr.setMouseCapture( new_captor, on_capture_lost ); + gFocusMgr.setMouseCapture( new_captor ); } LLMouseHandler* LLViewerWindow::getMouseCaptor() const @@ -4165,11 +4418,6 @@ LLMouseHandler* LLViewerWindow::getMouseCaptor() const return gFocusMgr.getMouseCapture(); } -BOOL LLViewerWindow::hasMouseCapture(const LLMouseHandler* possible_captor) const -{ - return possible_captor == gFocusMgr.getMouseCapture(); -} - S32 LLViewerWindow::getWindowHeight() const { return mVirtualWindowRect.getHeight(); @@ -4190,19 +4438,19 @@ S32 LLViewerWindow::getWindowDisplayWidth() const return mWindowRect.getWidth(); } -LLView* LLViewerWindow::getTopView() const +LLUICtrl* LLViewerWindow::getTopCtrl() const { - return gFocusMgr.getTopView(); + return gFocusMgr.getTopCtrl(); } -BOOL LLViewerWindow::hasTopView(LLView* view) const +BOOL LLViewerWindow::hasTopCtrl(LLView* view) const { - return view == gFocusMgr.getTopView(); + return view == gFocusMgr.getTopCtrl(); } -void LLViewerWindow::setTopView(LLView* new_top,void (*on_top_lost)(LLView* old_top)) +void LLViewerWindow::setTopCtrl(LLUICtrl* new_top) { - gFocusMgr.setTopView( new_top, on_top_lost ); + gFocusMgr.setTopCtrl( new_top ); } void LLViewerWindow::setupViewport(S32 x_offset, S32 y_offset) @@ -4810,6 +5058,8 @@ LLAlertDialog* LLViewerWindow::alertXmlEditText(const std::string& xml_filename, return alert; } +//////////////////////////////////////////////////////////////////////////// + LLBottomPanel::LLBottomPanel(const LLString &name, const LLRect &rect) : LLPanel(name, rect, FALSE), mIndicator(NULL) diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 5b56bbae06..8f3642ffd3 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -107,8 +107,8 @@ public: BOOL getLeftMouseDown() const { return mLeftMouseDown; } BOOL getRightMouseDown() const { return mRightMouseDown; } - LLView* getTopView() const; - BOOL hasTopView(LLView* view) const; + LLUICtrl* getTopCtrl() const; + BOOL hasTopCtrl(LLView* view) const; void setupViewport(S32 x_offset = 0, S32 y_offset = 0); void setup3DRender(); @@ -160,17 +160,18 @@ public: BOOL hasKeyboardFocus( const LLUICtrl* possible_focus ) const; BOOL childHasKeyboardFocus( const LLView* parent ) const; - void setMouseCapture(LLMouseHandler* new_captor,void (*on_capture_lost)(LLMouseHandler* old_captor)); // new_captor = NULL to release the mouse. - BOOL hasMouseCapture(const LLMouseHandler* possible_captor ) const; + void setMouseCapture(LLMouseHandler* new_captor); // new_captor = NULL to release the mouse. LLMouseHandler* getMouseCaptor() const; - void setTopView(LLView* new_top, void (*on_top_lost)(LLView* old_top)); // set new_top = NULL to release top_view. + void setTopCtrl(LLUICtrl* new_top); // set new_top = NULL to release top_view. void reshape(S32 width, S32 height); void sendShapeToSim(); void draw(); // void drawSelectedObjects(); + void updateDebugText(); + void drawDebugText(); static void loadUserImage(void **cb_data, const LLUUID &uuid); @@ -188,7 +189,7 @@ public: BOOL saveSnapshot(const LLString& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR); BOOL rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE, - BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR ); + BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR ); BOOL saveImageNumbered(LLImageRaw *raw, const LLString& extension = ""); void playSnapshotAnimAndSound(); @@ -259,7 +260,7 @@ private: void stopGL(BOOL save_state = TRUE); void restoreGL(const LLString& progress_message = LLString::null); void initFonts(F32 zoom_factor = 1.f); - + void analyzeHit( S32 x, // input S32 y_from_bot, // input @@ -272,6 +273,7 @@ private: F32* hit_u_coord, // output F32* hit_v_coord); // output + public: LLWindow* mWindow; // graphical window object @@ -314,13 +316,16 @@ protected: LLString mOverlayTitle; // Used for special titles such as "Second Life - Special E3 2003 Beta" + BOOL mIgnoreActivate; + U8* mPickBuffer; + + class LLDebugText* mDebugText; // Internal class for debug text + +protected: static char sSnapshotBaseName[LL_MAX_PATH]; /* Flawfinder: ignore */ static char sSnapshotDir[LL_MAX_PATH]; /* Flawfinder: ignore */ static char sMovieBaseName[LL_MAX_PATH]; /* Flawfinder: ignore */ - - BOOL mIgnoreActivate; - U8* mPickBuffer; }; class LLBottomPanel : public LLPanel diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 5db295874c..f0e797b6e9 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -90,6 +90,7 @@ #include "llwearablelist.h" #include "llworld.h" #include "pipeline.h" +#include "llglslshader.h" #include "viewer.h" #include "lscript_byteformat.h" @@ -2556,7 +2557,7 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) } // update wind effect - if ((gPipeline.getVertexShaderLevel(LLPipeline::SHADER_AVATAR) >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH)) + if ((LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_AVATAR) >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH)) { F32 hover_strength = 0.f; F32 time_delta = mRippleTimer.getElapsedTimeF32() - mRippleTimeLast; @@ -3015,38 +3016,30 @@ void LLVOAvatar::updateCharacter(LLAgent &agent) // clear debug text mDebugText.clear(); - if (LLVOAvatar::sShowAnimationDebug) { - LLString playing_anims; - for (LLMotion* motionp = mMotionController.getFirstActiveMotion(); - motionp; - motionp = mMotionController.getNextActiveMotion()) + for (LLMotionController::motion_list_t::iterator iter = mMotionController.getActiveMotions().begin(); + iter != mMotionController.getActiveMotions().end(); ++iter) + { + LLMotion* motionp = *iter; + if (motionp->getMinPixelArea() < getPixelArea()) { - if (motionp->getMinPixelArea() < getPixelArea()) + std::string output; + if (motionp->getName().empty()) { - char output[MAX_STRING]; /* Flawfinder: ignore */ - if (motionp->getName().empty()) - { - snprintf( /* Flawfinder: ignore */ - output, - MAX_STRING, - "%s - %d", - motionp->getID().asString().c_str(), - (U32)motionp->getPriority()); - } - else - { - snprintf( /* Flawfinder: ignore */ - output, - MAX_STRING, - "%s - %d", - motionp->getName().c_str(), - (U32)motionp->getPriority()); - } - addDebugText(output); + output = llformat("%s - %d", + motionp->getID().asString().c_str(), + (U32)motionp->getPriority()); } + else + { + output = llformat("%s - %d", + motionp->getName().c_str(), + (U32)motionp->getPriority()); + } + addDebugText(output); } + } } if (gNoRender) @@ -4592,7 +4585,7 @@ S32 LLVOAvatar::getCollisionVolumeID(std::string &name) //----------------------------------------------------------------------------- // addDebugText() //----------------------------------------------------------------------------- -void LLVOAvatar::addDebugText(const char* text) + void LLVOAvatar::addDebugText(const std::string& text) { mDebugText.append(1, '\n'); mDebugText.append(text); diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 2660e7c90d..3257e921bc 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -368,7 +368,7 @@ public: virtual LLVector3 getVolumePos(S32 joint_index, LLVector3& volume_offset); virtual LLJoint* findCollisionVolume(U32 volume_id); virtual S32 getCollisionVolumeID(std::string &name); - virtual void addDebugText(const char* text); + virtual void addDebugText(const std::string& text); virtual const LLUUID& getID(); virtual LLJoint *getJoint( const std::string &name ); diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 987d2ac7cb..94f9f0b21f 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -617,7 +617,6 @@ void LLVOSky::restoreGL() calcBrightnessScaleAndColors(); - // Water is currently broken on Mac. if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap) { LLCubeMap* cube_map = getCubeMap(); @@ -1232,18 +1231,14 @@ BOOL LLVOSky::updateSky() mSkyTex[side].createGLImage(mSkyTex[side].getWhich(FALSE)); } next_frame = 0; - //llSkyTex::stepCurrent(); } - if (!gSavedSettings.getBOOL("RenderDynamicReflections")) + std::vector<LLPointer<LLImageRaw> > images; + for (S32 side = 0; side < 6; side++) { - std::vector<LLPointer<LLImageRaw> > images; - for (S32 side = 0; side < 6; side++) - { - images.push_back(mSkyTex[side].getImageRaw(FALSE)); - } - mCubeMap->init(images); + images.push_back(mSkyTex[side].getImageRaw(FALSE)); } + mCubeMap->init(images); } } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index b5b9e06831..a42d447d5f 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -268,7 +268,11 @@ void LLVOVolume::animateTextures() { continue; } - if (result & LLViewerTextureAnim::ROTATE) + if (!(result & LLViewerTextureAnim::ROTATE)) + { + te->getRotation(&rot); + } + { F32 axis = -1; F32 s,t; @@ -293,16 +297,20 @@ void LLVOVolume::animateTextures() tex_mat.identity(); tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); - tex_mat.rotate(quat); - - if (result & LLViewerTextureAnim::SCALE) + tex_mat.rotate(quat); + + if (!(result & LLViewerTextureAnim::SCALE)) + { + te->getScale(&scale_s, &scale_t); + } + { scale.setVec(scale_s, scale_t, 1.f); LLMatrix4 mat; mat.initAll(scale, LLQuaternion(), LLVector3()); tex_mat *= mat; } - + tex_mat.translate(trans); } } @@ -310,6 +318,35 @@ void LLVOVolume::animateTextures() { if (mTexAnimMode && mTextureAnimp->mRate == 0) { + U8 start, count; + + if (mTextureAnimp->mFace == -1) + { + start = 0; + count = getNumTEs(); + } + else + { + start = (U8) mTextureAnimp->mFace; + count = 1; + } + + for (S32 i = start; i < start + count; i++) + { + if (mTexAnimMode & LLViewerTextureAnim::TRANSLATE) + { + setTEOffset(i, mTextureAnimp->mOffS, mTextureAnimp->mOffT); + } + if (mTexAnimMode & LLViewerTextureAnim::SCALE) + { + setTEScale(i, mTextureAnimp->mScaleS, mTextureAnimp->mScaleT); + } + if (mTexAnimMode & LLViewerTextureAnim::ROTATE) + { + setTERotation(i, mTextureAnimp->mRot); + } + } + gPipeline.markTextured(mDrawable); mFaceMappingChanged = TRUE; mTexAnimMode = 0; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 752d5a38c6..83420f8761 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -11,6 +11,7 @@ #include "llworld.h" #include "indra_constants.h" +#include "llstl.h" #include "llagent.h" #include "llviewercontrol.h" @@ -90,8 +91,7 @@ LLWorld::LLWorld(const U32 grids_per_region, const F32 meters_per_grid) LLWorld::~LLWorld() { gObjectList.killAllObjects(); - - mRegionList.deleteAllData(); + for_each(mRegionList.begin(), mRegionList.end(), DeletePointer()); } @@ -151,9 +151,9 @@ LLViewerRegion* LLWorld::addRegion(const U64 ®ion_handle, const LLHost &host) regionp->mCloudLayer.setWidth((F32)mWidth); regionp->mCloudLayer.setWindPointer(®ionp->mWind); - mRegionList.addData(regionp); - mActiveRegionList.addData(regionp); - mCulledRegionList.addData(regionp); + mRegionList.push_back(regionp); + mActiveRegionList.push_back(regionp); + mCulledRegionList.push_back(regionp); // Find all the adjacent regions, and attach them. @@ -205,9 +205,10 @@ void LLWorld::removeRegion(const LLHost &host) if (regionp == gAgent.getRegion()) { - LLViewerRegion *reg; - for (reg = mRegionList.getFirstData(); reg; reg = mRegionList.getNextData()) + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) { + LLViewerRegion* reg = *iter; llwarns << "RegionDump: " << reg->getName() << " " << reg->getHost() << " " << reg->getOriginGlobal() @@ -230,42 +231,23 @@ void LLWorld::removeRegion(const LLHost &host) from_region_handle(regionp->getHandle(), &x, &y); llinfos << "Removing region " << x << ":" << y << llendl; - // This code can probably be blitzed now... - if (!mRegionList.removeData(regionp)) - { - for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) - { - llwarns << "RegionDump: " << regionp->getName() - << " " << regionp->getHost() - << " " << regionp->getOriginGlobal() - << llendl; - } - - llerrs << "Region list is broken" << llendl; - } - - if (!mActiveRegionList.removeData(regionp)) - { - llwarns << "LLWorld.mActiveRegionList is broken." << llendl; - } - if (!mCulledRegionList.removeData(regionp)) - { - if (!mVisibleRegionList.removeData(regionp)) - { - llwarns << "LLWorld.mCulled/mVisibleRegionList are broken" << llendl;; - } - } + mRegionList.remove(regionp); + mActiveRegionList.remove(regionp); + mCulledRegionList.remove(regionp); + mVisibleRegionList.remove(regionp); + delete regionp; updateWaterObjects(); } -LLViewerRegion *LLWorld::getRegion(const LLHost &host) +LLViewerRegion* LLWorld::getRegion(const LLHost &host) { - LLViewerRegion *regionp; - for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; if (regionp->getHost() == host) { return regionp; @@ -274,16 +256,17 @@ LLViewerRegion *LLWorld::getRegion(const LLHost &host) return NULL; } -LLViewerRegion *LLWorld::getRegionFromPosAgent(const LLVector3 &pos) +LLViewerRegion* LLWorld::getRegionFromPosAgent(const LLVector3 &pos) { return getRegionFromPosGlobal(gAgent.getPosGlobalFromAgent(pos)); } -LLViewerRegion *LLWorld::getRegionFromPosGlobal(const LLVector3d &pos) +LLViewerRegion* LLWorld::getRegionFromPosGlobal(const LLVector3d &pos) { - LLViewerRegion *regionp; - for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; if (regionp->pointInRegionGlobal(pos)) { return regionp; @@ -357,11 +340,12 @@ LLVector3d LLWorld::clipToVisibleRegions(const LLVector3d &start_pos, const LLVe return regionp->getPosGlobalFromRegion(LLVector3(final_region_pos)); } -LLViewerRegion *LLWorld::getRegionFromHandle(const U64 &handle) +LLViewerRegion* LLWorld::getRegionFromHandle(const U64 &handle) { - LLViewerRegion *regionp; - for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; if (regionp->getHandle() == handle) { return regionp; @@ -374,9 +358,10 @@ LLViewerRegion *LLWorld::getRegionFromHandle(const U64 &handle) void LLWorld::updateAgentOffset(const LLVector3d &offset_global) { #if 0 - LLViewerRegion *regionp; - for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; regionp->setAgentOffset(offset_global); } #endif @@ -385,9 +370,10 @@ void LLWorld::updateAgentOffset(const LLVector3d &offset_global) BOOL LLWorld::positionRegionValidGlobal(const LLVector3d &pos_global) { - LLViewerRegion *regionp; - for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; if (regionp->pointInRegionGlobal(pos_global)) { return TRUE; @@ -552,32 +538,29 @@ void LLWorld::updateVisibilities() gCamera->setFar(mLandFarClip); - LLViewerRegion *regionp; - F32 diagonal_squared = F_SQRT2 * F_SQRT2 * mWidth * mWidth; // Go through the culled list and check for visible regions - for (regionp = mCulledRegionList.getFirstData(); - regionp; - regionp = mCulledRegionList.getNextData()) + for (region_list_t::iterator iter = mCulledRegionList.begin(); + iter != mCulledRegionList.end(); ) { + region_list_t::iterator curiter = iter++; + LLViewerRegion* regionp = *curiter; F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ(); F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); if (!regionp->getLand().hasZData() || gCamera->sphereInFrustum(regionp->getCenterAgent(), radius)) { - mCulledRegionList.removeCurrentData(); - mVisibleRegionList.addDataAtEnd(regionp); + mCulledRegionList.erase(curiter); + mVisibleRegionList.push_back(regionp); } } - F32 last_dist_squared = 0.0f; - F32 dist_squared; - - // Update all of the visible regions and make single bubble-sort pass - for (regionp = mVisibleRegionList.getFirstData(); - regionp; - regionp = mVisibleRegionList.getNextData()) + // Update all of the visible regions + for (region_list_t::iterator iter = mVisibleRegionList.begin(); + iter != mVisibleRegionList.end(); ) { + region_list_t::iterator curiter = iter++; + LLViewerRegion* regionp = *curiter; if (!regionp->getLand().hasZData()) { continue; @@ -587,44 +570,35 @@ void LLWorld::updateVisibilities() F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); if (gCamera->sphereInFrustum(regionp->getCenterAgent(), radius)) { + regionp->calculateCameraDistance(); if (!gNoRender) { regionp->getLand().updatePatchVisibilities(gAgent); } - - // sort by distance... closer regions to the front - // Note: regions use absolute frame so we use the agent's center - dist_squared = (F32)(gAgent.getCameraPositionGlobal() - regionp->getCenterGlobal()).magVecSquared(); - if (dist_squared < last_dist_squared) - { - mVisibleRegionList.swapCurrentWithPrevious(); - } - else - { - last_dist_squared = dist_squared; - } } else { - mVisibleRegionList.removeCurrentData(); - mCulledRegionList.addData(regionp); + mVisibleRegionList.erase(curiter); + mCulledRegionList.push_back(regionp); } } + // Sort visible regions + mVisibleRegionList.sort(LLViewerRegion::CompareDistance()); + gCamera->setFar(cur_far_clip); } void LLWorld::updateRegions(F32 max_update_time) { - LLViewerRegion *regionp; LLTimer update_timer; BOOL did_one = FALSE; // Perform idle time updates for the regions (and associated surfaces) - for (regionp = mRegionList.getFirstData(); - regionp; - regionp = mRegionList.getNextData()) + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; F32 max_time = max_update_time - update_timer.getElapsedTimeF32(); if (did_one && max_time <= 0.f) break; @@ -645,47 +619,45 @@ void LLWorld::updateClouds(const F32 dt) // don't move clouds in snapshot mode return; } - LLViewerRegion *regionp; - if (mActiveRegionList.getLength()) + if (mActiveRegionList.size()) { // Update all the cloud puff positions, and timer based stuff // such as death decay - for (regionp = mActiveRegionList.getFirstData(); - regionp; - regionp = mActiveRegionList.getNextData()) + for (region_list_t::iterator iter = mActiveRegionList.begin(); + iter != mActiveRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; regionp->mCloudLayer.updatePuffs(dt); } // Reshuffle who owns which puffs - for (regionp = mActiveRegionList.getFirstData(); - regionp; - regionp = mActiveRegionList.getNextData()) + for (region_list_t::iterator iter = mActiveRegionList.begin(); + iter != mActiveRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; regionp->mCloudLayer.updatePuffOwnership(); } // Add new puffs - for (regionp = mActiveRegionList.getFirstData(); - regionp; - regionp = mActiveRegionList.getNextData()) + for (region_list_t::iterator iter = mActiveRegionList.begin(); + iter != mActiveRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; regionp->mCloudLayer.updatePuffCount(); } } } -LLCloudGroup *LLWorld::findCloudGroup(const LLCloudPuff &puff) +LLCloudGroup* LLWorld::findCloudGroup(const LLCloudPuff &puff) { - LLViewerRegion *regionp; - if (mActiveRegionList.getLength()) + if (mActiveRegionList.size()) { // Update all the cloud puff positions, and timer based stuff // such as death decay - for (regionp = mActiveRegionList.getFirstData(); - regionp; - regionp = mActiveRegionList.getNextData()) + for (region_list_t::iterator iter = mActiveRegionList.begin(); + iter != mActiveRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; LLCloudGroup *groupp = regionp->mCloudLayer.findCloudGroup(puff); if (groupp) { @@ -702,11 +674,12 @@ void LLWorld::renderPropertyLines() S32 region_count = 0; S32 vertex_count = 0; - LLViewerRegion* region; - for (region = mVisibleRegionList.getFirstData(); region; region = mVisibleRegionList.getNextData() ) + for (region_list_t::iterator iter = mVisibleRegionList.begin(); + iter != mVisibleRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; region_count++; - vertex_count += region->renderPropertyLines(); + vertex_count += regionp->renderPropertyLines(); } } @@ -715,10 +688,11 @@ void LLWorld::updateNetStats() { F32 bits = 0.f; U32 packets = 0; - LLViewerRegion *regionp; - for (regionp = mActiveRegionList.getFirstData(); regionp; regionp = mActiveRegionList.getNextData()) + for (region_list_t::iterator iter = mActiveRegionList.begin(); + iter != mActiveRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; regionp->updateNetStats(); bits += regionp->mBitStat.getCurrent(); packets += llfloor( regionp->mPacketsStat.getCurrent() ); @@ -753,27 +727,24 @@ void LLWorld::updateNetStats() void LLWorld::printPacketsLost() { - LLViewerRegion *regionp; - llinfos << "Simulators:" << llendl; llinfos << "----------" << llendl; LLCircuitData *cdp = NULL; - for (regionp = mActiveRegionList.getFirstData(); - regionp; - regionp = mActiveRegionList.getNextData()) + for (region_list_t::iterator iter = mActiveRegionList.begin(); + iter != mActiveRegionList.end(); ++iter) + { + LLViewerRegion* regionp = *iter; + cdp = gMessageSystem->mCircuitInfo.findCircuit(regionp->getHost()); + if (cdp) { - cdp = gMessageSystem->mCircuitInfo.findCircuit(regionp->getHost()); - if (cdp) - { - LLVector3d range = regionp->getCenterGlobal() - gAgent.getPositionGlobal(); + LLVector3d range = regionp->getCenterGlobal() - gAgent.getPositionGlobal(); - llinfos << regionp->getHost() << ", range: " << range.magVec() << - " packets lost: " << - cdp->getPacketsLost() << llendl; - } + llinfos << regionp->getHost() << ", range: " << range.magVec() + << " packets lost: " << cdp->getPacketsLost() << llendl; } - + } + llinfos << "UserServer:" << llendl; llinfos << "-----------" << llendl; @@ -786,9 +757,11 @@ void LLWorld::printPacketsLost() void LLWorld::processCoarseUpdate(LLMessageSystem* msg, void** user_data) { - LLViewerRegion* region = NULL; - region = gWorldp->getRegion(msg->getSender()); - if( region ) region->updateCoarseLocations(msg); + LLViewerRegion* region = gWorldp->getRegion(msg->getSender()); + if( region ) + { + region->updateCoarseLocations(msg); + } } F32 LLWorld::getLandFarClip() const @@ -809,49 +782,55 @@ void LLWorld::updateWaterObjects() { return; } - S32 min_x, min_y, max_x, max_y; - U32 region_x, region_y; - - S32 rwidth = llfloor(getRegionWidthInMeters()); - - // First, determine the min and max "box" of water objects - LLViewerRegion *regionp; - regionp = mRegionList.getFirstData(); - - if (!regionp) + if (mRegionList.empty()) { llwarns << "No regions!" << llendl; return; } - from_region_handle(regionp->getHandle(), ®ion_x, ®ion_y); - min_x = max_x = region_x; - min_y = max_y = region_y; + // First, determine the min and max "box" of water objects + bool first = true; + S32 min_x, min_y, max_x, max_y; + U32 region_x, region_y; - LLVOWater *waterp; + S32 rwidth = llfloor(getRegionWidthInMeters()); - for (; regionp; regionp = mRegionList.getNextData()) + + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; from_region_handle(regionp->getHandle(), ®ion_x, ®ion_y); - min_x = llmin(min_x, (S32)region_x); - min_y = llmin(min_y, (S32)region_y); - max_x = llmax(max_x, (S32)region_x); - max_y = llmax(max_y, (S32)region_y); - waterp = regionp->getLand().getWaterObj(); + if (first) + { + first = false; + min_x = max_x = region_x; + min_y = max_y = region_y; + } + else + { + min_x = llmin(min_x, (S32)region_x); + min_y = llmin(min_y, (S32)region_y); + max_x = llmax(max_x, (S32)region_x); + max_y = llmax(max_y, (S32)region_y); + } + LLVOWater* waterp = regionp->getLand().getWaterObj(); if (waterp) { gObjectList.updateActive(waterp); } } - for (waterp = mHoleWaterObjects.getFirstData(); waterp; waterp = mHoleWaterObjects.getNextData()) + for (std::list<LLVOWater*>::iterator iter = mHoleWaterObjects.begin(); + iter != mHoleWaterObjects.end(); ++ iter) { + LLVOWater* waterp = *iter; gObjectList.killObject(waterp); } - mHoleWaterObjects.removeAllNodes(); + mHoleWaterObjects.clear(); // We only want to fill in holes for stuff that's near us, say, within 512m - regionp = gAgent.getRegion(); + LLViewerRegion* regionp = gAgent.getRegion(); from_region_handle(regionp->getHandle(), ®ion_x, ®ion_y); min_x = llmax((S32)region_x - 512, min_x); @@ -868,14 +847,14 @@ void LLWorld::updateWaterObjects() U64 region_handle = to_region_handle(x, y); if (!getRegionFromHandle(region_handle)) { - waterp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, gAgent.getRegion()); + LLVOWater* waterp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, gAgent.getRegion()); waterp->setUseTexture(FALSE); gPipeline.addObject(waterp); waterp->setPositionGlobal(LLVector3d(x + rwidth/2, y + rwidth/2, DEFAULT_WATER_HEIGHT)); waterp->setScale(LLVector3((F32)rwidth, (F32)rwidth, 0.f)); - mHoleWaterObjects.addData(waterp); + mHoleWaterObjects.push_back(waterp); } } } @@ -924,7 +903,7 @@ void LLWorld::updateWaterObjects() const S32 water_center_y = center_y + llround((wy + dim[1]) * 0.5f * gDirAxes[dir][1]); - waterp = mEdgeWaterObjects[dir]; + LLVOWater* waterp = mEdgeWaterObjects[dir]; if (!waterp || waterp->isDead()) { // The edge water objects can be dead because they're attached to the region that the @@ -952,7 +931,7 @@ void LLWorld::updateWaterObjects() //llinfos << "End water update" << llendl; } -LLViewerImage *LLWorld::getDefaultWaterTexture() +LLViewerImage* LLWorld::getDefaultWaterTexture() { return mDefaultWaterTexturep; } @@ -969,10 +948,10 @@ U64 LLWorld::getSpaceTimeUSec() const void LLWorld::requestCacheMisses() { - for(LLViewerRegion* regionp = mRegionList.getFirstData(); - regionp; - regionp = mRegionList.getNextData()) + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; regionp->requestCacheMisses(); } } @@ -980,10 +959,10 @@ void LLWorld::requestCacheMisses() LLString LLWorld::getInfoString() { LLString info_string("World Info:\n"); - for (LLViewerRegion* regionp = mRegionList.getFirstData(); - regionp; - regionp = mRegionList.getNextData()) + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; info_string += regionp->getInfoString(); } return info_string; @@ -992,10 +971,10 @@ LLString LLWorld::getInfoString() void LLWorld::disconnectRegions() { LLMessageSystem* msg = gMessageSystem; - for(LLViewerRegion* regionp = mRegionList.getFirstData(); - regionp; - regionp = mRegionList.getNextData()) + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; if (regionp == gAgent.getRegion()) { // Skip the main agent @@ -1075,8 +1054,11 @@ void process_region_handshake(LLMessageSystem* msg, void** user_data) void send_agent_pause() { // world not initialized yet - if (!gWorldp) return; - + if (!gWorldp) + { + return; + } + gMessageSystem->newMessageFast(_PREHASH_AgentPause); gMessageSystem->nextBlockFast(_PREHASH_AgentData); gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgentID); @@ -1085,11 +1067,10 @@ void send_agent_pause() gAgentPauseSerialNum++; gMessageSystem->addU32Fast(_PREHASH_SerialNum, gAgentPauseSerialNum); - LLViewerRegion *regionp; - for (regionp = gWorldp->mActiveRegionList.getFirstData(); - regionp; - regionp = gWorldp->mActiveRegionList.getNextData()) + for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin(); + iter != gWorldp->mActiveRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; gMessageSystem->sendReliable(regionp->getHost()); } @@ -1113,11 +1094,10 @@ void send_agent_resume() gMessageSystem->addU32Fast(_PREHASH_SerialNum, gAgentPauseSerialNum); - LLViewerRegion *regionp; - for (regionp = gWorldp->mActiveRegionList.getFirstData(); - regionp; - regionp = gWorldp->mActiveRegionList.getNextData()) + for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin(); + iter != gWorldp->mActiveRegionList.end(); ++iter) { + LLViewerRegion* regionp = *iter; gMessageSystem->sendReliable(regionp->getHost()); } diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h index 0d0d1b3211..4c1dc0343e 100644 --- a/indra/newview/llworld.h +++ b/indra/newview/llworld.h @@ -10,8 +10,6 @@ #define LL_LLWORLD_H #include "llpatchvertexarray.h" -#include "doublelinkedlist.h" -#include "linked_lists.h" #include "llmath.h" //#include "vmath.h" @@ -122,14 +120,17 @@ public: U64 getSpaceTimeUSec() const; LLString getInfoString(); + public: - LLDoubleLinkedList<LLViewerRegion> mActiveRegionList; + typedef std::list<LLViewerRegion*> region_list_t; + + region_list_t mActiveRegionList; LLViewerPartSim mPartSim; private: - LLLinkedList<LLViewerRegion> mRegionList; - LLDoubleLinkedList<LLViewerRegion> mVisibleRegionList; - LLDoubleLinkedList<LLViewerRegion> mCulledRegionList; + region_list_t mRegionList; + region_list_t mVisibleRegionList; + region_list_t mCulledRegionList; // Number of points on edge const U32 mWidth; @@ -156,7 +157,7 @@ private: U32 mMinRegionY; U32 mMaxRegionY; - LLLinkedList<LLVOWater> mHoleWaterObjects; + std::list<LLVOWater*> mHoleWaterObjects; LLPointer<LLVOWater> mEdgeWaterObjects[8]; LLPointer<LLViewerImage> mDefaultWaterTexturep; diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index fde1411563..9d2fb122e5 100644 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -1770,7 +1770,7 @@ BOOL outside_slop(S32 x, S32 y, S32 start_x, S32 start_y) BOOL LLWorldMapView::handleMouseDown( S32 x, S32 y, MASK mask ) { - gFocusMgr.setMouseCapture( this, NULL ); + gFocusMgr.setMouseCapture( this ); mMouseDownPanX = llround(sPanX); mMouseDownPanY = llround(sPanY); @@ -1782,7 +1782,7 @@ BOOL LLWorldMapView::handleMouseDown( S32 x, S32 y, MASK mask ) BOOL LLWorldMapView::handleMouseUp( S32 x, S32 y, MASK mask ) { - if (this == gFocusMgr.getMouseCapture()) + if (hasMouseCapture()) { if (mPanning) { @@ -1809,7 +1809,7 @@ BOOL LLWorldMapView::handleMouseUp( S32 x, S32 y, MASK mask ) handleClick(x, y, mask, &hit_type, &id); } gViewerWindow->showCursor(); - gFocusMgr.setMouseCapture( NULL, NULL ); + gFocusMgr.setMouseCapture( NULL ); return TRUE; } return FALSE; @@ -1855,7 +1855,7 @@ void LLWorldMapView::updateVisibleBlocks() BOOL LLWorldMapView::handleHover( S32 x, S32 y, MASK mask ) { - if (this == gFocusMgr.getMouseCapture()) + if (hasMouseCapture()) { if (mPanning || outside_slop(x, y, mMouseDownX, mMouseDownY)) { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6b7f60457d..52ceb481d9 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -71,6 +71,8 @@ #include "viewer.h" #include "llcubemap.h" #include "lldebugmessagebox.h" +#include "llglslshader.h" +#include "llviewerjoystick.h" #ifdef _DEBUG // Debug indices is disabled for now for debug performance - djs 4/24/02 @@ -110,84 +112,6 @@ S32 gTrivialAccepts = 0; BOOL gRenderForSelect = FALSE; -//glsl parameter tables -const char* LLPipeline::sReservedAttribs[] = -{ - "materialColor", - "specularColor", - "binormal" -}; - -U32 LLPipeline::sReservedAttribCount = LLPipeline::GLSL_END_RESERVED_ATTRIBS; - -const char* LLPipeline::sAvatarAttribs[] = -{ - "weight", - "clothing", - "gWindDir", - "gSinWaveParams", - "gGravity" -}; - -U32 LLPipeline::sAvatarAttribCount = sizeof(LLPipeline::sAvatarAttribs)/sizeof(char*); - -const char* LLPipeline::sAvatarUniforms[] = -{ - "matrixPalette" -}; - -U32 LLPipeline::sAvatarUniformCount = 1; - -const char* LLPipeline::sReservedUniforms[] = -{ - "diffuseMap", - "specularMap", - "bumpMap", - "environmentMap", - "scatterMap" -}; - -U32 LLPipeline::sReservedUniformCount = LLPipeline::GLSL_END_RESERVED_UNIFORMS; - -const char* LLPipeline::sTerrainUniforms[] = -{ - "detail0", - "detail1", - "alphaRamp" -}; - -U32 LLPipeline::sTerrainUniformCount = sizeof(LLPipeline::sTerrainUniforms)/sizeof(char*); - -const char* LLPipeline::sGlowUniforms[] = -{ - "delta" -}; - -U32 LLPipeline::sGlowUniformCount = sizeof(LLPipeline::sGlowUniforms)/sizeof(char*); - -const char* LLPipeline::sShinyUniforms[] = -{ - "origin" -}; - -U32 LLPipeline::sShinyUniformCount = sizeof(LLPipeline::sShinyUniforms)/sizeof(char*); - -const char* LLPipeline::sWaterUniforms[] = -{ - "screenTex", - "eyeVec", - "time", - "d1", - "d2", - "lightDir", - "specular", - "lightExp", - "fbScale", - "refScale" -}; - -U32 LLPipeline::sWaterUniformCount = sizeof(LLPipeline::sWaterUniforms)/sizeof(char*); - //---------------------------------------- void stamp(F32 x, F32 y, F32 xs, F32 ys) @@ -227,7 +151,6 @@ BOOL LLPipeline::sUseOcclusion = FALSE; BOOL LLPipeline::sSkipUpdate = FALSE; BOOL LLPipeline::sDynamicReflections = FALSE; BOOL LLPipeline::sRenderGlow = FALSE; -BOOL LLPipeline::sOverrideAgentCamera = FALSE; LLPipeline::LLPipeline() : mScreenTex(0), @@ -298,14 +221,7 @@ void LLPipeline::init() // Enable features stop_glerror(); - setShaders(); -} - -void LLPipeline::LLScatterShader::init(GLhandleARB shader, int map_stage) -{ - glUseProgramObjectARB(shader); - glUniform1iARB(glGetUniformLocationARB(shader, "scatterMap"), map_stage); - glUseProgramObjectARB(0); + LLShaderMgr::setShaders(); } LLPipeline::~LLPipeline() @@ -381,7 +297,6 @@ void LLPipeline::cleanup() } mObjectPartition.clear(); - mGroupQ.clear(); mVisibleList.clear(); mVisibleGroups.clear(); mDrawableGroups.clear(); @@ -400,7 +315,6 @@ void LLPipeline::destroyGL() stop_glerror(); unloadShaders(); mHighlightFaces.clear(); - mGroupQ.clear(); mVisibleList.clear(); mVisibleGroups.clear(); mDrawableGroups.clear(); @@ -460,7 +374,7 @@ void LLPipeline::restoreGL() if (mVertexShadersEnabled) { - setShaders(); + LLShaderMgr::setShaders(); } for (U32 i = 0; i < mObjectPartition.size()-1; i++) @@ -472,352 +386,6 @@ void LLPipeline::restoreGL() } } -//============================================================================ -// Load Shader - -static LLString get_object_log(GLhandleARB ret) -{ - LLString res; - - //get log length - GLint length; - glGetObjectParameterivARB(ret, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); - if (length > 0) - { - //the log could be any size, so allocate appropriately - GLcharARB* log = new GLcharARB[length]; - glGetInfoLogARB(ret, length, &length, log); - res = LLString(log); - delete[] log; - } - return res; -} - -void LLPipeline::dumpObjectLog(GLhandleARB ret, BOOL warns) -{ - LLString log = get_object_log(ret); - if (warns) - { - llwarns << log << llendl; - } - else - { - llinfos << log << llendl; - } -} - -GLhandleARB LLPipeline::loadShader(const LLString& filename, S32 cls, GLenum type) -{ - GLenum error; - error = glGetError(); - if (error != GL_NO_ERROR) - { - llwarns << "GL ERROR entering loadShader(): " << error << llendl; - } - - llinfos << "Loading shader file: " << filename << llendl; - - if (filename.empty()) - { - return 0; - } - - - //read in from file - FILE* file = NULL; - - S32 try_gpu_class = mVertexShaderLevel[cls]; - S32 gpu_class; - - //find the most relevant file - for (gpu_class = try_gpu_class; gpu_class > 0; gpu_class--) - { //search from the current gpu class down to class 1 to find the most relevant shader - std::stringstream fname; - fname << gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "shaders/class"); - fname << gpu_class << "/" << filename; - -// llinfos << "Looking in " << fname.str().c_str() << llendl; - file = fopen(fname.str().c_str(), "r"); /* Flawfinder: ignore */ - if (file) - { - break; // done - } - } - - if (file == NULL) - { - llinfos << "GLSL Shader file not found: " << filename << llendl; - return 0; - } - - //we can't have any lines longer than 1024 characters - //or any shaders longer than 1024 lines... deal - DaveP - GLcharARB buff[1024]; - GLcharARB* text[1024]; - GLuint count = 0; - - //copy file into memory - while(fgets(buff, 1024, file) != NULL) - { - text[count++] = strdup(buff); - } - fclose(file); - - //create shader object - GLhandleARB ret = glCreateShaderObjectARB(type); - error = glGetError(); - if (error != GL_NO_ERROR) - { - llwarns << "GL ERROR in glCreateShaderObjectARB: " << error << llendl; - } - else - { - //load source - glShaderSourceARB(ret, count, (const GLcharARB**) text, NULL); - error = glGetError(); - if (error != GL_NO_ERROR) - { - llwarns << "GL ERROR in glShaderSourceARB: " << error << llendl; - } - else - { - //compile source - glCompileShaderARB(ret); - error = glGetError(); - if (error != GL_NO_ERROR) - { - llwarns << "GL ERROR in glCompileShaderARB: " << error << llendl; - } - } - } - //free memory - for (GLuint i = 0; i < count; i++) - { - free(text[i]); - } - if (error == GL_NO_ERROR) - { - //check for errors - GLint success = GL_TRUE; - glGetObjectParameterivARB(ret, GL_OBJECT_COMPILE_STATUS_ARB, &success); - error = glGetError(); - if (error != GL_NO_ERROR || success == GL_FALSE) - { - //an error occured, print log - llwarns << "GLSL Compilation Error: (" << error << ") in " << filename << llendl; - dumpObjectLog(ret); - ret = 0; - } - } - else - { - ret = 0; - } - stop_glerror(); - - //successfully loaded, save results -#if 1 // 1.9.1 - if (ret) - { - mVertexShaderLevel[cls] = try_gpu_class; - } - else - { - if (mVertexShaderLevel[cls] > 1) - { - mVertexShaderLevel[cls] = mVertexShaderLevel[cls] - 1; - ret = loadShader(filename,cls,type); - if (ret && mMaxVertexShaderLevel[cls] > mVertexShaderLevel[cls]) - { - mMaxVertexShaderLevel[cls] = mVertexShaderLevel[cls]; - } - } - } -#else - if (ret) - { - S32 max = -1; - /*if (try_gpu_class == mMaxVertexShaderLevel[cls]) - { - max = gpu_class; - }*/ - saveVertexShaderLevel(cls,try_gpu_class,max); - } - else - { - if (mVertexShaderLevel[cls] > 1) - { - mVertexShaderLevel[cls] = mVertexShaderLevel[cls] - 1; - ret = loadShader(f,cls,type); - if (ret && mMaxVertexShaderLevel[cls] > mVertexShaderLevel[cls]) - { - saveVertexShaderLevel(cls, mVertexShaderLevel[cls], mVertexShaderLevel[cls]); - } - } - } -#endif - return ret; -} - -BOOL LLPipeline::linkProgramObject(GLhandleARB obj, BOOL suppress_errors) -{ - //check for errors - glLinkProgramARB(obj); - GLint success = GL_TRUE; - glGetObjectParameterivARB(obj, GL_OBJECT_LINK_STATUS_ARB, &success); - if (!suppress_errors && success == GL_FALSE) - { - //an error occured, print log - llwarns << "GLSL Linker Error:" << llendl; - } - - LLString log = get_object_log(obj); - LLString::toLower(log); - if (log.find("software") != LLString::npos) - { - llwarns << "GLSL Linker: Running in Software:" << llendl; - success = GL_FALSE; - suppress_errors = FALSE; - } - if (!suppress_errors) - { - dumpObjectLog(obj, !success); - } - - return success; -} - -BOOL LLPipeline::validateProgramObject(GLhandleARB obj) -{ - //check program validity against current GL - glValidateProgramARB(obj); - GLint success = GL_TRUE; - glGetObjectParameterivARB(obj, GL_OBJECT_VALIDATE_STATUS_ARB, &success); - if (success == GL_FALSE) - { - llwarns << "GLSL program not valid: " << llendl; - dumpObjectLog(obj); - } - else - { - dumpObjectLog(obj, FALSE); - } - - return success; -} - -//============================================================================ -// Shader Management - -void LLPipeline::setShaders() -{ - if (gGLManager.mHasFramebufferObject) - { - sDynamicReflections = gSavedSettings.getBOOL("RenderDynamicReflections"); - sRenderGlow = gSavedSettings.getBOOL("RenderGlow"); - } - else - { - sDynamicReflections = sRenderGlow = FALSE; - } - - //hack to reset buffers that change behavior with shaders - resetVertexBuffers(); - - if (gViewerWindow) - { - gViewerWindow->setCursor(UI_CURSOR_WAIT); - } - - // Lighting - setLightingDetail(-1); - - // Shaders - for (S32 i=0; i<SHADER_COUNT; i++) - { - mVertexShaderLevel[i] = 0; - mMaxVertexShaderLevel[i] = 0; - } - if (canUseVertexShaders()) - { - S32 light_class = 2; - S32 env_class = 2; - S32 obj_class = 0; - - if (getLightingDetail() == 0) - { - light_class = 1; - } - // Load lighting shaders - mVertexShaderLevel[SHADER_LIGHTING] = light_class; - mMaxVertexShaderLevel[SHADER_LIGHTING] = light_class; - mVertexShaderLevel[SHADER_ENVIRONMENT] = env_class; - mMaxVertexShaderLevel[SHADER_ENVIRONMENT] = env_class; - mVertexShaderLevel[SHADER_OBJECT] = obj_class; - mMaxVertexShaderLevel[SHADER_OBJECT] = obj_class; - - BOOL loaded = loadShadersLighting(); - - if (loaded) - { - mVertexShadersEnabled = TRUE; - mVertexShadersLoaded = 1; - - // Load all shaders to set max levels - loadShadersEnvironment(); - loadShadersObject(); - // Load max avatar shaders to set the max level - mVertexShaderLevel[SHADER_AVATAR] = 3; - mMaxVertexShaderLevel[SHADER_AVATAR] = 3; - loadShadersAvatar(); - - // Load shaders to correct levels - if (!gSavedSettings.getBOOL("RenderRippleWater")) - { - mVertexShaderLevel[SHADER_ENVIRONMENT] = 0; - loadShadersEnvironment(); // unloads - } - -#if LL_DARWIN // force avatar shaders off for mac - mVertexShaderLevel[SHADER_AVATAR] = 0; - mMaxVertexShaderLevel[SHADER_AVATAR] = 0; -#else - if (gSavedSettings.getBOOL("RenderAvatarVP")) - { - S32 avatar = gSavedSettings.getS32("RenderAvatarMode"); - S32 avatar_class = 1 + avatar; - // Set the actual level - mVertexShaderLevel[SHADER_AVATAR] = avatar_class; - loadShadersAvatar(); - if (mVertexShaderLevel[SHADER_AVATAR] != avatar_class) - { - if (mVertexShaderLevel[SHADER_AVATAR] == 0) - { - gSavedSettings.setBOOL("RenderAvatarVP", FALSE); - } - avatar = llmax(mVertexShaderLevel[SHADER_AVATAR]-1,0); - gSavedSettings.setS32("RenderAvatarMode", avatar); - } - } - else - { - mVertexShaderLevel[SHADER_AVATAR] = 0; - gSavedSettings.setS32("RenderAvatarMode", 0); - loadShadersAvatar(); // unloads - } -#endif - } - else - { - mVertexShadersEnabled = FALSE; - mVertexShadersLoaded = 0; - } - } - if (gViewerWindow) - { - gViewerWindow->setCursor(UI_CURSOR_ARROW); - } -} BOOL LLPipeline::canUseVertexShaders() { @@ -836,490 +404,10 @@ BOOL LLPipeline::canUseVertexShaders() void LLPipeline::unloadShaders() { - mObjectSimpleProgram.unload(); - mObjectShinyProgram.unload(); - mObjectBumpProgram.unload(); - mObjectAlphaProgram.unload(); - mWaterProgram.unload(); - mTerrainProgram.unload(); - mGlowProgram.unload(); - mGroundProgram.unload(); - mAvatarProgram.unload(); - mAvatarEyeballProgram.unload(); - mAvatarPickProgram.unload(); - mHighlightProgram.unload(); - - mVertexShaderLevel[SHADER_LIGHTING] = 0; - mVertexShaderLevel[SHADER_OBJECT] = 0; - mVertexShaderLevel[SHADER_AVATAR] = 0; - mVertexShaderLevel[SHADER_ENVIRONMENT] = 0; - mVertexShaderLevel[SHADER_INTERFACE] = 0; - - mLightVertex = mLightFragment = mScatterVertex = mScatterFragment = 0; + LLShaderMgr::unloadShaders(); mVertexShadersLoaded = 0; } -#if 0 // 1.9.2 -// Any time shader options change -BOOL LLPipeline::loadShaders() -{ - unloadShaders(); - - if (!canUseVertexShaders()) - { - return FALSE; - } - - S32 light_class = mMaxVertexShaderLevel[SHADER_LIGHTING]; - if (getLightingDetail() == 0) - { - light_class = 1; // Use minimum lighting shader - } - else if (getLightingDetail() == 1) - { - light_class = 2; // Use medium lighting shader - } - mVertexShaderLevel[SHADER_LIGHTING] = light_class; - //mVertexShaderLevel[SHADER_OBJECT] = llmin(mMaxVertexShaderLevel[SHADER_OBJECT], gSavedSettings.getS32("VertexShaderLevelObject")); - mVertexShaderLevel[SHADER_OBJECT] = 0; - mVertexShaderLevel[SHADER_AVATAR] = llmin(mMaxVertexShaderLevel[SHADER_AVATAR], gSavedSettings.getS32("VertexShaderLevelAvatar")); - mVertexShaderLevel[SHADER_ENVIRONMENT] = llmin(mMaxVertexShaderLevel[SHADER_ENVIRONMENT], gSavedSettings.getS32("VertexShaderLevelEnvironment")); - mVertexShaderLevel[SHADER_INTERFACE] = mMaxVertexShaderLevel[SHADER_INTERFACE]; - - BOOL loaded = loadShadersLighting(); - if (loaded) - { - loadShadersEnvironment(); // Must load this before object/avatar for scatter - loadShadersObject(); - loadShadersAvatar(); - loadShadersInterface(); - mVertexShadersLoaded = 1; - } - else - { - unloadShaders(); - mVertexShadersEnabled = FALSE; - mVertexShadersLoaded = 0; //-1; // -1 = failed - setLightingDetail(-1); - } - - return loaded; -} -#endif - -BOOL LLPipeline::loadShadersLighting() -{ - // Load light dependency shaders first - // All of these have to load for any shaders to function - - std::string lightvertex = "lighting/lightV.glsl"; - //get default light function implementation - mLightVertex = loadShader(lightvertex, SHADER_LIGHTING, GL_VERTEX_SHADER_ARB); - if( !mLightVertex ) - { - llwarns << "Failed to load " << lightvertex << llendl; - return FALSE; - } - - std::string lightfragment = "lighting/lightF.glsl"; - mLightFragment = loadShader(lightfragment, SHADER_LIGHTING, GL_FRAGMENT_SHADER_ARB); - if ( !mLightFragment ) - { - llwarns << "Failed to load " << lightfragment << llendl; - return FALSE; - } - - // NOTE: Scatter shaders use the ENVIRONMENT detail level - - std::string scattervertex = "environment/scatterV.glsl"; - mScatterVertex = loadShader(scattervertex, SHADER_ENVIRONMENT, GL_VERTEX_SHADER_ARB); - if ( !mScatterVertex ) - { - llwarns << "Failed to load " << scattervertex << llendl; - return FALSE; - } - - std::string scatterfragment = "environment/scatterF.glsl"; - mScatterFragment = loadShader(scatterfragment, SHADER_ENVIRONMENT, GL_FRAGMENT_SHADER_ARB); - if ( !mScatterFragment ) - { - llwarns << "Failed to load " << scatterfragment << llendl; - return FALSE; - } - - return TRUE; -} - -BOOL LLPipeline::loadShadersEnvironment() -{ - GLhandleARB baseObjects[] = - { - mLightFragment, - mLightVertex, - mScatterFragment, - mScatterVertex - }; - S32 baseCount = 4; - - BOOL success = TRUE; - - if (mVertexShaderLevel[SHADER_ENVIRONMENT] == 0) - { - mWaterProgram.unload(); - mGroundProgram.unload(); - mTerrainProgram.unload(); - mGlowProgram.unload(); - return FALSE; - } - - if (success) - { - //load water vertex shader - std::string waterfragment = "environment/waterF.glsl"; - std::string watervertex = "environment/waterV.glsl"; - mWaterProgram.mProgramObject = glCreateProgramObjectARB(); - mWaterProgram.attachObjects(baseObjects, baseCount); - mWaterProgram.attachObject(loadShader(watervertex, SHADER_ENVIRONMENT, GL_VERTEX_SHADER_ARB)); - mWaterProgram.attachObject(loadShader(waterfragment, SHADER_ENVIRONMENT, GL_FRAGMENT_SHADER_ARB)); - - success = mWaterProgram.mapAttributes(); - if (success) - { - success = mWaterProgram.mapUniforms(sWaterUniforms, sWaterUniformCount); - } - if (!success) - { - llwarns << "Failed to load " << watervertex << llendl; - } - } - if (success) - { - //load ground vertex shader - std::string groundvertex = "environment/groundV.glsl"; - std::string groundfragment = "environment/groundF.glsl"; - mGroundProgram.mProgramObject = glCreateProgramObjectARB(); - mGroundProgram.attachObjects(baseObjects, baseCount); - mGroundProgram.attachObject(loadShader(groundvertex, SHADER_ENVIRONMENT, GL_VERTEX_SHADER_ARB)); - mGroundProgram.attachObject(loadShader(groundfragment, SHADER_ENVIRONMENT, GL_FRAGMENT_SHADER_ARB)); - - success = mGroundProgram.mapAttributes(); - if (success) - { - success = mGroundProgram.mapUniforms(); - } - if (!success) - { - llwarns << "Failed to load " << groundvertex << llendl; - } - } - - if (success) - { - //load terrain vertex shader - std::string terrainvertex = "environment/terrainV.glsl"; - std::string terrainfragment = "environment/terrainF.glsl"; - mTerrainProgram.mProgramObject = glCreateProgramObjectARB(); - mTerrainProgram.attachObjects(baseObjects, baseCount); - mTerrainProgram.attachObject(loadShader(terrainvertex, SHADER_ENVIRONMENT, GL_VERTEX_SHADER_ARB)); - mTerrainProgram.attachObject(loadShader(terrainfragment, SHADER_ENVIRONMENT, GL_FRAGMENT_SHADER_ARB)); - success = mTerrainProgram.mapAttributes(); - if (success) - { - success = mTerrainProgram.mapUniforms(sTerrainUniforms, sTerrainUniformCount); - } - if (!success) - { - llwarns << "Failed to load " << terrainvertex << llendl; - } - } - - if (success) - { - //load glow shader - std::string glowvertex = "environment/glowV.glsl"; - std::string glowfragment = "environment/glowF.glsl"; - mGlowProgram.mProgramObject = glCreateProgramObjectARB(); - mGlowProgram.attachObjects(baseObjects, baseCount); - mGlowProgram.attachObject(loadShader(glowvertex, SHADER_ENVIRONMENT, GL_VERTEX_SHADER_ARB)); - mGlowProgram.attachObject(loadShader(glowfragment, SHADER_ENVIRONMENT, GL_FRAGMENT_SHADER_ARB)); - success = mGlowProgram.mapAttributes(); - if (success) - { - success = mGlowProgram.mapUniforms(sGlowUniforms, sGlowUniformCount); - } - if (!success) - { - llwarns << "Failed to load " << glowvertex << llendl; - } - } - - if( !success ) - { - mVertexShaderLevel[SHADER_ENVIRONMENT] = 0; - mMaxVertexShaderLevel[SHADER_ENVIRONMENT] = 0; - return FALSE; - } - - if (gWorldPointer) - { - gWorldPointer->updateWaterObjects(); - } - - return TRUE; -} - -BOOL LLPipeline::loadShadersObject() -{ - GLhandleARB baseObjects[] = - { - mLightFragment, - mLightVertex, - mScatterFragment, - mScatterVertex - }; - S32 baseCount = 4; - - BOOL success = TRUE; - - if (mVertexShaderLevel[SHADER_OBJECT] == 0) - { - mObjectShinyProgram.unload(); - mObjectSimpleProgram.unload(); - mObjectBumpProgram.unload(); - mObjectAlphaProgram.unload(); - return FALSE; - } - -#if 0 - if (success) - { - //load object (volume/tree) vertex shader - std::string simplevertex = "objects/simpleV.glsl"; - std::string simplefragment = "objects/simpleF.glsl"; - mObjectSimpleProgram.mProgramObject = glCreateProgramObjectARB(); - mObjectSimpleProgram.attachObjects(baseObjects, baseCount); - mObjectSimpleProgram.attachObject(loadShader(simplevertex, SHADER_OBJECT, GL_VERTEX_SHADER_ARB)); - mObjectSimpleProgram.attachObject(loadShader(simplefragment, SHADER_OBJECT, GL_FRAGMENT_SHADER_ARB)); - success = mObjectSimpleProgram.mapAttributes(); - if (success) - { - success = mObjectSimpleProgram.mapUniforms(); - } - if( !success ) - { - llwarns << "Failed to load " << simplevertex << llendl; - } - } - - if (success) - { - //load object bumpy vertex shader - std::string bumpshinyvertex = "objects/bumpshinyV.glsl"; - std::string bumpshinyfragment = "objects/bumpshinyF.glsl"; - mObjectBumpProgram.mProgramObject = glCreateProgramObjectARB(); - mObjectBumpProgram.attachObjects(baseObjects, baseCount); - mObjectBumpProgram.attachObject(loadShader(bumpshinyvertex, SHADER_OBJECT, GL_VERTEX_SHADER_ARB)); - mObjectBumpProgram.attachObject(loadShader(bumpshinyfragment, SHADER_OBJECT, GL_FRAGMENT_SHADER_ARB)); - success = mObjectBumpProgram.mapAttributes(); - if (success) - { - success = mObjectBumpProgram.mapUniforms(); - } - if( !success ) - { - llwarns << "Failed to load " << bumpshinyvertex << llendl; - } - } - - if (success) - { - //load object alpha vertex shader - std::string alphavertex = "objects/alphaV.glsl"; - std::string alphafragment = "objects/alphaF.glsl"; - mObjectAlphaProgram.mProgramObject = glCreateProgramObjectARB(); - mObjectAlphaProgram.attachObjects(baseObjects, baseCount); - mObjectAlphaProgram.attachObject(loadShader(alphavertex, SHADER_OBJECT, GL_VERTEX_SHADER_ARB)); - mObjectAlphaProgram.attachObject(loadShader(alphafragment, SHADER_OBJECT, GL_FRAGMENT_SHADER_ARB)); - - success = mObjectAlphaProgram.mapAttributes(); - if (success) - { - success = mObjectAlphaProgram.mapUniforms(); - } - if( !success ) - { - llwarns << "Failed to load " << alphavertex << llendl; - } - } -#endif - - if (success) - { - //load shiny vertex shader - std::string shinyvertex = "objects/shinyV.glsl"; - std::string shinyfragment = "objects/shinyF.glsl"; - mObjectShinyProgram.mProgramObject = glCreateProgramObjectARB(); - mObjectShinyProgram.attachObjects(baseObjects, baseCount); - mObjectShinyProgram.attachObject(loadShader(shinyvertex, SHADER_OBJECT, GL_VERTEX_SHADER_ARB)); - mObjectShinyProgram.attachObject(loadShader(shinyfragment, SHADER_OBJECT, GL_FRAGMENT_SHADER_ARB)); - - success = mObjectShinyProgram.mapAttributes(); - if (success) - { - success = mObjectShinyProgram.mapUniforms(LLPipeline::sShinyUniforms, LLPipeline::sShinyUniformCount); - } - if( !success ) - { - llwarns << "Failed to load " << shinyvertex << llendl; - } - } - - if( !success ) - { - mVertexShaderLevel[SHADER_OBJECT] = 0; - mMaxVertexShaderLevel[SHADER_OBJECT] = 0; - return FALSE; - } - - return TRUE; -} - -BOOL LLPipeline::loadShadersAvatar() -{ - GLhandleARB baseObjects[] = - { - mLightFragment, - mLightVertex, - mScatterFragment, - mScatterVertex - }; - S32 baseCount = 4; - - BOOL success = TRUE; - - if (mVertexShaderLevel[SHADER_AVATAR] == 0) - { - mAvatarProgram.unload(); - mAvatarEyeballProgram.unload(); - mAvatarPickProgram.unload(); - return FALSE; - } - - if (success) - { - //load specular (eyeball) vertex program - std::string eyeballvertex = "avatar/eyeballV.glsl"; - std::string eyeballfragment = "avatar/eyeballF.glsl"; - mAvatarEyeballProgram.mProgramObject = glCreateProgramObjectARB(); - mAvatarEyeballProgram.attachObjects(baseObjects, baseCount); - mAvatarEyeballProgram.attachObject(loadShader(eyeballvertex, SHADER_AVATAR, GL_VERTEX_SHADER_ARB)); - mAvatarEyeballProgram.attachObject(loadShader(eyeballfragment, SHADER_AVATAR, GL_FRAGMENT_SHADER_ARB)); - success = mAvatarEyeballProgram.mapAttributes(); - if (success) - { - success = mAvatarEyeballProgram.mapUniforms(); - } - if( !success ) - { - llwarns << "Failed to load " << eyeballvertex << llendl; - } - } - - if (success) - { - mAvatarSkinVertex = loadShader("avatar/avatarSkinV.glsl", SHADER_AVATAR, GL_VERTEX_SHADER_ARB); - //load avatar vertex shader - std::string avatarvertex = "avatar/avatarV.glsl"; - std::string avatarfragment = "avatar/avatarF.glsl"; - - mAvatarProgram.mProgramObject = glCreateProgramObjectARB(); - mAvatarProgram.attachObjects(baseObjects, baseCount); - mAvatarProgram.attachObject(mAvatarSkinVertex); - mAvatarProgram.attachObject(loadShader(avatarvertex, SHADER_AVATAR, GL_VERTEX_SHADER_ARB)); - mAvatarProgram.attachObject(loadShader(avatarfragment, SHADER_AVATAR, GL_FRAGMENT_SHADER_ARB)); - - success = mAvatarProgram.mapAttributes(sAvatarAttribs, sAvatarAttribCount); - if (success) - { - success = mAvatarProgram.mapUniforms(sAvatarUniforms, sAvatarUniformCount); - } - if( !success ) - { - llwarns << "Failed to load " << avatarvertex << llendl; - } - } - - if (success) - { - //load avatar picking shader - std::string pickvertex = "avatar/pickAvatarV.glsl"; - std::string pickfragment = "avatar/pickAvatarF.glsl"; - mAvatarPickProgram.mProgramObject = glCreateProgramObjectARB(); - mAvatarPickProgram.attachObject(loadShader(pickvertex, SHADER_AVATAR, GL_VERTEX_SHADER_ARB)); - mAvatarPickProgram.attachObject(loadShader(pickfragment, SHADER_AVATAR, GL_FRAGMENT_SHADER_ARB)); - mAvatarPickProgram.attachObject(mAvatarSkinVertex); - - success = mAvatarPickProgram.mapAttributes(sAvatarAttribs, sAvatarAttribCount); - if (success) - { - success = mAvatarPickProgram.mapUniforms(sAvatarUniforms, sAvatarUniformCount); - } - if( !success ) - { - llwarns << "Failed to load " << pickvertex << llendl; - } - } - - if( !success ) - { - mVertexShaderLevel[SHADER_AVATAR] = 0; - mMaxVertexShaderLevel[SHADER_AVATAR] = 0; - return FALSE; - } - - return TRUE; -} - -BOOL LLPipeline::loadShadersInterface() -{ - BOOL success = TRUE; - - if (mVertexShaderLevel[SHADER_INTERFACE] == 0) - { - mHighlightProgram.unload(); - return FALSE; - } - - if (success) - { - //load highlighting shader - std::string highlightvertex = "interface/highlightV.glsl"; - std::string highlightfragment = "interface/highlightF.glsl"; - mHighlightProgram.mProgramObject = glCreateProgramObjectARB(); - mHighlightProgram.attachObject(loadShader(highlightvertex, SHADER_INTERFACE, GL_VERTEX_SHADER_ARB)); - mHighlightProgram.attachObject(loadShader(highlightfragment, SHADER_INTERFACE, GL_FRAGMENT_SHADER_ARB)); - - success = mHighlightProgram.mapAttributes(); - if (success) - { - success = mHighlightProgram.mapUniforms(); - } - if( !success ) - { - llwarns << "Failed to load " << highlightvertex << llendl; - } - } - - if( !success ) - { - mVertexShaderLevel[SHADER_INTERFACE] = 0; - mMaxVertexShaderLevel[SHADER_INTERFACE] = 0; - return FALSE; - } - - return TRUE; -} - //============================================================================ void LLPipeline::enableShadows(const BOOL enable_shadows) @@ -1357,7 +445,7 @@ S32 LLPipeline::setLightingDetail(S32 level) if (mVertexShadersLoaded == 1) { - gPipeline.setShaders(); + LLShaderMgr::setShaders(); } } return mLightingDetail; @@ -1384,7 +472,6 @@ public: if (mTextures.find(params->mTexture) != mTextures.end()) { group->setState(LLSpatialGroup::GEOM_DIRTY); - gPipeline.markRebuild(group); } } } @@ -1828,9 +915,6 @@ void LLPipeline::updateCull(LLCamera& camera) } } - //do a terse update on some off-screen geometry - processGeometry(camera); - if (gSky.mVOSkyp.notNull() && gSky.mVOSkyp->mDrawable.notNull()) { // Hack for sky - always visible. @@ -2171,11 +1255,6 @@ void LLPipeline::markTextured(LLDrawable *drawablep) } } -void LLPipeline::markRebuild(LLSpatialGroup* group) -{ - mGroupQ.insert(group); -} - void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag, BOOL priority) { LLMemType mt(LLMemType::MTYPE_PIPELINE); @@ -2475,16 +1554,8 @@ void LLPipeline::postSort(LLCamera& camera) } - //rebuild offscreen geometry if (!sSkipUpdate) { - for (LLSpatialGroup::sg_set_t::iterator iter = mGroupQ.begin(); iter != mGroupQ.end(); ++iter) - { - LLSpatialGroup* group = *iter; - group->rebuildGeom(); - } - mGroupQ.clear(); - //rebuild drawable geometry for (LLSpatialGroup::sg_vector_t::iterator i = mDrawableGroups.begin(); i != mDrawableGroups.end(); ++i) { @@ -2721,10 +1792,10 @@ void LLPipeline::renderHighlights() LLGLEnable color_mat(GL_COLOR_MATERIAL); disableLights(); - if ((mVertexShaderLevel[SHADER_INTERFACE] > 0)) + if ((LLShaderMgr::sVertexShaderLevel[LLShaderMgr::SHADER_INTERFACE] > 0)) { - mHighlightProgram.bind(); - gPipeline.mHighlightProgram.vertexAttrib4f(LLPipeline::GLSL_MATERIAL_COLOR,1,0,0,0.5f); + gHighlightProgram.bind(); + gHighlightProgram.vertexAttrib4f(LLShaderMgr::MATERIAL_COLOR,1,0,0,0.5f); } if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED)) @@ -2763,9 +1834,9 @@ void LLPipeline::renderHighlights() // have touch-handlers. mHighlightFaces.clear(); - if (mVertexShaderLevel[SHADER_INTERFACE] > 0) + if (LLShaderMgr::sVertexShaderLevel[LLShaderMgr::SHADER_INTERFACE] > 0) { - mHighlightProgram.unbind(); + gHighlightProgram.unbind(); } } @@ -2858,7 +1929,7 @@ void LLPipeline::renderGeom(LLCamera& camera) { LLFastTimer t(LLFastTimer::FTM_POOLS); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); - calcNearbyLights(); + calcNearbyLights(camera); pool_set_t::iterator iter1 = mPools.begin(); while ( iter1 != mPools.end() ) { @@ -3001,22 +2072,6 @@ void LLPipeline::renderGeom(LLCamera& camera) } } -void LLPipeline::processGeometry(LLCamera& camera) -{ - if (sSkipUpdate) - { - return; - } - - for (U32 i = 0; i < mObjectPartition.size(); i++) - { - if (mObjectPartition[i] && hasRenderType(mObjectPartition[i]->mDrawableType)) - { - mObjectPartition[i]->processGeometry(&camera); - } - } -} - void LLPipeline::processOcclusion(LLCamera& camera) { //process occlusion (readback) @@ -3691,7 +2746,7 @@ static F32 calc_light_dist(LLVOVolume* light, const LLVector3& cam_pos, F32 max_ return dist; } -void LLPipeline::calcNearbyLights() +void LLPipeline::calcNearbyLights(LLCamera& camera) { if (mLightingDetail >= 1) { @@ -3699,34 +2754,39 @@ void LLPipeline::calcNearbyLights() // begin() == the closest light and rbegin() == the farthest light const S32 MAX_LOCAL_LIGHTS = 6; // LLVector3 cam_pos = gAgent.getCameraPositionAgent(); - LLVector3 cam_pos = gAgent.getPositionAgent(); + LLVector3 cam_pos = LLPipeline::sSkipUpdate || LLViewerJoystick::sOverrideCamera ? + camera.getOrigin() : + gAgent.getPositionAgent(); F32 max_dist = LIGHT_MAX_RADIUS * 4.f; // ignore enitrely lights > 4 * max light rad // UPDATE THE EXISTING NEARBY LIGHTS - light_set_t cur_nearby_lights; - for (light_set_t::iterator iter = mNearbyLights.begin(); - iter != mNearbyLights.end(); iter++) + if (!LLPipeline::sSkipUpdate) { - const Light* light = &(*iter); - LLDrawable* drawable = light->drawable; - LLVOVolume* volight = drawable->getVOVolume(); - if (!volight || !drawable->isState(LLDrawable::LIGHT)) - { - drawable->clearState(LLDrawable::NEARBY_LIGHT); - continue; - } - if (light->fade <= -LIGHT_FADE_TIME) - { - drawable->clearState(LLDrawable::NEARBY_LIGHT); - } - else + light_set_t cur_nearby_lights; + for (light_set_t::iterator iter = mNearbyLights.begin(); + iter != mNearbyLights.end(); iter++) { - F32 dist = calc_light_dist(volight, cam_pos, max_dist); - cur_nearby_lights.insert(Light(drawable, dist, light->fade)); + const Light* light = &(*iter); + LLDrawable* drawable = light->drawable; + LLVOVolume* volight = drawable->getVOVolume(); + if (!volight || !drawable->isState(LLDrawable::LIGHT)) + { + drawable->clearState(LLDrawable::NEARBY_LIGHT); + continue; + } + if (light->fade <= -LIGHT_FADE_TIME) + { + drawable->clearState(LLDrawable::NEARBY_LIGHT); + } + else + { + F32 dist = calc_light_dist(volight, cam_pos, max_dist); + cur_nearby_lights.insert(Light(drawable, dist, light->fade)); + } } + mNearbyLights = cur_nearby_lights; } - mNearbyLights = cur_nearby_lights; // FIND NEW LIGHTS THAT ARE IN RANGE light_set_t new_nearby_lights; @@ -3861,7 +2921,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) LLColor4 light_color = light->getLightColor(); light_color.mV[3] = 0.0f; - F32 fade = iter->fade; + F32 fade = LLPipeline::sSkipUpdate ? 1.f : iter->fade; if (fade < LIGHT_FADE_TIME) { // fade in/out light @@ -4407,255 +3467,6 @@ BOOL LLPipeline::getRenderSoundBeacons(void*) return sRenderSoundBeacons; } -//=============================== -// LLGLSL Shader implementation -//=============================== -LLGLSLShader::LLGLSLShader() -: mProgramObject(0) -{ } - -void LLGLSLShader::unload() -{ - stop_glerror(); - mAttribute.clear(); - mTexture.clear(); - mUniform.clear(); - - if (mProgramObject) - { - GLhandleARB obj[1024]; - GLsizei count; - - glGetAttachedObjectsARB(mProgramObject, 1024, &count, obj); - for (GLsizei i = 0; i < count; i++) - { - glDeleteObjectARB(obj[i]); - } - - glDeleteObjectARB(mProgramObject); - - mProgramObject = 0; - } - - //hack to make apple not complain - glGetError(); - - stop_glerror(); -} - -void LLGLSLShader::attachObject(GLhandleARB object) -{ - if (object != 0) - { - stop_glerror(); - glAttachObjectARB(mProgramObject, object); - stop_glerror(); - } - else - { - llwarns << "Attempting to attach non existing shader object. " << llendl; - } -} - -void LLGLSLShader::attachObjects(GLhandleARB* objects, S32 count) -{ - for (S32 i = 0; i < count; i++) - { - attachObject(objects[i]); - } -} - -BOOL LLGLSLShader::mapAttributes(const char** attrib_names, S32 count) -{ - //link the program - BOOL res = link(); - - mAttribute.clear(); - mAttribute.resize(LLPipeline::sReservedAttribCount + count, -1); - - if (res) - { //read back channel locations - - //read back reserved channels first - for (S32 i = 0; i < (S32) LLPipeline::sReservedAttribCount; i++) - { - const char* name = LLPipeline::sReservedAttribs[i]; - S32 index = glGetAttribLocationARB(mProgramObject, name); - if (index != -1) - { - mAttribute[i] = index; - llinfos << "Attribute " << name << " assigned to channel " << index << llendl; - } - } - - for (S32 i = 0; i < count; i++) - { - const char* name = attrib_names[i]; - S32 index = glGetAttribLocationARB(mProgramObject, name); - if (index != -1) - { - mAttribute[LLPipeline::sReservedAttribCount + i] = index; - llinfos << "Attribute " << name << " assigned to channel " << index << llendl; - } - } - - return TRUE; - } - - return FALSE; -} - -void LLGLSLShader::mapUniform(GLint index, const char** uniform_names, S32 count) -{ - if (index == -1) - { - return; - } - - GLenum type; - GLsizei length; - GLint size; - char name[1024]; /* Flawfinder: ignore */ - name[0] = 0; - - glGetActiveUniformARB(mProgramObject, index, 1024, &length, &size, &type, name); - - //find the index of this uniform - for (S32 i = 0; i < (S32) LLPipeline::sReservedUniformCount; i++) - { - if (mUniform[i] == -1 && !strncmp(LLPipeline::sReservedUniforms[i],name, strlen(LLPipeline::sReservedUniforms[i]))) /* Flawfinder: ignore */ - { - //found it - S32 location = glGetUniformLocationARB(mProgramObject, name); - mUniform[i] = location; - llinfos << "Uniform " << name << " is at location " << location << llendl; - mTexture[i] = mapUniformTextureChannel(location, type); - return; - } - } - - for (S32 i = 0; i < count; i++) - { - if (mUniform[i+LLPipeline::sReservedUniformCount] == -1 && - !strncmp(uniform_names[i],name, strlen(uniform_names[i]))) /* Flawfinder: ignore */ - { - //found it - S32 location = glGetUniformLocationARB(mProgramObject, name); - mUniform[i+LLPipeline::sReservedUniformCount] = location; - llinfos << "Uniform " << name << " is at location " << location << " stored in index " << - (i+LLPipeline::sReservedUniformCount) << llendl; - mTexture[i+LLPipeline::sReservedUniformCount] = mapUniformTextureChannel(location, type); - return; - } - } - - //llinfos << "Unknown uniform: " << name << llendl; - } - -GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type) -{ - if (type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB) - { //this here is a texture - glUniform1iARB(location, mActiveTextureChannels); - llinfos << "Assigned to texture channel " << mActiveTextureChannels << llendl; - return mActiveTextureChannels++; - } - return -1; -} - -BOOL LLGLSLShader::mapUniforms(const char** uniform_names, S32 count) -{ - BOOL res = TRUE; - - mActiveTextureChannels = 0; - mUniform.clear(); - mTexture.clear(); - - //initialize arrays - mUniform.resize(count + LLPipeline::sReservedUniformCount, -1); - mTexture.resize(count + LLPipeline::sReservedUniformCount, -1); - - bind(); - - //get the number of active uniforms - GLint activeCount; - glGetObjectParameterivARB(mProgramObject, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &activeCount); - - for (S32 i = 0; i < activeCount; i++) - { - mapUniform(i, uniform_names, count); - } - - unbind(); - - return res; -} - -BOOL LLGLSLShader::link(BOOL suppress_errors) -{ - return gPipeline.linkProgramObject(mProgramObject, suppress_errors); -} - -void LLGLSLShader::bind() -{ - glUseProgramObjectARB(mProgramObject); - if (mAttribute.size() > 0) - { - gPipeline.mMaterialIndex = mAttribute[0]; - } -} - -void LLGLSLShader::unbind() -{ - for (U32 i = 0; i < mAttribute.size(); ++i) - { - vertexAttrib4f(i, 0,0,0,1); - } - glUseProgramObjectARB(0); -} - -S32 LLGLSLShader::enableTexture(S32 uniform, S32 mode) -{ - if (uniform < 0 || uniform >= (S32)mTexture.size()) - { - llerrs << "LLGLSLShader::enableTexture: uniform out of range: " << uniform << llendl; - } - S32 index = mTexture[uniform]; - if (index != -1) - { - glActiveTextureARB(GL_TEXTURE0_ARB+index); - glEnable(mode); - } - return index; -} - -S32 LLGLSLShader::disableTexture(S32 uniform, S32 mode) -{ - S32 index = mTexture[uniform]; - if (index != -1) - { - glActiveTextureARB(GL_TEXTURE0_ARB+index); - glDisable(mode); - } - return index; -} - -void LLGLSLShader::vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - if (mAttribute[index] > 0) - { - glVertexAttrib4fARB(mAttribute[index], x, y, z, w); - } -} - -void LLGLSLShader::vertexAttrib4fv(U32 index, GLfloat* v) -{ - if (mAttribute[index] > 0) - { - glVertexAttrib4fvARB(mAttribute[index], v); - } -} - LLViewerObject* LLPipeline::pickObject(const LLVector3 &start, const LLVector3 &end, LLVector3 &collision) { LLDrawable* drawable = mObjectPartition[PARTITION_VOLUME]->pickDrawable(start, end, collision); @@ -4847,7 +3658,7 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam, LLVector3 origin = cube_cam.getOrigin(); - gPipeline.calcNearbyLights(); + gPipeline.calcNearbyLights(cube_cam); cube_map->bind(); for (S32 i = 0; i < 6; i++) @@ -4909,7 +3720,7 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam, cube_cam.setOrigin(origin); gPipeline.resetDrawOrders(); - gPipeline.mShinyOrigin.setVec(cube_cam.getOrigin(), cube_cam.getFar()*2.f); + gShinyOrigin.setVec(cube_cam.getOrigin(), cube_cam.getFar()*2.f); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); @@ -5112,12 +3923,7 @@ void LLPipeline::bindScreenToTexture() void LLPipeline::renderBloom(GLuint source, GLuint dest, GLuint buffer, U32 res, LLVector2 tc1, LLVector2 tc2) { - mGlowProgram.bind(); - - if (!gGLManager.mHasFramebufferObject) - { - llerrs << "WTF?" << llendl; - } + gGlowProgram.bind(); LLGLEnable tex(GL_TEXTURE_2D); LLGLDepthTest depth(GL_FALSE); @@ -5160,7 +3966,7 @@ void LLPipeline::renderBloom(GLuint source, GLuint dest, GLuint buffer, U32 res, i%2==0 ? dest : buffer); - glUniform1fARB(mGlowProgram.mUniform[LLPipeline::GLSL_GLOW_DELTA],delta); + glUniform1fARB(gGlowProgram.mUniform[LLShaderMgr::GLOW_DELTA],delta); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(tc1.mV[0], tc1.mV[1]); @@ -5182,7 +3988,7 @@ void LLPipeline::renderBloom(GLuint source, GLuint dest, GLuint buffer, U32 res, } glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - mGlowProgram.unbind(); + gGlowProgram.unbind(); glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); @@ -5220,107 +4026,3 @@ void LLPipeline::renderBloom(GLuint source, GLuint dest, GLuint buffer, U32 res, glPopMatrix(); } -void LLPipeline::updateCamera() -{ - LLWindow* window = gViewerWindow->getWindow(); - - F32 time = gFrameIntervalSeconds; - - S32 axis[] = - { - gSavedSettings.getS32("JoystickAxis0"), - gSavedSettings.getS32("JoystickAxis1"), - gSavedSettings.getS32("JoystickAxis2"), - gSavedSettings.getS32("JoystickAxis3"), - gSavedSettings.getS32("JoystickAxis4"), - gSavedSettings.getS32("JoystickAxis5") - }; - - F32 axis_scale[] = - { - gSavedSettings.getF32("JoystickAxisScale0"), - gSavedSettings.getF32("JoystickAxisScale1"), - gSavedSettings.getF32("JoystickAxisScale2"), - gSavedSettings.getF32("JoystickAxisScale3"), - gSavedSettings.getF32("JoystickAxisScale4"), - gSavedSettings.getF32("JoystickAxisScale5") - }; - - F32 dead_zone[] = - { - gSavedSettings.getF32("JoystickAxisDeadZone0"), - gSavedSettings.getF32("JoystickAxisDeadZone1"), - gSavedSettings.getF32("JoystickAxisDeadZone2"), - gSavedSettings.getF32("JoystickAxisDeadZone3"), - gSavedSettings.getF32("JoystickAxisDeadZone4"), - gSavedSettings.getF32("JoystickAxisDeadZone5") - }; - - F32 cur_delta[6]; - static F32 last_delta[] = {0,0,0,0,0,0}; - static F32 delta[] = { 0,0,0,0,0,0 }; - - F32 feather = gSavedSettings.getF32("FlycamFeathering"); - BOOL absolute = gSavedSettings.getBOOL("FlycamAbsolute"); - - for (U32 i = 0; i < 6; i++) - { - cur_delta[i] = window->getJoystickAxis(axis[i]); - F32 tmp = cur_delta[i]; - if (absolute) - { - cur_delta[i] = cur_delta[i] - last_delta[i]; - } - last_delta[i] = tmp; - - if (cur_delta[i] > 0) - { - cur_delta[i] = llmax(cur_delta[i]-dead_zone[i], 0.f); - } - else - { - cur_delta[i] = llmin(cur_delta[i]+dead_zone[i], 0.f); - } - cur_delta[i] *= axis_scale[i]; - - if (!absolute) - { - cur_delta[i] *= time; - } - - delta[i] = delta[i] + (cur_delta[i]-delta[i])*time*feather; - } - - mFlyCamPosition += LLVector3(delta) * mFlyCamRotation; - - LLMatrix3 rot_mat(delta[3], - delta[4], - delta[5]); - - mFlyCamRotation = LLQuaternion(rot_mat)*mFlyCamRotation; - - if (gSavedSettings.getBOOL("FlycamAutoLeveling")) - { - LLMatrix3 level(mFlyCamRotation); - - LLVector3 x = LLVector3(level.mMatrix[0]); - LLVector3 y = LLVector3(level.mMatrix[1]); - LLVector3 z = LLVector3(level.mMatrix[2]); - - y.mV[2] = 0.f; - y.normVec(); - - level.setRows(x,y,z); - level.orthogonalize(); - - LLQuaternion quat = LLQuaternion(level); - mFlyCamRotation = nlerp(llmin(feather*time,1.f), mFlyCamRotation, quat); - } - - LLMatrix3 mat(mFlyCamRotation); - - gCamera->setOrigin(mFlyCamPosition); - gCamera->mXAxis = LLVector3(mat.mMatrix[0]); - gCamera->mYAxis = LLVector3(mat.mMatrix[1]); - gCamera->mZAxis = LLVector3(mat.mMatrix[2]); -} diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 4d89b65c90..5baf01de51 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -43,41 +43,6 @@ bool LLRayAABB(const LLVector3 ¢er, const LLVector3 &size, const LLVector3& BOOL LLLineSegmentAABB(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size); BOOL setup_hud_matrices(BOOL for_select); -class LLGLSLShader -{ -public: - LLGLSLShader(); - - void unload(); - void attachObject(GLhandleARB object); - void attachObjects(GLhandleARB* objects = NULL, S32 count = 0); - BOOL mapAttributes(const char** attrib_names = NULL, S32 count = 0); - BOOL mapUniforms(const char** uniform_names = NULL, S32 count = 0); - void mapUniform(GLint index, const char** uniform_names = NULL, S32 count = 0); - void vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void vertexAttrib4fv(U32 index, GLfloat* v); - - GLint mapUniformTextureChannel(GLint location, GLenum type); - - - //enable/disable texture channel for specified uniform - //if given texture uniform is active in the shader, - //the corresponding channel will be active upon return - //returns channel texture is enabled in from [0-MAX) - S32 enableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D); - S32 disableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D); - - BOOL link(BOOL suppress_errors = FALSE); - void bind(); - void unbind(); - - GLhandleARB mProgramObject; - std::vector<GLint> mAttribute; - std::vector<GLint> mUniform; - std::vector<GLint> mTexture; - S32 mActiveTextureChannels; -}; - class LLPipeline { public: @@ -125,7 +90,6 @@ public: void markShift(LLDrawable *drawablep); void markTextured(LLDrawable *drawablep); void markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag = LLDrawable::REBUILD_ALL, BOOL priority = FALSE); - void markRebuild(LLSpatialGroup* groupp); void markRelight(LLDrawable *drawablep, const BOOL now = FALSE); //get the object between start and end that's closest to start. Return the point of collision in collision. @@ -149,17 +113,7 @@ public: void setUseVertexShaders(BOOL use_shaders); BOOL getUseVertexShaders() const { return mVertexShadersEnabled; } BOOL canUseVertexShaders(); - BOOL setVertexShaderLevel(S32 type, S32 level); - S32 getVertexShaderLevel(S32 type) const { return mVertexShaderLevel[type]; } - S32 getMaxVertexShaderLevel(S32 type) const { return mMaxVertexShaderLevel[type]; } - - void setShaders(); - void dumpObjectLog(GLhandleARB ret, BOOL warns = TRUE); - BOOL linkProgramObject(GLhandleARB obj, BOOL suppress_errors = FALSE); - BOOL validateProgramObject(GLhandleARB obj); - GLhandleARB loadShader(const LLString& filename, S32 cls, GLenum type); - // phases void resetFrameStats(); @@ -187,7 +141,6 @@ public: void renderGeom(LLCamera& camera); void renderHighlights(); void renderDebug(); - void processGeometry(LLCamera& camera); void processOcclusion(LLCamera& camera); void renderForSelect(std::set<LLViewerObject*>& objects); @@ -200,7 +153,7 @@ public: S32 getVisibleCount() const { return mVisibleList.size(); } S32 getLightCount() const { return mLights.size(); } - void calcNearbyLights(); + void calcNearbyLights(LLCamera& camera); void setupHWLights(LLDrawPool* pool); void setupAvatarLights(BOOL for_edit = FALSE); void enableLights(U32 mask, F32 shadow_factor); @@ -250,11 +203,6 @@ private: void initShaders(BOOL force); void unloadShaders(); BOOL loadShaders(); - BOOL loadShadersLighting(); - BOOL loadShadersObject(); - BOOL loadShadersAvatar(); - BOOL loadShadersEnvironment(); - BOOL loadShadersInterface(); void saveVertexShaderLevel(S32 type, S32 level, S32 max); void addToQuickLookup( LLDrawPool* new_poolp ); void removeFromQuickLookup( LLDrawPool* poolp ); @@ -262,15 +210,7 @@ private: public: enum {GPU_CLASS_MAX = 3 }; - enum EShaderClass - { - SHADER_LIGHTING, - SHADER_OBJECT, - SHADER_AVATAR, - SHADER_ENVIRONMENT, - SHADER_INTERFACE, - SHADER_COUNT - }; + enum LLRenderTypeMask { // Following are pool types (some are also object types) @@ -361,7 +301,7 @@ public: LLSpatialPartition* getSpatialPartition(LLViewerObject* vobj); LLSpatialPartition* getSpatialPartition(U32 index); - void updateCamera(); + void updateCamera(BOOL reset = FALSE); LLVector3 mFlyCamPosition; LLQuaternion mFlyCamRotation; @@ -390,7 +330,6 @@ public: static BOOL sSkipUpdate; //skip lod updates static BOOL sDynamicReflections; static BOOL sRenderGlow; - static BOOL sOverrideAgentCamera; //screen texture GLuint mScreenTex; @@ -412,140 +351,7 @@ public: //depth buffer object for rendering dynamic cube maps GLuint mCubeDepth; - class LLScatterShader - { - public: - static void init(GLhandleARB shader, int map_stage); - }; - - //utility shader objects (not shader programs) - GLhandleARB mLightVertex; - GLhandleARB mLightFragment; - GLhandleARB mScatterVertex; - GLhandleARB mScatterFragment; - - //global (reserved slot) shader parameters - static const char* sReservedAttribs[]; - static U32 sReservedAttribCount; - - typedef enum - { - GLSL_MATERIAL_COLOR = 0, - GLSL_SPECULAR_COLOR, - GLSL_BINORMAL, - GLSL_END_RESERVED_ATTRIBS - } eGLSLReservedAttribs; - - static const char* sReservedUniforms[]; - static U32 sReservedUniformCount; - - typedef enum - { - GLSL_DIFFUSE_MAP = 0, - GLSL_SPECULAR_MAP, - GLSL_BUMP_MAP, - GLSL_ENVIRONMENT_MAP, - GLSL_END_RESERVED_UNIFORMS - } eGLSLReservedUniforms; - - static const char* sShinyUniforms[]; - static U32 sShinyUniformCount; - - typedef enum - { - GLSL_SHINY_ORIGIN = GLSL_END_RESERVED_UNIFORMS - } eShinyUniforms; - - LLVector4 mShinyOrigin; - - //object shaders - LLGLSLShader mObjectSimpleProgram; - LLGLSLShader mObjectAlphaProgram; - LLGLSLShader mObjectBumpProgram; - LLGLSLShader mObjectShinyProgram; - - //water parameters - static const char* sWaterUniforms[]; - static U32 sWaterUniformCount; - - typedef enum - { - GLSL_WATER_SCREENTEX = GLSL_END_RESERVED_UNIFORMS, - GLSL_WATER_EYEVEC, - GLSL_WATER_TIME, - GLSL_WATER_WAVE_DIR1, - GLSL_WATER_WAVE_DIR2, - GLSL_WATER_LIGHT_DIR, - GLSL_WATER_SPECULAR, - GLSL_WATER_SPECULAR_EXP, - GLSL_WATER_FBSCALE, - GLSL_WATER_REFSCALE - } eWaterUniforms; - - - //terrain parameters - static const char* sTerrainUniforms[]; - static U32 sTerrainUniformCount; - - typedef enum - { - GLSL_TERRAIN_DETAIL0 = GLSL_END_RESERVED_UNIFORMS, - GLSL_TERRAIN_DETAIL1, - GLSL_TERRAIN_ALPHARAMP - } eTerrainUniforms; - - //glow parameters - static const char* sGlowUniforms[]; - static U32 sGlowUniformCount; - - typedef enum - { - GLSL_GLOW_DELTA = GLSL_END_RESERVED_UNIFORMS - } eGlowUniforms; - - //environment shaders - LLGLSLShader mTerrainProgram; - LLGLSLShader mGlowProgram; - LLGLSLShader mGroundProgram; - LLGLSLShader mWaterProgram; - - //interface shaders - LLGLSLShader mHighlightProgram; - //avatar shader parameter tables - static const char* sAvatarAttribs[]; - static U32 sAvatarAttribCount; - - typedef enum - { - GLSL_AVATAR_WEIGHT = GLSL_END_RESERVED_ATTRIBS, - GLSL_AVATAR_CLOTHING, - GLSL_AVATAR_WIND, - GLSL_AVATAR_SINWAVE, - GLSL_AVATAR_GRAVITY - } eAvatarAttribs; - - static const char* sAvatarUniforms[]; - static U32 sAvatarUniformCount; - - typedef enum - { - GLSL_AVATAR_MATRIX = GLSL_END_RESERVED_UNIFORMS - } eAvatarUniforms; - - //avatar skinning utility shader object - GLhandleARB mAvatarSkinVertex; - - //avatar shader handles - LLGLSLShader mAvatarProgram; - LLGLSLShader mAvatarEyeballProgram; - LLGLSLShader mAvatarPickProgram; - - //current avatar shader parameter pointer - GLint mAvatarMatrixParam; - GLint mMaterialIndex; - GLint mSpecularIndex; - LLColor4 mSunDiffuse; LLVector3 mSunDir; @@ -557,13 +363,11 @@ public: LLSpatialGroup::sg_vector_t mDrawableGroups; void clearRenderMap(); - -protected: + BOOL mVertexShadersEnabled; S32 mVertexShadersLoaded; // 0 = no, 1 = yes, -1 = failed - S32 mVertexShaderLevel[SHADER_COUNT]; - S32 mMaxVertexShaderLevel[SHADER_COUNT]; - + +protected: U32 mRenderTypeMask; U32 mRenderFeatureMask; U32 mRenderDebugFeatureMask; @@ -619,7 +423,6 @@ protected: // LLDrawable::drawable_list_t mBuildQ1; // priority LLDrawable::drawable_list_t mBuildQ2; // non-priority - LLSpatialGroup::sg_set_t mGroupQ; //spatial groups LLDrawable::drawable_set_t mActiveQ; diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 2c04a34da8..e9dfa0a382 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -272,9 +272,6 @@ class DarwinManifest(ViewerManifest): if self.prefix(src="", dst="Resources"): super(DarwinManifest, self).construct() - # the trial directory seems to be not used [rdw] - self.path('trial') - if self.prefix("cursors_mac"): self.path("*.tif") self.end_prefix("cursors_mac") |