bool dlgTaskPointType(OrderedTask &task, const unsigned index) { point_types.clear(); task.GetFactory().GetValidTypes(index) .CopyTo(std::back_inserter(point_types)); if (point_types.empty()) { assert(1); return false; } if (point_types.size() == 1) return SetPointType(task, index, point_types[0]); const auto &point = task.GetPoint(index); const auto current_type = task.GetFactory().GetType(point); unsigned initial_index = 0; const auto b = point_types.begin(), e = point_types.end(); auto i = std::find(b, e, current_type); if (i != e) initial_index = std::distance(b, i); MutateTaskPointRenderer item_renderer(current_type); int result = ListPicker(_("Task Point Type"), point_types.size(), initial_index, item_renderer.CalculateLayout(UIGlobals::GetDialogLook()), item_renderer, false, nullptr, TPTypeItemHelp); return result >= 0 && SetPointType(task, index, point_types[result]); }
bool ShowColorListDialog(RGB8Color &color) { unsigned default_index = 0; for (unsigned i = 1; i < ARRAY_SIZE(AirspaceLook::preset_colors); ++i) if (AirspaceLook::preset_colors[i] == color) default_index = i; /* auto item_renderer = MakeListItemRenderer([](Canvas &canvas, const PixelRect rc, unsigned i){ OnPaintListItem(canvas, rc, i); }); */ FunctionListItemRenderer item_renderer(OnPaintListItem); int index = ListPicker(_("Select Color"), ARRAY_SIZE(AirspaceLook::preset_colors), default_index, Layout::FastScale(18), item_renderer); if (index < 0) return false; assert((unsigned)index < ARRAY_SIZE(AirspaceLook::preset_colors)); color = AirspaceLook::preset_colors[index]; return true; }
bool dlgTaskPointType(OrderedTask** task, const unsigned index) { ordered_task = *task; active_index = index; point = &ordered_task->GetPoint(active_index); point_types.clear(); ordered_task->GetFactory().GetValidTypes(index) .CopyTo(std::back_inserter(point_types)); if (point_types.empty()) { assert(1); return false; } if (point_types.size() == 1) return SetPointType(point_types[0]); unsigned initial_index = 0; const auto b = point_types.begin(), e = point_types.end(); auto i = std::find(b, e, get_point_type()); if (i != e) initial_index = std::distance(b, i); FunctionListItemRenderer item_renderer(OnPointPaintListItem); int result = ListPicker(_("Task Point Type"), point_types.size(), initial_index, Layout::Scale(18), item_renderer, false, nullptr, TPTypeItemHelp); return result >= 0 && SetPointType(point_types[result]); }
int ComboPicker(SingleWindow &parent, const TCHAR *caption, const ComboList &combo_list, ListHelpCallback_t help_callback, bool enable_item_help) { ComboListPopup = &combo_list; const UPixelScalar font_height = UIGlobals::GetDialogLook().text_font->GetHeight() + Layout::FastScale(2); const UPixelScalar max_height = Layout::GetMaximumControlHeight(); const UPixelScalar row_height = font_height >= max_height ? font_height /* this formula is supposed to be a compromise between too small and too large: */ : (font_height + max_height) / 2; padding = (row_height - font_height) / 2; return ListPicker(parent, caption, combo_list.size(), combo_list.ComboPopupItemSavedIndex, row_height, OnPaintComboPopupListItem, false, help_callback, enable_item_help ? OnItemHelp : NULL); }
int dlgAirspaceColoursShowModal() { return ListPicker(UIGlobals::GetMainWindow(), _("Select Color"), ARRAY_SIZE(AirspaceLook::preset_colors), 0, Layout::FastScale(18), OnAirspaceColoursPaintListItem); }
int dlgAirspacePatternsShowModal(const AirspaceLook &look) { AirspacePatternsDialog dialog(look); return ListPicker(_("Select Pattern"), ARRAY_SIZE(AirspaceLook::brushes), 0, Layout::FastScale(18), dialog); }
int dlgAirspacePatternsShowModal(const AirspaceLook &look) { AirspacePatternsDialog dialog(look); return ListPicker(_("Select Pattern"), ARRAY_SIZE(AirspaceLook::brushes), 0, Layout::GetMaximumControlHeight(), dialog); }
FlarmId dlgFlarmDetailsListShowModal(SingleWindow &parent, const TCHAR *title, FlarmId _array[], unsigned count) { assert(count > 0); array = _array; UPixelScalar line_height = GetRowHeight(UIGlobals::GetDialogLook()); unsigned index = ListPicker(parent, title, count, 0, line_height, PaintListItem, true); return index < count ? array[index] : FlarmId::Undefined(); }
int ComboPicker(SingleWindow &parent, const TCHAR *caption, const ComboList &combo_list, ListHelpCallback_t help_callback, bool enable_item_help) { ComboListPopup = &combo_list; return ListPicker(parent, caption, combo_list.size(), combo_list.ComboPopupItemSavedIndex, Layout::Scale(18), OnPaintComboPopupListItem, false, help_callback, enable_item_help ? OnItemHelp : NULL); }
void dlgAlternatesListShowModal(SingleWindow &parent) { if (protected_task_manager == NULL) return; UpdateAlternates(); UPixelScalar line_height = Fonts::map_bold.GetHeight() + Layout::Scale(6) + Fonts::map_label.GetHeight(); int i = ListPicker(parent, _("Alternates"), alternates.size(), 0, line_height, PaintListItem, true); if (i < 0 || (unsigned)i >= alternates.size()) return; dlgWaypointDetailsShowModal(parent, alternates[i].waypoint); }
void ManagedFileListWidget::Add() { #ifdef HAVE_DOWNLOAD_MANAGER assert(Net::DownloadManager::IsAvailable()); std::vector<AvailableFile> list; for (auto i = repository.begin(), end = repository.end(); i != end; ++i) { const AvailableFile &remote_file = *i; if (IsDownloading(remote_file.GetName())) /* already downloading this file */ continue; ACPToWideConverter name(remote_file.GetName()); if (!name.IsValid()) continue; if (FindItem(name) < 0) list.push_back(remote_file); } if (list.empty()) return; add_list = &list; FunctionListItemRenderer item_renderer(OnPaintAddItem); int i = ListPicker(_("Select a file"), list.size(), 0, Layout::FastScale(18), item_renderer); add_list = NULL; if (i < 0) return; assert((unsigned)i < list.size()); const AvailableFile &remote_file = list[i]; ACPToWideConverter base(remote_file.GetName()); if (!base.IsValid()) return; Net::DownloadManager::Enqueue(remote_file.GetURI(), base); #endif }
void dlgAlternatesListShowModal(SingleWindow &parent) { if (protected_task_manager == NULL) return; UpdateAlternates(); const DialogLook &look = UIGlobals::GetDialogLook(); int i = ListPicker(parent, _("Alternates"), alternates.size(), 0, WaypointListRenderer::GetHeight(look), PaintListItem, true); if (i < 0 || (unsigned)i >= alternates.size()) return; dlgWaypointDetailsShowModal(parent, alternates[i].waypoint); }
void ManagedFileListWidget::Add() { #ifdef HAVE_DOWNLOAD_MANAGER assert(Net::DownloadManager::IsAvailable()); std::vector<AvailableFile> list; for (const auto &remote_file : repository) { if (IsDownloading(remote_file.GetName())) /* already downloading this file */ continue; const UTF8ToWideConverter name(remote_file.GetName()); if (!name.IsValid()) continue; if (FindItem(name) < 0) list.push_back(remote_file); } if (list.empty()) return; AddFileListItemRenderer item_renderer(list); int i = ListPicker(_("Select a file"), list.size(), 0, item_renderer.CalculateLayout(UIGlobals::GetDialogLook()), item_renderer); if (i < 0) return; assert((unsigned)i < list.size()); const AvailableFile &remote_file = list[i]; const UTF8ToWideConverter base(remote_file.GetName()); if (!base.IsValid()) return; Net::DownloadManager::Enqueue(remote_file.GetURI(), base); #endif }
void RASPSettingsPanel::Download() { unsigned n = 0; for (auto i = rasp_providers; i->url != nullptr; ++i) ++n; assert(n > 0); RaspProviderRenderer renderer; int i = ListPicker(_("Download"), n, 0, renderer.CalculateLayout(GetLook()), renderer); if (i < 0) return; const char *url = rasp_providers[i].url; auto path = LocalPath(_T(RASP_FILENAME)); { DialogJobRunner runner(UIGlobals::GetMainWindow(), GetLook(), _("Download"), true); Net::Session session; FileTransaction transaction(path); Net::DownloadToFileJob job(session, url, transaction.GetTemporaryPath()); if (!runner.Run(job) || !job.WasSuccessful()) return; transaction.Commit(); } rasp = std::make_shared<RaspStore>(std::move(path)); rasp->ScanAll(); DataGlobals::SetRasp(std::shared_ptr<RaspStore>(rasp)); FillItemControl(); }