SELECTION_AREA color now indicates selection mode

BLUE = Normal
GREEN = Addition
RED = Subtraction

Line color indicates "window" or "crossing" selection mode
This commit is contained in:
Oliver Walters 2017-05-09 17:28:54 +10:00 committed by Maciej Suminski
parent 2ae47d31cc
commit cd738297b0
3 changed files with 55 additions and 11 deletions

View File

@ -30,16 +30,36 @@
using namespace KIGFX::PREVIEW;
// Selection area colours
const COLOR4D SELECT_COLOR_L2R( 0.3, 0.3, 0.6, 0.3 ); // Slight blue
const COLOR4D SELECT_COLOR_R2L( 0.3, 0.6, 0.3, 0.3 ); // Slight green
const COLOR4D SELECT_MODE_NORMAL( 0.3, 0.3, 0.7, 0.3 ); // Slight blue
const COLOR4D SELECT_MODE_ADDITIVE( 0.3, 0.7, 0.3, 0.3 ); // Slight green
const COLOR4D SELECT_MODE_SUBTRACT( 0.7, 0.3, 0.3, 0.3 ); // Slight red
const COLOR4D SELECT_OUTLINE_L2R( 1.0, 1.0, 0.4, 1.0 );
const COLOR4D SELECT_OUTLINE_R2L( 0.4, 0.4, 1.0, 1.0 );
SELECTION_AREA::SELECTION_AREA()
SELECTION_AREA::SELECTION_AREA() :
m_additive( false ),
m_subtractive( false )
{
SetStrokeColor( COLOR4D( 1.0, 1.0, 0.4, 1.0 ) );
SetFillColor( COLOR4D( 0.3, 0.3, 0.5, 0.3 ) );
SetStrokeColor( SELECT_OUTLINE_L2R );
SetFillColor( SELECT_MODE_NORMAL );
}
void SELECTION_AREA::SetAdditive( bool aAdditive )
{
m_additive = aAdditive;
if( m_additive )
m_subtractive = false;
}
void SELECTION_AREA::SetSubtractive( bool aSubtractive )
{
m_subtractive = aSubtractive;
if ( m_subtractive )
m_additive = false;
}
const BOX2I SELECTION_AREA::ViewBBox() const
{
@ -54,8 +74,23 @@ const BOX2I SELECTION_AREA::ViewBBox() const
void SELECTION_AREA::drawPreviewShape( KIGFX::GAL& aGal ) const
{
// Set the fill color based on the direction of selection
aGal.SetFillColor( ( m_origin.x <= m_end.x ) ? SELECT_COLOR_L2R : SELECT_COLOR_R2L );
// Set the fill of the selection rectangle
// based on the selection mode
if( m_additive )
{
aGal.SetFillColor( SELECT_MODE_ADDITIVE );
}
else if( m_subtractive )
{
aGal.SetFillColor( SELECT_MODE_SUBTRACT );
}
else
{
aGal.SetFillColor( SELECT_MODE_NORMAL );
}
// Set the stroke color to indicate window or crossing selection
aGal.SetStrokeColor( ( m_origin.x <= m_end.x ) ? SELECT_OUTLINE_L2R : SELECT_OUTLINE_R2L );
aGal.DrawRectangle( m_origin, m_end );
}

View File

@ -80,8 +80,18 @@ public:
VECTOR2I GetEnd() const { return m_end; }
bool IsAdditive() const { return m_additive; }
bool IsSubtractive() const { return m_subtractive; }
void SetAdditive( bool aAdditive );
void SetSubtractive( bool aSubtractive );
private:
bool m_additive;
bool m_subtractive;
/**
* Draw the selection rectangle onto the GAL
*/

View File

@ -488,14 +488,13 @@ bool SELECTION_TOOL::selectMultiple()
if( evt->IsDrag( BUT_LEFT ) )
{
if( !m_additive && !m_subtractive )
{
clearSelection();
}
// Start drawing a selection box
area.SetOrigin( evt->DragOrigin() );
area.SetEnd( evt->Position() );
area.SetAdditive( m_additive );
area.SetSubtractive( m_subtractive );
view->SetVisible( &area, true );
view->Update( &area );
}