renaissance1: #i107215# Focus can be moved with Ctrl+Cursor Keys.

This commit is contained in:
Andre Fischer
2010-02-23 18:31:24 +01:00
parent 3c7bf4b67d
commit 1fbf7cba10
7 changed files with 79 additions and 26 deletions

View File

@@ -302,12 +302,12 @@ void FocusManager::ShowFocusIndicator (
// Scroll the focused page object into the visible area and repaint // Scroll the focused page object into the visible area and repaint
// it, so that the focus indicator becomes visible. // it, so that the focus indicator becomes visible.
mrSlideSorter.GetController().GetSelectionManager()->MakeRectangleVisible ( mrSlideSorter.GetController().GetSelectionManager()->MakeRectangleVisible (
GetFocusedPageDescriptor()->GetBoundingBox()); mrSlideSorter.GetView().GetLayouter().GetPageObjectBox(
rpDescriptor->GetPageIndex(), true));
} }
#ifndef UNIFY_FOCUS_AND_CURRENT_PAGE mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
mrSlideSorter.GetView().RequestRepaint (rpDescriptor);
#endif
NotifyFocusChangeListeners(); NotifyFocusChangeListeners();
} }
} }

View File

@@ -466,7 +466,8 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
FocusManager& rFocusManager (mrController.GetFocusManager()); FocusManager& rFocusManager (mrController.GetFocusManager());
BOOL bResult = FALSE; BOOL bResult = FALSE;
switch (rEvent.GetKeyCode().GetCode()) const KeyCode& rCode (rEvent.GetKeyCode());
switch (rCode.GetCode())
{ {
case KEY_RETURN: case KEY_RETURN:
if (rFocusManager.HasFocus()) if (rFocusManager.HasFocus())
@@ -485,7 +486,7 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
if ( ! rFocusManager.IsFocusShowing()) if ( ! rFocusManager.IsFocusShowing())
rFocusManager.ShowFocus(); rFocusManager.ShowFocus();
else else
if (rEvent.GetKeyCode().IsShift()) if (rCode.IsShift())
rFocusManager.MoveFocus (FocusManager::FMD_LEFT); rFocusManager.MoveFocus (FocusManager::FMD_LEFT);
else else
rFocusManager.MoveFocus (FocusManager::FMD_RIGHT); rFocusManager.MoveFocus (FocusManager::FMD_RIGHT);
@@ -527,25 +528,25 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
// Move the focus indicator left. // Move the focus indicator left.
case KEY_LEFT: case KEY_LEFT:
MoveFocus(FocusManager::FMD_LEFT, rEvent.GetKeyCode().IsShift()); MoveFocus(FocusManager::FMD_LEFT, rCode.IsShift(), rCode.IsMod1());
bResult = TRUE; bResult = TRUE;
break; break;
// Move the focus indicator right. // Move the focus indicator right.
case KEY_RIGHT: case KEY_RIGHT:
MoveFocus(FocusManager::FMD_RIGHT, rEvent.GetKeyCode().IsShift()); MoveFocus(FocusManager::FMD_RIGHT, rCode.IsShift(), rCode.IsMod1());
bResult = TRUE; bResult = TRUE;
break; break;
// Move the focus indicator up. // Move the focus indicator up.
case KEY_UP: case KEY_UP:
MoveFocus(FocusManager::FMD_UP, rEvent.GetKeyCode().IsShift()); MoveFocus(FocusManager::FMD_UP, rCode.IsShift(), rCode.IsMod1());
bResult = TRUE; bResult = TRUE;
break; break;
// Move the focus indicator down. // Move the focus indicator down.
case KEY_DOWN: case KEY_DOWN:
MoveFocus(FocusManager::FMD_DOWN, rEvent.GetKeyCode().IsShift()); MoveFocus(FocusManager::FMD_DOWN, rCode.IsShift(), rCode.IsMod1());
bResult = TRUE; bResult = TRUE;
break; break;
@@ -590,7 +591,7 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
break; break;
case KEY_F10: case KEY_F10:
if (rEvent.GetKeyCode().IsShift()) if (rCode.IsShift())
{ {
DeselectAllPages(); DeselectAllPages();
mrController.GetPageSelector().SelectPage( mrController.GetPageSelector().SelectPage(
@@ -613,7 +614,8 @@ BOOL SelectionFunction::KeyInput (const KeyEvent& rEvent)
void SelectionFunction::MoveFocus ( void SelectionFunction::MoveFocus (
const FocusManager::FocusMoveDirection eDirection, const FocusManager::FocusMoveDirection eDirection,
const bool bIsShiftDown) const bool bIsShiftDown,
const bool bIsControlDown)
{ {
// Remember the anchor of shift key multi selection. // Remember the anchor of shift key multi selection.
if (bIsShiftDown) if (bIsShiftDown)
@@ -662,6 +664,11 @@ void SelectionFunction::MoveFocus (
} }
} }
} }
else if (bIsControlDown)
{
// When control is pressed then do not alter the selection or the
// current page, just move the focus.
}
else else
{ {
// Without shift just select the focused page. // Without shift just select the focused page.

View File

@@ -233,7 +233,8 @@ private:
void MoveFocus ( void MoveFocus (
const FocusManager::FocusMoveDirection eDirection, const FocusManager::FocusMoveDirection eDirection,
const bool bIsShiftDown); const bool bIsShiftDown,
const bool bIsControlDown);
}; };
} } } // end of namespace ::sd::slidesorter::controller } } } // end of namespace ::sd::slidesorter::controller

