Makefile: remove spurious tab
[xcsoar.git] / src / MapWindow / GlueMapWindow.hpp
blobc438c84d6d343cb3dd49ab7870239d0c2e6217af
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_GLUE_MAP_WINDOW_HPP
25 #define XCSOAR_GLUE_MAP_WINDOW_HPP
27 #include "MapWindow.hpp"
28 #include "Time/PeriodClock.hpp"
29 #include "UIUtil/TrackingGestureManager.hpp"
30 #include "UIUtil/KineticManager.hpp"
31 #include "Renderer/ThermalBandRenderer.hpp"
32 #include "Renderer/FinalGlideBarRenderer.hpp"
33 #include "Renderer/VarioBarRenderer.hpp"
34 #include "Screen/Timer.hpp"
35 #include "Screen/Features.hpp"
37 #include <array>
39 struct Look;
40 struct GestureLook;
41 class Logger;
42 class SingleWindow;
44 class OffsetHistory
46 unsigned int pos;
47 std::array<RasterPoint, 30> offsets;
49 public:
50 OffsetHistory():pos(0) {
51 Reset();
54 void Reset();
55 void Add(RasterPoint p);
56 RasterPoint GetAverage() const;
60 class GlueMapWindow : public MapWindow {
61 const Logger *logger;
63 unsigned idle_robin;
65 PeriodClock mouse_down_clock;
67 enum DragMode {
68 DRAG_NONE,
70 #ifdef HAVE_MULTI_TOUCH
71 /**
72 * Dragging the map with two fingers; enters the "real" pan mode
73 * as soon as the user releases the finger press.
75 DRAG_MULTI_TOUCH_PAN,
76 #endif
78 DRAG_PAN,
79 DRAG_GESTURE,
80 DRAG_SIMULATOR,
81 } drag_mode;
83 GeoPoint drag_start_geopoint;
84 RasterPoint drag_start;
85 TrackingGestureManager gestures;
86 bool ignore_single_click;
88 #ifdef ENABLE_OPENGL
89 KineticManager kinetic_x, kinetic_y;
90 WindowTimer kinetic_timer;
91 #endif
93 /** flag to indicate if the MapItemList should be shown on mouse up */
94 bool arm_mapitem_list;
96 /**
97 * The projection which was active when dragging started.
99 Projection drag_projection;
101 DisplayMode last_display_mode;
103 OffsetHistory offset_history;
105 #ifndef ENABLE_OPENGL
107 * This mutex protects the attributes that are read by the
108 * DrawThread but written by another thread.
110 Mutex next_mutex;
113 * The new map settings. It is passed to
114 * MapWindowBlackboard::ReadMapSettings() before the next frame.
116 MapSettings next_settings_map;
119 * The new glide computer settings. It is passed to
120 * MapWindowBlackboard::ReadGetComputerSettings() before the next
121 * frame.
123 ComputerSettings next_settings_computer;
125 UIState next_ui_state;
126 #endif
128 ThermalBandRenderer thermal_band_renderer;
129 FinalGlideBarRenderer final_glide_bar_renderer;
130 VarioBarRenderer vario_bar_renderer;
132 const GestureLook &gesture_look;
134 WindowTimer map_item_timer;
136 public:
137 GlueMapWindow(const Look &look);
139 void SetLogger(Logger *_logger) {
140 logger = _logger;
143 void SetMapSettings(const MapSettings &new_value);
144 void SetComputerSettings(const ComputerSettings &new_value);
145 void SetUIState(const UIState &new_value);
148 * Update the blackboard from DeviceBlackboard and
149 * InterfaceBlackboard.
151 void ExchangeBlackboard();
154 * Suspend threads that are owned by this object.
156 void SuspendThreads();
159 * Resumt threads that are owned by this object.
161 void ResumeThreads();
164 * Trigger a full redraw of the map.
166 void FullRedraw();
168 void QuickRedraw();
170 bool Idle();
172 void Create(ContainerWindow &parent, const PixelRect &rc);
174 void SetPan(bool enable);
175 void TogglePan();
176 void PanTo(const GeoPoint &location);
178 bool ShowMapItems(const GeoPoint &location,
179 bool show_empty_message = true) const;
181 protected:
182 /* virtual methods from class MapWindow */
183 virtual void Render(Canvas &canvas, const PixelRect &rc) override;
184 virtual void DrawThermalEstimate(Canvas &canvas) const override;
185 virtual void RenderTrail(Canvas &canvas,
186 const RasterPoint aircraft_pos) override;
188 /* virtual methods from class Window */
189 virtual bool OnMouseDouble(PixelScalar x, PixelScalar y) override;
190 virtual bool OnMouseMove(PixelScalar x, PixelScalar y, unsigned keys) override;
191 virtual bool OnMouseDown(PixelScalar x, PixelScalar y) override;
192 virtual bool OnMouseUp(PixelScalar x, PixelScalar y) override;
193 virtual bool OnMouseWheel(PixelScalar x, PixelScalar y, int delta) override;
195 #ifdef HAVE_MULTI_TOUCH
196 virtual bool OnMultiTouchDown() override;
197 #endif
199 virtual bool OnKeyDown(unsigned key_code) override;
200 virtual void OnCancelMode() override;
201 virtual void OnPaint(Canvas &canvas) override;
202 virtual void OnPaintBuffer(Canvas& canvas) override;
203 virtual bool OnTimer(WindowTimer &timer) override;
206 * This event handler gets called when a gesture has
207 * been painted by the user
208 * @param gesture The gesture string (e.g. "ULR")
209 * @return True if the gesture was handled by the
210 * event handler, False otherwise
212 bool OnMouseGesture(const TCHAR* gesture);
214 private:
215 void DrawGesture(Canvas &canvas) const;
216 void DrawMapScale(Canvas &canvas, const PixelRect &rc,
217 const MapWindowProjection &projection) const;
218 void DrawFlightMode(Canvas &canvas, const PixelRect &rc) const;
219 void DrawGPSStatus(Canvas &canvas, const PixelRect &rc,
220 const NMEAInfo &info) const;
221 void DrawCrossHairs(Canvas &canvas) const;
222 void DrawPanInfo(Canvas &canvas) const;
223 void DrawThermalBand(Canvas &canvas, const PixelRect &rc) const;
224 void DrawFinalGlide(Canvas &canvas, const PixelRect &rc) const;
225 void DrawVario(Canvas &canvas, const PixelRect &rc) const;
226 void DrawStallRatio(Canvas &canvas, const PixelRect &rc) const;
228 void SwitchZoomClimb(bool circling);
230 void SaveDisplayModeScales();
232 void UpdateScreenAngle();
233 void UpdateProjection();
236 * Update the visible_projection location, but only if the new
237 * location is sufficiently distant from the current one. This
238 * shall avoid unnecessary map jiggling. This is a great
239 * improvement for E Ink displays to reduce flickering.
241 void SetLocationLazy(const GeoPoint location);
243 public:
244 void UpdateMapScale();
245 void UpdateDisplayMode();
246 void SetMapScale(fixed scale);
248 protected:
249 DisplayMode GetDisplayMode() const {
250 return GetUIState().display_mode;
253 bool InCirclingMode() const {
254 return GetUIState().display_mode == DisplayMode::CIRCLING;
258 #endif