void radio_group::add(checkbox& uiobj) { uiobj.radio(true); uiobj.check(false); uiobj.react(false); element_tag el; el.uiobj = &uiobj; el.eh_checked = uiobj.events().click.connect_unignorable([this](const arg_click& arg) { for (auto & i : ui_container_) i.uiobj->check(arg.window_handle == i.uiobj->handle()); }, true); el.eh_destroy = uiobj.events().destroy.connect_unignorable([this](const arg_destroy& arg) { for (auto i = ui_container_.begin(); i != ui_container_.end(); ++i) { if (arg.window_handle == i->uiobj->handle()) { ui_container_.erase(i); return; } } }); ui_container_.push_back(el); }
void initialize_widgets() { static internationalization i18n{}; auto bg_color = 0xefefef; fm.icon(main_icon()); fm.caption(i18n("form_title")); fm.background(bg_color); auto width = fm.size().width; lst_songs.append_header(i18n("Artist"), width / 6); lst_songs.append_header(i18n("Title"), width / 3); lst_songs.append_header(i18n("File"), width / 2); lbl_songs.caption(i18n("Songs") + L":"); lbl_songs.background(bg_color); lbl_songs.text_align(align::left, align_v::center); chk_matched.caption(i18n("Matched only")); chk_matched.background(bg_color); txt_search.multi_lines(false); btn_search.background(bg_color); pl.div("margin=10 vertical" "<weight=22 <search arrange=[variable, 120, 100, 22]> >" "<weight=10>" "<lst>" ); pl["lst"] << lst_songs; pl["search"] << lbl_songs << chk_matched << txt_search << btn_search; pl.collocate(); }
void radio_group::add(checkbox& uiobj) { uiobj.radio(true); uiobj.check(false); uiobj.react(false); element_tag el; el.uiobj = &uiobj; el.eh_checked = API::dev::make_event(events::click::identifier, uiobj, nana::make_fun(*this, &radio_group::_m_checked), true); el.eh_destroy = uiobj.make_event<events::destroy>(*this, &radio_group::_m_destroy); ui_container_.push_back(el); }
void filter_maps() { lst_songs.clear(); cout << "filtering..." << endl; { lst_songs.auto_draw(false); bool matched_only = chk_matched.checked(); performance_timer timer{}; auto keys = split(txt_search.caption()); for (const auto & kv : info_dict) { auto & value = kv.second; if (matched_only && !value->matched) continue; if (all_of(keys.begin(), keys.end(), [&value](const wstring& key){ return value->match_key(key); })) { auto & item = lst_songs.at(0).append(value); item.value(value); } } lst_songs.auto_draw(true); } }
void register_event_handlers() { lst_songs.events().dbl_click([&](const nana::arg_mouse & e) { static match_dialog dialog{}; auto selected = lst_songs.selected(); if (selected.size() > 0) { auto item = lst_songs.at(0).at(selected.front().item); const auto & info = item.value<map_info_ptr>(); dialog.src_file(info->full_path()); dialog.show_dialog(fm); info->matched = matcher::has_matched(info->full_path()); item.resolve_from(info); } }); auto filter = bind(&impl::filter_maps, this); chk_matched.events().click(filter); txt_search.events().key_press([this](const arg_keyboard & arg){ if (arg.key == '\r') filter_maps(); }); btn_search.events().click(filter); }