From 5ca9732f0a8b08b7d8be6cc9cc315f2f53ce3fd6 Mon Sep 17 00:00:00 2001 From: Richard Huang Date: Tue, 25 Aug 2020 10:33:01 +0100 Subject: [PATCH] KeyEvent class pimpling Change-Id: I459ad95131f7e6cf650bfae8b6b98d9ec934032d --- automated-tests/src/dali/utc-Dali-KeyEvent.cpp | 340 ++++++++++++++------- automated-tests/src/dali/utc-Dali-Scene.cpp | 72 +++-- automated-tests/src/dali/utc-Dali-Stage.cpp | 72 +++-- dali/devel-api/common/stage.h | 2 +- dali/devel-api/events/key-event-devel.cpp | 48 ++- dali/devel-api/events/key-event-devel.h | 84 ++++- dali/integration-api/events/key-event-integ.cpp | 24 +- dali/integration-api/events/key-event-integ.h | 48 ++- dali/integration-api/scene.h | 2 +- dali/internal/event/actors/actor-impl.h | 2 +- dali/internal/event/common/scene-impl.cpp | 5 +- dali/internal/event/common/scene-impl.h | 4 +- dali/internal/event/events/key-event-impl.cpp | 205 ++++++++----- dali/internal/event/events/key-event-impl.h | 224 ++++++++++---- dali/internal/event/events/key-event-processor.cpp | 15 +- dali/public-api/actors/custom-actor-impl.h | 2 +- dali/public-api/events/key-event.cpp | 123 +++----- dali/public-api/events/key-event.h | 132 +++++--- 18 files changed, 902 insertions(+), 502 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-KeyEvent.cpp b/automated-tests/src/dali/utc-Dali-KeyEvent.cpp index 68703a5..d1a0118 100644 --- a/automated-tests/src/dali/utc-Dali-KeyEvent.cpp +++ b/automated-tests/src/dali/utc-Dali-KeyEvent.cpp @@ -61,9 +61,7 @@ struct SignalData { functorCalled = false; - receivedKeyEvent.keyModifier = 0; - receivedKeyEvent.keyPressedName.clear(); - receivedKeyEvent.keyPressed.clear(); + receivedKeyEvent.Reset(); keyedActor.Reset(); } @@ -96,64 +94,184 @@ int UtcDaliKeyEventConstructor(void) { TestApplication application; // Reset all test adapter return codes - KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0, KeyEvent::Down); // set name to test, key string to i and modifier to shift + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); // set name to test, key string to i and modifier to shift + DALI_TEST_CHECK( event ); + + DALI_TEST_EQUALS(TEST_STRING_1, event.GetKeyName(), TEST_LOCATION); // check key name + DALI_TEST_EQUALS("I", event.GetLogicalKey(), TEST_LOCATION); // check logical key string + DALI_TEST_EQUALS("i", event.GetKeyString(), TEST_LOCATION); // check key string + DALI_TEST_EQUALS(99, event.GetKeyCode(), TEST_LOCATION); // check keyCode + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(0lu, event.GetTime(), TEST_LOCATION); // check time + DALI_TEST_EQUALS(KeyEvent::Down, event.GetState(), TEST_LOCATION); // check state + DALI_TEST_EQUALS("", event.GetCompose(), TEST_LOCATION); // check compose + DALI_TEST_EQUALS("", event.GetDeviceName(), TEST_LOCATION); // check device name + DALI_TEST_EQUALS(Device::Class::NONE, event.GetDeviceClass(), TEST_LOCATION); // check device class + DALI_TEST_EQUALS(Device::Subclass::NONE, event.GetDeviceSubclass(), TEST_LOCATION); // check device subclass - DALI_TEST_EQUALS(TEST_STRING_1, event.keyPressedName, TEST_LOCATION); // check key name - DALI_TEST_EQUALS("i", event.keyPressed, TEST_LOCATION); // check key string - DALI_TEST_EQUALS(99, event.keyCode, TEST_LOCATION); // check keyCode - DALI_TEST_EQUALS(SHIFT_MODIFIER, event.keyModifier, TEST_LOCATION); // check modifier - DALI_TEST_EQUALS(KeyEvent::Down, event.state, TEST_LOCATION); // check state END_TEST; } -int UtcDaliKeyEventAssignment(void) +int UtcDaliKeyEventCopyAssignment(void) { // Test Assignment operator - KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0, KeyEvent::Down); // set name to test, key string to i and modifier to shift + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); // set name to test, key string to i and modifier to shift + DALI_TEST_CHECK( event ); + + DALI_TEST_EQUALS(TEST_STRING_1, event.GetKeyName(), TEST_LOCATION); // check key name + DALI_TEST_EQUALS("I", event.GetLogicalKey(), TEST_LOCATION); // check logical key string + DALI_TEST_EQUALS("i", event.GetKeyString(), TEST_LOCATION); // check key string + DALI_TEST_EQUALS(99, event.GetKeyCode(), TEST_LOCATION); // check keyCode + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(0lu, event.GetTime(), TEST_LOCATION); // check time + DALI_TEST_EQUALS(KeyEvent::Down, event.GetState(), TEST_LOCATION); // check state + DALI_TEST_EQUALS("", event.GetCompose(), TEST_LOCATION); // check compose + DALI_TEST_EQUALS("", event.GetDeviceName(), TEST_LOCATION); // check device name + DALI_TEST_EQUALS(Device::Class::NONE, event.GetDeviceClass(), TEST_LOCATION); // check device class + DALI_TEST_EQUALS(Device::Subclass::NONE, event.GetDeviceSubclass(), TEST_LOCATION); // check device subclass + + Dali::KeyEvent event2 = DevelKeyEvent::New(TEST_STRING_1, "J", "j", 88, CTRL_MODIFIER, 0lu, KeyEvent::Up, "", "", Device::Class::USER, Device::Subclass::FINGER); // set name to test, key string to i and modifier to shift + DALI_TEST_CHECK( event2 ); + + DALI_TEST_EQUALS(TEST_STRING_1, event2.GetKeyName(), TEST_LOCATION); // check key name + DALI_TEST_EQUALS("J", event2.GetLogicalKey(), TEST_LOCATION); // check logical key string + DALI_TEST_EQUALS("j", event2.GetKeyString(), TEST_LOCATION); // check key string + DALI_TEST_EQUALS(88, event2.GetKeyCode(), TEST_LOCATION); // check keyCode + DALI_TEST_EQUALS(CTRL_MODIFIER, event2.GetKeyModifier(), TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(0lu, event2.GetTime(), TEST_LOCATION); // check time + DALI_TEST_EQUALS(KeyEvent::Up, event2.GetState(), TEST_LOCATION); // check state + DALI_TEST_EQUALS("", event2.GetCompose(), TEST_LOCATION); // check compose + DALI_TEST_EQUALS("", event2.GetDeviceName(), TEST_LOCATION); // check device name + DALI_TEST_EQUALS(Device::Class::USER, event2.GetDeviceClass(), TEST_LOCATION); // check device class + DALI_TEST_EQUALS(Device::Subclass::FINGER, event2.GetDeviceSubclass(), TEST_LOCATION); // check device subclass - DALI_TEST_EQUALS(TEST_STRING_1, event.keyPressedName, TEST_LOCATION); // check key name - DALI_TEST_EQUALS("i", event.keyPressed, TEST_LOCATION); // check key string - DALI_TEST_EQUALS(99, event.keyCode, TEST_LOCATION); // check keyCode - DALI_TEST_EQUALS(SHIFT_MODIFIER, event.keyModifier, TEST_LOCATION); // check modifier - DALI_TEST_EQUALS(KeyEvent::Down, event.state, TEST_LOCATION); // check state - - KeyEvent event2(TEST_STRING_1,"j", 88, CTRL_MODIFIER, 0, KeyEvent::Up); // set name to test, key string to i and modifier to shift + event = event2; + DALI_TEST_CHECK( event ); + + DALI_TEST_EQUALS(TEST_STRING_1, event.GetKeyName(), TEST_LOCATION); // check key name + DALI_TEST_EQUALS("J", event.GetLogicalKey(), TEST_LOCATION); // check logical key string + DALI_TEST_EQUALS("j", event.GetKeyString(), TEST_LOCATION); // check key string + DALI_TEST_EQUALS(88, event.GetKeyCode(), TEST_LOCATION); // check keyCode + DALI_TEST_EQUALS(CTRL_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(0lu, event.GetTime(), TEST_LOCATION); // check time + DALI_TEST_EQUALS(KeyEvent::Up, event.GetState(), TEST_LOCATION); // check state + DALI_TEST_EQUALS("", event.GetCompose(), TEST_LOCATION); // check compose + DALI_TEST_EQUALS("", event.GetDeviceName(), TEST_LOCATION); // check device name + DALI_TEST_EQUALS(Device::Class::USER, event.GetDeviceClass(), TEST_LOCATION); // check device class + DALI_TEST_EQUALS(Device::Subclass::FINGER, event.GetDeviceSubclass(), TEST_LOCATION); // check device subclass - DALI_TEST_EQUALS(TEST_STRING_1, event2.keyPressedName, TEST_LOCATION); // check key name - DALI_TEST_EQUALS("j", event2.keyPressed, TEST_LOCATION); // check key string - DALI_TEST_EQUALS(88, event2.keyCode, TEST_LOCATION); // check keyCode - DALI_TEST_EQUALS(CTRL_MODIFIER, event2.keyModifier, TEST_LOCATION); // check modifier - DALI_TEST_EQUALS(KeyEvent::Up, event2.state, TEST_LOCATION); // check state + END_TEST; +} - event = event2; +int UtcDaliKeyEventCopyConstructor(void) +{ + // Test Assignment operator + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); // set name to test, key string to i and modifier to shift + DALI_TEST_CHECK( event ); + + DALI_TEST_EQUALS(TEST_STRING_1, event.GetKeyName(), TEST_LOCATION); // check key name + DALI_TEST_EQUALS("I", event.GetLogicalKey(), TEST_LOCATION); // check logical key string + DALI_TEST_EQUALS("i", event.GetKeyString(), TEST_LOCATION); // check key string + DALI_TEST_EQUALS(99, event.GetKeyCode(), TEST_LOCATION); // check keyCode + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(0lu, event.GetTime(), TEST_LOCATION); // check time + DALI_TEST_EQUALS(KeyEvent::Down, event.GetState(), TEST_LOCATION); // check state + DALI_TEST_EQUALS("", event.GetCompose(), TEST_LOCATION); // check compose + DALI_TEST_EQUALS("", event.GetDeviceName(), TEST_LOCATION); // check device name + DALI_TEST_EQUALS(Device::Class::NONE, event.GetDeviceClass(), TEST_LOCATION); // check device class + DALI_TEST_EQUALS(Device::Subclass::NONE, event.GetDeviceSubclass(), TEST_LOCATION); // check device subclass - DALI_TEST_EQUALS(TEST_STRING_1, event.keyPressedName, TEST_LOCATION); // check key name - DALI_TEST_EQUALS("j", event.keyPressed, TEST_LOCATION); // check key string - DALI_TEST_EQUALS(88, event.keyCode, TEST_LOCATION); // check keyCode - DALI_TEST_EQUALS(CTRL_MODIFIER, event.keyModifier, TEST_LOCATION); // check modifier - DALI_TEST_EQUALS(KeyEvent::Up, event.state, TEST_LOCATION); // check state + KeyEvent event2( event ); + DALI_TEST_CHECK( event2 ); + + DALI_TEST_EQUALS(TEST_STRING_1, event2.GetKeyName(), TEST_LOCATION); // check key name + DALI_TEST_EQUALS("I", event2.GetLogicalKey(), TEST_LOCATION); // check logical key string + DALI_TEST_EQUALS("i", event2.GetKeyString(), TEST_LOCATION); // check key string + DALI_TEST_EQUALS(99, event2.GetKeyCode(), TEST_LOCATION); // check keyCode + DALI_TEST_EQUALS(SHIFT_MODIFIER, event2.GetKeyModifier(), TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(0lu, event2.GetTime(), TEST_LOCATION); // check time + DALI_TEST_EQUALS(KeyEvent::Down, event2.GetState(), TEST_LOCATION); // check state + DALI_TEST_EQUALS("", event2.GetCompose(), TEST_LOCATION); // check compose + DALI_TEST_EQUALS("", event2.GetDeviceName(), TEST_LOCATION); // check device name + DALI_TEST_EQUALS(Device::Class::NONE, event2.GetDeviceClass(), TEST_LOCATION); // check device class + DALI_TEST_EQUALS(Device::Subclass::NONE, event2.GetDeviceSubclass(), TEST_LOCATION); // check device subclass END_TEST; } -int UtcDaliKeyEventCopy(void) +int UtcDaliKeyEventMoveAssignment(void) { // Test Assignment operator - KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0, KeyEvent::Down); // set name to test, key string to i and modifier to shift - - DALI_TEST_EQUALS(TEST_STRING_1, event.keyPressedName, TEST_LOCATION); // check key name - DALI_TEST_EQUALS("i", event.keyPressed, TEST_LOCATION); // check key string - DALI_TEST_EQUALS(99, event.keyCode, TEST_LOCATION); // check keyCode - DALI_TEST_EQUALS(SHIFT_MODIFIER, event.keyModifier, TEST_LOCATION); // check modifier - DALI_TEST_EQUALS(KeyEvent::Down, event.state, TEST_LOCATION); // check state + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); // set name to test, key string to i and modifier to shift + DALI_TEST_CHECK( event ); + + DALI_TEST_EQUALS(TEST_STRING_1, event.GetKeyName(), TEST_LOCATION); // check key name + DALI_TEST_EQUALS("I", event.GetLogicalKey(), TEST_LOCATION); // check logical key string + DALI_TEST_EQUALS("i", event.GetKeyString(), TEST_LOCATION); // check key string + DALI_TEST_EQUALS(99, event.GetKeyCode(), TEST_LOCATION); // check keyCode + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(0lu, event.GetTime(), TEST_LOCATION); // check time + DALI_TEST_EQUALS(KeyEvent::Down, event.GetState(), TEST_LOCATION); // check state + DALI_TEST_EQUALS("", event.GetCompose(), TEST_LOCATION); // check compose + DALI_TEST_EQUALS("", event.GetDeviceName(), TEST_LOCATION); // check device name + DALI_TEST_EQUALS(Device::Class::NONE, event.GetDeviceClass(), TEST_LOCATION); // check device class + DALI_TEST_EQUALS(Device::Subclass::NONE, event.GetDeviceSubclass(), TEST_LOCATION); // check device subclass + + KeyEvent move; + move = std::move( event ); + DALI_TEST_CHECK( move ); + + DALI_TEST_EQUALS(TEST_STRING_1, move.GetKeyName(), TEST_LOCATION); // check key name + DALI_TEST_EQUALS("I", move.GetLogicalKey(), TEST_LOCATION); // check logical key string + DALI_TEST_EQUALS("i", move.GetKeyString(), TEST_LOCATION); // check key string + DALI_TEST_EQUALS(99, move.GetKeyCode(), TEST_LOCATION); // check keyCode + DALI_TEST_EQUALS(SHIFT_MODIFIER, move.GetKeyModifier(), TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(0lu, move.GetTime(), TEST_LOCATION); // check time + DALI_TEST_EQUALS(KeyEvent::Down, move.GetState(), TEST_LOCATION); // check state + DALI_TEST_EQUALS("", move.GetCompose(), TEST_LOCATION); // check compose + DALI_TEST_EQUALS("", move.GetDeviceName(), TEST_LOCATION); // check device name + DALI_TEST_EQUALS(Device::Class::NONE, move.GetDeviceClass(), TEST_LOCATION); // check device class + DALI_TEST_EQUALS(Device::Subclass::NONE, move.GetDeviceSubclass(), TEST_LOCATION); // check device subclass + + DALI_TEST_CHECK( !event ); - KeyEvent event2( event ); + END_TEST; +} - DALI_TEST_EQUALS(TEST_STRING_1, event2.keyPressedName, TEST_LOCATION); // check key name - DALI_TEST_EQUALS("i", event2.keyPressed, TEST_LOCATION); // check key string - DALI_TEST_EQUALS(99, event2.keyCode, TEST_LOCATION); // check keyCode - DALI_TEST_EQUALS(SHIFT_MODIFIER, event2.keyModifier, TEST_LOCATION); // check modifier - DALI_TEST_EQUALS(KeyEvent::Down, event2.state, TEST_LOCATION); // check state +int UtcDaliKeyEventMoveConstructor(void) +{ + // Test Assignment operator + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); // set name to test, key string to i and modifier to shift + DALI_TEST_CHECK( event ); + + DALI_TEST_EQUALS(TEST_STRING_1, event.GetKeyName(), TEST_LOCATION); // check key name + DALI_TEST_EQUALS("I", event.GetLogicalKey(), TEST_LOCATION); // check logical key string + DALI_TEST_EQUALS("i", event.GetKeyString(), TEST_LOCATION); // check key string + DALI_TEST_EQUALS(99, event.GetKeyCode(), TEST_LOCATION); // check keyCode + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(0lu, event.GetTime(), TEST_LOCATION); // check time + DALI_TEST_EQUALS(KeyEvent::Down, event.GetState(), TEST_LOCATION); // check state + DALI_TEST_EQUALS("", event.GetCompose(), TEST_LOCATION); // check compose + DALI_TEST_EQUALS("", event.GetDeviceName(), TEST_LOCATION); // check device name + DALI_TEST_EQUALS(Device::Class::NONE, event.GetDeviceClass(), TEST_LOCATION); // check device class + DALI_TEST_EQUALS(Device::Subclass::NONE, event.GetDeviceSubclass(), TEST_LOCATION); // check device subclass + + KeyEvent move = std::move( event ); + DALI_TEST_CHECK( move ); + + DALI_TEST_EQUALS(TEST_STRING_1, move.GetKeyName(), TEST_LOCATION); // check key name + DALI_TEST_EQUALS("I", move.GetLogicalKey(), TEST_LOCATION); // check logical key string + DALI_TEST_EQUALS("i", move.GetKeyString(), TEST_LOCATION); // check key string + DALI_TEST_EQUALS(99, move.GetKeyCode(), TEST_LOCATION); // check keyCode + DALI_TEST_EQUALS(SHIFT_MODIFIER, move.GetKeyModifier(), TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(0lu, move.GetTime(), TEST_LOCATION); // check time + DALI_TEST_EQUALS(KeyEvent::Down, move.GetState(), TEST_LOCATION); // check state + DALI_TEST_EQUALS("", move.GetCompose(), TEST_LOCATION); // check compose + DALI_TEST_EQUALS("", move.GetDeviceName(), TEST_LOCATION); // check device name + DALI_TEST_EQUALS(Device::Class::NONE, move.GetDeviceClass(), TEST_LOCATION); // check device class + DALI_TEST_EQUALS(Device::Subclass::NONE, move.GetDeviceSubclass(), TEST_LOCATION); // check device subclass + + DALI_TEST_CHECK( !event ); END_TEST; } @@ -163,12 +281,15 @@ int UtcDaliKeyEventIsShiftModifier(void) { TestApplication application; // Reset all test adapter return codes - KeyEvent event; - DALI_TEST_EQUALS(0, event.keyModifier, TEST_LOCATION); + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, CTRL_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); // set name to test, key string to i and modifier to shift + DALI_TEST_CHECK( event ); + + DALI_TEST_EQUALS(CTRL_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); + DALI_TEST_EQUALS(false, event.IsShiftModifier(), TEST_LOCATION); // check IsShiftModifier - event.keyModifier = SHIFT_MODIFIER; // Set to Shift Modifier + DevelKeyEvent::SetKeyModifier( event, SHIFT_MODIFIER ); // Set to Shift Modifier - DALI_TEST_EQUALS(SHIFT_MODIFIER, event.keyModifier, TEST_LOCATION); // check able to set + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); // check able to set DALI_TEST_EQUALS(true, event.IsShiftModifier(), TEST_LOCATION); // check IsShiftModifier @@ -180,12 +301,15 @@ int UtcDaliKeyEventIsCtrlModifier(void) { TestApplication application; // Reset all test adapter return codes - KeyEvent event; - DALI_TEST_EQUALS(0, event.keyModifier, TEST_LOCATION); + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); // set name to test, key string to i and modifier to shift + DALI_TEST_CHECK( event ); - event.keyModifier = CTRL_MODIFIER; // Set to Ctrl Modifier + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); + DALI_TEST_EQUALS(false, event.IsCtrlModifier(), TEST_LOCATION); // check IsCtrlModifier - DALI_TEST_EQUALS(CTRL_MODIFIER, event.keyModifier, TEST_LOCATION); // check able to set + DevelKeyEvent::SetKeyModifier( event, CTRL_MODIFIER ); // Set to Ctrl Modifier + + DALI_TEST_EQUALS(CTRL_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); // check able to set DALI_TEST_EQUALS(true, event.IsCtrlModifier(), TEST_LOCATION); // check IsCtrlModifier END_TEST; @@ -196,12 +320,15 @@ int UtcDaliKeyEventIsAltModifier(void) { TestApplication application; // Reset all test adapter return codes - KeyEvent event; - DALI_TEST_EQUALS(0, event.keyModifier, TEST_LOCATION); + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); // set name to test, key string to i and modifier to shift + DALI_TEST_CHECK( event ); + + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); + DALI_TEST_EQUALS(false, event.IsAltModifier(), TEST_LOCATION); // check IsAltModifier - event.keyModifier = ALT_MODIFIER; // Set to Alt Modifier + DevelKeyEvent::SetKeyModifier( event, ALT_MODIFIER ); // Set to Alt Modifier - DALI_TEST_EQUALS(ALT_MODIFIER, event.keyModifier, TEST_LOCATION); // check able to set + DALI_TEST_EQUALS(ALT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); // check able to set DALI_TEST_EQUALS(true, event.IsAltModifier(), TEST_LOCATION); // IsAltModifier END_TEST; @@ -212,9 +339,9 @@ int UtcDaliKeyEventIsNotShiftModifier(void) { TestApplication application; // Reset all test adapter return codes - KeyEvent event("i","i", 0, CTRL_MODIFIER, 0, KeyEvent::Down); + Dali::KeyEvent event = DevelKeyEvent::New("i", "I", "i", 0, CTRL_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); - DALI_TEST_EQUALS(CTRL_MODIFIER, event.keyModifier, TEST_LOCATION); // check different modifier used + DALI_TEST_EQUALS(CTRL_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); DALI_TEST_EQUALS(false, event.IsShiftModifier(), TEST_LOCATION); END_TEST; @@ -225,9 +352,9 @@ int UtcDaliKeyEventIsNotCtrlModifier(void) { TestApplication application; // Reset all test adapter return codes - KeyEvent event("i","i", 0, ALT_MODIFIER, 0, KeyEvent::Up); + Dali::KeyEvent event = DevelKeyEvent::New("i", "I", "i", 0, ALT_MODIFIER, 0lu, KeyEvent::Up, "", "", Device::Class::NONE, Device::Subclass::NONE); - DALI_TEST_EQUALS(ALT_MODIFIER, event.keyModifier, TEST_LOCATION); // check different modifier used + DALI_TEST_EQUALS(ALT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); DALI_TEST_EQUALS(false, event.IsCtrlModifier(), TEST_LOCATION); END_TEST; @@ -238,9 +365,9 @@ int UtcDaliKeyEventIsNotAltModifier(void) { TestApplication application; // Reset all test adapter return codes - KeyEvent event("i","i", 0, SHIFT_MODIFIER, 0, KeyEvent::Up); + Dali::KeyEvent event = DevelKeyEvent::New("i", "I", "i", 0, SHIFT_MODIFIER, 0lu, KeyEvent::Up, "", "", Device::Class::NONE, Device::Subclass::NONE); - DALI_TEST_EQUALS(SHIFT_MODIFIER, event.keyModifier, TEST_LOCATION); // check different modifier used + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION); DALI_TEST_EQUALS(false, event.IsAltModifier(), TEST_LOCATION); END_TEST; @@ -251,10 +378,10 @@ int UtcDaliKeyEventANDModifer(void) { TestApplication application; // Reset all test adapter return codes - KeyEvent event("i","i", 0, SHIFT_AND_CTRL_MODIFIER, 0, KeyEvent::Down); + Dali::KeyEvent event = DevelKeyEvent::New("i", "I", "i", 0, SHIFT_AND_CTRL_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); DALI_TEST_EQUALS(true, (bool)(event.IsCtrlModifier() & event.IsShiftModifier()), TEST_LOCATION); - event.keyModifier = SHIFT_MODIFIER; + DevelKeyEvent::SetKeyModifier( event, SHIFT_MODIFIER ); // Set to Shift Modifier DALI_TEST_EQUALS(false, (bool)(event.IsCtrlModifier() & event.IsShiftModifier()), TEST_LOCATION); END_TEST; @@ -265,24 +392,10 @@ int UtcDaliKeyEventORModifer(void) { TestApplication application; // Reset all test adapter return codes - KeyEvent event("i","i", 0, SHIFT_AND_CTRL_MODIFIER, 0, KeyEvent::Down); + Dali::KeyEvent event = DevelKeyEvent::New("i", "I", "i", 0, SHIFT_AND_CTRL_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); DALI_TEST_EQUALS(true, (bool)(event.IsCtrlModifier() | event.IsAltModifier()), TEST_LOCATION); - event.keyModifier = SHIFT_MODIFIER; - - DALI_TEST_EQUALS(false, (bool)(event.IsCtrlModifier() & event.IsAltModifier()), TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliKeyEventState(void) -{ - TestApplication application; // Reset all test adapter return codes - - KeyEvent event("i","i", 0, SHIFT_AND_CTRL_MODIFIER, 0, KeyEvent::Down); - DALI_TEST_EQUALS(true, (bool)(event.IsCtrlModifier() | event.IsAltModifier()), TEST_LOCATION); - - event.keyModifier = SHIFT_MODIFIER; + DevelKeyEvent::SetKeyModifier( event, SHIFT_MODIFIER ); // Set to Shift Modifier DALI_TEST_EQUALS(false, (bool)(event.IsCtrlModifier() & event.IsAltModifier()), TEST_LOCATION); END_TEST; @@ -302,6 +415,10 @@ int UtcDaliIntegrationKeyEvent(void) DALI_TEST_EQUALS( keyEvent.keyModifier, 0, TEST_LOCATION ); DALI_TEST_EQUALS( keyEvent.time, 0lu, TEST_LOCATION ); DALI_TEST_EQUALS( keyEvent.state, Integration::KeyEvent::Down, TEST_LOCATION); + DALI_TEST_EQUALS( keyEvent.compose, std::string(), TEST_LOCATION); + DALI_TEST_EQUALS( keyEvent.deviceName, std::string(), TEST_LOCATION); + DALI_TEST_EQUALS( keyEvent.deviceClass, Device::Class::NONE, TEST_LOCATION); + DALI_TEST_EQUALS( keyEvent.deviceSubclass, Device::Subclass::NONE, TEST_LOCATION); } { @@ -334,81 +451,86 @@ int UtcDaliIntegrationKeyEvent(void) END_TEST; } -int UtcDaliIntegrationKeyEventConvertor(void) +int UtcDaliKeyEventSetKeyName(void) { TestApplication application; - KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down); // set name to test, key string to i and modifier to shift + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); - Integration::KeyEvent keyEvent( event ); + DALI_TEST_EQUALS( TEST_STRING_1, event.GetKeyName(), TEST_LOCATION ); - DALI_TEST_EQUALS( keyEvent.type, Integration::Event::Key, TEST_LOCATION ); - DALI_TEST_CHECK( keyEvent.keyName == TEST_STRING_1 ); - DALI_TEST_CHECK( keyEvent.logicalKey == "" ); - DALI_TEST_CHECK( keyEvent.keyString == "i" ); - DALI_TEST_EQUALS( keyEvent.keyCode, 99, TEST_LOCATION ); - DALI_TEST_EQUALS( keyEvent.keyModifier, SHIFT_MODIFIER, TEST_LOCATION ); - DALI_TEST_EQUALS( keyEvent.time, 0lu, TEST_LOCATION ); - DALI_TEST_EQUALS( keyEvent.state, Integration::KeyEvent::Down, TEST_LOCATION); - DALI_TEST_EQUALS( keyEvent.compose, "", TEST_LOCATION); - DALI_TEST_EQUALS( keyEvent.deviceName, "", TEST_LOCATION); - DALI_TEST_EQUALS( keyEvent.deviceClass, Device::Class::NONE, TEST_LOCATION); - DALI_TEST_EQUALS( keyEvent.deviceSubclass, Device::Subclass::NONE, TEST_LOCATION); + DevelKeyEvent::SetKeyName( event, "keyName" ); + DALI_TEST_EQUALS( "keyName", event.GetKeyName(), TEST_LOCATION ); END_TEST; } -int UtcDaliKeyEventSetCompose(void) +int UtcDaliKeyEventSetKeyString(void) { TestApplication application; - KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down); + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); + + DALI_TEST_EQUALS( "i", event.GetKeyString(), TEST_LOCATION ); - DALI_TEST_EQUALS( event.GetCompose(), "", TEST_LOCATION); + DevelKeyEvent::SetKeyString( event, "keyString" ); + DALI_TEST_EQUALS( "keyString", event.GetKeyString(), TEST_LOCATION ); END_TEST; } -int UtcDaliKeyEventSetDeviceName(void) +int UtcDaliKeyEventSetKeyCode(void) { TestApplication application; - KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down); + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); - DALI_TEST_EQUALS( event.GetDeviceName(), "", TEST_LOCATION); + DALI_TEST_EQUALS( 99, event.GetKeyCode(), TEST_LOCATION ); + + DevelKeyEvent::SetKeyCode( event, 88 ); + DALI_TEST_EQUALS( 88, event.GetKeyCode(), TEST_LOCATION ); END_TEST; } -int UtcDaliKeyEventSetDeviceClass(void) +int UtcDaliKeyEventSetKeyModifier(void) { TestApplication application; - KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down); + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); + + DALI_TEST_EQUALS( SHIFT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION ); - DALI_TEST_EQUALS( event.GetDeviceClass(), Device::Class::NONE, TEST_LOCATION); + DevelKeyEvent::SetKeyModifier( event, ALT_MODIFIER ); + DALI_TEST_EQUALS( ALT_MODIFIER, event.GetKeyModifier(), TEST_LOCATION ); END_TEST; } -int UtcDaliKeyEventSetDeviceSubclass(void) +int UtcDaliKeyEventSetTime(void) { TestApplication application; - KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down); + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); - DALI_TEST_EQUALS( event.GetDeviceSubclass(), Device::Subclass::NONE, TEST_LOCATION); + DALI_TEST_EQUALS( 0lu, event.GetTime(), TEST_LOCATION ); + + DevelKeyEvent::SetTime( event, 100lu ); + DALI_TEST_EQUALS( 100lu, event.GetTime(), TEST_LOCATION ); END_TEST; } -int UtcDaliKeyEventSetLogicalKey(void) +int UtcDaliKeyEventSetState(void) { TestApplication application; - KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down); + Dali::KeyEvent event = DevelKeyEvent::New(TEST_STRING_1, "I", "i", 99, SHIFT_MODIFIER, 0lu, KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE); + + DALI_TEST_EQUALS( KeyEvent::Down, event.GetState(), TEST_LOCATION ); - DALI_TEST_EQUALS( DevelKeyEvent::GetLogicalKey( event ), "", TEST_LOCATION ); + DevelKeyEvent::SetState( event, KeyEvent::Up ); + DALI_TEST_EQUALS( KeyEvent::Up, event.GetState(), TEST_LOCATION ); END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-Scene.cpp b/automated-tests/src/dali/utc-Dali-Scene.cpp index 59ea755..418c2ed 100644 --- a/automated-tests/src/dali/utc-Dali-Scene.cpp +++ b/automated-tests/src/dali/utc-Dali-Scene.cpp @@ -64,9 +64,7 @@ struct KeyEventSignalData { functorCalled = false; - receivedKeyEvent.keyModifier = 0; - receivedKeyEvent.keyPressedName.clear(); - receivedKeyEvent.keyPressed.clear(); + receivedKeyEvent.Reset(); } bool functorCalled; @@ -182,9 +180,7 @@ struct KeyEventGeneratedSignalData { functorCalled = false; - receivedKeyEvent.keyModifier = 0; - receivedKeyEvent.keyPressedName.clear(); - receivedKeyEvent.keyPressed.clear(); + receivedKeyEvent.Reset(); } bool functorCalled; @@ -569,10 +565,10 @@ int UtcDaliSceneSignalKeyEventP(void) application.ProcessEvent( event ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -580,10 +576,10 @@ int UtcDaliSceneSignalKeyEventP(void) application.ProcessEvent( event2 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event2.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event2.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -591,10 +587,10 @@ int UtcDaliSceneSignalKeyEventP(void) application.ProcessEvent( event3 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event3.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event3.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -602,10 +598,10 @@ int UtcDaliSceneSignalKeyEventP(void) application.ProcessEvent( event4 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event4.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event4.state == static_cast( data.receivedKeyEvent.GetState() ) ); END_TEST; } @@ -1054,10 +1050,10 @@ int UtcDaliSceneKeyEventGeneratedSignalP(void) application.ProcessEvent( event ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -1065,10 +1061,10 @@ int UtcDaliSceneKeyEventGeneratedSignalP(void) application.ProcessEvent( event2 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event2.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event2.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -1076,10 +1072,10 @@ int UtcDaliSceneKeyEventGeneratedSignalP(void) application.ProcessEvent( event3 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event3.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event3.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -1087,10 +1083,10 @@ int UtcDaliSceneKeyEventGeneratedSignalP(void) application.ProcessEvent( event4 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event4.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event4.state == static_cast( data.receivedKeyEvent.GetState() ) ); END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-Stage.cpp b/automated-tests/src/dali/utc-Dali-Stage.cpp index d1a6444..341ec31 100644 --- a/automated-tests/src/dali/utc-Dali-Stage.cpp +++ b/automated-tests/src/dali/utc-Dali-Stage.cpp @@ -75,9 +75,7 @@ struct KeyEventGeneratedSignalData { functorCalled = false; - receivedKeyEvent.keyModifier = 0; - receivedKeyEvent.keyPressedName.clear(); - receivedKeyEvent.keyPressed.clear(); + receivedKeyEvent.Reset(); } bool functorCalled; @@ -119,9 +117,7 @@ struct KeyEventSignalData { functorCalled = false; - receivedKeyEvent.keyModifier = 0; - receivedKeyEvent.keyPressedName.clear(); - receivedKeyEvent.keyPressed.clear(); + receivedKeyEvent.Reset(); } bool functorCalled; @@ -870,10 +866,10 @@ int UtcDaliStageKeyEventGeneratedSignalP(void) application.ProcessEvent( event ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -881,10 +877,10 @@ int UtcDaliStageKeyEventGeneratedSignalP(void) application.ProcessEvent( event2 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event2.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event2.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -892,10 +888,10 @@ int UtcDaliStageKeyEventGeneratedSignalP(void) application.ProcessEvent( event3 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event3.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event3.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -903,10 +899,10 @@ int UtcDaliStageKeyEventGeneratedSignalP(void) application.ProcessEvent( event4 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event4.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event4.state == static_cast( data.receivedKeyEvent.GetState() ) ); END_TEST; } @@ -923,10 +919,10 @@ int UtcDaliStageSignalKeyEventP(void) application.ProcessEvent( event ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -934,10 +930,10 @@ int UtcDaliStageSignalKeyEventP(void) application.ProcessEvent( event2 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event2.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event2.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -945,10 +941,10 @@ int UtcDaliStageSignalKeyEventP(void) application.ProcessEvent( event3 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event3.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event3.state == static_cast( data.receivedKeyEvent.GetState() ) ); data.Reset(); @@ -956,10 +952,10 @@ int UtcDaliStageSignalKeyEventP(void) application.ProcessEvent( event4 ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier ); - DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName ); - DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed ); - DALI_TEST_CHECK( event4.state == static_cast( data.receivedKeyEvent.state ) ); + DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.GetKeyModifier() ); + DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.GetKeyName() ); + DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.GetKeyString() ); + DALI_TEST_CHECK( event4.state == static_cast( data.receivedKeyEvent.GetState() ) ); END_TEST; } diff --git a/dali/devel-api/common/stage.h b/dali/devel-api/common/stage.h index 50ba0de..81e5b2f 100644 --- a/dali/devel-api/common/stage.h +++ b/dali/devel-api/common/stage.h @@ -46,7 +46,7 @@ class WheelEvent; struct Vector2; struct Vector3; struct Vector4; -struct KeyEvent; +class KeyEvent; /** * @brief The Stage is a top-level object used for displaying a tree of Actors. diff --git a/dali/devel-api/events/key-event-devel.cpp b/dali/devel-api/events/key-event-devel.cpp index 502404e..6b6d336 100644 --- a/dali/devel-api/events/key-event-devel.cpp +++ b/dali/devel-api/events/key-event-devel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +25,51 @@ namespace Dali namespace DevelKeyEvent { -std::string GetLogicalKey( KeyEvent keyEvent ) +KeyEvent New( const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const Dali::KeyEvent::State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass ) { - return GetImplementation( &keyEvent )->GetLogicalKey(); + Internal::KeyEventPtr internal = Internal::KeyEvent::New( keyName, logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass ); + + return KeyEvent( internal.Get() ); +} + +void SetKeyName( KeyEvent keyEvent, const std::string& keyName ) +{ + GetImplementation( keyEvent ).SetKeyName( keyName ); +} + +void SetKeyString( KeyEvent keyEvent, const std::string& keyString ) +{ + GetImplementation( keyEvent ).SetKeyString( keyString ); +} + +void SetKeyCode( KeyEvent keyEvent, int32_t keyCode ) +{ + GetImplementation( keyEvent ).SetKeyCode( keyCode ); +} + +void SetKeyModifier( KeyEvent keyEvent, int32_t keyModifier ) +{ + GetImplementation( keyEvent ).SetKeyModifier( keyModifier ); +} + +void SetTime( KeyEvent keyEvent, unsigned long time ) +{ + GetImplementation( keyEvent ).SetTime( time ); +} + +void SetState( KeyEvent keyEvent, const KeyEvent::State& state ) +{ + GetImplementation( keyEvent ).SetState( state ); } } // namespace DevelKeyEvent diff --git a/dali/devel-api/events/key-event-devel.h b/dali/devel-api/events/key-event-devel.h index bdf1680..ad8b32e 100644 --- a/dali/devel-api/events/key-event-devel.h +++ b/dali/devel-api/events/key-event-devel.h @@ -2,7 +2,7 @@ #define DALI_KEY_EVENT_DEVEL_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,15 +28,87 @@ namespace DevelKeyEvent { /** - * @brief Gets the logical key string. + * @brief Creates an initialized WheelEvent. * - * For example, when the user presses 'shift' key and '1' key together, the logical key is "exclamation". - * Plus, the keyPressedName is "1", and the keyPressed is "!". + * @SINCE_1_9.27 + * @param[in] keyName The name of the key pressed or command from the IMF, if later then the some following parameters will be needed. + * @param[in] logicalKey The logical key symbol (eg. shift + 1 == "exclamation") + * @param[in] keyString The string of input characters or key pressed + * @param[in] keyCode The unique key code for the key pressed. + * @param[in] keyModifier The key modifier for special keys like shift and alt + * @param[in] timeStamp The time (in ms) that the key event occurred. + * @param[in] keyState The state of the key event. + * @param[in] compose The key compose + * @param[in] deviceName The name of device the key event originated from + * @param[in] deviceClass The class of device the key event originated from + * @param[in] deviceSubclass The subclass of device the key event originated from + * @return A handle to a newly allocated Dali resource + */ +DALI_CORE_API KeyEvent New( const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const Dali::KeyEvent::State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass ); + +/** + * @brief Set the name given to the key pressed + * + * @SINCE_1_9.27 + * @param[in] keyEvent The instance of KeyEvent. + * @param[in] keyName The name given to the key pressed. + */ +void SetKeyName( KeyEvent keyEvent, const std::string& keyName ); + +/** + * @brief Set the actual string of input characters that should be used for input editors. + * + * @SINCE_1_9.27 + * @param[in] keyEvent The instance of KeyEvent. + * @param[in] keyString The actual string of input characters + */ +void SetKeyString( KeyEvent keyEvent, const std::string& keyString ); + +/** + * @brief Set the unique key code for the key pressed. + * + * @SINCE_1_9.27 + * @param[in] keyEvent The instance of KeyEvent. + * @param[in] keyCode The unique key code for the key pressed + */ +void SetKeyCode( KeyEvent keyEvent, int32_t keyCode ); + +/** + * @brief Set the key modifier for special keys like Shift, Alt and Ctrl which modify the next key pressed. + * + * @SINCE_1_9.27 + * @param[in] keyEvent The instance of KeyEvent. + * @param[in] keyModifier The key modifier + */ +void SetKeyModifier( KeyEvent keyEvent, int32_t keyModifier ); + +/** + * @brief Set the time (in ms) that the key event occurred. + * + * @SINCE_1_9.27 + * @param[in] keyEvent The instance of KeyEvent. + * @param[in] time The time (in ms) + */ +void SetTime( KeyEvent keyEvent, unsigned long time ); + +/** + * @brief Set the state of the key event. * + * @SINCE_1_9.27 * @param[in] keyEvent The instance of KeyEvent. - * @return The logical key symbol + * @param[in] state The state of the key event */ -DALI_CORE_API std::string GetLogicalKey( KeyEvent keyEvent ); +void SetState( KeyEvent keyEvent, const KeyEvent::State& state ); } // namespace DevelKeyEvent diff --git a/dali/integration-api/events/key-event-integ.cpp b/dali/integration-api/events/key-event-integ.cpp index db7e1bc..a548e9c 100755 --- a/dali/integration-api/events/key-event-integ.cpp +++ b/dali/integration-api/events/key-event-integ.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,28 +61,6 @@ KeyEvent::KeyEvent( const std::string& keyName, const std::string& logicalKey, c { } -KeyEvent::KeyEvent( const Dali::KeyEvent& event ) -: Event( Key ), - keyName( event.keyPressedName ), - logicalKey( "" ), - keyString( event.keyPressed ), - keyCode( event.keyCode ), - keyModifier( event.keyModifier ), - time( event.time ), - state( static_cast< Integration::KeyEvent::State >( event.state ) ), - compose( "" ), - deviceName( "" ), - deviceClass( Device::Class::NONE ), - deviceSubclass( Device::Subclass::NONE ) -{ - const Internal::KeyEventImpl* keyEventImpl = GetImplementation( &event ); - logicalKey = keyEventImpl->GetLogicalKey(); - compose = keyEventImpl->GetCompose(); - deviceName = keyEventImpl->GetDeviceName(); - deviceClass = keyEventImpl->GetDeviceClass(); - deviceSubclass = keyEventImpl->GetDeviceSubclass(); -} - KeyEvent::~KeyEvent() { } diff --git a/dali/integration-api/events/key-event-integ.h b/dali/integration-api/events/key-event-integ.h index 4eadad7..e484448 100755 --- a/dali/integration-api/events/key-event-integ.h +++ b/dali/integration-api/events/key-event-integ.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_KEY_EVENT_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,17 +55,17 @@ struct DALI_CORE_API KeyEvent : public Event /** * Constructor - * @param[in] keyName The name of the key pressed or command from the IMF, if later then the some following parameters will be needed. - * @param[in] logicalKey The logical key symbol (eg. shift + 1 == "exclamation") - * @param[in] keyString A string of input characters or key pressed - * @param[in] keyCode The unique key code for the key pressed. - * @param[in] keyModifier The key modifier for special keys like shift and alt - * @param[in] timeStamp The time (in ms) that the key event occurred. - * @param[in] keyState The state of the key event. - * @param[in] compose The key compose - * @param[in] deviceName Name of device KeyEvent originated from - * @param[in] deviceClass Class of device KeyEvent originated from - * @param[in] deviceSubclass Subclass of device KeyEvent originated from + * @param[in] keyName The name of the key pressed or command from the IMF, if later then the some following parameters will be needed. + * @param[in] logicalKey The logical key symbol (eg. shift + 1 == "exclamation") + * @param[in] keyString The string of input characters or key pressed + * @param[in] keyCode The unique key code for the key pressed. + * @param[in] keyModifier The key modifier for special keys like shift and alt + * @param[in] timeStamp The time (in ms) that the key event occurred. + * @param[in] keyState The state of the key event. + * @param[in] compose The key compose + * @param[in] deviceName The name of device KeyEvent originated from + * @param[in] deviceClass The class of device KeyEvent originated from + * @param[in] deviceSubclass The subclass of device KeyEvent originated from */ KeyEvent(const std::string& keyName, const std::string& logicalKey, @@ -80,12 +80,6 @@ struct DALI_CORE_API KeyEvent : public Event const Device::Subclass::Type deviceSubclass ); /** - * Constructor, creates a Integration::KeyEvent from a Dali::KeyEvent - * @param[in] event Dali::KeyEvent to convert from - */ - explicit KeyEvent( const Dali::KeyEvent& event ); - - /** * Virtual destructor */ virtual ~KeyEvent(); @@ -93,7 +87,7 @@ struct DALI_CORE_API KeyEvent : public Event // Data /** - *@copydoc Dali::KeyEvent::keyPressedName + * The name of the key pressed or command from the IMF */ std::string keyName; @@ -103,22 +97,22 @@ struct DALI_CORE_API KeyEvent : public Event std::string logicalKey; /** - *@copydoc Dali::KeyEvent::keyPressed + * The string of input characters or key pressed */ std::string keyString; /** - * @copydoc Dali::KeyEvent::keyCode + * The unique key code for the key pressed. */ int keyCode; /** - *@copydoc Dali::KeyEvent::keyModifier + * The key modifier for special keys like shift and alt */ int keyModifier; /** - *@copydoc Dali::KeyEvent::time + * The time (in ms) that the key event occurred. */ unsigned long time; @@ -129,22 +123,22 @@ struct DALI_CORE_API KeyEvent : public Event State state; /** - * A string if this keystroke has modified a string in the middle of being composed - this string replaces the previous one. + * If this keystroke has modified a string in the middle of being composed - this string replaces the previous one. */ std::string compose; /** - * Name of device KeyEvent originated from + * The name of device KeyEvent originated from */ std::string deviceName; /** - * Class of device KeyEvent originated from + * The class of device KeyEvent originated from */ Device::Class::Type deviceClass; /** - * Subclass of device KeyEvent originated from + * The subclass of device KeyEvent originated from */ Device::Subclass::Type deviceSubclass; }; diff --git a/dali/integration-api/scene.h b/dali/integration-api/scene.h index c335154..b69eb10 100755 --- a/dali/integration-api/scene.h +++ b/dali/integration-api/scene.h @@ -31,7 +31,7 @@ namespace Dali { class Actor; -struct KeyEvent; +class KeyEvent; class Layer; class RenderTaskList; class TouchEvent; diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index b98408f..e34b5c5 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -42,7 +42,7 @@ namespace Dali { -struct KeyEvent; +class KeyEvent; class TouchData; class TouchEvent; class WheelEvent; diff --git a/dali/internal/event/common/scene-impl.cpp b/dali/internal/event/common/scene-impl.cpp index 09486d8..4b44566 100644 --- a/dali/internal/event/common/scene-impl.cpp +++ b/dali/internal/event/common/scene-impl.cpp @@ -291,7 +291,7 @@ SceneGraph::Scene* Scene::GetSceneObject() const return mSceneObject; } -void Scene::EmitKeyEventSignal(const KeyEvent& event) +void Scene::EmitKeyEventSignal(const Dali::KeyEvent& event) { if ( !mKeyEventSignal.Empty() ) { @@ -300,9 +300,10 @@ void Scene::EmitKeyEventSignal(const KeyEvent& event) } } -bool Scene::EmitKeyEventGeneratedSignal(const KeyEvent& event) +bool Scene::EmitKeyEventGeneratedSignal(const Dali::KeyEvent& event) { // Emit the KeyEventGenerated signal when KeyEvent is generated + Dali::Integration::Scene handle( this ); return mKeyEventGeneratedSignal.Emit( event ); } diff --git a/dali/internal/event/common/scene-impl.h b/dali/internal/event/common/scene-impl.h index 9db7d02..a271761 100644 --- a/dali/internal/event/common/scene-impl.h +++ b/dali/internal/event/common/scene-impl.h @@ -187,14 +187,14 @@ public: * Used by the EventProcessor to emit key event signals. * @param[in] event The key event. */ - void EmitKeyEventSignal(const KeyEvent& event); + void EmitKeyEventSignal(const Dali::KeyEvent& event); /** * Used by the KeyEventProcessor to emit KeyEventGenerated signals. * @param[in] event The key event. * @return The return is true if KeyEvent is consumed, otherwise false. */ - bool EmitKeyEventGeneratedSignal(const KeyEvent& event); + bool EmitKeyEventGeneratedSignal(const Dali::KeyEvent& event); /** * Emits the event processing finished signal. diff --git a/dali/internal/event/events/key-event-impl.cpp b/dali/internal/event/events/key-event-impl.cpp index 8f0c84f..dcad8d2 100755 --- a/dali/internal/event/events/key-event-impl.cpp +++ b/dali/internal/event/events/key-event-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,135 +26,190 @@ namespace Dali namespace { -/** - * This container stores a mapping between public key event and impl as we cannot add data members in public one. - * In practice this keeps the impl "alive" in between KeyEvent constructor and destructor calls so that getter - * methods can be called to access the new data members. There is a 1:1 mapping between KeyEvent and KeyEventImpl. - */ -struct KeyImplMapping -{ - KeyEvent* keyEvent; - Internal::KeyEventImpl* impl; -}; -Vector< KeyImplMapping > gKeyEventToImplMapping; - +const uint32_t MODIFIER_SHIFT = 0x1; +const uint32_t MODIFIER_CTRL = 0x2; +const uint32_t MODIFIER_ALT = 0x4; +const int32_t KEY_INVALID_CODE = -1; } namespace Internal { -KeyEventImpl::KeyEventImpl( KeyEvent* keyEvent ) -: mLogicalKey( "" ), +KeyEvent::KeyEvent() +: mKeyName( "" ), + mLogicalKey( "" ), + mKeyString( "" ), + mKeyCode( KEY_INVALID_CODE ), + mKeyModifier( 0 ), + mTime( 0 ), + mState( Dali::KeyEvent::Down ), mCompose( "" ), mDeviceName( "" ), mDeviceClass( Device::Class::NONE ), mDeviceSubclass( Device::Subclass::NONE ) { - gKeyEventToImplMapping.PushBack( { keyEvent, this } ); } -KeyEventImpl::~KeyEventImpl() +KeyEvent::KeyEvent( const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const Dali::KeyEvent::State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass ) +: mKeyName( keyName ), + mLogicalKey( logicalKey ), + mKeyString( keyString ), + mKeyCode( keyCode ), + mKeyModifier( keyModifier ), + mTime( timeStamp ), + mState( keyState ), + mCompose( compose ), + mDeviceName( deviceName ), + mDeviceClass( deviceClass ), + mDeviceSubclass( deviceSubclass ) { - for( auto&& iter : gKeyEventToImplMapping ) - { - if( this == iter.impl ) - { - gKeyEventToImplMapping.Erase( &iter ); // iter is reference to KeyImplMapping, take address of it for Erase - return; - } - } } -KeyEventImpl& KeyEventImpl::operator=( const KeyEventImpl& rhs ) +KeyEvent::~KeyEvent() { - if( this != &rhs ) - { - mLogicalKey = rhs.mLogicalKey; - mCompose = rhs.mCompose; - mDeviceName = rhs.mDeviceName; - mDeviceClass = rhs.mDeviceClass; - mDeviceSubclass = rhs.mDeviceSubclass; - } +} - return *this; +KeyEventPtr KeyEvent::New( const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const Dali::KeyEvent::State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass ) +{ + KeyEventPtr keyEvent = new KeyEvent( keyName, logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass ); + return keyEvent; } -std::string KeyEventImpl::GetLogicalKey() const +bool KeyEvent::IsShiftModifier() const { - return mLogicalKey; + return ( ( MODIFIER_SHIFT & mKeyModifier ) == MODIFIER_SHIFT ); } -void KeyEventImpl::SetLogicalKey( const std::string& logicalKey ) +bool KeyEvent::IsCtrlModifier() const { - mLogicalKey = logicalKey; + return ( ( MODIFIER_CTRL & mKeyModifier ) == MODIFIER_CTRL ); } -std::string KeyEventImpl::GetCompose() const +bool KeyEvent::IsAltModifier() const { - return mCompose; + return ( ( MODIFIER_ALT & mKeyModifier ) == MODIFIER_ALT ); } -void KeyEventImpl::SetCompose( const std::string& compose ) +const std::string& KeyEvent::GetCompose() const { - mCompose = compose; + return mCompose; } -std::string KeyEventImpl::GetDeviceName() const +const std::string& KeyEvent::GetDeviceName() const { return mDeviceName; } -void KeyEventImpl::SetDeviceName( const std::string& deviceName ) + +Device::Class::Type KeyEvent::GetDeviceClass() const { - mDeviceName = deviceName; + return mDeviceClass; } -Device::Class::Type KeyEventImpl::GetDeviceClass() const + +Device::Subclass::Type KeyEvent::GetDeviceSubclass() const { - return mDeviceClass; + return mDeviceSubclass; } -void KeyEventImpl::SetDeviceClass( Device::Class::Type deviceClass ) + +const std::string& KeyEvent::GetKeyName() const { - mDeviceClass = deviceClass; + return mKeyName; } -Device::Subclass::Type KeyEventImpl::GetDeviceSubclass() const + +const std::string& KeyEvent::GetKeyString() const { - return mDeviceSubclass; + return mKeyString; +} + + +const std::string& KeyEvent::GetLogicalKey() const +{ + return mLogicalKey; +} + + +int32_t KeyEvent::GetKeyCode() const +{ + return mKeyCode; +} + + +int32_t KeyEvent::GetKeyModifier() const +{ + return mKeyModifier; +} + + +unsigned long KeyEvent::GetTime() const +{ + return mTime; +} + + +Dali::KeyEvent::State KeyEvent::GetState() const +{ + return mState; +} + + +void KeyEvent::SetKeyName( const std::string& keyName ) +{ + mKeyName = keyName; } -void KeyEventImpl::SetDeviceSubclass( Device::Subclass::Type deviceSubclass ) + +void KeyEvent::SetKeyString( const std::string& keyString ) { - mDeviceSubclass = deviceSubclass; + mKeyString = keyString; } -} // namsespace Internal -Internal::KeyEventImpl* GetImplementation( KeyEvent* keyEvent ) +void KeyEvent::SetKeyCode( int32_t keyCode ) { - Internal::KeyEventImpl* impl( NULL ); - for( auto&& iter : gKeyEventToImplMapping ) - { - if( iter.keyEvent == keyEvent ) - { - impl = iter.impl; - } - } - return impl; + mKeyCode = keyCode; } -const Internal::KeyEventImpl* GetImplementation( const KeyEvent* keyEvent ) + +void KeyEvent::SetKeyModifier( int32_t keyModifier ) { - Internal::KeyEventImpl* impl( NULL ); - for( auto&& iter : gKeyEventToImplMapping ) - { - if( iter.keyEvent == keyEvent ) - { - impl = iter.impl; - } - } - return impl; + mKeyModifier = keyModifier; } + +void KeyEvent::SetTime( unsigned long time ) +{ + mTime = time; +} + + +void KeyEvent::SetState( const Dali::KeyEvent::State& state ) +{ + mState = state; +} + +} // namespace Internal + } // namespace Dali diff --git a/dali/internal/event/events/key-event-impl.h b/dali/internal/event/events/key-event-impl.h index eed0cb9..8b8f7d4 100755 --- a/dali/internal/event/events/key-event-impl.h +++ b/dali/internal/event/events/key-event-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_KEY_EVENT_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -27,121 +28,238 @@ namespace Dali namespace Internal { -struct KeyEventImpl +class KeyEvent; +typedef IntrusivePtr< KeyEvent > KeyEventPtr; + +/** + * @copydoc Dali::KeyEvent + */ +class KeyEvent : public BaseObject { public: /** + * @brief Default constructor. + */ + KeyEvent(); + + /** * @brief Constructor. + * + * @param[in] keyName The name of the key pressed or command from the IMF, if later then the some following parameters will be needed. + * @param[in] logicalKey The logical key symbol (eg. shift + 1 == "exclamation") + * @param[in] keyString The string of input characters or key pressed + * @param[in] keyCode The unique key code for the key pressed. + * @param[in] keyModifier The key modifier for special keys like shift and alt + * @param[in] timeStamp The time (in ms) that the key event occurred. + * @param[in] keyState The state of the key event. + * @param[in] compose The key compose + * @param[in] deviceName The name of device the key event originated from + * @param[in] deviceClass The class of device the key event originated from + * @param[in] deviceSubclass The subclass of device the key event originated from */ - KeyEventImpl( Dali::KeyEvent* keyEvent ); + KeyEvent( const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const Dali::KeyEvent::State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass ); /** * @brief Destructor. */ - ~KeyEventImpl(); + ~KeyEvent(); /** - * @brief Assignment operator. - * @param[in] rhs A reference to the copied handle - * @return A reference to this + * Create a new KeyEvent. + * + * @param[in] keyName The name of the key pressed or command from the IMF, if later then the some following parameters will be needed. + * @param[in] logicalKey The logical key symbol (eg. shift + 1 == "exclamation") + * @param[in] keyString The string of input characters or key pressed + * @param[in] keyCode The unique key code for the key pressed. + * @param[in] keyModifier The key modifier for special keys like shift and alt + * @param[in] timeStamp The time (in ms) that the key event occurred. + * @param[in] keyState The state of the key event. + * @param[in] compose The key compose + * @param[in] deviceName The name of device the key event originated from + * @param[in] deviceClass The class of device the key event originated from + * @param[in] deviceSubclass The subclass of device the key event originated from + * @return A smart-pointer to the newly allocated KeyEvent. */ - KeyEventImpl& operator=( const KeyEventImpl& rhs ); + static KeyEventPtr New( const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const Dali::KeyEvent::State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass ); /** - * @brief Get the key symbol string. - * @return The key symbol + * @copydoc Dali::KeyEvent::IsShiftModifier() */ - std::string GetLogicalKey() const; + bool IsShiftModifier() const; /** - * @brief Set the key symbol string to the KeyEvent. - * @param[in] key The key symbol to set + * @copydoc Dali::KeyEvent::IsCtrlModifier() */ - void SetLogicalKey( const std::string& logicalKey ); + bool IsCtrlModifier() const; /** - * @brief Get the compose string. - * - * @return The compose string. + * @copydoc Dali::KeyEvent::IsAltModifier() */ - std::string GetCompose() const; + bool IsAltModifier() const; /** - * @brief Set the compose string to the KeyEvent - * A string if this keystroke has modified a string in the middle of being composed, - * this string replaces the previous one. - * - * @param[in] compose The compose string to set + * @copydoc Dali::KeyEvent::GetCompose() + */ + const std::string& GetCompose() const; + + /** + * @copydoc Dali::KeyEvent::GetDeviceName() */ - void SetCompose( const std::string& compose ); + const std::string& GetDeviceName() const; /** - * @brief Get the device name the key event originated from + * @copydoc Dali::KeyEvent::GetDeviceClass() + */ + Device::Class::Type GetDeviceClass() const; + + /** + * @copydoc Dali::KeyEvent::GetDeviceSubclass() + */ + Device::Subclass::Type GetDeviceSubclass() const; + + /** + * @copydoc Dali::KeyEvent::GetKeyName() + */ + const std::string& GetKeyName() const; + + /** + * @copydoc Dali::KeyEvent::GetKeyString() + */ + const std::string& GetKeyString() const; + + /** + * @copydoc Dali::KeyEvent::GetLogicalKey() + */ + const std::string& GetLogicalKey() const; + + /** + * @copydoc Dali::KeyEvent::GetKeyCode() + */ + int32_t GetKeyCode() const; + + /** + * @copydoc Dali::KeyEvent::GetKeyModifier() + */ + int32_t GetKeyModifier() const; + + /** + * @copydoc Dali::KeyEvent::GetTime() + */ + unsigned long GetTime() const; + + /** + * @copydoc Dali::KeyEvent::GetState() + */ + Dali::KeyEvent::State GetState() const; + + /** + * @brief Set the name given to the key pressed * - * @return The device name + * @param[in] keyName The name given to the key pressed. */ - std::string GetDeviceName() const; + void SetKeyName( const std::string& keyName ); /** - * @brief Set the device name to the KeyEvent + * @brief Set the actual string of input characters that should be used for input editors. * - * @param[in] deviceName Device name string to set + * @param[in] The actual string of input characters */ - void SetDeviceName( const std::string& deviceName ); + void SetKeyString( const std::string& keyString ); /** - * @brief Get the device class the key event originated from + * @brief Set the unique key code for the key pressed. * - * @return The device class + * @param[in] keyCode The unique key code for the key pressed */ - Device::Class::Type GetDeviceClass() const; + void SetKeyCode( int32_t keyCode ); /** - * @brief Set the device class to the KeyEvent + * @brief Set the key modifier for special keys like Shift, Alt and Ctrl which modify the next key pressed. * - * @param[in] deviceClass Device class to set + * @param[in] keyModifier The key modifier */ - void SetDeviceClass( Device::Class::Type deviceClass ); + void SetKeyModifier( int32_t keyModifier ); /** - * @brief Get the device subclass the key event originated from + * @brief Set the time (in ms) that the key event occurred. * - * @return The device subclass + * @param[in] time The time (in ms) */ - Device::Subclass::Type GetDeviceSubclass() const; + void SetTime( unsigned long time ); /** - * @brief Set the device subclass to the KeyEvent + * @brief Set the state of the key event. * - * @param[in] deviceClass Device subclass to set + * @param[in] state The state of the key event */ - void SetDeviceSubclass( Device::Subclass::Type deviceSubclass ); + void SetState( const Dali::KeyEvent::State& state ); private: - // Undefined - KeyEventImpl(); + // Not copyable or movable - // Undefined - KeyEventImpl( const KeyEventImpl& rhs ); + KeyEvent( const KeyEvent& rhs ) = delete; ///< Deleted copy constructor + KeyEvent( KeyEvent&& rhs ) = delete; ///< Deleted move constructor + KeyEvent& operator=( const KeyEvent& rhs ) = delete; ///< Deleted copy assignment operator + KeyEvent& operator=( KeyEvent&& rhs ) = delete; ///< Deleted move assignment operator private: - std::string mLogicalKey; - std::string mCompose; - std::string mDeviceName; - Device::Class::Type mDeviceClass; - Device::Subclass::Type mDeviceSubclass; + std::string mKeyName; ///< The name of the key pressed + std::string mLogicalKey; ///< The logical key symbol + std::string mKeyString; ///< The string of input characters + int mKeyCode; ///< TThe unique key code + int mKeyModifier; ///< The key modifier + unsigned long mTime; ///< The time that the key event occurred. + Dali::KeyEvent::State mState; ///< The state of the key event. + std::string mCompose; ///< The key compose + std::string mDeviceName; ///< The name of device the key event originated from + Device::Class::Type mDeviceClass; ///< The class of device the key event originated from + Device::Subclass::Type mDeviceSubclass; ///< The subclass of device the key event originated from }; } // namespace Internal // Helpers for public-api forwarding methods -Internal::KeyEventImpl* GetImplementation( KeyEvent* keyEvent ); +inline Internal::KeyEvent& GetImplementation( Dali::KeyEvent& keyEvent ) +{ + DALI_ASSERT_ALWAYS( keyEvent && "Key Event handle is empty" ); + + BaseObject& object = keyEvent.GetBaseObject(); + + return static_cast< Internal::KeyEvent& >( object ); +} + +inline const Internal::KeyEvent& GetImplementation( const Dali::KeyEvent& keyEvent ) +{ + DALI_ASSERT_ALWAYS( keyEvent && "Key Event handle is empty" ); + + const BaseObject& object = keyEvent.GetBaseObject(); -const Internal::KeyEventImpl* GetImplementation( const KeyEvent* keyEvent ); + return static_cast< const Internal::KeyEvent& >( object ); +} } // namespace Dali diff --git a/dali/internal/event/events/key-event-processor.cpp b/dali/internal/event/events/key-event-processor.cpp index 65be14e..e72adc3 100755 --- a/dali/internal/event/events/key-event-processor.cpp +++ b/dali/internal/event/events/key-event-processor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ // INTERNAL INCLUDES #include #include -#include #include #include @@ -42,18 +41,14 @@ KeyEventProcessor::~KeyEventProcessor() void KeyEventProcessor::ProcessKeyEvent( const Integration::KeyEvent& event ) { - KeyEvent keyEvent(event.keyName, event.keyString, event.keyCode, event.keyModifier, event.time, static_cast(event.state)); - GetImplementation( &keyEvent )->SetLogicalKey( event.logicalKey ); - GetImplementation( &keyEvent )->SetCompose( event.compose ); - GetImplementation( &keyEvent )->SetDeviceName( event.deviceName ); - GetImplementation( &keyEvent )->SetDeviceClass( event.deviceClass ); - GetImplementation( &keyEvent )->SetDeviceSubclass( event.deviceSubclass ); + KeyEventPtr keyEvent( new KeyEvent( event.keyName, event.logicalKey, event.keyString, event.keyCode, event.keyModifier, event.time, static_cast( event.state ), event.compose, event.deviceName, event.deviceClass, event.deviceSubclass ) ); + Dali::KeyEvent keyEventHandle( keyEvent.Get() ); // Emit the key event signal from the scene. - bool consumed = mScene.EmitKeyEventGeneratedSignal( keyEvent ); + bool consumed = mScene.EmitKeyEventGeneratedSignal( keyEventHandle ); if( !consumed ) { - mScene.EmitKeyEventSignal(keyEvent); + mScene.EmitKeyEventSignal( keyEventHandle ); } } diff --git a/dali/public-api/actors/custom-actor-impl.h b/dali/public-api/actors/custom-actor-impl.h index 698e625..6860db6 100644 --- a/dali/public-api/actors/custom-actor-impl.h +++ b/dali/public-api/actors/custom-actor-impl.h @@ -44,7 +44,7 @@ class Animation; class CustomActor; class CustomActorImpl; class RelayoutContainer; -struct KeyEvent; +class KeyEvent; class HoverEvent; class WheelEvent; struct Vector2; diff --git a/dali/public-api/events/key-event.cpp b/dali/public-api/events/key-event.cpp index 30a1323..9b3bba8 100755 --- a/dali/public-api/events/key-event.cpp +++ b/dali/public-api/events/key-event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,119 +24,96 @@ namespace Dali { -namespace +KeyEvent::KeyEvent() +: BaseHandle() { -const uint32_t MODIFIER_SHIFT = 0x1; -const uint32_t MODIFIER_CTRL = 0x2; -const uint32_t MODIFIER_ALT = 0x4; -const int32_t KEY_INVALID_CODE = -1; } -KeyEvent::KeyEvent() -: keyPressedName(""), - keyPressed(""), - keyCode(KEY_INVALID_CODE), - keyModifier(0), - time(0), - state(KeyEvent::Down) +KeyEvent::KeyEvent( const KeyEvent& rhs ) = default; + +KeyEvent::KeyEvent( KeyEvent&& rhs ) = default; + +KeyEvent::~KeyEvent() { - new Internal::KeyEventImpl( this ); } -KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyString, int32_t keyCode, int32_t keyModifier,unsigned long timeStamp, const State& keyState) -: keyPressedName(keyName), - keyPressed(keyString), - keyCode(keyCode), - keyModifier(keyModifier), - time(timeStamp), - state(keyState) +KeyEvent& KeyEvent::operator=( const KeyEvent& rhs ) = default; + +KeyEvent& KeyEvent::operator=( KeyEvent&& rhs ) = default; + +bool KeyEvent::IsShiftModifier() const { - new Internal::KeyEventImpl( this ); + return GetImplementation( *this ).IsShiftModifier(); } -KeyEvent::KeyEvent( const KeyEvent& rhs ) -: keyPressedName( rhs.keyPressedName ), - keyPressed( rhs.keyPressed ), - keyCode( rhs.keyCode ), - keyModifier( rhs.keyModifier ), - time( rhs.time ), - state( rhs.state ) +bool KeyEvent::IsCtrlModifier() const { - Internal::KeyEventImpl* impl = new Internal::KeyEventImpl( this ); - *impl = *GetImplementation( &rhs ); + return GetImplementation( *this ).IsCtrlModifier(); } -KeyEvent& KeyEvent::operator=( const KeyEvent& rhs ) +bool KeyEvent::IsAltModifier() const { - if( this != &rhs ) - { - keyPressedName = rhs.keyPressedName; - keyPressed = rhs.keyPressed; - keyCode = rhs.keyCode; - keyModifier = rhs.keyModifier; - time = rhs.time; - state = rhs.state; - - *GetImplementation( this ) = *GetImplementation( &rhs ); - } - - return *this; + return GetImplementation( *this ).IsAltModifier(); } -KeyEvent::~KeyEvent() +const std::string& KeyEvent::GetCompose() const { - delete GetImplementation( this ); + return GetImplementation( *this ).GetCompose(); } -bool KeyEvent::IsShiftModifier() const +const std::string& KeyEvent::GetDeviceName() const { - if ((MODIFIER_SHIFT & keyModifier) == MODIFIER_SHIFT) - { - return true; - } + return GetImplementation( *this ).GetDeviceName(); +} - return false; +Device::Class::Type KeyEvent::GetDeviceClass() const +{ + return GetImplementation( *this ).GetDeviceClass(); } -bool KeyEvent::IsCtrlModifier() const +Device::Subclass::Type KeyEvent::GetDeviceSubclass() const { - if ((MODIFIER_CTRL & keyModifier) == MODIFIER_CTRL) - { - return true; - } + return GetImplementation( *this ).GetDeviceSubclass(); +} - return false; +const std::string& KeyEvent::GetKeyName() const +{ + return GetImplementation( *this ).GetKeyName(); } -bool KeyEvent::IsAltModifier() const +const std::string& KeyEvent::GetKeyString() const { - if ((MODIFIER_ALT & keyModifier) == MODIFIER_ALT) - { - return true; - } + return GetImplementation( *this ).GetKeyString(); +} - return false; +const std::string& KeyEvent::GetLogicalKey() const +{ + return GetImplementation( *this ).GetLogicalKey(); } -std::string KeyEvent::GetCompose() const +int32_t KeyEvent::GetKeyCode() const { - return GetImplementation( this )->GetCompose(); + return GetImplementation( *this ).GetKeyCode(); } -std::string KeyEvent::GetDeviceName() const +int32_t KeyEvent::GetKeyModifier() const { - return GetImplementation( this )->GetDeviceName(); + return GetImplementation( *this ).GetKeyModifier(); } -Device::Class::Type KeyEvent::GetDeviceClass() const +unsigned long KeyEvent::GetTime() const { - return GetImplementation( this )->GetDeviceClass(); + return GetImplementation( *this ).GetTime(); } -Device::Subclass::Type KeyEvent::GetDeviceSubclass() const +KeyEvent::State KeyEvent::GetState() const { - return GetImplementation( this )->GetDeviceSubclass(); + return GetImplementation( *this ).GetState(); } +KeyEvent::KeyEvent( Internal::KeyEvent* internal ) +: BaseHandle( internal ) +{ +} } // namespace Dali diff --git a/dali/public-api/events/key-event.h b/dali/public-api/events/key-event.h index 6cd17ad..66bda0d 100755 --- a/dali/public-api/events/key-event.h +++ b/dali/public-api/events/key-event.h @@ -2,7 +2,7 @@ #define DALI_KEY_EVENT_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,17 +24,24 @@ // INTERNAL INCLUDES #include +#include #include namespace Dali { + +namespace Internal DALI_INTERNAL +{ +class KeyEvent; +} + /** * @addtogroup dali_core_events * @{ */ /** - * @brief The key event structure is used to store a key press. + * @brief The key event class is used to store a key press. * * It facilitates processing of these key presses and passing to other * libraries like Toolkit. The keyString is the actual character you @@ -48,8 +55,11 @@ namespace Dali * module. * @SINCE_1_0.0 */ -struct DALI_CORE_API KeyEvent +class DALI_CORE_API KeyEvent : public BaseHandle { + +public: + // Enumerations /** @@ -64,23 +74,12 @@ struct DALI_CORE_API KeyEvent }; /** - * @brief Default constructor. - * @SINCE_1_0.0 - */ - KeyEvent(); - - /** - * @brief Constructor. + * @brief An uninitialized KeyEvent instance. * + * Calling member functions with an uninitialized KeyEvent handle is not allowed. * @SINCE_1_0.0 - * @param[in] keyName The name of the key pressed or command from the IMF, if later then the some following parameters will be needed - * @param[in] keyString A string of input characters or key pressed - * @param[in] keyCode The unique key code for the key pressed - * @param[in] keyModifier The key modifier for special keys like shift and alt - * @param[in] timeStamp The time (in ms) that the key event occurred - * @param[in] keyState The state of the key event */ - KeyEvent(const std::string& keyName, const std::string& keyString, int32_t keyCode, int32_t keyModifier, unsigned long timeStamp, const State& keyState); + KeyEvent(); /** * @brief Copy constructor. @@ -90,7 +89,15 @@ struct DALI_CORE_API KeyEvent KeyEvent( const KeyEvent& rhs ); /** - * @brief Assignment operator. + * @brief Move constructor. + * + * @SINCE_1_9.27 + * @param[in] rhs A reference to the moved handle + */ + KeyEvent( KeyEvent&& rhs ); + + /** + * @brief Copy assignment operator. * @SINCE_1_2.36 * @param[in] rhs A reference to the copied handle * @return A reference to this @@ -98,6 +105,15 @@ struct DALI_CORE_API KeyEvent KeyEvent& operator=( const KeyEvent& rhs ); /** + * @brief Move assignment operator. + * + * @SINCE_1_9.27 + * @param[in] rhs A reference to the moved handle + * @return A reference to this + */ + KeyEvent& operator=( KeyEvent&& rhs ); + + /** * @brief Destructor. * @SINCE_1_0.0 */ @@ -130,18 +146,18 @@ struct DALI_CORE_API KeyEvent /** * @brief Get the key compose string. * - * @SINCE_1_3.22 + * @SINCE_1_9.27 * @return The compose string */ - std::string GetCompose() const; + const std::string& GetCompose() const; /** * @brief Get the device name the key event originated from. * - * @SINCE_1_2.60 + * @SINCE_1_9.27 * @return The device name */ - std::string GetDeviceName() const; + const std::string& GetDeviceName() const; /** * @brief Get the device class the key event originated from. @@ -161,45 +177,83 @@ struct DALI_CORE_API KeyEvent */ Device::Subclass::Type GetDeviceSubclass() const; - // Data + /** + * @brief Get the name given to the key pressed or command from the IMF + * + * @SINCE_1_9.27 + * @return The name given to the key pressed. + */ + const std::string& GetKeyName() const; /** - * @brief Name given to the key pressed. + * @brief Get the actual string of input characters that should be used for input editors. + * + * @SINCE_1_9.27 + * @return The actual string of input characters */ - std::string keyPressedName; + const std::string& GetKeyString() const; /** - * @brief The actual string returned that should be used for input editors. + * @brief Gets the logical key string. + * + * For example, when the user presses 'shift' key and '1' key together, the logical key is "exclamation". + * Plus, the key name is "1", and the key string is "!". + * + * @SINCE_1_9.27 + * @return The logical key symbol */ - std::string keyPressed; + const std::string& GetLogicalKey() const; /** - * @brief Keycode for the key pressed. + * @brief Get the unique key code for the key pressed. * - * @remarks We recommend not to use this key code value - * directly because its meaning might be changed in the future. Currently, it means a - * platform-specific key code. You need to use IsKey() to know what a key event means - * instead of direct comparison of key code value. + * @SINCE_1_9.27 + * @return The unique key code for the key pressed + * + * @remarks We recommend not to use this key code value directly because its meaning + * might be changed in the future. Currently, it means a platform-specific key code. + * You need to use IsKey() to know what a key event means instead of direct comparison + * of key code value. */ - int32_t keyCode; + int32_t GetKeyCode() const; /** - * @brief special keys like shift, alt and control which modify the next key pressed. + * @brief Return the key modifier for special keys like Shift, Alt and Ctrl which modify the next key pressed. + * + * @SINCE_1_9.27 + * @return The key modifier */ - int32_t keyModifier; + int32_t GetKeyModifier() const; /** - * @brief The time (in ms) that the key event occurred. + * @brief Get the time (in ms) that the key event occurred. + * + * @SINCE_1_9.27 + * @return The time (in ms) */ - unsigned long time; + unsigned long GetTime() const; /** - * @brief State of the key event. + * @brief Get the state of the key event. * * @see State + * + * @SINCE_1_9.27 + * @return The state of the key event */ - State state; + State GetState() const; +public: // Not intended for application developers + + /// @cond internal + /** + * @brief This constructor is used internally to Create an initialized KeyEvent handle. + * + * @SINCE_1_9.27 + * @param[in] keyEvent A pointer to a newly allocated Dali resource + */ + explicit DALI_INTERNAL KeyEvent( Internal::KeyEvent* keyEvent ); + /// @endcond }; /** -- 2.7.4