Update Vizia
Text sizes are still broken.
This commit is contained in:
parent
084d34fe5c
commit
9ab07cf4eb
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -3498,7 +3498,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vizia"
|
name = "vizia"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#656a7ee5bc720c6eea23b46c8480ecc9ee826da9"
|
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#163ae29c603c51371a8a98cca3f4434f7bf38d37"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"vizia_baseview",
|
"vizia_baseview",
|
||||||
"vizia_core",
|
"vizia_core",
|
||||||
|
@ -3507,7 +3507,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vizia_baseview"
|
name = "vizia_baseview"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#656a7ee5bc720c6eea23b46c8480ecc9ee826da9"
|
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#163ae29c603c51371a8a98cca3f4434f7bf38d37"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"baseview 0.1.0 (git+https://github.com/robbert-vdh/baseview.git?branch=feature/resize)",
|
"baseview 0.1.0 (git+https://github.com/robbert-vdh/baseview.git?branch=feature/resize)",
|
||||||
"femtovg",
|
"femtovg",
|
||||||
|
@ -3519,7 +3519,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vizia_core"
|
name = "vizia_core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#656a7ee5bc720c6eea23b46c8480ecc9ee826da9"
|
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#163ae29c603c51371a8a98cca3f4434f7bf38d37"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"copypasta",
|
"copypasta",
|
||||||
|
@ -3544,7 +3544,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vizia_derive"
|
name = "vizia_derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#656a7ee5bc720c6eea23b46c8480ecc9ee826da9"
|
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#163ae29c603c51371a8a98cca3f4434f7bf38d37"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
|
@ -77,42 +77,39 @@ pub(crate) struct WindowModel {
|
||||||
|
|
||||||
impl Model for ParamModel {
|
impl Model for ParamModel {
|
||||||
fn event(&mut self, _cx: &mut vizia::Context, event: &mut vizia::Event) {
|
fn event(&mut self, _cx: &mut vizia::Context, event: &mut vizia::Event) {
|
||||||
if let Some(param_event) = event.message.downcast() {
|
|
||||||
// `ParamEvent` gets downcast into `NormalizedParamEvent` by the `Message`
|
// `ParamEvent` gets downcast into `NormalizedParamEvent` by the `Message`
|
||||||
// implementation below
|
// implementation below
|
||||||
match *param_event {
|
event.map(|param_event, _| match *param_event {
|
||||||
RawParamEvent::BeginSetParameter(p) => unsafe {
|
RawParamEvent::BeginSetParameter(p) => unsafe {
|
||||||
self.context.raw_begin_set_parameter(p)
|
self.context.raw_begin_set_parameter(p)
|
||||||
},
|
},
|
||||||
RawParamEvent::SetParameterNormalized(p, v) => unsafe {
|
RawParamEvent::SetParameterNormalized(p, v) => unsafe {
|
||||||
self.context.raw_set_parameter_normalized(p, v)
|
self.context.raw_set_parameter_normalized(p, v)
|
||||||
},
|
},
|
||||||
RawParamEvent::EndSetParameter(p) => unsafe {
|
RawParamEvent::EndSetParameter(p) => unsafe { self.context.raw_end_set_parameter(p) },
|
||||||
self.context.raw_end_set_parameter(p)
|
});
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Model for WindowModel {
|
impl Model for WindowModel {
|
||||||
fn event(&mut self, cx: &mut vizia::Context, event: &mut vizia::Event) {
|
fn event(&mut self, cx: &mut vizia::Context, event: &mut vizia::Event) {
|
||||||
// This gets fired whenever the inner window gets resized
|
// This gets fired whenever the inner window gets resized
|
||||||
if let Some(WindowEvent::WindowResize) = event.message.downcast() {
|
event.map(|window_event, _| {
|
||||||
|
if let WindowEvent::WindowResize = window_event {
|
||||||
let logical_size = (cx.window_size.width, cx.window_size.height);
|
let logical_size = (cx.window_size.width, cx.window_size.height);
|
||||||
let old_logical_size @ (old_logical_width, old_logical_height) =
|
let old_logical_size @ (old_logical_width, old_logical_height) =
|
||||||
self.vizia_state.size.load();
|
self.vizia_state.size.load();
|
||||||
let scale_factor = cx.user_scale_factor;
|
let scale_factor = cx.user_scale_factor;
|
||||||
let old_user_scale_factor = self.vizia_state.scale_factor.load();
|
let old_user_scale_factor = self.vizia_state.scale_factor.load();
|
||||||
|
|
||||||
// Don't do anything if the current size already matches the new size, this
|
// Don't do anything if the current size already matches the new size, this could
|
||||||
// could otherwise also cause a feedback loop on resize failure
|
// otherwise also cause a feedback loop on resize failure
|
||||||
if logical_size == old_logical_size && scale_factor == old_user_scale_factor {
|
if logical_size == old_logical_size && scale_factor == old_user_scale_factor {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Our embedded baseview window will have already been resized. If the host does
|
// Our embedded baseview window will have already been resized. If the host does not
|
||||||
// not accept our new size, then we'll try to undo that
|
// accept our new size, then we'll try to undo that
|
||||||
self.vizia_state.size.store(logical_size);
|
self.vizia_state.size.store(logical_size);
|
||||||
self.vizia_state.scale_factor.store(scale_factor);
|
self.vizia_state.scale_factor.store(scale_factor);
|
||||||
if !self.context.request_resize() {
|
if !self.context.request_resize() {
|
||||||
|
@ -125,6 +122,7 @@ impl Model for WindowModel {
|
||||||
cx.user_scale_factor = old_user_scale_factor;
|
cx.user_scale_factor = old_user_scale_factor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,16 +78,16 @@ enum ParamSliderInternalEvent {
|
||||||
|
|
||||||
impl Model for ParamSliderInternal {
|
impl Model for ParamSliderInternal {
|
||||||
fn event(&mut self, _cx: &mut Context, event: &mut Event) {
|
fn event(&mut self, _cx: &mut Context, event: &mut Event) {
|
||||||
if let Some(param_slider_internal_event) = event.message.downcast() {
|
event.map(
|
||||||
match param_slider_internal_event {
|
|param_slider_internal_event, _| match param_slider_internal_event {
|
||||||
ParamSliderInternalEvent::SetStyle(style) => self.style = *style,
|
ParamSliderInternalEvent::SetStyle(style) => self.style = *style,
|
||||||
ParamSliderInternalEvent::SetTextInputActive(active) => {
|
ParamSliderInternalEvent::SetTextInputActive(active) => {
|
||||||
// When this gets set to `true` the textbox widget will be created, and when it
|
// When this gets set to `true` the textbox widget will be created, and when it
|
||||||
// gets created we'll focus it and select all text
|
// gets created we'll focus it and select all text
|
||||||
self.text_input_active = *active;
|
self.text_input_active = *active;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,8 +350,7 @@ impl View for ParamSlider {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn event(&mut self, cx: &mut Context, event: &mut Event) {
|
fn event(&mut self, cx: &mut Context, event: &mut Event) {
|
||||||
if let Some(param_slider_event) = event.message.downcast() {
|
event.map(|param_slider_event, _| match param_slider_event {
|
||||||
match param_slider_event {
|
|
||||||
ParamSliderEvent::CancelTextInput => {
|
ParamSliderEvent::CancelTextInput => {
|
||||||
cx.emit(ParamSliderInternalEvent::SetTextInputActive(false));
|
cx.emit(ParamSliderInternalEvent::SetTextInputActive(false));
|
||||||
cx.current.set_active(cx, false);
|
cx.current.set_active(cx, false);
|
||||||
|
@ -367,11 +366,9 @@ impl View for ParamSlider {
|
||||||
|
|
||||||
cx.emit(ParamSliderInternalEvent::SetTextInputActive(false));
|
cx.emit(ParamSliderInternalEvent::SetTextInputActive(false));
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(window_event) = event.message.downcast() {
|
event.map(|window_event, _| match window_event {
|
||||||
match window_event {
|
|
||||||
WindowEvent::MouseDown(MouseButton::Left) => {
|
WindowEvent::MouseDown(MouseButton::Left) => {
|
||||||
if cx.modifiers.alt() {
|
if cx.modifiers.alt() {
|
||||||
// ALt+Click brings up a text entry dialog
|
// ALt+Click brings up a text entry dialog
|
||||||
|
@ -393,8 +390,8 @@ impl View for ParamSlider {
|
||||||
cx.focused = cx.current;
|
cx.focused = cx.current;
|
||||||
cx.current.set_active(cx, true);
|
cx.current.set_active(cx, true);
|
||||||
|
|
||||||
// When holding down shift while clicking on a parameter we want to
|
// When holding down shift while clicking on a parameter we want to granuarly
|
||||||
// granuarly edit the parameter without jumping to a new value
|
// edit the parameter without jumping to a new value
|
||||||
cx.emit(RawParamEvent::BeginSetParameter(self.param_ptr));
|
cx.emit(RawParamEvent::BeginSetParameter(self.param_ptr));
|
||||||
if cx.modifiers.shift() {
|
if cx.modifiers.shift() {
|
||||||
self.granular_drag_start_x_value = Some((cx.mouse.cursorx, unsafe {
|
self.granular_drag_start_x_value = Some((cx.mouse.cursorx, unsafe {
|
||||||
|
@ -409,13 +406,12 @@ impl View for ParamSlider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll set this here because weird things like Alt+double click should not
|
// We'll set this here because weird things like Alt+double click should not cause
|
||||||
// cause the next click to become a reset
|
// the next click to become a reset
|
||||||
self.is_double_click = false;
|
self.is_double_click = false;
|
||||||
}
|
}
|
||||||
WindowEvent::MouseDoubleClick(MouseButton::Left) => {
|
WindowEvent::MouseDoubleClick(MouseButton::Left) => {
|
||||||
// Vizia will send a regular mouse down after this, so we'll handle the reset
|
// Vizia will send a regular mouse down after this, so we'll handle the reset there
|
||||||
// there
|
|
||||||
self.is_double_click = true;
|
self.is_double_click = true;
|
||||||
}
|
}
|
||||||
WindowEvent::MouseUp(MouseButton::Left) => {
|
WindowEvent::MouseUp(MouseButton::Left) => {
|
||||||
|
@ -470,8 +466,7 @@ impl View for ParamSlider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ impl View for ResizeHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn event(&mut self, cx: &mut Context, event: &mut Event) {
|
fn event(&mut self, cx: &mut Context, event: &mut Event) {
|
||||||
if let Some(window_event) = event.message.downcast() {
|
event.map(|window_event, meta| match *window_event {
|
||||||
match *window_event {
|
|
||||||
WindowEvent::MouseDown(MouseButton::Left) => {
|
WindowEvent::MouseDown(MouseButton::Left) => {
|
||||||
// The handle is a triangle, so we should also interac twith it as if it was a
|
// The handle is a triangle, so we should also interac twith it as if it was a
|
||||||
// triangle
|
// triangle
|
||||||
|
@ -54,7 +53,7 @@ impl View for ResizeHandle {
|
||||||
cx.mouse.cursory * cx.style.dpi_factor as f32,
|
cx.mouse.cursory * cx.style.dpi_factor as f32,
|
||||||
);
|
);
|
||||||
|
|
||||||
event.consume();
|
meta.consume();
|
||||||
} else {
|
} else {
|
||||||
// TODO: The click should be forwarded to the element behind the triangle
|
// TODO: The click should be forwarded to the element behind the triangle
|
||||||
}
|
}
|
||||||
|
@ -76,10 +75,10 @@ impl View for ResizeHandle {
|
||||||
if self.drag_active {
|
if self.drag_active {
|
||||||
// We need to convert our measurements into physical pixels relative to the
|
// We need to convert our measurements into physical pixels relative to the
|
||||||
// initial drag to be able to keep a consistent ratio. This 'relative to the
|
// initial drag to be able to keep a consistent ratio. This 'relative to the
|
||||||
// start' bit is important because otherwise we would be comparing the
|
// start' bit is important because otherwise we would be comparing the position
|
||||||
// position to the same absoltue screen spotion.
|
// to the same absoltue screen spotion.
|
||||||
// TODO: This may start doing fun things when the window grows so large that
|
// TODO: This may start doing fun things when the window grows so large that it
|
||||||
// it gets pushed upwards or leftwards
|
// gets pushed upwards or leftwards
|
||||||
let (compensated_physical_x, compensated_physical_y) = (
|
let (compensated_physical_x, compensated_physical_y) = (
|
||||||
x * self.start_scale_factor as f32,
|
x * self.start_scale_factor as f32,
|
||||||
y * self.start_scale_factor as f32,
|
y * self.start_scale_factor as f32,
|
||||||
|
@ -92,13 +91,13 @@ impl View for ResizeHandle {
|
||||||
// Prevent approaching zero here because uh
|
// Prevent approaching zero here because uh
|
||||||
.max(0.25);
|
.max(0.25);
|
||||||
|
|
||||||
// If this is different then the window will automatically be resized at the end of the frame
|
// If this is different then the window will automatically be resized at the end
|
||||||
|
// of the frame
|
||||||
cx.user_scale_factor = new_scale_factor;
|
cx.user_scale_factor = new_scale_factor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw(&self, cx: &mut DrawContext, canvas: &mut Canvas) {
|
fn draw(&self, cx: &mut DrawContext, canvas: &mut Canvas) {
|
||||||
|
|
Loading…
Reference in a new issue