36 namespace ArgusSamples
51 PROPAGATE_ERROR(Window::getInstance().registerObserver(
this));
53 const char *description =
54 "Press 'Ctrl-Up' to increase the focus position, press 'Ctrl-Down' to decrease the focus\n"
56 "Press 'Esc' to exit.\n";
64 PROPAGATE_ERROR(Window::getInstance().unregisterObserver(
this));
70 PROPAGATE_ERROR(Window::getInstance().
shutdown());
92 Window &window = Window::getInstance();
95 PROPAGATE_ERROR(
start());
98 PROPAGATE_ERROR(window.eventLoop());
108 static bool changeFocusPosition(int32_t direction)
113 if ((direction != -1) && (direction != 1))
114 ORIGINATE_ERROR(
"Invalid direction");
116 const int32_t diff = ((focusPositionRange.max - focusPositionRange.min) + 99) / 100;
118 int32_t newPosition = dispatcher.
m_focusPosition.get() + diff * direction;
121 std::min(focusPositionRange.max, std::max(focusPositionRange.min, newPosition));
125 PROPAGATE_ERROR(dispatcher.
message(
"Changed focuser position to %d in range [%d, %d]\n",
126 newPosition, focusPositionRange.min, focusPositionRange.max));
133 if ((key == Key(
"Escape")) ||
134 (key == Key(
"c", KeyModifier(KeyModifier::MASK_CONTROL))))
136 PROPAGATE_ERROR(Window::getInstance().requestExit());
138 else if (key == Key(
"Up", KeyModifier(KeyModifier::MASK_CONTROL)))
140 PROPAGATE_ERROR(changeFocusPosition(+1));
142 else if (key == Key(
"Down", KeyModifier(KeyModifier::MASK_CONTROL)))
144 PROPAGATE_ERROR(changeFocusPosition(-1));