Apply vibration pattern array and change ui
authorHokwon Song <hokwon.song@samsung.com>
Thu, 14 Mar 2013 05:26:16 +0000 (14:26 +0900)
committerHokwon Song <hokwon.song@samsung.com>
Mon, 18 Mar 2013 05:48:13 +0000 (14:48 +0900)
Change-Id: I392ad4aff0717f5012c3f763e1d2665ff95d65c0
Signed-off-by: Hokwon Song <hokwon.song@samsung.com>
project/inc/VibratorPanel.h
project/res/screen-size-normal/IDC_VIBRATOR_PANEL.xml
project/src/VibratorPanel.cpp

index c999abe..3db51e4 100644 (file)
@@ -49,11 +49,14 @@ private:
        Tizen::Ui::Controls::Button* __pButtonDefault;
        Tizen::Ui::Controls::Slider* __pSliderSetTime;
        Tizen::Ui::Controls::Slider* __pSliderSetLevel;
+       Tizen::Ui::Controls::Slider* __pSliderSetRepeat;
        Tizen::System::Vibrator* __pVibrator;
        Tizen::Ui::Controls::Label* __pLabelVibrationTime;
        Tizen::Ui::Controls::Label* __pLabelVibrationLevel;
+       Tizen::System::IntensityDurationVibrationPattern _vibartionPattern[2];
        int __vibrationTime;
        int __vibrationLevel;
+       int __vibrationRepeat;
 };
 
 
index 2800c09..542d692 100644 (file)
@@ -4,45 +4,55 @@
 -->
 <!DOCTYPE ScenePanel SYSTEM "UIForm.dtd">
 
-<ScenePanel Bversion="3.0.0.201301251814" Dversion="20120315">
+<ScenePanel Bversion="2.0.0.201303111437" Dversion="20120315">
     <Panel id="IDC_VIBRATOR_PANEL">
         <property backgroundColor="" backgroundColorOpacity="0" compositeEnabled="true" groupStyle="GROUP_STYLE_NONE"/>
         <layout height="622" mode="Portrait" type="NONE" width="480" x="0" y="0"/>
         <layout height="300" mode="Landscape" type="NONE" width="93" x="0" y="0"/>
     </Panel>
     <Label id="IDC_LABEL_VIBRATOR_TIME" parent="IDC_VIBRATOR_PANEL">
-        <property backgroundBitmapPath="" backgroundColor="" backgroundColorOpacity="0" horizontalAlign="ALIGN_CENTER" text="SET VIBRATION TIME" textColor="" textSize="30" textStyle="LABEL_TEXT_STYLE_NORMAL" verticalAlign="ALIGN_MIDDLE"/>
-        <layout height="112" mode="Portrait" width="440" x="20" y="32"/>
+        <property backgroundBitmapPath="" backgroundColor="" backgroundColorOpacity="0" horizontalAlign="ALIGN_CENTER" text="Set vibration time" textColor="" textSize="30" textStyle="LABEL_TEXT_STYLE_NORMAL" verticalAlign="ALIGN_MIDDLE"/>
+        <layout height="84" mode="Portrait" width="440" x="23" y="14"/>
         <layout height="71" mode="Landscape" width="388" x="0" y="41"/>
     </Label>
     <Label id="IDC_LABEL_VIBRATOR_LEVEL" parent="IDC_VIBRATOR_PANEL">
-        <property backgroundBitmapPath="" backgroundColor="" backgroundColorOpacity="0" horizontalAlign="ALIGN_CENTER" text="SET VIBRATION LEVEL" textColor="" textSize="30" textStyle="LABEL_TEXT_STYLE_NORMAL" verticalAlign="ALIGN_MIDDLE"/>
-        <layout height="112" mode="Portrait" width="440" x="20" y="288"/>
+        <property backgroundBitmapPath="" backgroundColor="" backgroundColorOpacity="0" horizontalAlign="ALIGN_CENTER" text="Set vibration level" textColor="" textSize="30" textStyle="LABEL_TEXT_STYLE_NORMAL" verticalAlign="ALIGN_MIDDLE"/>
+        <layout height="84" mode="Portrait" width="440" x="23" y="181"/>
         <layout height="71" mode="Landscape" width="388" x="0" y="219"/>
     </Label>
     <Slider id="IDC_SLIDER_VIBRATOR_TIME" parent="IDC_VIBRATOR_PANEL">
