Ui scaling interface tweaks

This commit is contained in:
Imbris 2019-07-27 15:26:31 -04:00
parent 8e15117be7
commit ff518a4a23
6 changed files with 68 additions and 76 deletions

BIN
assets/voxygen/element/nothing.png (Stored with Git LFS)

Binary file not shown.

View File

@ -145,7 +145,6 @@ image_ids! {
<ImageGraphic>
charwindow_gradient:"voxygen/element/misc_bg/charwindow.png",
nothing: "voxygen/element/nothing.png",
// Spell Book Window
spellbook_icon: "voxygen/element/icons/spellbook.png",
@ -196,6 +195,6 @@ image_ids! {
social_icon: "voxygen/element/icons/social.png",
<BlankGraphic>
blank: (),
nothing: (),
}
}

View File

@ -123,7 +123,7 @@ pub struct DebugInfo {
pub ping_ms: f64,
pub coordinates: Option<comp::Pos>,
}
//#[derive(Serialize, Deserialize)]
pub enum Event {
SendMessage(String),
AdjustMousePan(u32),
@ -167,8 +167,6 @@ pub struct Show {
open_windows: Windows,
map: bool,
inventory_test_button: bool,
rel_to_win: bool,
absolute: bool,
mini_map: bool,
ingame: bool,
settings_tab: SettingsTab,
@ -320,8 +318,6 @@ impl Hud {
settings_tab: SettingsTab::Interface,
want_grab: true,
ingame: true,
rel_to_win: true,
absolute: false,
},
to_focus: None,
force_ungrab: false,
@ -638,13 +634,8 @@ impl Hud {
// Settings
if let Windows::Settings = self.show.open_windows {
for event in SettingsWindow::new(
&global_state,
&self.show,
&self.imgs,
&self.fonts,
)
.set(self.ids.settings_window, ui_widgets)
for event in SettingsWindow::new(&global_state, &self.show, &self.imgs, &self.fonts)
.set(self.ids.settings_window, ui_widgets)
{
match event {
settings_window::Event::ToggleHelp => self.show.toggle_help(),

View File

@ -29,7 +29,6 @@ widget_ids! {
show_help_label,
ui_scale_label,
ui_scale_slider,
ui_scale_slider_2,
ui_scale_button,
ui_scale_value,
relative_to_win_button,
@ -108,7 +107,7 @@ impl<'a> SettingsWindow<'a> {
global_state: &'a GlobalState,
show: &'a Show,
imgs: &'a Imgs,
fonts: &'a Fonts,
fonts: &'a Fonts,
) -> Self {
Self {
global_state,
@ -322,29 +321,31 @@ impl<'a> Widget for SettingsWindow<'a> {
.font_size(18)
.font_id(self.fonts.opensans)
.color(TEXT_COLOR)
.set(state.ids.ui_scale_label, ui);
.set(state.ids.ui_scale_label, ui);
// Relative Scaling Button
if Button::image(match ui_scale {
ScaleMode::Absolute(_) => self.imgs.check,
ScaleMode::RelativeToWindow(_) => self.imgs.check_checked,
ScaleMode::DpiFactor => self.imgs.check_checked,
})
.w_h(288.0 / 24.0, 288.0 / 24.0)
.down_from(state.ids.ui_scale_label, 20.0)
.hover_image(match ui_scale {
ScaleMode::Absolute(_) => self.imgs.check_mo,
ScaleMode::RelativeToWindow(_) => self.imgs.check_checked,
ScaleMode::DpiFactor => self.imgs.check_checked,
})
.press_image(match ui_scale {
ScaleMode::Absolute(_) => self.imgs.check_press,
ScaleMode::RelativeToWindow(_) => self.imgs.check_checked,
ScaleMode::DpiFactor => self.imgs.check_checked,
})
.set(state.ids.relative_to_win_button, ui)
.was_clicked()
let (check_img, check_mo_img, check_press_img, relative_selected) = match ui_scale {
ScaleMode::RelativeToWindow(_) => (
self.imgs.check_checked,
self.imgs.check_checked,
self.imgs.check_checked,
true,
),
ScaleMode::Absolute(_) | ScaleMode::DpiFactor => (
self.imgs.check,
self.imgs.check_mo,
self.imgs.check_press,
false,
),
};
if Button::image(check_img)
.w_h(288.0 / 24.0, 288.0 / 24.0)
.down_from(state.ids.ui_scale_label, 20.0)
.hover_image(check_mo_img)
.press_image(check_press_img)
.set(state.ids.relative_to_win_button, ui)
.was_clicked()
&& !relative_selected
{
events.push(Event::UiScale(ScaleChange::ToRelative));
}
@ -358,26 +359,28 @@ impl<'a> Widget for SettingsWindow<'a> {
.set(state.ids.relative_to_win_text, ui);
// Absolute Scaling Button
if Button::image(match ui_scale {
ScaleMode::Absolute(_) => self.imgs.check_checked,
ScaleMode::RelativeToWindow(_) => self.imgs.check,
ScaleMode::DpiFactor => self.imgs.check,
})
.w_h(288.0 / 24.0, 288.0 / 24.0)
.down_from(state.ids.relative_to_win_button, 20.0)
.hover_image(match ui_scale {
ScaleMode::Absolute(_) => self.imgs.check_checked,
ScaleMode::RelativeToWindow(_) => self.imgs.check_mo,
ScaleMode::DpiFactor => self.imgs.check_mo,
})
.press_image(match ui_scale {
ScaleMode::Absolute(_) => self.imgs.check_checked,
ScaleMode::RelativeToWindow(_) => self.imgs.check_press,
ScaleMode::DpiFactor => self.imgs.check_press,
})
.set(state.ids.absolute_scale_button, ui)
.was_clicked()
let (check_img, check_mo_img, check_press_img, absolute_selected) = match ui_scale {
ScaleMode::Absolute(_) => (
self.imgs.check_checked,
self.imgs.check_checked,
self.imgs.check_checked,
true,
),
ScaleMode::RelativeToWindow(_) | ScaleMode::DpiFactor => (
self.imgs.check,
self.imgs.check_mo,
self.imgs.check_press,
false,
),
};
if Button::image(check_img)
.w_h(288.0 / 24.0, 288.0 / 24.0)
.down_from(state.ids.relative_to_win_button, 20.0)
.hover_image(check_mo_img)
.press_image(check_press_img)
.set(state.ids.absolute_scale_button, ui)
.was_clicked()
&& !absolute_selected
{
events.push(Event::UiScale(ScaleChange::ToAbsolute));
}
@ -409,23 +412,21 @@ impl<'a> Widget for SettingsWindow<'a> {
events.push(Event::UiScale(ScaleChange::Adjust(2.0f64.powf(new_val))));
}
Text::new(&format!("{:.2}", scale))
.up_from(state.ids.ch_transp_value, 75.0)
.up_from(state.ids.ch_transp_value, 75.0)
.font_size(14)
.font_id(self.fonts.opensans)
.color(TEXT_COLOR)
.set(state.ids.ui_scale_value, ui);
} else {
if let Some(_val) =
ImageSlider::continuous(5.0, 0.0, 10.0, self.imgs.nothing, self.imgs.slider)
.w_h(210.0, 22.0)
.right_from(state.ids.absolute_scale_text, 10.0)
.track_breadth(12.0)
.slider_length(10.0)
.track_color(Color::Rgba(1.0, 1.0, 1.0, 0.2))
.slider_color(Color::Rgba(1.0, 1.0, 1.0, 0.2))
.pad_track((5.0, 5.0))
.set(state.ids.ui_scale_slider_2, ui)
{}
ImageSlider::continuous(0.0, 0.0, 1.0, self.imgs.nothing, self.imgs.slider)
.w_h(208.0, 22.0)
.right_from(state.ids.absolute_scale_text, 10.0)
.track_breadth(12.0)
.slider_length(10.0)
.track_color(Color::Rgba(1.0, 1.0, 1.0, 0.2))
.slider_color(Color::Rgba(1.0, 1.0, 1.0, 0.2))
.pad_track((5.0, 5.0))
.set(state.ids.ui_scale_slider, ui);
}
// Crosshair Options

View File

@ -2,7 +2,7 @@ use crate::{
render::{Consts, Globals, Renderer},
ui::{
self,
img_ids::{ImageGraphic, VoxelGraphic},
img_ids::{BlankGraphic, ImageGraphic, VoxelGraphic},
ImageSlider, Ui,
},
GlobalState,
@ -180,7 +180,9 @@ image_ids! {
icon_border_mo: "voxygen/element/buttons/border_mo.png",
icon_border_press: "voxygen/element/buttons/border_press.png",
icon_border_pressed: "voxygen/element/buttons/border_pressed.png",
nothing: "voxygen/element/nothing.png",
<BlankGraphic>
nothing: (),
}
}

View File

@ -2,7 +2,7 @@ use crate::{
render::Renderer,
ui::{
self,
img_ids::{ImageGraphic, VoxelGraphic},
img_ids::{BlankGraphic, ImageGraphic, VoxelGraphic},
Ui,
},
GlobalState,
@ -70,7 +70,9 @@ image_ids! {
<ImageGraphic>
bg: "voxygen/background/bg_main.png",
error_frame: "voxygen/element/frames/window_2.png",
nothing: "voxygen/element/nothing.png",
<BlankGraphic>
nothing: (),
}
}