6#include <ibase/TModelObserverCompWrap.h>
7#include <iqtgui/TGuiObserverWrap.h>
8#include <iqtgui/TGuiComponentBase.h>
9#include <iprm/ISelectionParam.h>
10#include <iprm/IEnableableParam.h>
11#include <imod/CMultiModelDispatcherBase.h>
14#include <imtgui/IWidgetProvider.h>
15#include <imtgui/IMonitorInfoProvider.h>
16#include <imtwidgets/CMenuPanel.h>
17#include <imtwidgets/IMenuPanelDelegate.h>
23class CMenuPanelCompBase:
24 public ibase::TModelObserverCompBaseWrap<
25 iqtgui::TGuiObserverWrap<
26 iqtgui::TGuiComponentBase<imtwidgets::CMenuPanel>,
27 imod::TSingleModelObserverBase<iprm::ISelectionParam>>>
30 typedef ibase::TModelObserverCompBaseWrap<
31 iqtgui::TGuiObserverWrap<
32 iqtgui::TGuiComponentBase<imtwidgets::CMenuPanel>,
33 imod::TSingleModelObserverBase<iprm::ISelectionParam>>> BaseClass;
35 I_BEGIN_COMPONENT(CMenuPanelCompBase);
36 I_ASSIGN(m_animationDelayAttrPtr,
"AnimationDelay",
"Animation delay",
true, 800);
37 I_ASSIGN(m_animationDurationAttrPtr,
"AnimationDuration",
"Animation duration",
true, 150);
38 I_ASSIGN(m_animationEnabledAttrPtr,
"AnimationEnabled",
"Animation enabled",
true,
true);
39 I_ASSIGN(m_isShowOverAttrPtr,
"ShowOver",
"Show expanded menu over the underlaying widget",
true,
true);
40 I_ASSIGN(m_physicalResolutionAttrPtr,
"PhysicalResolution",
"Physical monitor resolution",
true, 3.5);
41 I_ASSIGN(m_indentAttrPtr,
"Indent",
"Item indentation",
true, 6);
42 I_ASSIGN(m_itemHeightAttrPtr,
"ItemHeight",
"Item Height",
true, 15);
43 I_ASSIGN(m_iconSizeRatioAttrPtr,
"IconSizeRatio",
"Icon size ratio relative to item height",
true, 1);
44 I_ASSIGN(m_iconSizeHoverRatioAttrPtr,
"IconSizeHoverRatio",
"Icon size ratio under mouse (relative to item normal size)",
true, 1.2);
45 I_ASSIGN(m_fontSizeRatioAttrPtr,
"FontSizeRatio",
"Font pixel size ratio relative to icon size",
true, 0.3);
46 I_ASSIGN(m_topPaddingAttrPtr,
"TopPadding",
"Top panel padding",
true, 1);
47 I_ASSIGN(m_leftPaddingAttrPtr,
"LeftPadding",
"Left item padding",
true, 0);
48 I_ASSIGN(m_rightPaddingAttrPtr,
"RightPadding",
"Right item padding",
true, 20);
49 I_ASSIGN(m_iconToTextPaddingAttrPtr,
"IconToTextPadding",
"Icon to text item padding",
true, 1);
50 I_ASSIGN_MULTI_0(m_bottomPagesIdsAttrPtr,
"BottomPagesIds",
"The list of pages ids that should be placed at bottom of the page",
false);
54 I_ATTR(
int, m_animationDelayAttrPtr);
55 I_ATTR(
int, m_animationDurationAttrPtr);
56 I_ATTR(
bool, m_animationEnabledAttrPtr);
57 I_ATTR(
bool, m_isShowOverAttrPtr);
58 I_MULTIATTR(QByteArray, m_bottomPagesIdsAttrPtr);
59 I_ATTR(
double, m_physicalResolutionAttrPtr);
60 I_ATTR(
double, m_indentAttrPtr);
61 I_ATTR(
double, m_itemHeightAttrPtr);
62 I_ATTR(
double, m_iconSizeRatioAttrPtr);
63 I_ATTR(
double, m_iconSizeHoverRatioAttrPtr);
64 I_ATTR(
double, m_fontSizeRatioAttrPtr);
65 I_ATTR(
double, m_topPaddingAttrPtr);
66 I_ATTR(
double, m_leftPaddingAttrPtr);
67 I_ATTR(
double, m_rightPaddingAttrPtr);
68 I_ATTR(
double, m_iconToTextPaddingAttrPtr);
72class CMenuPanelComp:
public CMenuPanelCompBase
75 typedef CMenuPanelCompBase BaseClass;
77 I_BEGIN_COMPONENT(CMenuPanelComp);
78 I_ASSIGN(m_menuPanelVisibilityCompPtr,
"MenuPanelVisibility",
"Menu panel visibility status",
false,
"MenuPanelVisibility");
79 I_ASSIGN_TO(m_menuPanelVisibilityModelCompPtr, m_menuPanelVisibilityCompPtr,
false);
80 I_ASSIGN(m_widgetProviderCompPtr,
"WidgetProvider",
"Widget provider for parent widget",
false,
"WidgetProvider");
81 I_ASSIGN(m_monitorInfoProviderCompPtr,
"MonitorInfoProvider",
"Monitor info provider (count, size, resolution, etc.)",
false,
"MonitorInfoProvider");
82 I_ASSIGN_TO(m_monitorInfoProviderModelPtr, m_monitorInfoProviderCompPtr,
false);
83 I_ASSIGN(m_menuPanelDelegateCompPtr,
"MenuPanelDelegate",
"Delegate for menu panel",
true,
"MenuPanelDelegate");
84 I_ASSIGN(m_hideDisabledAttrPtr,
"HideDisabled",
"Hide disabled items",
true,
false);
90 void OnPageIdChanged(
const QByteArray& selectedPageId,
const QByteArray& deselectedPageId);
93 virtual void UpdateGui(
const istd::IChangeable::ChangeSet& changeSet)
override;
94 virtual void OnGuiModelAttached()
override;
95 virtual void OnGuiModelDetached()
override;
98 virtual void OnGuiCreated()
override;
99 virtual void OnGuiRetranslate()
override;
100 virtual void OnGuiDesignChanged()
override;
103 class PageSubselectionObserver:
public imod::CMultiModelDispatcherBase
106 explicit PageSubselectionObserver(CMenuPanelComp& parent);
109 virtual void OnModelChanged(
int modelId,
const istd::IChangeable::ChangeSet& changeSet)
override;
112 CMenuPanelComp& m_parent;
115 class PageVisualStatusObserver:
public imod::CMultiModelDispatcherBase
118 explicit PageVisualStatusObserver(CMenuPanelComp& parent);
121 virtual void OnModelChanged(
int modelId,
const istd::IChangeable::ChangeSet& changeSet)
override;
124 CMenuPanelComp& m_parent;
127 class MonitorsInfoObserver:
public imod::TSingleModelObserverBase<imtgui::IMonitorInfoProvider>
130 explicit MonitorsInfoObserver(CMenuPanelComp& parent);
133 virtual void OnUpdate(
const istd::IChangeable::ChangeSet& changeSet);
136 CMenuPanelComp& m_parent;
139 class MenuPanelVisibility:
public imod::TSingleModelObserverBase<iprm::IEnableableParam>
142 explicit MenuPanelVisibility(CMenuPanelComp& parent);
145 virtual void OnUpdate(
const istd::IChangeable::ChangeSet& changeSet);
148 CMenuPanelComp& m_parent;
153 QByteArray parentPageId;
154 const iprm::ISelectionParam* selectionPtr;
158 QMap<QByteArray, PageInfo> m_pagesInfoMap;
159 int m_subselectionModelIndex;
160 int m_visualStatusModelIndex;
161 PageSubselectionObserver m_pageSubselectionObserver;
162 PageVisualStatusObserver m_pageVisualStatusObserver;
163 MonitorsInfoObserver m_monitorInfoObserver;
164 MenuPanelVisibility m_menuPanelVisibilityObserver;
166 I_REF(iprm::IEnableableParam, m_menuPanelVisibilityCompPtr);
167 I_REF(imod::IModel, m_menuPanelVisibilityModelCompPtr);
168 I_REF(imtgui::IWidgetProvider, m_widgetProviderCompPtr);
169 I_REF(imtgui::IMonitorInfoProvider, m_monitorInfoProviderCompPtr);
170 I_REF(imod::IModel, m_monitorInfoProviderModelPtr);
171 I_REF(imtwidgets::IMenuPanelDelegate, m_menuPanelDelegateCompPtr);
172 I_ATTR(
bool, m_hideDisabledAttrPtr);
174 double m_resolutionX;
175 double m_resolutionY;
179 bool IsPageEnabled(
const QByteArray& pageId)
const;
180 void UpdateSelection(
const iprm::ISelectionParam& selection,
const QByteArray& parentId);
181 void CreatePageTree(
const iprm::ISelectionParam& selection,
const QByteArray& parentId);
182 QByteArray FindSelectedItem();
183 void UpdatePageSubselection();
184 void UpdatePageState();
185 void UpdateMonitorsInfo();
186 void UpdateWidgetSizeAttributes();
187 void UpdateMenuPanelVisibility();