mirror of https://github.com/lapce/lapce.git
switch to opengl backend
This commit is contained in:
parent
ec493d49f5
commit
4abb0faf0a
File diff suppressed because it is too large
Load Diff
|
@ -47,7 +47,7 @@ xi-unicode = "0.3.0"
|
|||
fuzzy-matcher = "0.3.7"
|
||||
uuid = { version = "0.8.2", features = ["v4"] }
|
||||
lsp-types = { version = "0.89.2", features = ["proposed"] }
|
||||
druid = { git = "https://github.com/lapce/druid", features = [ "svg", "im", "serde", ] }
|
||||
druid = { git = "https://github.com/lapce/druid", branch = "opengl", features = [ "svg", "im", "serde", ] }
|
||||
#druid = { path = "../../druid/druid", features = ["svg", "im" , "serde"] }
|
||||
toml = { version = "0.5.8", features = ["preserve_order"] }
|
||||
structdesc = { git = "https://github.com/lapce/structdesc" }
|
||||
|
|
|
@ -28,9 +28,7 @@
|
|||
};
|
||||
use xi_unicode::EmojiExt;
|
||||
|
||||
use crate::buffer::data::{
|
||||
BufferData, BufferDataListener, EditableBufferData,
|
||||
};
|
||||
use crate::buffer::data::{BufferData, BufferDataListener, EditableBufferData};
|
||||
use crate::buffer::decoration::BufferDecoration;
|
||||
use crate::config::{Config, LapceTheme};
|
||||
use crate::editor::EditorLocationNew;
|
||||
|
@ -872,11 +870,7 @@ pub fn history_text_layout(
|
|||
}
|
||||
}
|
||||
}
|
||||
Some(layout_builder.build_with_info(
|
||||
true,
|
||||
config.editor.tab_width,
|
||||
Some(bounds),
|
||||
))
|
||||
Some(layout_builder.build().unwrap())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
@ -922,7 +916,7 @@ pub fn new_text_layout(
|
|||
}
|
||||
}
|
||||
}
|
||||
layout_builder.build_with_info(true, config.editor.tab_width, Some(bounds))
|
||||
layout_builder.build().unwrap()
|
||||
}
|
||||
|
||||
pub fn indent_on_line(&self, line: usize) -> String {
|
||||
|
|
|
@ -43,7 +43,7 @@ xi-rope = { git = "https://github.com/lapce/xi-editor", features = ["serde"] }
|
|||
xi-unicode = "0.3.0"
|
||||
fuzzy-matcher = "0.3.7"
|
||||
lsp-types = { version = "0.89.2", features = ["proposed"] }
|
||||
druid = { git = "https://github.com/lapce/druid", features = [ "svg", "im", "serde", ] }
|
||||
druid = { git = "https://github.com/lapce/druid", branch = "opengl", features = [ "svg", "im", "serde", ] }
|
||||
#druid = { path = "../../druid/druid", features = ["svg", "im" , "serde"] }
|
||||
toml = { version = "0.5.8", features = ["preserve_order"] }
|
||||
structdesc = { git = "https://github.com/lapce/structdesc" }
|
||||
|
|
|
@ -561,11 +561,8 @@ fn paint_content(
|
|||
)
|
||||
.clone(),
|
||||
)
|
||||
.build_with_info(
|
||||
true,
|
||||
data.config.editor.tab_width,
|
||||
Some([rect.x0, rect.x1]),
|
||||
);
|
||||
.build()
|
||||
.unwrap();
|
||||
ctx.draw_text(
|
||||
&text_layout,
|
||||
Point::new(0.0, line_height * line as f64 + y_shift),
|
||||
|
@ -721,7 +718,9 @@ fn paint_content(
|
|||
&text_layout,
|
||||
Point::new(
|
||||
0.0,
|
||||
line_height * line as f64 + y_shift + line_padding,
|
||||
line_height * line as f64
|
||||
+ (line_height - text_layout.size().height) / 2.0
|
||||
+ line_padding,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,12 +13,11 @@
|
|||
data::LapceTabData,
|
||||
editor::LapceEditorBufferData,
|
||||
state::LapceWorkspace,
|
||||
|
||||
};
|
||||
|
||||
use crate::{
|
||||
svg::{file_svg_new, get_svg},
|
||||
tab::LapceIcon
|
||||
tab::LapceIcon,
|
||||
};
|
||||
|
||||
pub struct LapceEditorHeader {
|
||||
|
@ -120,7 +119,8 @@ pub fn paint_buffer(
|
|||
workspace: &LapceWorkspace,
|
||||
) {
|
||||
let shadow_width = 5.0;
|
||||
let rect = ctx.size().to_rect();
|
||||
let size = ctx.size();
|
||||
let rect = size.to_rect();
|
||||
ctx.blurred_rect(
|
||||
rect,
|
||||
shadow_width,
|
||||
|
@ -174,7 +174,13 @@ pub fn paint_buffer(
|
|||
)
|
||||
.build()
|
||||
.unwrap();
|
||||
ctx.draw_text(&text_layout, Point::new(30.0, 7.0));
|
||||
ctx.draw_text(
|
||||
&text_layout,
|
||||
Point::new(
|
||||
30.0,
|
||||
(size.height - text_layout.size().height) / 2.0,
|
||||
),
|
||||
);
|
||||
|
||||
if let Some(workspace_path) = workspace.path.as_ref() {
|
||||
path = path
|
||||
|
@ -201,7 +207,13 @@ pub fn paint_buffer(
|
|||
)
|
||||
.build()
|
||||
.unwrap();
|
||||
ctx.draw_text(&text_layout, Point::new(30.0 + x + 5.0, 7.0));
|
||||
ctx.draw_text(
|
||||
&text_layout,
|
||||
Point::new(
|
||||
30.0 + x + 5.0,
|
||||
(size.height - text_layout.size().height) / 2.0,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -220,11 +220,13 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceWindowData, _env: &Env) {
|
|||
if let Some(keymaps) =
|
||||
data.keypress.command_keymaps.get(&item.command.cmd)
|
||||
{
|
||||
let origin = Point::new(
|
||||
rect.x1,
|
||||
self.line_height * i as f64 + self.line_height / 2.0,
|
||||
);
|
||||
keymaps[0].paint(ctx, origin, Alignment::Right, &data.config);
|
||||
if !keymaps.is_empty() {
|
||||
let origin = Point::new(
|
||||
rect.x1,
|
||||
self.line_height * i as f64 + self.line_height / 2.0,
|
||||
);
|
||||
keymaps[0].paint(ctx, origin, Alignment::Right, &data.config);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use druid::FontWeight;
|
||||
use druid::kurbo::Line;
|
||||
use druid::piet::{Svg, TextAttribute, TextLayout};
|
||||
use druid::FontWeight;
|
||||
use druid::{
|
||||
kurbo::Rect,
|
||||
piet::{Text, TextLayoutBuilder},
|
||||
|
@ -26,7 +27,7 @@
|
|||
use crate::{
|
||||
editor::view::LapceEditorView,
|
||||
scroll::{LapceIdentityWrapper, LapceScrollNew},
|
||||
svg::{symbol_svg_new, file_svg_new},
|
||||
svg::{file_svg_new, symbol_svg_new},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
@ -515,7 +516,12 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &PaletteViewData, _env: &Env) {
|
|||
.unwrap()
|
||||
};
|
||||
|
||||
let line = text_layout.cursor_line_for_text_position(cursor);
|
||||
let pos = text_layout.hit_test_text_position(cursor);
|
||||
let line_metric = text_layout.line_metric(0).unwrap();
|
||||
let p0 = (pos.point.x, line_metric.y_offset);
|
||||
let p1 = (pos.point.x, line_metric.y_offset + line_metric.height);
|
||||
let line = Line::new(p0, p1);
|
||||
|
||||
ctx.stroke(
|
||||
line,
|
||||
data.config
|
||||
|
@ -546,95 +552,98 @@ fn paint_palette_item(
|
|||
indices: &[usize],
|
||||
line_height: f64,
|
||||
config: &Config,
|
||||
)
|
||||
{
|
||||
let (svg, text, text_indices, hint, hint_indices) = match palette_item_content {
|
||||
PaletteItemContent::File(path, _) => Self::file_paint_items(path, indices),
|
||||
#[allow(unused_variables)]
|
||||
PaletteItemContent::DocumentSymbol {
|
||||
kind,
|
||||
name,
|
||||
range,
|
||||
container_name,
|
||||
} => {
|
||||
let text = name.to_string();
|
||||
let hint = container_name.clone().unwrap_or_else(|| "".to_string());
|
||||
let text_indices = indices
|
||||
.iter()
|
||||
.filter_map(|i| {
|
||||
let i = *i;
|
||||
if i < text.len() {
|
||||
Some(i)
|
||||
} else {
|
||||
None
|
||||
) {
|
||||
let (svg, text, text_indices, hint, hint_indices) =
|
||||
match palette_item_content {
|
||||
PaletteItemContent::File(path, _) => {
|
||||
Self::file_paint_items(path, indices)
|
||||
}
|
||||
#[allow(unused_variables)]
|
||||
PaletteItemContent::DocumentSymbol {
|
||||
kind,
|
||||
name,
|
||||
range,
|
||||
container_name,
|
||||
} => {
|
||||
let text = name.to_string();
|
||||
let hint =
|
||||
container_name.clone().unwrap_or_else(|| "".to_string());
|
||||
let text_indices = indices
|
||||
.iter()
|
||||
.filter_map(|i| {
|
||||
let i = *i;
|
||||
if i < text.len() {
|
||||
Some(i)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let hint_indices = indices
|
||||
.iter()
|
||||
.filter_map(|i| {
|
||||
let i = *i;
|
||||
if i >= text.len() {
|
||||
Some(i - text.len())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
(symbol_svg_new(kind), text, text_indices, hint, hint_indices)
|
||||
}
|
||||
PaletteItemContent::Line(_, text) => {
|
||||
(None, text.clone(), indices.to_vec(), "".to_string(), vec![])
|
||||
}
|
||||
PaletteItemContent::ReferenceLocation(rel_path, _location) => {
|
||||
Self::file_paint_items(rel_path, indices)
|
||||
}
|
||||
PaletteItemContent::Workspace(w) => {
|
||||
let text = w.path.as_ref().unwrap().to_str().unwrap();
|
||||
let text = match &w.kind {
|
||||
LapceWorkspaceType::Local => text.to_string(),
|
||||
LapceWorkspaceType::RemoteSSH(user, host) => {
|
||||
format!("[{user}@{host}] {text}")
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let hint_indices = indices
|
||||
.iter()
|
||||
.filter_map(|i| {
|
||||
let i = *i;
|
||||
if i >= text.len() {
|
||||
Some(i - text.len())
|
||||
} else {
|
||||
None
|
||||
LapceWorkspaceType::RemoteWSL => {
|
||||
format!("[wsl] {text}")
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
(symbol_svg_new(kind), text, text_indices, hint, hint_indices)
|
||||
}
|
||||
PaletteItemContent::Line(_, text) => {
|
||||
(None, text.clone(), indices.to_vec(), "".to_string(), vec![])
|
||||
}
|
||||
PaletteItemContent::ReferenceLocation(rel_path, _location) => {
|
||||
Self::file_paint_items(rel_path, indices)
|
||||
}
|
||||
PaletteItemContent::Workspace(w) => {
|
||||
let text = w.path.as_ref().unwrap().to_str().unwrap();
|
||||
let text = match &w.kind {
|
||||
LapceWorkspaceType::Local => text.to_string(),
|
||||
LapceWorkspaceType::RemoteSSH(user, host) => {
|
||||
format!("[{user}@{host}] {text}")
|
||||
}
|
||||
LapceWorkspaceType::RemoteWSL => {
|
||||
format!("[wsl] {text}")
|
||||
}
|
||||
};
|
||||
(None, text, indices.to_vec(), "".to_string(), vec![])
|
||||
}
|
||||
PaletteItemContent::Command(command) => (
|
||||
None,
|
||||
command
|
||||
.palette_desc
|
||||
.as_ref()
|
||||
.map(|m| m.to_string())
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
indices.to_vec(),
|
||||
"".to_string(),
|
||||
vec![],
|
||||
),
|
||||
PaletteItemContent::Theme(theme) => (
|
||||
None,
|
||||
theme.to_string(),
|
||||
indices.to_vec(),
|
||||
"".to_string(),
|
||||
vec![],
|
||||
),
|
||||
PaletteItemContent::TerminalLine(_line, content) => (
|
||||
None,
|
||||
content.clone(),
|
||||
indices.to_vec(),
|
||||
"".to_string(),
|
||||
vec![],
|
||||
),
|
||||
PaletteItemContent::SshHost(user, host) => (
|
||||
None,
|
||||
format!("{user}@{host}"),
|
||||
indices.to_vec(),
|
||||
"".to_string(),
|
||||
vec![],
|
||||
),
|
||||
};
|
||||
};
|
||||
(None, text, indices.to_vec(), "".to_string(), vec![])
|
||||
}
|
||||
PaletteItemContent::Command(command) => (
|
||||
None,
|
||||
command
|
||||
.palette_desc
|
||||
.as_ref()
|
||||
.map(|m| m.to_string())
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
indices.to_vec(),
|
||||
"".to_string(),
|
||||
vec![],
|
||||
),
|
||||
PaletteItemContent::Theme(theme) => (
|
||||
None,
|
||||
theme.to_string(),
|
||||
indices.to_vec(),
|
||||
"".to_string(),
|
||||
vec![],
|
||||
),
|
||||
PaletteItemContent::TerminalLine(_line, content) => (
|
||||
None,
|
||||
content.clone(),
|
||||
indices.to_vec(),
|
||||
"".to_string(),
|
||||
vec![],
|
||||
),
|
||||
PaletteItemContent::SshHost(user, host) => (
|
||||
None,
|
||||
format!("{user}@{host}"),
|
||||
indices.to_vec(),
|
||||
"".to_string(),
|
||||
vec![],
|
||||
),
|
||||
};
|
||||
|
||||
if let Some(svg) = svg.as_ref() {
|
||||
let width = 14.0;
|
||||
|
@ -655,16 +664,20 @@ fn paint_palette_item(
|
|||
|
||||
let focus_color = config.get_color_unchecked(LapceTheme::EDITOR_FOCUS);
|
||||
|
||||
let full_text = if hint.is_empty() {
|
||||
text.clone()
|
||||
} else {
|
||||
text.clone() + " " + &hint
|
||||
};
|
||||
let mut text_layout = ctx
|
||||
.text()
|
||||
.new_text_layout(text)
|
||||
.new_text_layout(full_text.clone())
|
||||
.font(FontFamily::SYSTEM_UI, 14.0)
|
||||
.text_color(
|
||||
config
|
||||
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||
.clone(),
|
||||
);
|
||||
|
||||
for i in &text_indices {
|
||||
let i = *i;
|
||||
text_layout = text_layout.range_attribute(
|
||||
|
@ -674,23 +687,21 @@ fn paint_palette_item(
|
|||
text_layout = text_layout
|
||||
.range_attribute(i..i + 1, TextAttribute::Weight(FontWeight::BOLD));
|
||||
}
|
||||
let text_layout = text_layout.build().unwrap();
|
||||
let x = svg_x + 5.0;
|
||||
let y = line_height * line as f64 + 4.0;
|
||||
let point = Point::new(x, y);
|
||||
ctx.draw_text(&text_layout, point);
|
||||
|
||||
if !hint.is_empty() {
|
||||
let text_x = text_layout.size().width;
|
||||
let mut text_layout = ctx
|
||||
.text()
|
||||
.new_text_layout(hint)
|
||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||
.text_color(
|
||||
config.get_color_unchecked(LapceTheme::EDITOR_DIM).clone(),
|
||||
text_layout = text_layout
|
||||
.range_attribute(
|
||||
text.len() + 1..full_text.len(),
|
||||
TextAttribute::FontSize(13.0),
|
||||
)
|
||||
.range_attribute(
|
||||
text.len() + 1..full_text.len(),
|
||||
TextAttribute::TextColor(
|
||||
config.get_color_unchecked(LapceTheme::EDITOR_DIM).clone(),
|
||||
),
|
||||
);
|
||||
for i in &hint_indices {
|
||||
let i = *i;
|
||||
let i = *i + text.len() + 1;
|
||||
text_layout = text_layout.range_attribute(
|
||||
i..i + 1,
|
||||
TextAttribute::TextColor(focus_color.clone()),
|
||||
|
@ -700,19 +711,20 @@ fn paint_palette_item(
|
|||
TextAttribute::Weight(FontWeight::BOLD),
|
||||
);
|
||||
}
|
||||
let text_layout = text_layout.build().unwrap();
|
||||
ctx.draw_text(
|
||||
&text_layout,
|
||||
Point::new(x + text_x + 4.0, line as f64 * line_height + 5.0),
|
||||
);
|
||||
}
|
||||
|
||||
let text_layout = text_layout.build().unwrap();
|
||||
let x = svg_x + 5.0;
|
||||
let y = line_height * line as f64
|
||||
+ (line_height - text_layout.size().height) / 2.0;
|
||||
let point = Point::new(x, y);
|
||||
ctx.draw_text(&text_layout, point);
|
||||
}
|
||||
|
||||
fn file_paint_items(
|
||||
path: &Path,
|
||||
indices: &[usize],
|
||||
) -> (Option<Svg>, String, Vec<usize>, String, Vec<usize>)
|
||||
{
|
||||
) -> (Option<Svg>, String, Vec<usize>, String, Vec<usize>) {
|
||||
let svg = file_svg_new(path);
|
||||
let file_name = path
|
||||
.file_name()
|
||||
|
@ -844,7 +856,7 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &PaletteViewData, _env: &Env) {
|
|||
}
|
||||
|
||||
let item = &items[line];
|
||||
|
||||
|
||||
Self::paint_palette_item(
|
||||
&item.content,
|
||||
ctx,
|
||||
|
@ -857,8 +869,6 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &PaletteViewData, _env: &Env) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub struct PalettePreview {}
|
||||
|
||||
impl PalettePreview {
|
||||
|
|
|
@ -388,12 +388,15 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
|||
);
|
||||
}
|
||||
|
||||
ctx.blurred_rect(
|
||||
self.header_rect,
|
||||
shadow_width,
|
||||
data.config
|
||||
.get_color_unchecked(LapceTheme::LAPCE_DROPDOWN_SHADOW),
|
||||
);
|
||||
ctx.with_save(|ctx| {
|
||||
ctx.clip(self.header_rect.inflate(0.0, 50.0) + Vec2::new(0.0, 50.0));
|
||||
ctx.blurred_rect(
|
||||
self.header_rect,
|
||||
shadow_width,
|
||||
data.config
|
||||
.get_color_unchecked(LapceTheme::LAPCE_DROPDOWN_SHADOW),
|
||||
);
|
||||
});
|
||||
let text_layout = ctx
|
||||
.text()
|
||||
.new_text_layout("Settings")
|
||||
|
@ -1024,10 +1027,6 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
|||
|
||||
let text = ctx.text();
|
||||
let text = self.name(text, data);
|
||||
text.set_color(
|
||||
data.config
|
||||
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND),
|
||||
);
|
||||
y += padding;
|
||||
ctx.draw_text(text, Point::new(0.0, y));
|
||||
y += text.size().height + padding;
|
||||
|
@ -1063,10 +1062,6 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
|||
};
|
||||
let text = ctx.text();
|
||||
let text = self.desc(text, data);
|
||||
text.set_color(
|
||||
data.config
|
||||
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND),
|
||||
);
|
||||
ctx.draw_text(text, Point::new(x, y));
|
||||
|
||||
if let Some(input) = self.input_widget.as_mut() {
|
||||
|
|
|
@ -13,10 +13,7 @@
|
|||
state::Mode,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
svg::get_svg,
|
||||
tab::LapceIcon,
|
||||
};
|
||||
use crate::{svg::get_svg, tab::LapceIcon};
|
||||
|
||||
pub struct LapceStatusNew {
|
||||
height: f64,
|
||||
|
@ -222,31 +219,27 @@ fn paint(
|
|||
|
||||
if data.config.lapce.modal {
|
||||
let (mode, color) = {
|
||||
let mode =
|
||||
if data.focus_area == FocusArea::Panel(PanelKind::Terminal) {
|
||||
match data.terminal.terminals.get(&data.terminal.active_term_id) {
|
||||
Some(terminal) => terminal.mode,
|
||||
None => Mode::Normal
|
||||
}
|
||||
} else {
|
||||
data.main_split
|
||||
.active_editor()
|
||||
.map(|e| e.cursor.get_mode())
|
||||
.unwrap_or(Mode::Normal)
|
||||
};
|
||||
let mode = if data.focus_area
|
||||
== FocusArea::Panel(PanelKind::Terminal)
|
||||
{
|
||||
match data.terminal.terminals.get(&data.terminal.active_term_id)
|
||||
{
|
||||
Some(terminal) => terminal.mode,
|
||||
None => Mode::Normal,
|
||||
}
|
||||
} else {
|
||||
data.main_split
|
||||
.active_editor()
|
||||
.map(|e| e.cursor.get_mode())
|
||||
.unwrap_or(Mode::Normal)
|
||||
};
|
||||
match mode {
|
||||
Mode::Normal => (
|
||||
"Normal", LapceTheme::STATUS_MODAL_NORMAL,
|
||||
),
|
||||
Mode::Insert => (
|
||||
"Insert", LapceTheme::STATUS_MODAL_INSERT,
|
||||
),
|
||||
Mode::Visual => (
|
||||
"Visual", LapceTheme::STATUS_MODAL_VISUAL,
|
||||
),
|
||||
Mode::Terminal => (
|
||||
"Terminal", LapceTheme::STATUS_MODAL_TERMINAL,
|
||||
),
|
||||
Mode::Normal => ("Normal", LapceTheme::STATUS_MODAL_NORMAL),
|
||||
Mode::Insert => ("Insert", LapceTheme::STATUS_MODAL_INSERT),
|
||||
Mode::Visual => ("Visual", LapceTheme::STATUS_MODAL_VISUAL),
|
||||
Mode::Terminal => {
|
||||
("Terminal", LapceTheme::STATUS_MODAL_TERMINAL)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -263,11 +256,11 @@ fn paint(
|
|||
.unwrap();
|
||||
let text_size = text_layout.size();
|
||||
let fill_size = Size::new(text_size.width + 10.0, size.height);
|
||||
ctx.fill(
|
||||
fill_size.to_rect(),
|
||||
data.config.get_color_unchecked(color)
|
||||
ctx.fill(fill_size.to_rect(), data.config.get_color_unchecked(color));
|
||||
ctx.draw_text(
|
||||
&text_layout,
|
||||
Point::new(5.0, (size.height - text_layout.size().height) / 2.0),
|
||||
);
|
||||
ctx.draw_text(&text_layout, Point::new(5.0, 4.0));
|
||||
left += text_size.width + 10.0;
|
||||
}
|
||||
|
||||
|
@ -285,7 +278,10 @@ fn paint(
|
|||
)
|
||||
.build()
|
||||
.unwrap();
|
||||
ctx.draw_text(&text_layout, Point::new(left + 10.0, 4.0));
|
||||
ctx.draw_text(
|
||||
&text_layout,
|
||||
Point::new(left + 10.0, (size.height - text_layout.size().height) / 2.0),
|
||||
);
|
||||
left += 10.0 + text_layout.size().width;
|
||||
|
||||
for progress in data.progresses.iter() {
|
||||
|
@ -306,7 +302,13 @@ fn paint(
|
|||
)
|
||||
.build()
|
||||
.unwrap();
|
||||
ctx.draw_text(&text_layout, Point::new(left + 10.0, 4.0));
|
||||
ctx.draw_text(
|
||||
&text_layout,
|
||||
Point::new(
|
||||
left + 10.0,
|
||||
(size.height - text_layout.size().height) / 2.0,
|
||||
),
|
||||
);
|
||||
left += 10.0 + text_layout.size().width;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue