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
// it, so that the focus indicator becomes visible.
mrSlideSorter.GetController().GetSelectionManager()->MakeRectangleVisible (
GetFocusedPageDescriptor()->GetBoundingBox());
mrSlideSorter.GetView().GetLayouter().GetPageObjectBox(
rpDescriptor->GetPageIndex(), true));
}
#ifndef UNIFY_FOCUS_AND_CURRENT_PAGE
mrSlideSorter.GetView().RequestRepaint (rpDescriptor);
#endif
mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
NotifyFocusChangeListeners();
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -235,6 +235,7 @@ PageObjectPainter::PageObjectPainter (
mpShadowPainter(),
maNormalBackground(),
maSelectionBackground(),
maFocusedSelectionBackground(),
maMouseOverBackground()
{
LocalResource aResource (IMG_ICONS);
@@ -294,6 +295,7 @@ void PageObjectPainter::NotifyResize (void)
{
maNormalBackground.SetEmpty();
maSelectionBackground.SetEmpty();
maFocusedSelectionBackground.SetEmpty();
maMouseOverBackground.SetEmpty();
}
@@ -326,15 +328,22 @@ void PageObjectPainter::PaintBackground (
}
else if (rpDescriptor->HasState(model::PageDescriptor::ST_Selected))
{
rDevice.DrawBitmap(
aBox.TopLeft(),
maSelectionBackground);
if (rpDescriptor->HasState(model::PageDescriptor::ST_Focused))
rDevice.DrawBitmap(
aBox.TopLeft(),
maFocusedSelectionBackground);
else
rDevice.DrawBitmap(
aBox.TopLeft(),
maSelectionBackground);
}
else
{
rDevice.DrawBitmap(
aBox.TopLeft(),
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);
maSelectionBackground = CreateBackgroundBitmap(rDevice, Theme::SelectedPage);
maFocusedSelectionBackground = CreateBackgroundBitmap(
rDevice, Theme::SelectedAndFocusedPage);
maMouseOverBackground = CreateBackgroundBitmap(rDevice, Theme::MouseOverPage);
}
}
@@ -563,12 +574,7 @@ Bitmap PageObjectPainter::CreateBackgroundBitmap(
aBitmapDevice.DrawLine(Point(0,nY), Point(aSize.Width(),nY));
}
// Paint the border.
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));
PaintBorder(aBitmapDevice, eColorType, Rectangle(Point(0,0), aSize));
// Get bounding box of the preview around which a shadow is painted.
// 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 ==========================================================
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()),
maNormalGradient(),
maSelectedGradient(),
maSelectedAndFocusedGradient(),
maMouseOverGradient(),
maRawShadow(),
maInsertionIndicator()
@@ -107,15 +108,21 @@ void Theme::Update (const ::boost::shared_ptr<controller::Properties>& rpPropert
maBackgroundColor = rpProperties->GetBackgroundColor().GetColor();
#ifdef USE_SYSTEM_SELECTION_COLOR
const ColorData aSelectionColor (rpProperties->GetSelectionColor().GetColor());
maSelectedGradient.maFillColor1 = ChangeLuminance(aSelectionColor, +50);
maSelectedGradient.maFillColor2 = ChangeLuminance(aSelectionColor, -10);
maSelectedGradient.maBorderColor1 = ChangeLuminance(aSelectionColor, -10);
maSelectedGradient.maBorderColor2 = ChangeLuminance(aSelectionColor, -30);
maMouseOverGradient.maFillColor1 = ChangeLuminance(aSelectionColor, -30);
maMouseOverGradient.maFillColor2 = ChangeLuminance(aSelectionColor, -90);
maMouseOverGradient.maBorderColor1 = ChangeLuminance(aSelectionColor, -30);
maMouseOverGradient.maBorderColor2 = ChangeLuminance(aSelectionColor, -10);
maSelectedAndFocusedGradient.maFillColor1 = ChangeLuminance(aSelectionColor, +30);
maSelectedAndFocusedGradient.maFillColor2 = ChangeLuminance(aSelectionColor, -30);
maSelectedAndFocusedGradient.maBorderColor1 = ChangeLuminance(aSelectionColor, -30);
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
@@ -124,6 +131,11 @@ void Theme::Update (const ::boost::shared_ptr<controller::Properties>& rpPropert
maSelectedGradient.maBorderColor1 = 0x6db5e1;
maSelectedGradient.maBorderColor2 = 0x0e85cd;
maSelectedAndFocusedGradient.maFillColor1 = 0xb7daf0;
maSelectedAndFocusedGradient.maFillColor2 = 0x6db5e1;
maSelectedAndFocusedGradient.maBorderColor1 = 0x6db5e1;
maSelectedAndFocusedGradient.maBorderColor2 = 0x0e85cd;
maMouseOverGradient.maFillColor1 = 0x0e85cd;
maMouseOverGradient.maFillColor2 = 0x044c99;
maMouseOverGradient.maBorderColor1 = 0x6db5e1;
@@ -236,6 +248,10 @@ ColorData Theme::GetGradientColor (
pDescriptor = &maSelectedGradient;
break;
case SelectedAndFocusedPage:
pDescriptor = &maSelectedAndFocusedGradient;
break;
case MouseOverPage:
pDescriptor = &maMouseOverGradient;
break;