diff options
Diffstat (limited to 'indra/newview/llfloatercolorpicker.cpp')
-rw-r--r-- | indra/newview/llfloatercolorpicker.cpp | 108 |
1 files changed, 55 insertions, 53 deletions
diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index 8ad13367c0..603f54fb49 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -68,12 +68,12 @@ // ////////////////////////////////////////////////////////////////////////////// -LLFloaterColorPicker::LLFloaterColorPicker (LLColorSwatchCtrl* swatch, BOOL show_apply_immediate ) +LLFloaterColorPicker::LLFloaterColorPicker (LLColorSwatchCtrl* swatch, bool show_apply_immediate ) : LLFloater(LLSD()), mComponents ( 3 ), - mMouseDownInLumRegion ( FALSE ), - mMouseDownInHueRegion ( FALSE ), - mMouseDownInSwatch ( FALSE ), + mMouseDownInLumRegion ( false ), + mMouseDownInHueRegion ( false ), + mMouseDownInSwatch ( false ), // *TODO: Specify this in XML mRGBViewerImageLeft ( 140 ), mRGBViewerImageTop ( 356 ), @@ -99,7 +99,7 @@ LLFloaterColorPicker::LLFloaterColorPicker (LLColorSwatchCtrl* swatch, BOOL show mPaletteRegionWidth ( mLumRegionLeft + mLumRegionWidth - 10 ), mPaletteRegionHeight ( 40 ), mSwatch ( swatch ), - mActive ( TRUE ), + mActive ( true ), mCanApplyImmediately ( show_apply_immediate ), mContextConeOpacity ( 0.f ), mContextConeInAlpha (CONTEXT_CONE_IN_ALPHA), @@ -113,8 +113,8 @@ LLFloaterColorPicker::LLFloaterColorPicker (LLColorSwatchCtrl* swatch, BOOL show if (!mCanApplyImmediately) { - mApplyImmediateCheck->setEnabled(FALSE); - mApplyImmediateCheck->set(FALSE); + mApplyImmediateCheck->setEnabled(false); + mApplyImmediateCheck->set(false); } } @@ -131,6 +131,8 @@ void LLFloaterColorPicker::createUI () // create RGB type area (not really RGB but it's got R,G & B in it.,.. LLPointer<LLImageRaw> raw = new LLImageRaw ( mRGBViewerImageWidth, mRGBViewerImageHeight, mComponents ); + LLImageDataLock lock(raw); + U8* bits = raw->getData(); S32 linesize = mRGBViewerImageWidth * mComponents; for ( S32 y = 0; y < mRGBViewerImageHeight; ++y ) @@ -151,7 +153,7 @@ void LLFloaterColorPicker::createUI () * ( bits + x + y * linesize + 2 ) = ( U8 )( bVal * 255.0f ); } } - mRGBImage = LLViewerTextureManager::getLocalTexture( (LLImageRaw*)raw, FALSE ); + mRGBImage = LLViewerTextureManager::getLocalTexture( (LLImageRaw*)raw, false ); gGL.getTexUnit(0)->bind(mRGBImage); mRGBImage->setAddressMode(LLTexUnit::TAM_CLAMP); @@ -167,15 +169,15 @@ void LLFloaterColorPicker::createUI () void LLFloaterColorPicker::showUI () { openFloater(getKey()); - setVisible ( TRUE ); - setFocus ( TRUE ); + setVisible ( true ); + setFocus ( true ); // HACK: if system color picker is required - close the SL one we made and use default system dialog if ( gSavedSettings.getBOOL ( "UseDefaultColorPicker" ) ) { LLColorSwatchCtrl* swatch = getSwatch (); - setVisible ( FALSE ); + setVisible ( false ); // code that will get switched in for default system color picker if ( swatch ) @@ -205,14 +207,14 @@ void LLFloaterColorPicker::showUI () ////////////////////////////////////////////////////////////////////////////// // called after the dialog is rendered -BOOL LLFloaterColorPicker::postBuild() +bool LLFloaterColorPicker::postBuild() { mCancelBtn = getChild<LLButton>( "cancel_btn" ); mCancelBtn->setClickedCallback ( onClickCancel, this ); mSelectBtn = getChild<LLButton>( "select_btn"); mSelectBtn->setClickedCallback ( onClickSelect, this ); - mSelectBtn->setFocus ( TRUE ); + mSelectBtn->setFocus ( true ); mPipetteBtn = getChild<LLButton>("color_pipette" ); @@ -233,7 +235,7 @@ BOOL LLFloaterColorPicker::postBuild() LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterColorPicker::onColorSelect, this, _1)); - return TRUE; + return true; } ////////////////////////////////////////////////////////////////////////////// @@ -419,7 +421,7 @@ void LLFloaterColorPicker::onClickSelect ( void* data ) void LLFloaterColorPicker::onClickPipette( ) { - BOOL pipette_active = mPipetteBtn->getToggleState(); + bool pipette_active = mPipetteBtn->getToggleState(); pipette_active = !pipette_active; if (pipette_active) { @@ -466,8 +468,8 @@ void LLFloaterColorPicker::onColorSelect( const LLTextureEntry& te ) void LLFloaterColorPicker::onMouseCaptureLost() { - setMouseDownInHueRegion(FALSE); - setMouseDownInLumRegion(FALSE); + setMouseDownInHueRegion(false); + setMouseDownInLumRegion(false); } F32 LLFloaterColorPicker::getSwatchTransparency() @@ -476,7 +478,7 @@ F32 LLFloaterColorPicker::getSwatchTransparency() return getTransparencyType() == TT_ACTIVE ? 1.f : LLFloater::getCurrentTransparency(); } -BOOL LLFloaterColorPicker::isColorChanged() +bool LLFloaterColorPicker::isColorChanged() { return ((getOrigR() != getCurR()) || (getOrigG() != getCurG()) || (getOrigB() != getCurB())); } @@ -521,7 +523,7 @@ void LLFloaterColorPicker::draw() mRGBViewerImageLeft + mRGBViewerImageWidth + 1, mRGBViewerImageTop, LLColor4 ( 0.0f, 0.0f, 0.0f, alpha ), - FALSE ); + false ); // draw luminance slider for ( S32 y = 0; y < mLumRegionHeight; ++y ) @@ -543,7 +545,7 @@ void LLFloaterColorPicker::draw() gl_triangle_2d ( startX, startY, startX + mLumMarkerSize, startY - mLumMarkerSize, startX + mLumMarkerSize, startY + mLumMarkerSize, - LLColor4 ( 0.75f, 0.75f, 0.75f, 1.0f ), TRUE ); + LLColor4 ( 0.75f, 0.75f, 0.75f, 1.0f ), true ); // draw luminance slider outline gl_rect_2d ( mLumRegionLeft, @@ -551,7 +553,7 @@ void LLFloaterColorPicker::draw() mLumRegionLeft + mLumRegionWidth + 1, mLumRegionTop, LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ), - FALSE ); + false ); // draw selected color swatch gl_rect_2d ( mSwatchRegionLeft, @@ -559,7 +561,7 @@ void LLFloaterColorPicker::draw() mSwatchRegionLeft + mSwatchRegionWidth, mSwatchRegionTop, LLColor4 ( getCurR (), getCurG (), getCurB (), alpha ), - TRUE ); + true ); // draw selected color swatch outline gl_rect_2d ( mSwatchRegionLeft, @@ -567,7 +569,7 @@ void LLFloaterColorPicker::draw() mSwatchRegionLeft + mSwatchRegionWidth + 1, mSwatchRegionTop, LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ), - FALSE ); + false ); // color palette code is a little more involved so break it out into its' own method drawPalette (); @@ -635,8 +637,8 @@ void LLFloaterColorPicker::drawPalette () // draw palette entry color if ( mPalette [ curEntry ] ) { - gl_rect_2d ( x1 + 2, y1 - 2, x2 - 2, y2 + 2, *mPalette [ curEntry++ ] % alpha, TRUE ); - gl_rect_2d ( x1 + 1, y1 - 1, x2 - 1, y2 + 1, LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ), FALSE ); + gl_rect_2d ( x1 + 2, y1 - 2, x2 - 2, y2 + 2, *mPalette [ curEntry++ ] % alpha, true ); + gl_rect_2d ( x1 + 1, y1 - 1, x2 - 1, y2 + 1, LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ), false ); } } } @@ -740,7 +742,7 @@ void LLFloaterColorPicker::onTextEntryChanged ( LLUICtrl* ctrl ) ////////////////////////////////////////////////////////////////////////////// // -BOOL LLFloaterColorPicker::updateRgbHslFromPoint ( S32 xPosIn, S32 yPosIn ) +bool LLFloaterColorPicker::updateRgbHslFromPoint ( S32 xPosIn, S32 yPosIn ) { if ( xPosIn >= mRGBViewerImageLeft && xPosIn <= mRGBViewerImageLeft + mRGBViewerImageWidth && @@ -753,7 +755,7 @@ BOOL LLFloaterColorPicker::updateRgbHslFromPoint ( S32 xPosIn, S32 yPosIn ) getCurL () ); // indicate a value changed - return TRUE; + return true; } else if ( xPosIn >= mLumRegionLeft && @@ -768,15 +770,15 @@ BOOL LLFloaterColorPicker::updateRgbHslFromPoint ( S32 xPosIn, S32 yPosIn ) ( ( F32 )yPosIn - ( ( F32 )mRGBViewerImageTop - ( F32 )mRGBViewerImageHeight ) ) / ( F32 )mRGBViewerImageHeight ); // indicate a value changed - return TRUE; + return true; } - return FALSE; + return false; } ////////////////////////////////////////////////////////////////////////////// // -BOOL LLFloaterColorPicker::handleMouseDown ( S32 x, S32 y, MASK mask ) +bool LLFloaterColorPicker::handleMouseDown ( S32 x, S32 y, MASK mask ) { // make it the frontmost gFloaterView->bringToFront(this); @@ -791,13 +793,13 @@ BOOL LLFloaterColorPicker::handleMouseDown ( S32 x, S32 y, MASK mask ) { gFocusMgr.setMouseCapture(this); // mouse button down - setMouseDownInHueRegion ( TRUE ); + setMouseDownInHueRegion ( true ); // update all values based on initial click updateRgbHslFromPoint ( x, y ); // required by base class - return TRUE; + return true; } // rect containing RGB area @@ -810,10 +812,10 @@ BOOL LLFloaterColorPicker::handleMouseDown ( S32 x, S32 y, MASK mask ) { gFocusMgr.setMouseCapture(this); // mouse button down - setMouseDownInLumRegion ( TRUE ); + setMouseDownInLumRegion ( true ); // required by base class - return TRUE; + return true; } // rect containing swatch area @@ -822,13 +824,13 @@ BOOL LLFloaterColorPicker::handleMouseDown ( S32 x, S32 y, MASK mask ) mSwatchRegionLeft + mSwatchRegionWidth, mSwatchRegionTop - mSwatchRegionHeight ); - setMouseDownInSwatch( FALSE ); + setMouseDownInSwatch( false ); if ( swatchRect.pointInRect ( x, y ) ) { - setMouseDownInSwatch( TRUE ); + setMouseDownInSwatch( true ); // required - dont drag windows here. - return TRUE; + return true; } // rect containing palette area @@ -842,7 +844,7 @@ BOOL LLFloaterColorPicker::handleMouseDown ( S32 x, S32 y, MASK mask ) // release keyboard focus so we can change text values if (gFocusMgr.childHasKeyboardFocus(this)) { - mSelectBtn->setFocus(TRUE); + mSelectBtn->setFocus(true); } // calculate which palette index we selected @@ -865,7 +867,7 @@ BOOL LLFloaterColorPicker::handleMouseDown ( S32 x, S32 y, MASK mask ) updateTextEntry (); } - return TRUE; + return true; } // dispatch to base class for the rest of things @@ -875,7 +877,7 @@ BOOL LLFloaterColorPicker::handleMouseDown ( S32 x, S32 y, MASK mask ) ////////////////////////////////////////////////////////////////////////////// // -BOOL LLFloaterColorPicker::handleHover ( S32 x, S32 y, MASK mask ) +bool LLFloaterColorPicker::handleHover ( S32 x, S32 y, MASK mask ) { // if we're the front most window if ( isFrontmost () ) @@ -895,7 +897,7 @@ BOOL LLFloaterColorPicker::handleHover ( S32 x, S32 y, MASK mask ) clamped_y = llclamp(y, mLumRegionTop - mLumRegionHeight, mLumRegionTop); } - // update the stored RGB/HSL values using the mouse position - returns TRUE if RGB was updated + // update the stored RGB/HSL values using the mouse position - returns true if RGB was updated if ( updateRgbHslFromPoint ( clamped_x, clamped_y ) ) { // update text entry fields @@ -933,7 +935,7 @@ BOOL LLFloaterColorPicker::handleHover ( S32 x, S32 y, MASK mask ) highlightEntry = xOffset + yOffset * numPaletteColumns; } - return TRUE; + return true; } } @@ -943,7 +945,7 @@ BOOL LLFloaterColorPicker::handleHover ( S32 x, S32 y, MASK mask ) ////////////////////////////////////////////////////////////////////////////// // reverts state once mouse button is released -BOOL LLFloaterColorPicker::handleMouseUp ( S32 x, S32 y, MASK mask ) +bool LLFloaterColorPicker::handleMouseUp ( S32 x, S32 y, MASK mask ) { getWindow()->setCursor ( UI_CURSOR_ARROW ); @@ -1001,8 +1003,8 @@ BOOL LLFloaterColorPicker::handleMouseUp ( S32 x, S32 y, MASK mask ) } // mouse button not down anymore - setMouseDownInHueRegion ( FALSE ); - setMouseDownInLumRegion ( FALSE ); + setMouseDownInHueRegion ( false ); + setMouseDownInLumRegion ( false ); // mouse button not down in color swatch anymore mMouseDownInSwatch = false; @@ -1027,10 +1029,10 @@ void LLFloaterColorPicker::cancelSelection () LLColorSwatchCtrl::onColorChanged( getSwatch(), LLColorSwatchCtrl::COLOR_CANCEL ); // hide picker dialog - this->setVisible ( FALSE ); + this->setVisible ( false ); } -void LLFloaterColorPicker::setMouseDownInHueRegion ( BOOL mouse_down_in_region ) +void LLFloaterColorPicker::setMouseDownInHueRegion ( bool mouse_down_in_region ) { mMouseDownInHueRegion = mouse_down_in_region; if (mouse_down_in_region) @@ -1038,12 +1040,12 @@ void LLFloaterColorPicker::setMouseDownInHueRegion ( BOOL mouse_down_in_region ) if (gFocusMgr.childHasKeyboardFocus(this)) { // get focus out of spinners so that they can update freely - mSelectBtn->setFocus(TRUE); + mSelectBtn->setFocus(true); } } } -void LLFloaterColorPicker::setMouseDownInLumRegion ( BOOL mouse_down_in_region ) +void LLFloaterColorPicker::setMouseDownInLumRegion ( bool mouse_down_in_region ) { mMouseDownInLumRegion = mouse_down_in_region; if (mouse_down_in_region) @@ -1051,12 +1053,12 @@ void LLFloaterColorPicker::setMouseDownInLumRegion ( BOOL mouse_down_in_region ) if (gFocusMgr.childHasKeyboardFocus(this)) { // get focus out of spinners so that they can update freely - mSelectBtn->setFocus(TRUE); + mSelectBtn->setFocus(true); } } } -void LLFloaterColorPicker::setMouseDownInSwatch (BOOL mouse_down_in_swatch) +void LLFloaterColorPicker::setMouseDownInSwatch (bool mouse_down_in_swatch) { mMouseDownInSwatch = mouse_down_in_swatch; if (mouse_down_in_swatch) @@ -1064,12 +1066,12 @@ void LLFloaterColorPicker::setMouseDownInSwatch (BOOL mouse_down_in_swatch) if (gFocusMgr.childHasKeyboardFocus(this)) { // get focus out of spinners so that they can update freely - mSelectBtn->setFocus(TRUE); + mSelectBtn->setFocus(true); } } } -void LLFloaterColorPicker::setActive(BOOL active) +void LLFloaterColorPicker::setActive(bool active) { // shut down pipette tool if active if (!active && mPipetteBtn->getToggleState()) |