bool MainWindow::OnTimer(WindowTimer &_timer) { if (_timer != timer) return SingleWindow::OnTimer(_timer); ProcessTimer(); UpdateGaugeVisibility(); if (!CommonInterface::GetUISettings().enable_thermal_assistant_gauge) { thermal_assistant.Clear(); } else if (!CommonInterface::Calculated().circling || InputEvents::IsFlavour(_T("TA"))) { thermal_assistant.Hide(); } else if (!HasDialog()) { if (!thermal_assistant.IsDefined()) thermal_assistant.Set(new GaugeThermalAssistant(CommonInterface::GetLiveBlackboard(), look->thermal_assistant_gauge)); if (!thermal_assistant.IsVisible()) { thermal_assistant.Show(); GaugeThermalAssistant *widget = (GaugeThermalAssistant *)thermal_assistant.Get(); widget->Raise(); } } battery_timer.Process(); return true; }
void MainWindow::OnPause() { if (!IsRunning() && HasDialog()) /* suspending before initialization has finished doesn't leave anything worth resuming, so let's just quit now */ CancelDialog(); SingleWindow::OnPause(); }
bool MainWindow::OnClose() { if (HasDialog() || !IsRunning()) /* no shutdown dialog if XCSoar hasn't completed initialization yet (e.g. if we are in the simulator prompt) */ return SingleWindow::OnClose(); if (UIActions::CheckShutdown()) { Shutdown(); } return true; }
bool MainWindow::OnMouseDouble(PixelScalar x, PixelScalar y) { if (SingleWindow::OnMouseDouble(x, y)) return true; StopDragging(); if (!HasDialog()) InputEvents::ShowMenu(); return false; }
bool MainWindow::OnMouseDouble(PixelPoint p) { if (SingleWindow::OnMouseDouble(p)) return true; StopDragging(); if (!HasDialog()) InputEvents::ShowMenu(); return false; }
bool MainWindow::OnMouseDown(PixelScalar x, PixelScalar y) { if (SingleWindow::OnMouseDown(x, y)) return true; if (!dragging && !HasDialog()) { dragging = true; SetCapture(); gestures.Start(x, y, Layout::Scale(20)); } return true; }
bool MainWindow::OnMouseDown(PixelPoint p) { if (SingleWindow::OnMouseDown(p)) return true; if (!dragging && !HasDialog()) { dragging = true; SetCapture(); gestures.Start(p, Layout::Scale(20)); } return true; }
void MainWindow::OnSetFocus() { SingleWindow::OnSetFocus(); if (!HasDialog()) { /* the main window should never have the keyboard focus; if we happen to get the focus despite of that, forward it to the map window to make keyboard shortcuts work */ if (map != NULL && widget == NULL) map->SetFocus(); else if (widget != NULL) widget->SetFocus(); } else /* recover the dialog focus if it got lost */ GetTopDialog().FocusFirstControl(); }
void MainWindow::UpdateTrafficGaugeVisibility() { const FlarmData &flarm = CommonInterface::Basic().flarm; bool traffic_visible = (force_traffic_gauge || (CommonInterface::GetUISettings().traffic.enable_gauge && !flarm.traffic.IsEmpty())) && !CommonInterface::GetUIState().screen_blanked && /* hide the traffic gauge while the traffic widget is visible, to avoid showing the same information twice */ !InputEvents::IsFlavour(_T("Traffic")); if (traffic_visible && suppress_traffic_gauge) { if (flarm.status.available && flarm.status.alarm_level != FlarmTraffic::AlarmType::NONE) suppress_traffic_gauge = false; else traffic_visible = false; } if (traffic_visible) { if (HasDialog()) return; if (!traffic_gauge.IsDefined()) traffic_gauge.Set(new GaugeFLARM(CommonInterface::GetLiveBlackboard(), GetLook().flarm_gauge)); if (!traffic_gauge.IsVisible()) { traffic_gauge.Show(); GaugeFLARM *widget = (GaugeFLARM *)traffic_gauge.Get(); widget->Raise(); } } else traffic_gauge.Hide(); }
/** * Check whether the specified dialog is the top-most one. */ bool IsTopDialog(WndForm &dialog) { assert(HasDialog()); return &dialog == dialogs.top(); }
void MainWindow::ReinitialiseLayout() { if (map == NULL) { #ifdef ANDROID if (HasDialog()) dialogs.top()->ReinitialiseLayout(); // adapt simulator prompt #endif /* without the MapWindow, it is safe to assume that the MainWindow is just being initialized, and the InfoBoxes aren't initialized yet either, so there is nothing to do here */ return; } #ifndef ENABLE_OPENGL if (draw_thread == NULL) /* no layout changes during startup */ return; #endif InfoBoxManager::Destroy(); const UISettings &ui_settings = CommonInterface::GetUISettings(); const PixelRect rc = GetClientRect(); const InfoBoxLayout::Layout ib_layout = InfoBoxLayout::Calculate(rc, ui_settings.info_boxes.geometry); Fonts::SizeInfoboxFont(ib_layout.control_width); InfoBoxManager::Create(*this, ib_layout, look->info_box, look->units); InfoBoxManager::ProcessTimer(); map_rect = ib_layout.remaining; popup.Destroy(); popup.Create(rc); ReinitialiseLayout_vario(ib_layout); ReinitialiseLayout_flarm(rc, ib_layout); ReinitialiseLayoutTA(rc, ib_layout); if (map != NULL) { if (FullScreen) InfoBoxManager::Hide(); else InfoBoxManager::Show(); const PixelRect main_rect = GetMainRect(); const PixelRect bottom_rect = GetBottomWidgetRect(main_rect, bottom_widget); if (bottom_widget != nullptr) bottom_widget->Move(bottom_rect); map->Move(GetMapRectAbove(main_rect, bottom_rect)); map->FullRedraw(); } if (widget != NULL) widget->Move(GetMainRect(rc)); #ifdef ANDROID // move topmost dialog to fit into the current layout, or close it if (HasDialog()) dialogs.top()->ReinitialiseLayout(); #endif if (map != NULL) map->BringToBottom(); }