Compare commits
1 Commits
ee0616885f
...
d6a9711ceb
| Author | SHA1 | Date | |
|---|---|---|---|
| d6a9711ceb |
@@ -80,10 +80,24 @@ impl TextView {
|
|||||||
self.tex.as_ref()
|
self.tex.as_ref()
|
||||||
}
|
}
|
||||||
pub fn desired_width(&mut self, ctx: &mut SizeCtx) -> Len {
|
pub fn desired_width(&mut self, ctx: &mut SizeCtx) -> Len {
|
||||||
Len::abs(self.render(ctx).size.x)
|
if let Some(hint) = &self.hint
|
||||||
|
&& let [line] = &self.buf.lines[..]
|
||||||
|
&& line.text().is_empty()
|
||||||
|
{
|
||||||
|
ctx.width(hint)
|
||||||
|
} else {
|
||||||
|
Len::abs(self.render(ctx).size.x)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn desired_height(&mut self, ctx: &mut SizeCtx) -> Len {
|
pub fn desired_height(&mut self, ctx: &mut SizeCtx) -> Len {
|
||||||
Len::abs(self.render(ctx).size.y)
|
if let Some(hint) = &self.hint
|
||||||
|
&& let [line] = &self.buf.lines[..]
|
||||||
|
&& line.text().is_empty()
|
||||||
|
{
|
||||||
|
ctx.height(hint)
|
||||||
|
} else {
|
||||||
|
Len::abs(self.render(ctx).size.y)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn draw(&mut self, painter: &mut Painter) -> UiRegion {
|
pub fn draw(&mut self, painter: &mut Painter) -> UiRegion {
|
||||||
let tex = self.render(&mut painter.size_ctx());
|
let tex = self.render(&mut painter.size_ctx());
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
layout::{
|
layout::{
|
||||||
Axis, PrimitiveLayers, Len, Modules, Size, TextAttrs, TextBuffer, TextData, RenderedText,
|
Axis, Len, Modules, PrimitiveLayers, RenderedText, Size, TextAttrs, TextBuffer, TextData,
|
||||||
TextureHandle, Textures, UiRegion, UiVec2, Vec2, WidgetId, Widgets,
|
TextureHandle, Textures, UiRegion, UiVec2, Vec2, WidgetId, Widgets,
|
||||||
},
|
},
|
||||||
render::{Mask, MaskIdx, Primitive, PrimitiveHandle, PrimitiveInst},
|
render::{Mask, MaskIdx, Primitive, PrimitiveHandle, PrimitiveInst},
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ impl MaskIdx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
|
#[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
|
||||||
pub struct Mask {
|
pub struct Mask {
|
||||||
pub region: UiRegion,
|
pub region: UiRegion,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,15 +96,19 @@ impl UiRenderer {
|
|||||||
device,
|
device,
|
||||||
&self.primitive_layout,
|
&self.primitive_layout,
|
||||||
rlayer.primitives.buffers(),
|
rlayer.primitives.buffers(),
|
||||||
)
|
);
|
||||||
|
primitives.updated = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.textures.update(&mut ui.data.textures) {
|
let mut changed = false;
|
||||||
self.rsc_group = Self::rsc_group(device, &self.rsc_layout, &self.textures, &self.masks)
|
changed |= self.textures.update(&mut ui.data.textures);
|
||||||
}
|
|
||||||
if ui.data.masks.changed {
|
if ui.data.masks.changed {
|
||||||
ui.data.masks.changed = false;
|
ui.data.masks.changed = false;
|
||||||
self.masks.update(device, queue, &ui.data.masks[..]);
|
self.masks.update(device, queue, &ui.data.masks[..]);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if changed {
|
||||||
|
self.rsc_group = Self::rsc_group(device, &self.rsc_layout, &self.textures, &self.masks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ macro_rules! primitives {
|
|||||||
($($name:ident: $ty:ty => $binding:expr,)*) => {
|
($($name:ident: $ty:ty => $binding:expr,)*) => {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct PrimitiveData {
|
pub struct PrimitiveData {
|
||||||
$($name: PrimitiveVec<$ty>,)*
|
$(pub(crate) $name: PrimitiveVec<$ty>,)*
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PrimitiveBuffers {
|
pub struct PrimitiveBuffers {
|
||||||
@@ -116,6 +116,7 @@ impl Primitives {
|
|||||||
mask_idx,
|
mask_idx,
|
||||||
}: PrimitiveInst<P>,
|
}: PrimitiveInst<P>,
|
||||||
) -> PrimitiveHandle {
|
) -> PrimitiveHandle {
|
||||||
|
self.updated = true;
|
||||||
let vec = P::vec(&mut self.data);
|
let vec = P::vec(&mut self.data);
|
||||||
let i = vec.add(primitive);
|
let i = vec.add(primitive);
|
||||||
let inst = PrimitiveInstance {
|
let inst = PrimitiveInstance {
|
||||||
@@ -153,6 +154,7 @@ impl Primitives {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn free(&mut self, h: &PrimitiveHandle) -> MaskIdx {
|
pub fn free(&mut self, h: &PrimitiveHandle) -> MaskIdx {
|
||||||
|
self.updated = true;
|
||||||
self.data.free(h.binding, h.data_idx);
|
self.data.free(h.binding, h.data_idx);
|
||||||
self.free.push(h.inst_idx);
|
self.free.push(h.inst_idx);
|
||||||
self.instances[h.inst_idx].mask_idx
|
self.instances[h.inst_idx].mask_idx
|
||||||
|
|||||||
Reference in New Issue
Block a user