edit mode ui fixes
This commit is contained in:
@@ -22,6 +22,21 @@ impl Positioning {
|
|||||||
pub const fn moves_with_space(self) -> bool {
|
pub const fn moves_with_space(self) -> bool {
|
||||||
matches!(self, Self::Floating | Self::Anchored | Self::Static)
|
matches!(self, Self::Floating | Self::Anchored | Self::Static)
|
||||||
}
|
}
|
||||||
|
pub const fn get_lerp(self) -> Option<f32> {
|
||||||
|
match self {
|
||||||
|
Self::FollowHead { lerp } => Some(lerp),
|
||||||
|
Self::FollowHand { lerp, .. } => Some(lerp),
|
||||||
|
Self::Floating | Self::Anchored | Self::Static => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub const fn with_lerp(mut self, value: f32) -> Self {
|
||||||
|
match self {
|
||||||
|
Self::FollowHead { ref mut lerp } => *lerp = value,
|
||||||
|
Self::FollowHand { ref mut lerp, .. } => *lerp = value,
|
||||||
|
Self::Floating | Self::Anchored | Self::Static => {}
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contains the window state for a given set
|
// Contains the window state for a given set
|
||||||
|
|||||||
@@ -45,8 +45,8 @@
|
|||||||
<TopButton sticky="0" id="top_pos" src="edit/anchor.svg" tooltip="EDIT_MODE.POSITIONING" press="::EditModeTab pos" />
|
<TopButton sticky="0" id="top_pos" src="edit/anchor.svg" tooltip="EDIT_MODE.POSITIONING" press="::EditModeTab pos" />
|
||||||
<TopButton sticky="0" id="top_alpha" src="edit/fade.svg" tooltip="EDIT_MODE.OPACITY" press="::EditModeTab alpha" />
|
<TopButton sticky="0" id="top_alpha" src="edit/fade.svg" tooltip="EDIT_MODE.OPACITY" press="::EditModeTab alpha" />
|
||||||
<TopButton sticky="0" id="top_curve" src="edit/curve.svg" tooltip="EDIT_MODE.ADJUST_CURVATURE" press="::EditModeTab curve" />
|
<TopButton sticky="0" id="top_curve" src="edit/curve.svg" tooltip="EDIT_MODE.ADJUST_CURVATURE" press="::EditModeTab curve" />
|
||||||
<TopButton sticky="0" id="top_move" src="edit/move-all.svg" tooltip="EDIT_MODE.MOVE_PRESS_AND_DRAG" />
|
<!-- TopButton sticky="0" id="top_move" src="edit/move-all.svg" tooltip="EDIT_MODE.MOVE_PRESS_AND_DRAG" / -->
|
||||||
<TopButton sticky="0" id="top_resize" src="edit/resize.svg" tooltip="EDIT_MODE.RESIZE_PRESS_AND_DRAG" />
|
<!-- TopButton sticky="0" id="top_resize" src="edit/resize.svg" tooltip="EDIT_MODE.RESIZE_PRESS_AND_DRAG" / -->
|
||||||
<TopButtonDanger src="edit/delete.svg" tooltip="EDIT_MODE.DELETE" press="::EditModeDeletePress" release="::EditModeDeleteRelease" />
|
<TopButtonDanger src="edit/delete.svg" tooltip="EDIT_MODE.DELETE" press="::EditModeDeletePress" release="::EditModeDeleteRelease" />
|
||||||
<div width="8" height="100%" />
|
<div width="8" height="100%" />
|
||||||
<TopButtonFaded src="watch/edit.svg" tooltip="EDIT_MODE.LEAVE" press="::EditToggle" />
|
<TopButtonFaded src="watch/edit.svg" tooltip="EDIT_MODE.LEAVE" press="::EditToggle" />
|
||||||
@@ -63,20 +63,21 @@
|
|||||||
<PosButton id="pos_hand_l" src="watch/controller_l.svg" tooltip="EDIT_MODE.POS_HAND_L" press="::EditModeSetPos hand_l" />
|
<PosButton id="pos_hand_l" src="watch/controller_l.svg" tooltip="EDIT_MODE.POS_HAND_L" press="::EditModeSetPos hand_l" />
|
||||||
<PosButton id="pos_hand_r" src="watch/controller_r.svg" tooltip="EDIT_MODE.POS_HAND_R" press="::EditModeSetPos hand_r" />
|
<PosButton id="pos_hand_r" src="watch/controller_r.svg" tooltip="EDIT_MODE.POS_HAND_R" press="::EditModeSetPos hand_r" />
|
||||||
</div>
|
</div>
|
||||||
<div padding="8" gap="8" justify_content="center" align_items="center">
|
<div id="pos_interpolation" padding="8" gap="8" justify_content="center" align_items="center">
|
||||||
<label translation="EDIT_MODE.INTERPOLATION" />
|
<label translation="EDIT_MODE.INTERPOLATION" />
|
||||||
<Slider id="lerp_slider" width="250" height="16" min_value="0.05" max_value="1" value="1" step="0.05" />
|
<Slider id="lerp_slider" width="250" height="16" min_value="0.05" max_value="1" value="1" step="0.05" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="tab_alpha" display="none" height="100" padding="8" gap="8" justify_content="center" align_items="center">
|
<div id="tab_alpha" display="none" height="100" padding="8" gap="8" justify_content="center" align_items="center">
|
||||||
<label translation="EDIT_MODE.OPACITY" />
|
<div width="100%" padding="8" gap="8" justify_content="center" align_items="center">
|
||||||
<Slider id="alpha_slider" width="200" height="16" min_value="0.1" max_value="1" value="1" step="0.05" />
|
<label translation="EDIT_MODE.OPACITY" />
|
||||||
<CheckBox id="additive_box" translation="EDIT_MODE.BLENDING_ADDITIVE" tooltip="EDIT_MODE.ALPHA_BLEND_MODE" tooltip_side="bottom" />
|
<Slider id="alpha_slider" width="200" height="16" min_value="0.1" max_value="1" value="1" step="0.05" />
|
||||||
|
</div>
|
||||||
|
<div width="100%" padding="8" gap="8" justify_content="center" align_items="center">
|
||||||
|
<CheckBox id="additive_box" translation="EDIT_MODE.BLENDING_ADDITIVE" tooltip="EDIT_MODE.ALPHA_BLEND_MODE" tooltip_side="bottom" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="tab_curve" display="none" height="100" flex_direction="column">
|
<div id="tab_curve" display="none" height="100" flex_direction="column">
|
||||||
<div padding="8" gap="8" justify_content="center" align_items="center">
|
|
||||||
<label translation="EDIT_MODE.CURVATURE_EXPLANATION" />
|
|
||||||
</div>
|
|
||||||
<div padding="8" gap="8" justify_content="center" align_items="center">
|
<div padding="8" gap="8" justify_content="center" align_items="center">
|
||||||
<label translation="EDIT_MODE.CURVATURE" />
|
<label translation="EDIT_MODE.CURVATURE" />
|
||||||
<Slider id="curve_slider" width="250" height="16" min_value="0" max_value="0.5" value="0.15" step="0.01" />
|
<Slider id="curve_slider" width="250" height="16" min_value="0" max_value="0.5" value="0.15" step="0.01" />
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div id="edit_delete" display="none">
|
<div id="edit_delete" display="none">
|
||||||
<Button macro="button_style" _press="::EditModeDeleteDown" _release="::EditModeDeleteUp" tooltip="LONG_PRESS_TO_DELETE_SET" tooltip_side="top" border_color="~color_danger_translucent" color="~color_danger_5" color2="~color_danger_1" >
|
<Button macro="button_style" _press="::EditModeDeleteDown" _release="::EditModeDeleteUp" tooltip="WATCH.LONG_PRESS_TO_DELETE_SET" tooltip_side="top" border_color="~color_danger_translucent" color="~color_danger_5" color2="~color_danger_1" >
|
||||||
<sprite color="~set_color" width="40" height="40" src="edit/delete.svg" />
|
<sprite color="~set_color" width="40" height="40" src="edit/delete.svg" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
"ADD_NEW_SET": "Add a new set",
|
"ADD_NEW_SET": "Add a new set",
|
||||||
"SWITCH_TO_SET": "Switch to set",
|
"SWITCH_TO_SET": "Switch to set",
|
||||||
"TOGGLE_FOR_CURRENT_SET": "Toggle for current set",
|
"TOGGLE_FOR_CURRENT_SET": "Toggle for current set",
|
||||||
"LONG_PRESS_TO_DELETE_SET": "Long press to delete set"
|
"LONG_PRESS_TO_DELETE_SET": "Hold to delete"
|
||||||
},
|
},
|
||||||
"EDIT_MODE": {
|
"EDIT_MODE": {
|
||||||
"ADJUST_CURVATURE": "Adjust curvature",
|
"ADJUST_CURVATURE": "Adjust curvature",
|
||||||
"ALPHA_BLEND_MODE": "Alpha blend mode",
|
"ALPHA_BLEND_MODE": "Alpha blend mode",
|
||||||
"BLENDING_ADDITIVE": "Additive",
|
"BLENDING_ADDITIVE": "Additive blending",
|
||||||
"CURVATURE": "Curvature",
|
"CURVATURE": "Curvature",
|
||||||
"DELETE": "Long press to remove from current set",
|
"DELETE": "Long press to remove from current set",
|
||||||
"HINT_POINT_WINDOW": "Point at a window to change its parameters.\nOnce done, leave edit mode using the button on the right.",
|
"HINT_POINT_WINDOW": "Point at a window to change its parameters.\nOnce done, leave edit mode using the button on the right.",
|
||||||
|
|||||||
@@ -309,6 +309,7 @@ fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
|
|||||||
panel.state.tabs = ButtonPaneTabSwitcher::new(&mut panel, &["none", "pos", "alpha", "curve"])?;
|
panel.state.tabs = ButtonPaneTabSwitcher::new(&mut panel, &["none", "pos", "alpha", "curve"])?;
|
||||||
|
|
||||||
set_up_checkbox(&mut panel, "additive_box", cb_assign_additive)?;
|
set_up_checkbox(&mut panel, "additive_box", cb_assign_additive)?;
|
||||||
|
set_up_slider(&mut panel, "lerp_slider", cb_assign_lerp)?;
|
||||||
set_up_slider(&mut panel, "alpha_slider", cb_assign_alpha)?;
|
set_up_slider(&mut panel, "alpha_slider", cb_assign_alpha)?;
|
||||||
set_up_slider(&mut panel, "curve_slider", cb_assign_curve)?;
|
set_up_slider(&mut panel, "curve_slider", cb_assign_curve)?;
|
||||||
|
|
||||||
@@ -329,6 +330,11 @@ fn reset_panel(
|
|||||||
state: &panel.layout.state,
|
state: &panel.layout.state,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let c = panel
|
||||||
|
.parser_state
|
||||||
|
.fetch_component_as::<ComponentSlider>("lerp_slider")?;
|
||||||
|
c.set_value(&mut common, state.positioning.get_lerp().unwrap_or(1.0));
|
||||||
|
|
||||||
let c = panel
|
let c = panel
|
||||||
.parser_state
|
.parser_state
|
||||||
.fetch_component_as::<ComponentSlider>("alpha_slider")?;
|
.fetch_component_as::<ComponentSlider>("alpha_slider")?;
|
||||||
@@ -353,6 +359,12 @@ fn reset_panel(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fn cb_assign_lerp(_app: &mut AppState, owc: &mut OverlayWindowConfig, lerp: f32) {
|
||||||
|
owc.dirty = true;
|
||||||
|
let active_state = owc.active_state.as_mut().unwrap();
|
||||||
|
active_state.positioning = active_state.positioning.with_lerp(lerp);
|
||||||
|
}
|
||||||
|
|
||||||
const fn cb_assign_alpha(_app: &mut AppState, owc: &mut OverlayWindowConfig, alpha: f32) {
|
const fn cb_assign_alpha(_app: &mut AppState, owc: &mut OverlayWindowConfig, alpha: f32) {
|
||||||
owc.dirty = true;
|
owc.dirty = true;
|
||||||
owc.active_state.as_mut().unwrap().alpha = alpha;
|
owc.active_state.as_mut().unwrap().alpha = alpha;
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
use std::{collections::HashMap, rc::Rc};
|
use std::{collections::HashMap, rc::Rc};
|
||||||
|
|
||||||
use wgui::{
|
use wgui::{
|
||||||
components::button::ComponentButton, event::CallbackDataCommon, layout::WidgetID,
|
components::button::ComponentButton,
|
||||||
parser::Fetchable, renderer_vk::text::custom_glyph::CustomGlyphData,
|
event::{CallbackDataCommon, StyleSetRequest},
|
||||||
|
layout::WidgetID,
|
||||||
|
parser::Fetchable,
|
||||||
|
renderer_vk::text::custom_glyph::CustomGlyphData,
|
||||||
|
taffy,
|
||||||
widget::sprite::WidgetSprite,
|
widget::sprite::WidgetSprite,
|
||||||
};
|
};
|
||||||
use wlx_common::{common::LeftRight, windowing::Positioning};
|
use wlx_common::{common::LeftRight, windowing::Positioning};
|
||||||
@@ -18,11 +22,13 @@ struct PosButtonState {
|
|||||||
sprite: CustomGlyphData,
|
sprite: CustomGlyphData,
|
||||||
component: Rc<ComponentButton>,
|
component: Rc<ComponentButton>,
|
||||||
positioning: Positioning,
|
positioning: Positioning,
|
||||||
|
has_interpolation: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(super) struct PositioningHandler {
|
pub(super) struct PositioningHandler {
|
||||||
top_sprite_id: WidgetID,
|
top_sprite_id: WidgetID,
|
||||||
|
interpolation_id: WidgetID,
|
||||||
buttons: HashMap<&'static str, Rc<PosButtonState>>,
|
buttons: HashMap<&'static str, Rc<PosButtonState>>,
|
||||||
active_button: Option<Rc<PosButtonState>>,
|
active_button: Option<Rc<PosButtonState>>,
|
||||||
}
|
}
|
||||||
@@ -50,22 +56,27 @@ impl PositioningHandler {
|
|||||||
anyhow::anyhow!("Element with id=\"{sprite_id}\" must have a valid src!")
|
anyhow::anyhow!("Element with id=\"{sprite_id}\" must have a valid src!")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
let (positioning, has_interpolation) = key_to_pos(name);
|
||||||
|
|
||||||
buttons.insert(
|
buttons.insert(
|
||||||
*name,
|
*name,
|
||||||
Rc::new(PosButtonState {
|
Rc::new(PosButtonState {
|
||||||
component,
|
component,
|
||||||
name,
|
name,
|
||||||
sprite,
|
sprite,
|
||||||
positioning: key_to_pos(name),
|
positioning,
|
||||||
|
has_interpolation,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let top_sprite_id = panel.parser_state.get_widget_id("top_pos_sprite")?;
|
let top_sprite_id = panel.parser_state.get_widget_id("top_pos_sprite")?;
|
||||||
|
let interpolation_id = panel.parser_state.get_widget_id("pos_interpolation")?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
buttons,
|
buttons,
|
||||||
active_button: None,
|
active_button: None,
|
||||||
top_sprite_id,
|
top_sprite_id,
|
||||||
|
interpolation_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +88,17 @@ impl PositioningHandler {
|
|||||||
new.component.set_sticky_state(common, true);
|
new.component.set_sticky_state(common, true);
|
||||||
self.active_button = Some(new.clone());
|
self.active_button = Some(new.clone());
|
||||||
|
|
||||||
|
let interpolation_disp = if new.has_interpolation {
|
||||||
|
taffy::Display::Flex
|
||||||
|
} else {
|
||||||
|
taffy::Display::None
|
||||||
|
};
|
||||||
|
|
||||||
|
common.alterables.set_style(
|
||||||
|
self.interpolation_id,
|
||||||
|
StyleSetRequest::Display(interpolation_disp),
|
||||||
|
);
|
||||||
|
|
||||||
// change top sprite
|
// change top sprite
|
||||||
if let Some(mut sprite) = common
|
if let Some(mut sprite) = common
|
||||||
.state
|
.state
|
||||||
@@ -94,7 +116,7 @@ impl PositioningHandler {
|
|||||||
) -> Box<ModifyOverlayTask> {
|
) -> Box<ModifyOverlayTask> {
|
||||||
self.change_highlight(common, key);
|
self.change_highlight(common, key);
|
||||||
|
|
||||||
let pos = key_to_pos(key);
|
let (pos, _) = key_to_pos(key);
|
||||||
Box::new(move |app, owc| {
|
Box::new(move |app, owc| {
|
||||||
let state = owc.active_state.as_mut().unwrap(); //want panic
|
let state = owc.active_state.as_mut().unwrap(); //want panic
|
||||||
state.positioning = pos;
|
state.positioning = pos;
|
||||||
@@ -108,20 +130,26 @@ impl PositioningHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn key_to_pos(key: &str) -> Positioning {
|
fn key_to_pos(key: &str) -> (Positioning, bool) {
|
||||||
match key {
|
match key {
|
||||||
"static" => Positioning::Static,
|
"static" => (Positioning::Static, false),
|
||||||
"anchored" => Positioning::Anchored,
|
"anchored" => (Positioning::Anchored, false),
|
||||||
"floating" => Positioning::Floating,
|
"floating" => (Positioning::Floating, false),
|
||||||
"hmd" => Positioning::FollowHead { lerp: 1.0 },
|
"hmd" => (Positioning::FollowHead { lerp: 1.0 }, true),
|
||||||
"hand_l" => Positioning::FollowHand {
|
"hand_l" => (
|
||||||
hand: LeftRight::Left,
|
Positioning::FollowHand {
|
||||||
lerp: 1.0,
|
hand: LeftRight::Left,
|
||||||
},
|
lerp: 1.0,
|
||||||
"hand_r" => Positioning::FollowHand {
|
},
|
||||||
hand: LeftRight::Right,
|
true,
|
||||||
lerp: 1.0,
|
),
|
||||||
},
|
"hand_r" => (
|
||||||
|
Positioning::FollowHand {
|
||||||
|
hand: LeftRight::Right,
|
||||||
|
lerp: 1.0,
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
),
|
||||||
_ => {
|
_ => {
|
||||||
panic!("cannot translate to positioning: {key}")
|
panic!("cannot translate to positioning: {key}")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user