-        <property backgroundColor="" backgroundStyle="BACKGROUND_STYLE_DEFAULT" barColor="" color="" colorOfTitleText="" colorOpacity="100" disabledThumbBitmap="" disabledThumbTextColor="" groupStyle="GROUP_STYLE_NONE" highlightedThumbBitmap="" highlightedThumbTextColor="" leftIconBitmapPath="" max="10" min="1" normalThumbBitmap="" normalThumbTextColor="" pressedThumbBitmap="" pressedThumbTextColor="" rightIconBitmapPath="" showTitleText="false" sliderStyle="SLIDER_STYLE_BUBBLE" titleText="" value="10"/>
-        <layout height="112" mode="Portrait" width="440" x="20" y="144"/>
+        <property backgroundColor="" backgroundStyle="BACKGROUND_STYLE_DEFAULT" barColor="" color="" colorOfTitleText="" colorOpacity="100" disabledThumbBitmap="" disabledThumbTextColor="" groupStyle="GROUP_STYLE_NONE" highlightedThumbBitmap="" highlightedThumbTextColor="" leftIconBitmapPath="" max="10" min="1" normalThumbBitmap="" normalThumbTextColor="" pressedThumbBitmap="" pressedThumbTextColor="" rightIconBitmapPath="" showTitleText="false" titleText="" value="10"/>
+        <layout height="84" mode="Portrait" width="440" x="23" y="98"/>
         <layout height="122" mode="Landscape" width="388" x="0" y="133"/>
     </Slider>
     <Slider id="IDC_SLIDER_VIBRATOR_LEVEL" parent="IDC_VIBRATOR_PANEL">
-        <property backgroundColor="" backgroundStyle="BACKGROUND_STYLE_DEFAULT" barColor="" color="" colorOfTitleText="" colorOpacity="100" disabledThumbBitmap="" disabledThumbTextColor="" groupStyle="GROUP_STYLE_NONE" highlightedThumbBitmap="" highlightedThumbTextColor="" leftIconBitmapPath="" max="100" min="1" normalThumbBitmap="" normalThumbTextColor="" pressedThumbBitmap="" pressedThumbTextColor="" rightIconBitmapPath="" showTitleText="false" sliderStyle="SLIDER_STYLE_BUBBLE" titleText="" value="100"/>
-        <layout height="112" mode="Portrait" width="439" x="20" y="400"/>
+        <property backgroundColor="" backgroundStyle="BACKGROUND_STYLE_DEFAULT" barColor="" color="" colorOfTitleText="" colorOpacity="100" disabledThumbBitmap="" disabledThumbTextColor="" groupStyle="GROUP_STYLE_NONE" highlightedThumbBitmap="" highlightedThumbTextColor="" leftIconBitmapPath="" max="100" min="1" normalThumbBitmap="" normalThumbTextColor="" pressedThumbBitmap="" pressedThumbTextColor="" rightIconBitmapPath="" showTitleText="false" titleText="" value="100"/>
+        <layout height="84" mode="Portrait" width="440" x="23" y="264"/>
         <layout height="122" mode="Landscape" width="388" x="0" y="178"/>
     </Slider>
     <Button id="IDC_BUTTON_START" parent="IDC_VIBRATOR_PANEL">
-        <property DisabledBitmapX="0" DisabledBitmapY="0" NormalBitmapX="0" NormalBitmapY="0" PressedBitmapX="0" PressedBitmapY="0" disableTextColor="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="Custom Lv." textSize="24" verticalAlign="ALIGN_MIDDLE"/>
+        <property DisabledBitmapX="0" DisabledBitmapY="0" NormalBitmapX="0" NormalBitmapY="0" PressedBitmapX="0" PressedBitmapY="0" disableTextColor="" disabledBGBitmapPath="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedBitmapPath="" highlightedBitmapX="0" highlightedBitmapY="0" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="Custom Lv." textSize="24" verticalAlign="ALIGN_MIDDLE"/>
         <layout height="74" mode="Portrait" width="146" x="170" y="531"/>
         <layout height="72" mode="Landscape" width="388" x="0" y="228"/>
     </Button>
     <Button id="IDC_BUTTON_STOP" parent="IDC_VIBRATOR_PANEL">
