foobar2000 SDK  2015-08-03
BumpableElem.h
Go to the documentation of this file.
1 template<typename TClass>
2 class ImplementBumpableElem : public TClass {
3 private:
5 public:
7 
8  BEGIN_MSG_MAP_EX(ImplementBumpableElem)
9  MSG_WM_DESTROY(OnDestroy)
10  CHAIN_MSG_MAP(__super)
11  END_MSG_MAP_HOOK()
12 
13  void notify(const GUID & p_what, t_size p_param1, const void * p_param2, t_size p_param2size) {
14  if (p_what == ui_element_notify_visibility_changed && p_param2 == 0 && m_flash.m_hWnd != NULL) m_flash.Deactivate();
15  __super::notify(p_what, p_param1, p_param2, p_param2size);
16  }
17 
18  static bool Bump() {
19  for(pfc::const_iterator<TSelf*> walk = instances.first(); walk.is_valid(); ++walk) {
20  if ((*walk)->_bump()) return true;
21  }
22  return false;
23  }
25  PFC_ASSERT(core_api::is_main_thread());
26  instances -= this;
27  }
28 private:
29  void OnDestroy() throw() {
30  m_selfDestruct = true;
31  m_flash.CleanUp();
32  SetMsgHandled(FALSE);
33  }
34  bool _bump() {
35  if (m_selfDestruct || m_hWnd == NULL) return false;
36  //PROBLEM: This assumes we're implementing service_base methods at this point. Explodes if called during constructors/destructors.
37  if (!this->m_callback->request_activation(this)) return false;
38  m_flash.Activate(*this);
39  this->set_default_focus();
40  return true;
41  }
42  void _init() {
43  m_selfDestruct = false;
44  PFC_ASSERT(core_api::is_main_thread());
45  instances += this;
46  }
50 };
51 
52 template<typename TClass>
54 
55 
56 template<typename TImpl, typename TInterface = ui_element_v2> class ui_element_impl_withpopup : public ui_element_impl<ImplementBumpableElem<TImpl>, TInterface> {
57 public:
58  t_uint32 get_flags() {return KFlagHavePopupCommand | KFlagSupportsBump;}
60 };
61 
62 template<typename TImpl, typename TInterface = ui_element_v2> class ui_element_impl_visualisation : public ui_element_impl<ImplementBumpableElem<TImpl>, TInterface> {
63 public:
64  t_uint32 get_flags() {return KFlagsVisualisation | KFlagSupportsBump;}
66 };
CFlashWindow m_flash
Definition: BumpableElem.h:49
t_size const void * p_param2
Definition: BumpableElem.h:13
Definition: pfc.h:71
static pfc::avltree_t< TSelf * > instances
Definition: BumpableElem.h:47
void Deactivate()
Definition: misc.h:214
TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD_WITH_INITIALIZER(ImplementBumpableElem, TClass,{_init();}) BEGIN_MSG_MAP_EX(ImplementBumpableElem) MSG_WM_DESTROY(OnDestroy) CHAIN_MSG_MAP(__super) END_MSG_MAP_HOOK() void notify(const GUID &p_what
size_t t_size
Definition: int_types.h:48
t_size const void t_size p_param2size
Definition: BumpableElem.h:13
void CleanUp()
Definition: misc.h:228
__super::notify(p_what, p_param1, p_param2, p_param2size)
ImplementBumpableElem< TClass > TSelf
Definition: BumpableElem.h:4
static bool Bump()
Definition: BumpableElem.h:18
bool is_main_thread()
Returns true if calling thread is main app thread, false otherwise.
void Activate(CWindow parent)
Definition: misc.h:209
static const GUID ui_element_notify_visibility_changed
Sent when a portion of the GUI is shown/hidden. First parameter is a bool flag indicating whether you...
Definition: ui_element.h:538
uint32_t t_uint32
Definition: int_types.h:5