scissor stack fixes, proper render & event transformations

This commit is contained in:
Aleksander
2025-09-29 22:04:16 +02:00
parent b73870236f
commit a1edc2f0b8
24 changed files with 361 additions and 218 deletions

View File

@@ -10,7 +10,7 @@ use crate::{
globals::Globals,
i18n::{I18n, Translation},
layout::WidgetID,
renderer_vk::text::{TextStyle, FONT_SYSTEM},
renderer_vk::text::{FONT_SYSTEM, TextStyle},
};
use super::{WidgetObj, WidgetState};
@@ -109,7 +109,7 @@ impl WidgetLabel {
impl WidgetObj for WidgetLabel {
fn draw(&mut self, state: &mut super::DrawState, _params: &super::DrawParams) {
let boundary = drawing::Boundary::construct(state.transform_stack);
let boundary = drawing::Boundary::construct_relative(state.transform_stack);
if self.last_boundary != boundary {
self.last_boundary = boundary;

View File

@@ -11,6 +11,7 @@ use crate::{
},
layout::{Layout, LayoutState, WidgetID},
stack::{ScissorStack, TransformStack},
widget,
};
pub mod div;
@@ -248,8 +249,8 @@ impl WidgetState {
PrimitiveExtent {
boundary: drawing::Boundary::from_pos_size(
Vec2::new(
transform.pos.x + transform.dim.x * (1.0 - info.handle_size.x) * self.data.scrolling.x,
transform.pos.y + transform.dim.y - thickness - margin,
transform.abs_pos.x + transform.dim.x * (1.0 - info.handle_size.x) * self.data.scrolling.x,
transform.abs_pos.y + transform.dim.y - thickness - margin,
),
Vec2::new(transform.dim.x * info.handle_size.x, thickness),
),
@@ -265,8 +266,8 @@ impl WidgetState {
PrimitiveExtent {
boundary: drawing::Boundary::from_pos_size(
Vec2::new(
transform.pos.x + transform.dim.x - thickness - margin,
transform.pos.y + transform.dim.y * (1.0 - info.handle_size.y) * self.data.scrolling.y,
transform.abs_pos.x + transform.dim.x - thickness - margin,
transform.abs_pos.y + transform.dim.y * (1.0 - info.handle_size.y) * self.data.scrolling.y,
),
Vec2::new(thickness, transform.dim.y * info.handle_size.y),
),

View File

@@ -36,7 +36,7 @@ impl WidgetRectangle {
impl WidgetObj for WidgetRectangle {
fn draw(&mut self, state: &mut super::DrawState, _params: &super::DrawParams) {
let boundary = drawing::Boundary::construct(state.transform_stack);
let boundary = drawing::Boundary::construct_relative(state.transform_stack);
let round_units = match self.params.round {
WLength::Units(units) => units as u8,

View File

@@ -7,8 +7,8 @@ use crate::{
drawing::{self, PrimitiveExtent},
layout::WidgetID,
renderer_vk::text::{
custom_glyph::{CustomGlyph, CustomGlyphData},
DEFAULT_METRICS, FONT_SYSTEM,
custom_glyph::{CustomGlyph, CustomGlyphData},
},
};
@@ -37,7 +37,7 @@ impl WidgetSprite {
impl WidgetObj for WidgetSprite {
fn draw(&mut self, state: &mut super::DrawState, _params: &super::DrawParams) {
let boundary = drawing::Boundary::construct(state.transform_stack);
let boundary = drawing::Boundary::construct_relative(state.transform_stack);
if let Some(glyph_data) = self.params.glyph_data.as_ref() {
let glyph = CustomGlyph {