-        <property DisabledBitmapX="0" DisabledBitmapY="0" NormalBitmapX="0" NormalBitmapY="0" PressedBitmapX="0" PressedBitmapY="0" disableTextColor="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="STOP" textSize="24" verticalAlign="ALIGN_MIDDLE"/>
+        <property DisabledBitmapX="0" DisabledBitmapY="0" NormalBitmapX="0" NormalBitmapY="0" PressedBitmapX="0" PressedBitmapY="0" disableTextColor="" disabledBGBitmapPath="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedBitmapPath="" highlightedBitmapX="0" highlightedBitmapY="0" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="STOP" textSize="24" verticalAlign="ALIGN_MIDDLE"/>
         <layout height="74" mode="Portrait" width="146" x="320" y="531"/>
         <layout height="72" mode="Landscape" width="259" x="0" y="228"/>
     </Button>
     <Button id="IDC_BUTTON_SET_DEFAULT" parent="IDC_VIBRATOR_PANEL">
-        <property DisabledBitmapX="0" DisabledBitmapY="0" NormalBitmapX="0" NormalBitmapY="0" PressedBitmapX="0" PressedBitmapY="0" disableTextColor="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="System Lv." textSize="24" verticalAlign="ALIGN_MIDDLE"/>
+        <property DisabledBitmapX="0" DisabledBitmapY="0" NormalBitmapX="0" NormalBitmapY="0" PressedBitmapX="0" PressedBitmapY="0" disableTextColor="" disabledBGBitmapPath="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedBitmapPath="" highlightedBitmapX="0" highlightedBitmapY="0" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="System Lv." textSize="24" verticalAlign="ALIGN_MIDDLE"/>
         <layout height="74" mode="Portrait" width="146" x="20" y="531"/>
         <layout height="72" mode="Landscape" width="93" x="0" y="228"/>
     </Button>
+    <Label id="IDC_LABEL1" parent="IDC_VIBRATOR_PANEL">
+        <property backgroundBitmapPath="" backgroundColor="" backgroundColorOpacity="0" horizontalAlign="ALIGN_CENTER" text="Set vibration repeat" textColor="" textSize="30" textStyle="LABEL_TEXT_STYLE_NORMAL" verticalAlign="ALIGN_MIDDLE"/>
+        <layout height="84" mode="Portrait" width="440" x="23" y="348"/>
+        <layout height="71" mode="Landscape" width="388" x="-295" y="229"/>
+    </Label>
+    <Slider id="IDC_SLIDER_VIBRATOR_REPEAT" parent="IDC_VIBRATOR_PANEL">
+        <property backgroundColor="" backgroundStyle="BACKGROUND_STYLE_DEFAULT" barColor="" color="" colorOfTitleText="" colorOpacity="100" disabledThumbBitmap="" disabledThumbTextColor="" groupStyle="GROUP_STYLE_NONE" highlightedThumbBitmap="" highlightedThumbTextColor="" leftIconBitmapPath="" max="10" min="1" normalThumbBitmap="" normalThumbTextColor="" pressedThumbBitmap="" pressedThumbTextColor="" rightIconBitmapPath="" showTitleText="false" titleText="" value="10"/>
+        <layout height="84" mode="Portrait" width="440" x="23" y="431"/>
+        <layout height="122" mode="Landscape" width="622" x="-529" y="178"/>
+    </Slider>
 </ScenePanel>
index 56615c4..feb99d1 100644 (file)
@@ -32,6 +32,7 @@ const int ID_SLIDER_SET_LEVEL = 122;
 const int VIBRATION_DURATION = 5;
 const int VIBRATION_LEVEL = 50;
 const int VIBRATION_TIME_IN_SEC = 1000;
