Euphoria
helptexthover.cc
Go to the documentation of this file.
1 #include "core/helptexthover.h"
2 
3 #include "assert/assert.h"
4 
5 
6 namespace
7 {
8  enum State : int
9  {
10  state_no_hover,
11  state_hover_text
12  };
13 
14  // return if the help text should be displayed or not
15  bool
16  update
17  (
18  int& state,
19  float& timer,
20  float time_to_hover,
21  float time_to_hide,
22  bool currently_hovering_over_widget, float dt
23  )
24  {
25  switch(state)
26  {
27  case state_no_hover:
28  if(currently_hovering_over_widget)
29  {
30  timer += dt;
31 
32  if(timer > time_to_hover)
33  {
34  timer = 0.0f;
35  state = state_hover_text;
36  return true;
37  }
38  else
39  {
40  return false;
41  }
42  }
43  else
44  {
45  timer = 0.0f;
46  return false;
47  }
48  case state_hover_text:
49  if(currently_hovering_over_widget)
50  {
51  timer = 0.0f;
52  return true;
53  }
54  else
55  {
56  timer += dt;
57  if(timer > time_to_hide)
58  {
59  state = state_no_hover;
60  timer = 0.0f;
61  }
62 
63  return false;
64  }
65  default:
66  DIE("invalid state");
67  return false;
68  }
69  }
70 }
71 
72 namespace eu::core
73 {
74 
75 void HelpTextHover::update(bool currently_hovering_over_widget, float dt)
76 {
78  (
79  state,
80  timer,
83  currently_hovering_over_widget, dt
84  );
85 }
86 
87 }
#define DIE(message)
Definition: assert.h:67
State
enum to catch adding arguments during parsing in a callback
Definition: argparse.h:23
void update(bool currently_hovering_over_widget, float dt)
ParserState state
Definition: ui_text.cc:134