--- a/camerauis/cameraapp/generic/src/CamPreCaptureContainerBase.cpp Tue May 11 15:56:11 2010 +0300
+++ b/camerauis/cameraapp/generic/src/CamPreCaptureContainerBase.cpp Tue May 25 12:22:04 2010 +0300
@@ -34,7 +34,9 @@
#include <cameraapp.mbg>
#include <cameraapp.rsg>
#include <vgacamsettings.rsg>
-
+#include <touchfeedback.h>
+#include <akntoolbar.h>
+#include <akntoolbarextension.h>
#include "CamAppUiBase.h"
#include "CamPreCaptureContainerBase.h"
@@ -62,7 +64,8 @@
#include "camconfiguration.h"
#include "CameraUiConfigManager.h"
#include "camstartuplogo.h"
-
+#include "camvfgridinterface.h"
+#include "camlinevfgriddrawer.h"
// CONSTANTS
const TInt KZoomPanelTimeout = 4000000; // 4s
@@ -73,8 +76,13 @@
const TInt KNumberOfBlinks = 3;
const TInt KNumberOfBlinksVideo = 8;
-#include "camvfgridinterface.h"
-#include "camlinevfgriddrawer.h"
+const TRect KIconRect(0, 0, 40, 40);
+const TInt32 KCaptureButtonWidth( 50 );
+const TInt32 KCaptureButtonYDelta( 35 );
+const TInt32 KCaptureIconDelta( 7 );
+const TUint32 KToolbarExtensionBgColor = 0x00000000;
+const TInt KToolBarExtensionBgAlpha = 0x7F;
+
// Snapshot data is needed in timelapse mode
const TUint KCameraEventInterest = ( ECamCameraEventClassVfControl
@@ -303,6 +311,15 @@
TRAP_IGNORE(iStartupLogo = CCamStartupLogo::NewL(*appUi->StartupLogoController(), aRect));
}
+ // Capture icon rectangle
+ TRect containerRect = Rect();
+ TPoint center( containerRect.Center() );
+
+ iCaptureRect.SetRect( center.iX - KCaptureButtonWidth/2,
+ containerRect.iBr.iY - KCaptureButtonWidth - KCaptureButtonYDelta,
+ center.iX + KCaptureButtonWidth/2,
+ containerRect.iBr.iY - KCaptureButtonYDelta );
+
PRINT( _L("Camera <= CCamPreCaptureContainerBase::BaseConstructL ") );
}
@@ -484,11 +501,13 @@
// so will be processed by the container.
// Handle Zoom in key if we are not saving video
+ // and if toolbar extension is not visible
PRINT( _L("Camera <> CCamPreCaptureContainerBase::OfferKeyEventL B") )
if ( IsZoomKeyL( aKeyEvent, aType )
&& ECamCompleting != iController.CurrentOperation()
&& !iController.CurrentlySavingVideo()
- && !appUi->IsSecondCameraEnabled() )
+ && !appUi->IsSecondCameraEnabled()
+ && !appUi->IsToolBarExtensionVisible() )
{
// Offer the key event to the zoom pane/model
TKeyResponse resp = iZoomPane->OfferKeyEventL( aKeyEvent, aType );
@@ -550,6 +569,13 @@
PRINT( _L("Camera <> CCamPreCaptureContainerBase::OfferKeyEventL calling StopZoom()") );
zoom_pane->StopZoom();
}
+
+ // Stop blinking icon when capture is initiated
+ if ( iIndBlinkTimer && iIndBlinkTimer->IsActive() )
+ {
+ iIndBlinkTimer->Cancel();
+ iDrawIndicator = ETrue;
+ }
}
TBool viewFinderRunning = iReceivedVfFrame;
if ( iController.UiConfigManagerPtr() &&
@@ -725,11 +751,42 @@
iPhotoSceneUsesReticule = !iController.CurrentSceneHasForcedFocus();
HandleOperationStateChangeEventL();
}
-
}
+ iCaptureButtonShown = CaptureButtonActive();
break;
}
// ---------------------------------------------------
+ case ECamEventEngineStateChanged:
+ {
+ PRINT1( _L("Camera <> Start mode indi blinking, op:%d"), iController.CurrentOperation() );
+
+ if ( !iController.UiConfigManagerPtr()->IsCustomCaptureButtonSupported()
+ && !iController.EngineRequestsPending()
+ && iController.TargetMode() == iController.CurrentMode()
+ && iController.CurrentOperation() == ECamNoOperation
+ && !iBlinkResolutionIndicator )
+ {
+ PRINT( _L("Camera <> mode indi blinking - starting timers") );
+ if ( !iIndBlinkTimer )
+ {
+ iIndBlinkTimer = CPeriodic::NewL( EPriorityLess );
+ }
+ else
+ {
+ iIndBlinkTimer->Cancel();
+ }
+
+ iToggleCountdown = 2 * KNumberOfBlinks;
+ iBlinkModeIndicator = ETrue;
+ iIndBlinkTimer->Start( KIndicatorBlinkDelay,
+ KIndicatorBlinkDelay,
+ TCallBack( IndicatorVisible, this) );
+
+ iDrawIndicator = ETrue;
+ }
+ break;
+ }
+ // ---------------------------------------------------
case ECamEventExitRequested:
{
iShuttingDown = ETrue;
@@ -798,6 +855,8 @@
case ECamEventVideoQualityChanged:
if ( iBlinkResolutionIndicator )
{
+ iBlinkModeIndicator = EFalse;
+
// Force the first blink to occur right away
iDrawIndicator = EFalse;
DrawResolutionIndicator();
@@ -892,7 +951,7 @@
ResetVFGridVisibility();
}
else
- {
+ { // Background
if ( iIndBlinkTimer )
{
iIndBlinkTimer->Cancel();
@@ -914,7 +973,7 @@
// Update the view ID for when we come back.
TCamAppViewIds viewId = static_cast<TCamAppViewIds>( iView.Id().iUid );
- SetPreviousViewId( viewId );
+ SetPreviousViewId( viewId );
}
PRINT( _L( "Camera <= CCamPreCaptureContainerBase::HandleForegroundEventL" ) );
}
@@ -1061,6 +1120,13 @@
}
DrawScreenFurniture( gc );
DrawNaviControls( gc );
+
+ // Draw capture button
+ if( iCaptureButtonShown )
+ {
+ DrawCaptureButton( gc );
+ }
+
PRINT( _L( "Camera <= CCamPreCaptureContainerBase::Draw" ) );
}
@@ -2383,37 +2449,105 @@
//
void CCamPreCaptureContainerBase::HandlePointerEventL( const TPointerEvent& aPointerEvent )
{
- PRINT3( _L("CCamPreCaptureContainerBase::HandlePointerEventL iType=%d iPosition=(%d, %d)"),
+ PRINT3( _L("Camera => CCamPreCaptureContainerBase::HandlePointerEventL iType=%d iPosition=(%d, %d)"),
aPointerEvent.iType,
aPointerEvent.iPosition.iX,
aPointerEvent.iPosition.iY );
CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() );
- if ( !appUi->IsSecondCameraEnabled() )
+ // Capture button
+ TRect captureRect( iCaptureRect );
+ captureRect.Grow( 30, 30 );
+
+ if ( iCaptureButtonShown && captureRect.Contains( aPointerEvent.iPosition ) )
{
- // don't let zoom pane be used when capturing image
- if ( iController.CurrentMode() != ECamControllerImage ||
- (iController.CurrentOperation() != ECamCapturing &&
- iController.CurrentOperation() != ECamCompleting) )
+ if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
+ {
+ MTouchFeedback* feedback = MTouchFeedback::Instance();
+ if ( !iCaptureIconPressed && feedback )
+ {
+ feedback->InstantFeedback( ETouchFeedbackBasicButton );
+ }
+ iCaptureIconPressed = ETrue;
+ DrawNow( captureRect );
+ }
+ else if ( aPointerEvent.iType == TPointerEvent::EButton1Up
+ && iCaptureIconPressed )
{
- if ( iZoomPane )
- {
- if ( iZoomPane->HandlePointerEventL( aPointerEvent ) )
+ iCaptureIconPressed = EFalse;
+
+ // Give feedback on button release
+ MTouchFeedback* feedback = MTouchFeedback::Instance();
+ if ( feedback )
+ {
+ feedback->InstantFeedback( ETouchFeedbackBasicButton );
+ }
+
+ // About to start capture ... hide stop zoom etc.
+ if ( iZoomPane )
+ {
+ PRINT( _L("Camera <> CCamPreCaptureContainerBase::HandlePointerEventL - StopZoom()") );
+ iZoomPane->StopZoom();
+ iZoomPane->MakeVisible( EFalse, ETrue );
+ }
+ // Stop blinking icon when capture is initiated
+ if ( iIndBlinkTimer && iIndBlinkTimer->IsActive() )
+ {
+ iIndBlinkTimer->Cancel();
+ iDrawIndicator = ETrue;
+ }
+
+ if ( iController.CurrentMode() == ECamControllerVideo )
+ {
+ iView.HandleCommandL( ECamCmdRecord );
+ }
+ else
+ {
+ iView.HandleCommandL( ECamCmdCaptureImage );
+ }
+ }
+ else
+ {
+ // Avoid compiler warning
+ }
+ }
+ else
+ {
+ PRINT( _L("Camera <> CCamPreCaptureContainerBase::HandlePointerEventL - outside button region") );
+ // Drags can potentially start from inside button area
+ if ( iCaptureIconPressed && aPointerEvent.iType != TPointerEvent::EDrag )
+ {
+ iCaptureIconPressed = EFalse;
+ DrawNow( captureRect );
+ }
+
+ if ( !appUi->IsSecondCameraEnabled() )
+ {
+ // don't let zoom pane be used when capturing image
+ if ( iController.CurrentMode() != ECamControllerImage ||
+ ( iController.CurrentOperation() != ECamCapturing &&
+ iController.CurrentOperation() != ECamCompleting &&
+ iController.CurrentOperation() != ECamFocusing ) )
+ {
+ if ( iZoomPane )
{
- ShowZoomPaneWithTimer();
- return;
+ if ( iZoomPane->HandlePointerEventL( aPointerEvent ) )
+ {
+ ShowZoomPaneWithTimer();
+ return;
+ }
}
+ }
+
+ if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
+ !appUi->DrawPreCaptureCourtesyUI() )
+ {
+ appUi->HandleCommandL( ECamCmdRaiseCourtesyUI );
}
+ CCamContainerBase::HandlePointerEventL( aPointerEvent );
}
+ }
- if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
- !appUi->DrawPreCaptureCourtesyUI() )
- {
- appUi->HandleCommandL( ECamCmdRaiseCourtesyUI );
- }
-
- CCamContainerBase::HandlePointerEventL( aPointerEvent );
- }
PRINT( _L("Camera <= CCamPreCaptureContainerBase::HandlePointerEventL") );
}
@@ -2675,33 +2809,30 @@
return resolutionIconLayout.Rect();
}
+// -------------------------------------------------------------
+// CCamPreCaptureContainerBase::BlinkResolutionIndicatorOnChange
+// -------------------------------------------------------------
+//
void CCamPreCaptureContainerBase::BlinkResolutionIndicatorOnChange( TBool aBlink )
{
iBlinkResolutionIndicator = aBlink;
}
+// -------------------------------------------------------------
+// CCamPreCaptureContainerBase::DrawResolutionIndicator
+// -------------------------------------------------------------
+//
void CCamPreCaptureContainerBase::DrawResolutionIndicator()
{
PRINT( _L("Camera => CCamPreCaptureContainerBase::DrawResolutionIndicator") );
iToggleCountdown--;
- // Stop immediately the periodic timer for showing correctly
- // the text "Processing image" when capturing a still image.
- TBool stillCapturing = ECamControllerImage == iController.CurrentMode() &&
- ECamImageCaptureSingle == iController.CurrentImageMode() &&
- iController.IsProcessingCapture();
- if ( stillCapturing )
- {
- iBlinkResolutionIndicator = EFalse;
- iIndBlinkTimer->Cancel();
- return;
- }
-
// State changed, need to redraw
ActivateGc();
// Invalidate the flash icon area
- TRect rect( iResolutionIndicators[iCurrentIndicator]->LayoutRect() );
+ TRect rect( (iBlinkModeIndicator) ? iSidePane->ModeIndicatorLayoutRect()
+ : iResolutionIndicators[iCurrentIndicator]->LayoutRect() );
RWindow window = Window();
window.Invalidate( rect );
window.BeginRedraw( rect );
@@ -2709,17 +2840,35 @@
// Redraw the background in that area
Redraw( rect );
- // Draw the flash icon itself
+ // Draw the icon
CWindowGc& gc = SystemGc();
- if( iDrawIndicator )
+ if ( iBlinkModeIndicator )
{
- iResolutionIndicators[iCurrentIndicator]->DisplayIcon();
+ iSidePane->DrawModeIndicator( gc, iDrawIndicator );
}
else
{
- iResolutionIndicators[iCurrentIndicator]->ClearIcon();
+ // Mode indicator should be visible, while the resolution indicator blinks
+ if ( !iController.UiConfigManagerPtr()->IsCustomCaptureButtonSupported() )
+ {
+ iSidePane->DrawModeIndicator( gc, ETrue );
+ }
+
+ if( iDrawIndicator )
+ {
+ iResolutionIndicators[iCurrentIndicator]->DisplayIcon();
+ }
+ else
+ {
+ iResolutionIndicators[iCurrentIndicator]->ClearIcon();
+ }
+ iResolutionIndicators[iCurrentIndicator]->Draw( gc );
+
+ // If blink timer is canceled abruptly(like capture image) at some places, resolution indicator may go missing in pre-capture mode.
+ // So alway set resolution clear flag to EFlase after drawing resolution indicator to avoiding missing indicator.
+ // This do not affect indicator blink function because this just set the flag, do not draw the indicator.
+ iResolutionIndicators[iCurrentIndicator]->DisplayIcon();
}
- iResolutionIndicators[iCurrentIndicator]->Draw( gc );
// Tell the window redraw is finished and deactivate Gc
window.EndRedraw();
@@ -2729,12 +2878,17 @@
if ( iDrawIndicator && iToggleCountdown <= 0 )
{
iBlinkResolutionIndicator = EFalse;
+ iBlinkModeIndicator = EFalse;
iIndBlinkTimer->Cancel();
}
PRINT( _L("Camera <= CCamPreCaptureContainerBase::DrawResolutionIndicator") );
}
+// -------------------------------------------------------------
+// CCamPreCaptureContainerBase::IndicatorVisible
+// -------------------------------------------------------------
+//
TInt CCamPreCaptureContainerBase::IndicatorVisible( TAny *aSelf )
{
PRINT( _L("Camera => CCamPreCaptureContainerBase::IndicatorVisible") );
@@ -2749,5 +2903,65 @@
return KErrNone;
}
+// -------------------------------------------------------------
+// CCamPreCaptureContainerBase::DrawCaptureButton
+// -------------------------------------------------------------
+//
+void CCamPreCaptureContainerBase::DrawCaptureButton( CBitmapContext& aGc ) const
+ {
+ TRect containerRect = Rect();
+ TPoint iconTl( containerRect.Center().iX - KCaptureButtonWidth/2 + KCaptureIconDelta,
+ containerRect.iBr.iY - KCaptureButtonYDelta - KCaptureButtonWidth + KCaptureIconDelta );
+
+ aGc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
+ aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+ aGc.SetPenStyle( CGraphicsContext::ENullPen );
+
+ if ( iCaptureIconPressed )
+ {
+ aGc.SetBrushColor( KRgbBlack );
+ }
+ else
+ {
+ aGc.SetBrushColor( TRgb( KToolbarExtensionBgColor, KToolBarExtensionBgAlpha ) );
+ }
+ aGc.DrawEllipse( iCaptureRect );
+
+ aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
+ aGc.SetPenStyle( CGraphicsContext::ESolidPen );
+ aGc.BitBltMasked( iconTl, iCaptureIcon, KIconRect, iCaptureMask, EFalse );
+ }
+
+// -------------------------------------------------------------
+// CCamPreCaptureContainerBase::FocusChanged
+// -------------------------------------------------------------
+//
+void CCamPreCaptureContainerBase::FocusChanged( TDrawNow aDrawNow )
+ {
+ PRINT2( _L("Camera <> CCamPreCaptureContainerBase::FocusChanged, draw:%d, focused:%d"), aDrawNow,
+ IsFocused() );
+ iCaptureButtonShown = CaptureButtonActive();
+ if ( aDrawNow )
+ {
+ DrawNow();
+ }
+ }
+
+// -------------------------------------------------------------
+// CCamPreCaptureContainerBase::CaptureButtonActive
+// -------------------------------------------------------------
+//
+TBool CCamPreCaptureContainerBase::CaptureButtonActive() const
+ {
+ TBool buttonActive = EFalse;
+ if ( iController.UiConfigManagerPtr()->IsCustomCaptureButtonSupported()
+ && iController.IsTouchScreenSupported() )
+ {
+ buttonActive = IsFocused() && iController.CurrentOperation() == ECamNoOperation;
+ PRINT1( _L("Camera <> capture button active:%d"), buttonActive );
+ }
+ return buttonActive;
+ }
+
// End of File