+const int VIBRATION_REPEAT_COUNT = 3;
 
 VibratorPanel::VibratorPanel(void)
        : __pButtonStart(null)
@@ -44,6 +45,7 @@ VibratorPanel::VibratorPanel(void)
        , __pLabelVibrationLevel(null)
        , __vibrationTime(VIBRATION_DURATION)
        , __vibrationLevel(VIBRATION_LEVEL)
+       , __vibrationRepeat(VIBRATION_REPEAT_COUNT)
 {
        __pVibrator->Construct();
 }
@@ -79,6 +81,12 @@ VibratorPanel::OnInitializing(void)
                __pSliderSetLevel->SetValue(this->__vibrationLevel);
        }
 
+       __pSliderSetRepeat = static_cast< Slider* >(GetControl(L"IDC_SLIDER_VIBRATOR_REPEAT"));
+       if (__pSliderSetRepeat != null)
+       {
+               __pSliderSetRepeat->SetValue(this->__vibrationRepeat);
+       }
+
        __pButtonStart = static_cast< Button* >(GetControl(L"IDC_BUTTON_START"));
        if (__pButtonStart != null)
        {
@@ -91,7 +99,6 @@ VibratorPanel::OnInitializing(void)
        {
                __pButtonStop->SetActionId(ID_BUTTON_STOP);
                __pButtonStop->AddActionEventListener(*this);
-               __pButtonStop->SetEnabled(false);
        }
 
        __pButtonDefault = static_cast< Button* >(GetControl(L"IDC_BUTTON_SET_DEFAULT"));
@@ -118,30 +125,37 @@ VibratorPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
        {
        case ID_BUTTON_START:
        {
-               __pVibrator->Start((__pSliderSetTime->GetValue()) * VIBRATION_TIME_IN_SEC, VIBRATION_TIME_IN_SEC,
-                                                  VIBRATION_DURATION, __pSliderSetLevel->GetValue());
-               __pButtonDefault->SetEnabled(false);
-               __pButtonStart->SetEnabled(false);
-               __pButtonStop->SetEnabled(true);
+               // Initialise vibration pattern
+               int length = sizeof(_vibartionPattern);
+
+               _vibartionPattern[0].intensity = __pSliderSetLevel->GetValue();
+               _vibartionPattern[0].duration = (__pSliderSetTime->GetValue()) * VIBRATION_TIME_IN_SEC;
+               _vibartionPattern[1].intensity = 0;
+               _vibartionPattern[1].duration = VIBRATION_TIME_IN_SEC;
+
+               // Vibrate with a given pattern and level
+               __pVibrator->Start(_vibartionPattern, length, __pSliderSetRepeat->GetValue());
                break;
        }
 
        case ID_BUTTON_STOP:
        {
                __pVibrator->Stop();
-               __pButtonDefault->SetEnabled(true);
-               __pButtonStart->SetEnabled(true);
-               __pButtonStop->SetEnabled(false);
                break;
        }
 
        case ID_BUTTON_DEFAULT:
        {
-               __pVibrator->Start((__pSliderSetTime->GetValue()) * VIBRATION_TIME_IN_SEC, VIBRATION_TIME_IN_SEC,
-                                                  VIBRATION_DURATION);
-               __pButtonDefault->SetEnabled(false);
-               __pButtonStart->SetEnabled(false);
-               __pButtonStop->SetEnabled(true);
+               // Initialise vibration pattern
+               int length = sizeof(_vibartionPattern);
+
+               _vibartionPattern[0].intensity = -1; // System default vibration intensity
+               _vibartionPattern[0].duration = (__pSliderSetTime->GetValue()) * VIBRATION_TIME_IN_SEC;
+               _vibartionPattern[1].intensity = 0;
+               _vibartionPattern[1].duration = VIBRATION_TIME_IN_SEC;
+
+               // Vibrate with a given pattern and system default level
+               __pVibrator->Start(_vibartionPattern, length,  __pSliderSetRepeat->GetValue());
                break;
        }