本文整理汇总了C++中CVideo::current_resolution方法的典型用法代码示例。如果您正苦于以下问题:C++ CVideo::current_resolution方法的具体用法?C++ CVideo::current_resolution怎么用?C++ CVideo::current_resolution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVideo
的用法示例。
在下文中一共展示了CVideo::current_resolution方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: show_video_mode_dialog
bool show_video_mode_dialog(CVideo& video)
{
const resize_lock prevent_resizing;
// For some reason, this line prevents the dialog from being opened from GUI2...
//const events::event_context dialog_events_context;
std::vector<std::pair<int,int> > resolutions
= video.get_available_resolutions();
if(resolutions.empty()) {
gui2::show_transient_message(
video
, ""
, _("There are no alternative video modes available"));
return false;
}
std::vector<std::string> options;
unsigned current_choice = 0;
for(size_t k = 0; k < resolutions.size(); ++k) {
std::pair<int, int> const& res = resolutions[k];
if (res == video.current_resolution())
current_choice = static_cast<unsigned>(k);
std::ostringstream option;
option << res.first << utils::unicode_multiplication_sign << res.second;
const int div = boost::math::gcd(res.first, res.second);
const int ratio[2] = {res.first/div, res.second/div};
if (ratio[0] <= 10 || ratio[1] <= 10)
option << " (" << ratio[0] << ':' << ratio[1] << ')';
options.push_back(option.str());
}
gui2::tsimple_item_selector dlg(_("Choose Resolution"), "", options);
dlg.set_selected_index(current_choice);
dlg.show(video);
int choice = dlg.selected_index();
if(choice == -1 || resolutions[static_cast<size_t>(choice)] == video.current_resolution()) {
return false;
}
video.set_resolution(resolutions[static_cast<size_t>(choice)]);
return true;
}