// EXTERNAL INCLUDES
#include <Ecore.h>
#include <Evas.h>
-#ifndef WAYLAND
+#ifdef WAYLAND
+#include <Ecore_Wayland.h>
+#else
#include <Ecore_X.h>
#endif
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+#include <iomanip>
+#include <fstream>
#include <dali/public-api/images/native-image.h>
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/events/touch-point.h>
#include <dali/public-api/common/stage.h>
-#include <dali/public-api/actors/blending.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
#include <dali/public-api/images/buffer-image.h>
+#include <dali/public-api/images/pixel.h>
#include <dali/integration-api/debug.h>
}
};
+#ifdef ENABLE_INDICATOR_IMAGE_SAVING
+
+void SaveIndicatorImage( Dali::NativeImageSourcePtr nativeImageSource )
+{
+ // Save image data to disk in BMP form.
+ static int gFilenameCounter = 0;
+ static const char bmpHeader[] = {
+ 0x42, 0x4d, 0x0a, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x7c, 0x00,
+ 0x00, 0x00,
+ 0xe0, 0x01, 0x00, 0x00, // Width (480)
+ 0x1b, 0x00, 0x00, 0x00, // Height ( 27)
+ 0x01, 0x00, 0x20, 0x00, 0x03, 0x00,
+ 0x00, 0x00, 0x80, 0xca, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+
+ // This is a BMP header with width & height hard-coded in.
+ // The data was first determined by dumping the raw data and inspecting in GIMP, before creating this header data.
+ std::vector<unsigned char> buffer;
+ unsigned int w = 0;
+ unsigned int h = 0;
+ Dali::Pixel::Format pixelFormat;
+ if( nativeImageSource->GetPixels( buffer, w, h, pixelFormat ) )
+ {
+ int imageSize = w * h * 4;
+ std::stringstream fileName;
+ // Give each file an incremental filename.
+ fileName << "/opt/usr/media/Images/out-" << std::setfill( '0' ) << std::setw( 5 ) << gFilenameCounter << ".bmp";
+
+ std::ofstream outfile( fileName.str().c_str(), std::ofstream::binary );
+ if( outfile.is_open() )
+ {
+ DALI_LOG_WARNING( "Saving Indicator Image w:%d, h:%d, %s\n", w, h, fileName.str().c_str() );
+
+ outfile.write( bmpHeader, sizeof( bmpHeader ) / sizeof( bmpHeader[0] ) ); // Size of the BMP header.
+ outfile.write( (const char*)buffer.data(), imageSize );
+ outfile.close();
+ gFilenameCounter++;
+ }
+ else
+ {
+ DALI_LOG_ERROR( "COULD NOT OPEN FOR SAVING: %s\n", fileName.str().c_str() );
+ }
+ }
+}
+
+#endif
+
} // anonymous namespace
Debug::Filter* gIndicatorLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_INDICATOR");
#endif
-#ifndef WAYLAND
// Impl to hide EFL implementation.
+
struct Indicator::Impl
{
- // Construction & Destruction
+ enum // operation mode
+ {
+ INDICATOR_HIDE,
+ INDICATOR_STAY_WITH_DURATION
+ };
/**
* Constructor
: mIndicator(indicator),
mEcoreEventHandler(NULL)
{
- // Register Client message events for quick panel state.
+#if defined(DALI_PROFILE_MOBILE)
+#if defined(WAYLAND)
+ mEcoreEventHandler = ecore_event_handler_add(ECORE_WL_EVENT_INDICATOR_FLICK, EcoreEventIndicator, this);
+#else
mEcoreEventHandler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, EcoreEventClientMessage, this);
+#endif
+#endif // WAYLAND && DALI_PROFILE_MOBILE
}
/**
*/
~Impl()
{
- ecore_event_handler_del(mEcoreEventHandler);
+ if ( mEcoreEventHandler )
+ {
+ ecore_event_handler_del(mEcoreEventHandler);
+ }
}
- /**
- * Called when the client messages (i.e. quick panel state) are received.
- */
- static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
+ static void SetIndicatorVisibility( void* data, int operation )
{
- Ecore_X_Event_Client_Message* clientMessageEvent((Ecore_X_Event_Client_Message*)event);
Indicator::Impl* indicatorImpl((Indicator::Impl*)data);
- if (clientMessageEvent == NULL || indicatorImpl == NULL || indicatorImpl->mIndicator == NULL)
+ if ( indicatorImpl == NULL || indicatorImpl->mIndicator == NULL)
{
- return ECORE_CALLBACK_PASS_ON;
+ return;
}
-
-#ifndef DALI_PROFILE_UBUNTU
- if (clientMessageEvent->message_type == ECORE_X_ATOM_E_INDICATOR_FLICK_DONE)
+ if ( operation == INDICATOR_STAY_WITH_DURATION )
{
// if indicator is not showing, INDICATOR_FLICK_DONE is given
if( indicatorImpl->mIndicator->mVisible == Dali::Window::AUTO &&
indicatorImpl->mIndicator->ShowIndicator( AUTO_INDICATOR_STAY_DURATION );
}
}
- else if( clientMessageEvent->message_type == ECORE_X_ATOM_E_MOVE_QUICKPANEL_STATE )
+ else if( operation == INDICATOR_HIDE )
{
if( indicatorImpl->mIndicator->mVisible == Dali::Window::AUTO &&
indicatorImpl->mIndicator->mIsShowing )
indicatorImpl->mIndicator->ShowIndicator( HIDE_NOW );
}
}
-#endif
+ }
+#if defined(DALI_PROFILE_MOBILE)
+#if defined(WAYLAND)
+ /**
+ * Called when the Ecore indicator event is received.
+ */
+ static Eina_Bool EcoreEventIndicator( void* data, int type, void* event )
+ {
+ SetIndicatorVisibility( data, INDICATOR_STAY_WITH_DURATION );
+ return ECORE_CALLBACK_PASS_ON;
+ }
+#else
+ /**
+ * Called when the client messages (i.e. quick panel state) are received.
+ */
+ static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
+ {
+ Ecore_X_Event_Client_Message* clientMessageEvent((Ecore_X_Event_Client_Message*)event);
+ if ( clientMessageEvent != NULL )
+ {
+ if (clientMessageEvent->message_type == ECORE_X_ATOM_E_INDICATOR_FLICK_DONE)
+ {
+ SetIndicatorVisibility( data, INDICATOR_STAY_WITH_DURATION );
+ }
+ else if ( clientMessageEvent->message_type == ECORE_X_ATOM_E_MOVE_QUICKPANEL_STATE )
+ {
+ SetIndicatorVisibility( data, INDICATOR_HIDE );
+ }
+ }
return ECORE_CALLBACK_PASS_ON;
}
+#endif
+#endif // WAYLAND && DALI_PROFILE_MOBILE
// Data
Indicator* mIndicator;
Ecore_Event_Handler* mEcoreEventHandler;
};
-#endif
Indicator::LockFile::LockFile(const std::string filename)
: mFilename(filename),
// hide the indicator by default
mIndicatorActor.SetVisible( false );
-#ifndef WAYLAND
// create impl to handle ecore event
mImpl = new Impl(this);
-#endif
}
Indicator::~Indicator()
{
-#ifndef WAYLAND
if(mImpl)
{
delete mImpl;
mImpl = NULL;
}
-#endif
if(mEventActor)
{
break;
case Dali::PointState::UP:
+ case Dali::PointState::INTERRUPTED:
{
IpcDataEvMouseUp ipcUp( touchEvent.time );
mServerConnection->SendEvent( OP_EV_MOUSE_UP, &ipcUp, sizeof(ipcUp) );
DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "W:%d H:%d", mImageWidth, mImageHeight );
Dali::NativeImageSourcePtr nativeImageSource = Dali::NativeImageSource::New( mPixmap );
+#ifdef ENABLE_INDICATOR_IMAGE_SAVING
+ SaveIndicatorImage( nativeImageSource );
+#endif
+
if( nativeImageSource )
{
Dali::Texture texture = Dali::Texture::New( *nativeImageSource );