View File

@@ -83,6 +83,7 @@ private:
::boost::scoped_ptr<FramePainter> mpShadowPainter; ::boost::scoped_ptr<FramePainter> mpShadowPainter;
Bitmap maNormalBackground; Bitmap maNormalBackground;
Bitmap maSelectionBackground; Bitmap maSelectionBackground;
Bitmap maFocusedSelectionBackground;
Bitmap maMouseOverBackground; Bitmap maMouseOverBackground;
void PaintBackground ( void PaintBackground (
@@ -101,6 +102,10 @@ private:
OutputDevice& rDevice, OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor) const; const model::SharedPageDescriptor& rpDescriptor) const;
void PrepareBackgrounds (OutputDevice& rDevice); void PrepareBackgrounds (OutputDevice& rDevice);
void PaintBorder (
OutputDevice& rDevice,
const Theme::GradientColorType eColorType,
const Rectangle& rBox) const;
Bitmap CreateBackgroundBitmap( Bitmap CreateBackgroundBitmap(
const OutputDevice& rReferenceDevice, const OutputDevice& rReferenceDevice,
const Theme::GradientColorType eType) const; const Theme::GradientColorType eType) const;

View File

@@ -84,6 +84,7 @@ public:
enum GradientColorType { enum GradientColorType {
NormalPage, NormalPage,
SelectedPage, SelectedPage,
SelectedAndFocusedPage,
MouseOverPage MouseOverPage
}; };
enum GradientColorClass { enum GradientColorClass {
@@ -115,6 +116,7 @@ private:
ColorData maBackgroundColor; ColorData maBackgroundColor;
GradientDescriptor maNormalGradient; GradientDescriptor maNormalGradient;
GradientDescriptor maSelectedGradient; GradientDescriptor maSelectedGradient;
GradientDescriptor maSelectedAndFocusedGradient;
GradientDescriptor maMouseOverGradient; GradientDescriptor maMouseOverGradient;
BitmapEx maRawShadow; BitmapEx maRawShadow;
BitmapEx maInsertionIndicator; BitmapEx maInsertionIndicator;

View File

@@ -235,6 +235,7 @@ PageObjectPainter::PageObjectPainter (
mpShadowPainter(), mpShadowPainter(),
maNormalBackground(), maNormalBackground(),
maSelectionBackground(), maSelectionBackground(),
maFocusedSelectionBackground(),
maMouseOverBackground() maMouseOverBackground()
{ {
LocalResource aResource (IMG_ICONS); LocalResource aResource (IMG_ICONS);
@@ -294,6 +295,7 @@ void PageObjectPainter::NotifyResize (void)
{ {
maNormalBackground.SetEmpty(); maNormalBackground.SetEmpty();
maSelectionBackground.SetEmpty(); maSelectionBackground.SetEmpty();
maFocusedSelectionBackground.SetEmpty();
maMouseOverBackground.SetEmpty(); maMouseOverBackground.SetEmpty();
} }
@@ -326,15 +328,22 @@ void PageObjectPainter::PaintBackground (
} }
else if (rpDescriptor->HasState(model::PageDescriptor::ST_Selected)) else if (rpDescriptor->HasState(model::PageDescriptor::ST_Selected))
{ {
rDevice.DrawBitmap( if (rpDescriptor->HasState(model::PageDescriptor::ST_Focused))
aBox.TopLeft(), rDevice.DrawBitmap(
maSelectionBackground); aBox.TopLeft(),
maFocusedSelectionBackground);
else
rDevice.DrawBitmap(
aBox.TopLeft(),
maSelectionBackground);
} }
else else
{ {
rDevice.DrawBitmap( rDevice.DrawBitmap(
aBox.TopLeft(), aBox.TopLeft(),
maNormalBackground); maNormalBackground);
if (rpDescriptor->HasState(model::PageDescriptor::ST_Focused))
PaintBorder(rDevice, Theme::SelectedPage, aBox);
} }
} }
@@ -519,6 +528,8 @@ void PageObjectPainter::PrepareBackgrounds (OutputDevice& rDevice)
{ {
maNormalBackground = CreateBackgroundBitmap(rDevice, Theme::NormalPage); maNormalBackground = CreateBackgroundBitmap(rDevice, Theme::NormalPage);
maSelectionBackground = CreateBackgroundBitmap(rDevice, Theme::SelectedPage); maSelectionBackground = CreateBackgroundBitmap(rDevice, Theme::SelectedPage);
maFocusedSelectionBackground = CreateBackgroundBitmap(
rDevice, Theme::SelectedAndFocusedPage);
maMouseOverBackground = CreateBackgroundBitmap(rDevice, Theme::MouseOverPage); maMouseOverBackground = CreateBackgroundBitmap(rDevice, Theme::MouseOverPage);
} }
} }
@@ -563,12 +574,7 @@ Bitmap PageObjectPainter::CreateBackgroundBitmap(
aBitmapDevice.DrawLine(Point(0,nY), Point(aSize.Width(),nY)); aBitmapDevice.DrawLine(Point(0,nY), Point(aSize.Width(),nY));
} }
// Paint the border. PaintBorder(aBitmapDevice, eColorType, Rectangle(Point(0,0), aSize));
aBitmapDevice.SetFillColor();
aBitmapDevice.SetLineColor(mpTheme->GetGradientColor(eColorType, Theme::Border2));
aBitmapDevice.DrawRect(Rectangle(Point(0,0),aSize));
aBitmapDevice.SetLineColor(mpTheme->GetGradientColor(eColorType, Theme::Border1));
aBitmapDevice.DrawLine(Point(0,0),Point(aSize.Width()-1,0));
// Get bounding box of the preview around which a shadow is painted. // Get bounding box of the preview around which a shadow is painted.
// Compensate for the border around the preview. // Compensate for the border around the preview.
@@ -590,6 +596,22 @@ Bitmap PageObjectPainter::CreateBackgroundBitmap(
void PageObjectPainter::PaintBorder (
OutputDevice& rDevice,
const Theme::GradientColorType eColorType,
const Rectangle& rBox) const
{
const Size aSize (mpPageObjectLayouter->GetPageObjectSize());
rDevice.SetFillColor();
rDevice.SetLineColor(mpTheme->GetGradientColor(eColorType, Theme::Border2));
rDevice.DrawRect(rBox);
rDevice.SetLineColor(mpTheme->GetGradientColor(eColorType, Theme::Border1));
rDevice.DrawLine(rBox.TopLeft(), rBox.TopRight());
}
//===== FramePainter ========================================================== //===== FramePainter ==========================================================
PageObjectPainter::FramePainter::FramePainter (const BitmapEx& rShadowBitmap) PageObjectPainter::FramePainter::FramePainter (const BitmapEx& rShadowBitmap)

View File

@@ -87,6 +87,7 @@ Theme::Theme (const ::boost::shared_ptr<controller::Properties>& rpProperties)
: maBackgroundColor(rpProperties->GetBackgroundColor().GetColor()), : maBackgroundColor(rpProperties->GetBackgroundColor().GetColor()),
maNormalGradient(), maNormalGradient(),
maSelectedGradient(), maSelectedGradient(),
maSelectedAndFocusedGradient(),
maMouseOverGradient(), maMouseOverGradient(),
maRawShadow(), maRawShadow(),
maInsertionIndicator() maInsertionIndicator()
@@ -107,15 +108,21 @@ void Theme::Update (const ::boost::shared_ptr<controller::Properties>& rpPropert
maBackgroundColor = rpProperties->GetBackgroundColor().GetColor(); maBackgroundColor = rpProperties->GetBackgroundColor().GetColor();
#ifdef USE_SYSTEM_SELECTION_COLOR #ifdef USE_SYSTEM_SELECTION_COLOR
const ColorData aSelectionColor (rpProperties->GetSelectionColor().GetColor()); const ColorData aSelectionColor (rpProperties->GetSelectionColor().GetColor());
maSelectedGradient.maFillColor1 = ChangeLuminance(aSelectionColor, +50); maSelectedGradient.maFillColor1 = ChangeLuminance(aSelectionColor, +50);
maSelectedGradient.maFillColor2 = ChangeLuminance(aSelectionColor, -10); maSelectedGradient.maFillColor2 = ChangeLuminance(aSelectionColor, -10);
maSelectedGradient.maBorderColor1 = ChangeLuminance(aSelectionColor, -10); maSelectedGradient.maBorderColor1 = ChangeLuminance(aSelectionColor, -10);
maSelectedGradient.maBorderColor2 = ChangeLuminance(aSelectionColor, -30); maSelectedGradient.maBorderColor2 = ChangeLuminance(aSelectionColor, -30);
maMouseOverGradient.maFillColor1 = ChangeLuminance(aSelectionColor, -30); maSelectedAndFocusedGradient.maFillColor1 = ChangeLuminance(aSelectionColor, +30);
maMouseOverGradient.maFillColor2 = ChangeLuminance(aSelectionColor, -90); maSelectedAndFocusedGradient.maFillColor2 = ChangeLuminance(aSelectionColor, -30);
maMouseOverGradient.maBorderColor1 = ChangeLuminance(aSelectionColor, -30); maSelectedAndFocusedGradient.maBorderColor1 = ChangeLuminance(aSelectionColor, -30);
maMouseOverGradient.maBorderColor2 = ChangeLuminance(aSelectionColor, -10); maSelectedAndFocusedGradient.maBorderColor2 = ChangeLuminance(aSelectionColor, -50);
maMouseOverGradient.maFillColor1 = ChangeLuminance(aSelectionColor, +90);
maMouseOverGradient.maFillColor2 = ChangeLuminance(aSelectionColor, +30);
maMouseOverGradient.maBorderColor1 = ChangeLuminance(aSelectionColor, +10);
maMouseOverGradient.maBorderColor2 = ChangeLuminance(aSelectionColor, +30);
#else #else
@@ -124,6 +131,11 @@ void Theme::Update (const ::boost::shared_ptr<controller::Properties>& rpPropert
maSelectedGradient.maBorderColor1 = 0x6db5e1; maSelectedGradient.maBorderColor1 = 0x6db5e1;
maSelectedGradient.maBorderColor2 = 0x0e85cd; maSelectedGradient.maBorderColor2 = 0x0e85cd;
maSelectedAndFocusedGradient.maFillColor1 = 0xb7daf0;
maSelectedAndFocusedGradient.maFillColor2 = 0x6db5e1;
maSelectedAndFocusedGradient.maBorderColor1 = 0x6db5e1;
maSelectedAndFocusedGradient.maBorderColor2 = 0x0e85cd;
maMouseOverGradient.maFillColor1 = 0x0e85cd; maMouseOverGradient.maFillColor1 = 0x0e85cd;
maMouseOverGradient.maFillColor2 = 0x044c99; maMouseOverGradient.maFillColor2 = 0x044c99;
maMouseOverGradient.maBorderColor1 = 0x6db5e1; maMouseOverGradient.maBorderColor1 = 0x6db5e1;
@@ -236,6 +248,10 @@ ColorData Theme::GetGradientColor (
pDescriptor = &maSelectedGradient; pDescriptor = &maSelectedGradient;
break; break;
case SelectedAndFocusedPage:
pDescriptor = &maSelectedAndFocusedGradient;
break;
case MouseOverPage: case MouseOverPage:
pDescriptor = &maMouseOverGradient; pDescriptor = &maMouseOverGradient;
break; break;