Add pixel scale preference option.
This commit is contained in:
parent
c5dec73784
commit
3a781c87ad
4 changed files with 78 additions and 0 deletions
|
@ -51,6 +51,38 @@
|
|||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
{GUI_FILLER}
|
||||
|
||||
[column]
|
||||
horizontal_grow = true
|
||||
{_GUI_PREFERENCES_MAIN_COMPOSITE_SLIDER
|
||||
( _ "Pixel scale multiplier:")
|
||||
pixel_scale_slider (
|
||||
minimum_value,maximum_value=1,4
|
||||
step_size=1
|
||||
tooltip= _ "Set the global pixel scale multiplier. A pixel scale multiplier of 2 will make everything look twice as large."
|
||||
)
|
||||
}
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
{GUI_FILLER}
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[toggle_button]
|
||||
id = "auto_pixel_scale"
|
||||
label = _ "Automatic pixel scale multiplier"
|
||||
tooltip = _ "Choose pixel scale multiplier automatically based on current resolution"
|
||||
[/toggle_button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
|
|
|
@ -71,6 +71,12 @@ void disable_widget_on_toggle(window& window, widget& w, const std::string& id)
|
|||
find_widget<W>(&window, id, false).set_active(dynamic_cast<selectable_item&>(w).get_value_bool());
|
||||
}
|
||||
|
||||
template<typename W>
|
||||
void disable_widget_on_toggle_inverted(window& window, widget& w, const std::string& id)
|
||||
{
|
||||
find_widget<W>(&window, id, false).set_active(!dynamic_cast<selectable_item&>(w).get_value_bool());
|
||||
}
|
||||
|
||||
// Ensure the specified index is between 0 and one less than the max
|
||||
// number of pager layers (since get_layer_count returns one-past-end).
|
||||
int index_in_pager_range(const int first, const stacked_widget& pager)
|
||||
|
@ -408,6 +414,15 @@ void preferences_dialog::post_build(window& window)
|
|||
connect_signal_notify_modified(res_list,
|
||||
std::bind(&preferences_dialog::handle_res_select, this));
|
||||
|
||||
/* PIXEL SCALE */
|
||||
register_integer("pixel_scale_slider", true,
|
||||
pixel_scale, set_pixel_scale);
|
||||
|
||||
/* AUTOMATIC PIXEL SCALE */
|
||||
register_bool("auto_pixel_scale", true,
|
||||
auto_pixel_scale, set_auto_pixel_scale,
|
||||
[&](widget& w) { disable_widget_on_toggle_inverted<slider>(window, w, "pixel_scale_slider"); }, true);
|
||||
|
||||
/* SHOW FLOATING LABELS */
|
||||
register_bool("show_floating_labels", true,
|
||||
show_floating_labels, set_show_floating_labels);
|
||||
|
@ -985,6 +1000,7 @@ void preferences_dialog::pre_show(window& window)
|
|||
|
||||
gui2::bind_status_label<slider>(&window, "max_saves_slider");
|
||||
gui2::bind_status_label<slider>(&window, "turbo_slider");
|
||||
gui2::bind_status_label<slider>(&window, "pixel_scale_slider");
|
||||
|
||||
//gui2::bind_status_label<slider>(&window, "scaling_slider", [](slider& s)->std::string {
|
||||
// return s.get_value_label() + "%";
|
||||
|
|
|
@ -72,6 +72,9 @@ const int def_window_height = 720;
|
|||
const int min_font_scaling = 80;
|
||||
const int max_font_scaling = 150;
|
||||
|
||||
const int min_pixel_scale = 1;
|
||||
const int max_pixel_scale = 4;
|
||||
|
||||
class prefs_event_handler : public events::sdl_handler {
|
||||
public:
|
||||
virtual void handle_event(const SDL_Event &) {}
|
||||
|
@ -406,6 +409,27 @@ point resolution()
|
|||
);
|
||||
}
|
||||
|
||||
int pixel_scale()
|
||||
{
|
||||
// For now this has a minimum value of 1 and a maximum of 4.
|
||||
return std::max<int>(std::min<int>(prefs["pixel_scale"].to_int(1), max_pixel_scale), min_pixel_scale);
|
||||
}
|
||||
|
||||
void set_pixel_scale(const int scale)
|
||||
{
|
||||
prefs["pixel_scale"] = std::clamp(scale, min_pixel_scale, max_pixel_scale);
|
||||
}
|
||||
|
||||
bool auto_pixel_scale()
|
||||
{
|
||||
return get("auto_pixel_scale", true);
|
||||
}
|
||||
|
||||
void set_auto_pixel_scale(bool choice)
|
||||
{
|
||||
prefs["auto_pixel_scale"] = choice;
|
||||
}
|
||||
|
||||
bool maximized()
|
||||
{
|
||||
return get("maximized", !fullscreen());
|
||||
|
|
|
@ -75,6 +75,12 @@ namespace preferences {
|
|||
point resolution();
|
||||
void _set_resolution(const point& res);
|
||||
|
||||
int pixel_scale();
|
||||
void set_pixel_scale(const int scale);
|
||||
|
||||
bool auto_pixel_scale();
|
||||
void set_auto_pixel_scale(bool choice);
|
||||
|
||||
bool maximized();
|
||||
void _set_maximized(bool ison);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue