src/hbplugins/feedback/feedbackeffectplugin/hbfeedbackeffectutils.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
   131         
   131         
   132         case HbPrivate::ItemType_MenuListView:
   132         case HbPrivate::ItemType_MenuListView:
   133 
   133 
   134         case HbPrivate::ItemType_GroupBoxHeadingWidget:
   134         case HbPrivate::ItemType_GroupBoxHeadingWidget:
   135 
   135 
       
   136         case HbPrivate::ItemType_GroupBoxContentWidget:
       
   137 
       
   138         case HbPrivate::ItemType_DataGroupHeadingWidget:
       
   139 
   136             family = HbFeedbackEffectUtils::List;
   140             family = HbFeedbackEffectUtils::List;
   137             IF_INSTANCEOF_SET_FAMILY(HbGridView, Grid)
   141             IF_INSTANCEOF_SET_FAMILY(HbGridView, Grid)
   138             break;
   142             break;
   139 
   143 
   140         case Hb::ItemType_GridViewItem:
   144         case Hb::ItemType_GridViewItem:
   245                         effect = HbFeedback::BasicButton;
   249                         effect = HbFeedback::BasicButton;
   246                     }
   250                     }
   247                 }
   251                 }
   248             }
   252             }
   249 
   253 
   250             if (widget->type() == HbPrivate::ItemType_NavigationButton ||
   254             if (widget->type() == HbPrivate::ItemType_NavigationButton
   251                 widget->type() == HbPrivate::ItemType_IndicatorButton) {
   255                 // Commented out until use cases are clarified
       
   256                 /*|| widget->type() == HbPrivate::ItemType_IndicatorButton*/) {
   252                 effect = HbFeedback::BasicButton;
   257                 effect = HbFeedback::BasicButton;
   253             }
   258             }
   254             
   259             
   255             // input widget special case
   260             // input widget special case
   256             if (widget->type() == Hb::ItemType_InputCharacterButton) {
   261             if (widget->type() == Hb::ItemType_InputCharacterButton) {
   270                 }
   275                 }
   271             }
   276             }
   272             break;
   277             break;
   273 
   278 
   274         case HbFeedbackEffectUtils::List:
   279         case HbFeedbackEffectUtils::List:
   275             if (modifiers & Hb::ModifierCollapsedItem) {
   280             if (modifiers & (Hb::ModifierExpandedItem | Hb::ModifierCollapsedItem)) {
   276                 effect = HbFeedback::BasicItem;
   281                 effect = HbFeedback::BasicItem;
   277             }
   282             }
   278             else {
   283             else {
   279                 effect = HbFeedback::SensitiveItem;
   284                 effect = HbFeedback::SensitiveItem;
   280             }
   285             }
   363             }
   368             }
   364 
   369 
   365             // expandable or collapsable items give a BasicItem feedback
   370             // expandable or collapsable items give a BasicItem feedback
   366             if (const HbTreeViewItem* treeItem = qobject_cast<const HbTreeViewItem *>(widget)) {
   371             if (const HbTreeViewItem* treeItem = qobject_cast<const HbTreeViewItem *>(widget)) {
   367                 if (itemView->model()->rowCount(treeItem->modelIndex()) > 0) {
   372                 if (itemView->model()->rowCount(treeItem->modelIndex()) > 0) {
   368                     effect = HbFeedback::BasicItem;
       
   369                 }
       
   370                 else {
       
   371                     effect = HbFeedback::SensitiveItem;
       
   372                 }
       
   373             }
       
   374 
       
   375             // Expandable or collapsible data form item gives BasicItem feedback
       
   376             if (const HbDataFormViewItem* dataFormItem = qobject_cast<const HbDataFormViewItem *>(widget)) {
       
   377                 if (itemView->model()->rowCount(dataFormItem->modelIndex()) > 0) {
       
   378                     effect = HbFeedback::BasicItem;
   373                     effect = HbFeedback::BasicItem;
   379                 }
   374                 }
   380                 else {
   375                 else {
   381                     effect = HbFeedback::SensitiveItem;
   376                     effect = HbFeedback::SensitiveItem;
   382                 }
   377                 }
   428                         effect = HbFeedback::BasicButton;
   423                         effect = HbFeedback::BasicButton;
   429                     }
   424                     }
   430                 }
   425                 }
   431             }
   426             }
   432 
   427 
   433             if (widget->type() == HbPrivate::ItemType_NavigationButton ||
   428             if (widget->type() == HbPrivate::ItemType_NavigationButton
   434                 widget->type() == HbPrivate::ItemType_IndicatorButton) {
   429                 // Commented out until use cases are clarified
       
   430                 /*|| widget->type() == HbPrivate::ItemType_IndicatorButton*/) {
   435                 effect = HbFeedback::BasicButton;
   431                 effect = HbFeedback::BasicButton;
   436             }
   432             }
   437 
   433 
   438             // input widget special case
   434             // input widget special case
   439             if (widget->type() == Hb::ItemType_InputCharacterButton
   435             if (widget->type() == Hb::ItemType_InputCharacterButton
   455             }
   451             }
   456 
   452 
   457             break;
   453             break;
   458 
   454 
   459         case HbFeedbackEffectUtils::List:
   455         case HbFeedbackEffectUtils::List:
   460             if (modifiers & Hb::ModifierCollapsedItem) {
   456             if (modifiers & (Hb::ModifierExpandedItem | Hb::ModifierCollapsedItem)) {
   461                 effect = HbFeedback::BasicItem;
   457                 effect = HbFeedback::BasicItem;
   462             }
   458             }
   463             else {
   459             else {
   464                 effect = HbFeedback::SensitiveItem;
   460                 effect = HbFeedback::SensitiveItem;
   465             }
   461             }
   488                 effect = HbFeedback::SensitiveButton;
   484                 effect = HbFeedback::SensitiveButton;
   489             }
   485             }
   490             break;
   486             break;
   491 
   487 
   492         case HbFeedbackEffectUtils::Editor:
   488         case HbFeedbackEffectUtils::Editor:
   493             effect = HbFeedback::None;
   489             effect = HbFeedback::Editor;
   494             break;
   490             break;
   495 
   491 
   496         default:
   492         default:
   497             break;
   493             break;
   498     }
   494     }
   700         }
   696         }
   701         else if (QString(widget->metaObject()->className()) == "HbSelectionControl") {
   697         else if (QString(widget->metaObject()->className()) == "HbSelectionControl") {
   702             feedbackAllowed = false;
   698             feedbackAllowed = false;
   703         }
   699         }
   704     }
   700     }
       
   701     else if (QString(widget->metaObject()->className()) == "HbComboDropDown") {
       
   702         feedbackAllowed = true;
       
   703     }
   705     return feedbackAllowed;
   704     return feedbackAllowed;
   706 }
   705 }
   707 
   706 
   708 /*!
   707 /*!
   709     Returns the instant feedback effect on key press interaction.
   708     Returns the instant feedback effect on key press interaction.
   715 }
   714 }
   716 
   715 
   717 /*!
   716 /*!
   718     Returns the instant feedback effect on selection changed events.
   717     Returns the instant feedback effect on selection changed events.
   719 */
   718 */
   720 HbFeedback::InstantEffect HbFeedbackEffectUtils::instantOnSelectionChanged(const HbWidget *widget)
   719 HbFeedback::InstantEffect HbFeedbackEffectUtils::instantOnSelectionChanged(const HbWidget *widget, Hb::InteractionModifiers modifiers)
   721 {
   720 {
   722     HbFeedback::InstantEffect effect = HbFeedback::None;
   721     HbFeedback::InstantEffect effect = HbFeedback::None;
   723 
   722 
   724     if ( const HbAbstractViewItem * viewItem = qobject_cast<const HbAbstractViewItem *>(widget)) {
   723     if ( const HbAbstractViewItem * viewItem = qobject_cast<const HbAbstractViewItem *>(widget)) {
   725         const HbAbstractItemView* itemView = viewItem->itemView();
   724         const HbAbstractItemView* itemView = viewItem->itemView();
   739                     break;
   738                     break;
   740                 }
   739                 }
   741                 default:
   740                 default:
   742                     break;
   741                     break;
   743             }
   742             }
       
   743             if (modifiers == Hb::ModifierScrolling) {
       
   744                 effect = HbFeedback::StopFlick;
       
   745             }
   744 		}
   746 		}
   745 	}
   747 	}
   746 
   748 
   747         return effect;
   749         return effect;
   748 }
   750 }
   783     Returns the intensity of the feedback for a continuous interaction.
   785     Returns the intensity of the feedback for a continuous interaction.
   784 */
   786 */
   785 int HbFeedbackEffectUtils::intensity(const HbWidget *widget, Hb::ContinuousInteraction interaction, QPointF delta)
   787 int HbFeedbackEffectUtils::intensity(const HbWidget *widget, Hb::ContinuousInteraction interaction, QPointF delta)
   786 {
   788 {
   787     Q_UNUSED(interaction);
   789     Q_UNUSED(interaction);
   788     int intensity = HbFeedback::IntensitySmooth;
   790     Q_UNUSED(delta);
       
   791 
       
   792     int intensity = HbFeedback::IntensityFull;
       
   793 
   789     if (const HbAbstractSliderControl *slider = qobject_cast<const HbAbstractSliderControl *>(widget)) {
   794     if (const HbAbstractSliderControl *slider = qobject_cast<const HbAbstractSliderControl *>(widget)) {
   790         switch(parentItemType(slider)) {
   795         switch(parentItemType(slider)) {
   791             case HbPrivate::ItemType_ZoomSlider:
   796             case HbPrivate::ItemType_ZoomSlider:
   792 
   797 
   793             case HbPrivate::ItemType_VolumeSlider:
   798             case HbPrivate::ItemType_VolumeSlider:
   801                 break;
   806                 break;
   802                 }
   807                 }
   803             default:
   808             default:
   804                 break;
   809                 break;
   805        }
   810        }
   806      } else if (const HbProgressSlider *progressbar = qobject_cast<const HbProgressSlider *>(widget)) {
   811     }
   807         Q_UNUSED(progressbar);
   812     else if (const HbScrollBar *scrollbar = qobject_cast<const HbScrollBar *>(widget)) {
   808         intensity = HbFeedback::IntensitySmooth;
       
   809      } else if (const HbScrollBar *scrollbar = qobject_cast<const HbScrollBar *>(widget)) {
       
   810         Q_UNUSED(scrollbar);
   813         Q_UNUSED(scrollbar);
   811         intensity = HbFeedback::IntensitySmooth;
   814         intensity = HbFeedback::IntensitySmooth;
   812     } else if (const HbGridView *gridView = qobject_cast<const HbGridView *>(widget)) {
   815     }
   813         Q_UNUSED(gridView);
   816     else {
   814         intensity = HbFeedback::IntensitySmooth;
   817         // The default intensity for continuous effects
   815     } else if (widget->type() == Hb::ItemType_VirtualTrackPoint) {
       
   816         intensity = HbFeedback::IntensityFull;
   818         intensity = HbFeedback::IntensityFull;
   817     } else if (widget->type() == Hb::ItemType_WritingBox) {
       
   818         intensity = HbFeedback::IntensitySmooth;
       
   819     } else {
       
   820         intensity = int((abs(25*HbFeedback::IntensityFull*delta.toPoint().y()) / widget->rect().height()) + (abs(25*HbFeedback::IntensityFull*delta.toPoint().x()) / widget->rect().width()));
       
   821 
       
   822         if (intensity > HbFeedback::IntensityFull) {
       
   823             intensity = HbFeedback::IntensityFull;
       
   824         }
       
   825     }
       
   826 
       
   827     if (interaction == Hb::ContinuousRotated) {
       
   828         intensity = HbFeedback::IntensitySmooth;
       
   829     }
   819     }
   830 
   820 
   831     return intensity;
   821     return intensity;
   832 }
   822 }
   833 
   823 
   879         }
   869         }
   880     }
   870     }
   881     return menuEmpty;
   871     return menuEmpty;
   882 }
   872 }
   883 
   873 
       
   874 /*!
       
   875   Returns the default modalities to be used when playing feedback effect asociated with this \a widget, \a interaction, \a modifiers.
       
   876 */
       
   877 HbFeedback::Modalities HbFeedbackEffectUtils::modalities(const HbWidget *widget, Hb::InstantInteraction interaction, Hb::InteractionModifiers modifiers )
       
   878 {
       
   879     Q_UNUSED(modifiers)
       
   880 
       
   881     HbFeedback::Modalities modalities = 0;
       
   882 
       
   883     switch( interaction ) {
       
   884     case Hb::InstantPressed :
       
   885     case Hb::InstantMultitouchActivated:
       
   886         modalities |= HbFeedback::Tactile;
       
   887         modalities |= HbFeedback::Audio;
       
   888         break;
       
   889     case Hb::InstantReleased:
       
   890     case Hb::InstantLongPressed:
       
   891     case Hb::InstantKeyRepeated:
       
   892     case Hb::InstantDraggedOver:
       
   893     case Hb::InstantFlicked:
       
   894     case Hb::InstantRotated90Degrees:
       
   895     case Hb::InstantPopupOpened:
       
   896     case Hb::InstantPopupClosed:
       
   897     case Hb::InstantSelectionChanged:
       
   898         modalities =  HbFeedback::Tactile;
       
   899         break;
       
   900     case Hb::InstantClicked:
       
   901         modalities = HbFeedback::Tactile;
       
   902         if(widget->type() == Hb::ItemType_CheckBox) {
       
   903             modalities |= HbFeedback::Audio;
       
   904         }
       
   905         break;
       
   906     default:
       
   907         modalities = HbFeedback::Tactile;
       
   908         break;
       
   909     }
       
   910     return modalities;
       
   911 }
       
   912 
       
   913 /*!
       
   914   Returns the default modalities to be used when playing feedback effect asociated with this \a widget, \a interaction, \a modifiers.
       
   915 */
       
   916 HbFeedback::Modalities HbFeedbackEffectUtils::modalities(const HbWidget * widget, Hb::ContinuousInteraction interaction, Hb::InteractionModifiers modifiers )
       
   917 {
       
   918     Q_UNUSED(widget)
       
   919     Q_UNUSED(interaction)
       
   920     Q_UNUSED(modifiers)
       
   921     return HbFeedback::Tactile;
       
   922 }