This commit is contained in:
parent
181741fe68
commit
a92c3fdf0c
3 changed files with 32 additions and 50 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -792,6 +792,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-jotdown"
|
name = "cosmic-jotdown"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
source = "git+https://git.nations.lol/fnmain/cosmic-jotdown#1207336fd313c970233ab332cf04683fbd7df693"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmic-text",
|
"cosmic-text",
|
||||||
"jotdown",
|
"jotdown",
|
||||||
|
@ -1031,6 +1032,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "egui-glyphon"
|
name = "egui-glyphon"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
source = "git+https://git.nations.lol/fnmain/egui-glyphon#3626c7e55d45734eff9b1b7df04349d97de77667"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"egui",
|
"egui",
|
||||||
"egui-wgpu",
|
"egui-wgpu",
|
||||||
|
@ -1628,6 +1630,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glyphon"
|
name = "glyphon"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
source = "git+https://git.nations.lol/fnmain/glyphon.git#01ab64704b123d1ae61a5022b2b8ea2a7a4573e8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmic-text",
|
"cosmic-text",
|
||||||
"etagere",
|
"etagere",
|
||||||
|
@ -1869,6 +1872,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jotdown"
|
name = "jotdown"
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
|
source = "git+https://git.nations.lol/fnmain/jotdown#8239b2b51d2ad3517bb0e71440e7bcd5114e08d2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"databake",
|
"databake",
|
||||||
]
|
]
|
||||||
|
|
13
build.rs
13
build.rs
|
@ -12,11 +12,20 @@ fn main() {
|
||||||
let file = std::fs::read_to_string(&path).unwrap();
|
let file = std::fs::read_to_string(&path).unwrap();
|
||||||
let name = path.file_name().unwrap();
|
let name = path.file_name().unwrap();
|
||||||
|
|
||||||
let jot: Cow<'_, [Event<'_>]> = Cow::Owned(jotdown::Parser::new(&file).collect::<Vec<_>>());
|
let mut jot = jotdown::Parser::new(&file).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
jot.push(Event::Start(
|
||||||
|
jotdown::Container::Paragraph,
|
||||||
|
jotdown::Attributes(None),
|
||||||
|
));
|
||||||
|
jot.push(Event::Str("Click anywhere to return to home screen".into()));
|
||||||
|
jot.push(Event::End(jotdown::Container::Paragraph));
|
||||||
|
|
||||||
std::fs::write(
|
std::fs::write(
|
||||||
Path::new(&out).join(name),
|
Path::new(&out).join(name),
|
||||||
jot.bake(&Default::default()).to_string(),
|
Cow::Owned::<'_, [Event<'_>]>(jot)
|
||||||
|
.bake(&Default::default())
|
||||||
|
.to_string(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
65
src/app.rs
65
src/app.rs
|
@ -37,7 +37,6 @@ pub struct Portfolio {
|
||||||
to_beamwidth: f32,
|
to_beamwidth: f32,
|
||||||
font_system: Arc<Mutex<FontSystem>>,
|
font_system: Arc<Mutex<FontSystem>>,
|
||||||
name_buffers: [(Arc<RwLock<Buffer>>, Vec2); 3],
|
name_buffers: [(Arc<RwLock<Buffer>>, Vec2); 3],
|
||||||
click_anywhere_buffer: (Vec2, Arc<RwLock<Buffer>>),
|
|
||||||
window: ContextWindow,
|
window: ContextWindow,
|
||||||
buffer_size: Vec2,
|
buffer_size: Vec2,
|
||||||
max_size: Rect,
|
max_size: Rect,
|
||||||
|
@ -62,7 +61,6 @@ pub enum ContextBlock {
|
||||||
Image {
|
Image {
|
||||||
alt_text: Arc<RwLock<Buffer>>,
|
alt_text: Arc<RwLock<Buffer>>,
|
||||||
image: Image<'static>,
|
image: Image<'static>,
|
||||||
size: Vec2,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +251,6 @@ impl ContextWindow {
|
||||||
ContextBlock::Image {
|
ContextBlock::Image {
|
||||||
alt_text: Arc::new(RwLock::new(buffer.buffer)),
|
alt_text: Arc::new(RwLock::new(buffer.buffer)),
|
||||||
image,
|
image,
|
||||||
size,
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const IMAGE_PADDING: f32 = 8.0;
|
const IMAGE_PADDING: f32 = 8.0;
|
||||||
|
@ -274,7 +271,21 @@ impl ContextWindow {
|
||||||
res.0 = res.0.translate(Vec2::new(ls.x, 0.0));
|
res.0 = res.0.translate(Vec2::new(ls.x, 0.0));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
last_image_size = Some(size + Vec2::new(IMAGE_PADDING, 0.0));
|
if size.x > max_width {
|
||||||
|
let max_size = Vec2::new(max_width, size.y);
|
||||||
|
let new_size = ImageSize {
|
||||||
|
max_size,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.calc_size(max_size, size);
|
||||||
|
res.0 = Rect::from_min_size(
|
||||||
|
Pos2::new(buffer.indent.indent, self.size.y + paragraph_height),
|
||||||
|
new_size,
|
||||||
|
);
|
||||||
|
self.size.y += new_size.y + paragraph_height;
|
||||||
|
} else {
|
||||||
|
last_image_size = Some(size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res
|
res
|
||||||
} else {
|
} else {
|
||||||
|
@ -301,7 +312,6 @@ impl ContextWindow {
|
||||||
if let Some(size) = last_image_size {
|
if let Some(size) = last_image_size {
|
||||||
self.size.y += size.y;
|
self.size.y += size.y;
|
||||||
}
|
}
|
||||||
self.size.y += CONTEXT_METRICS.line_height * 3.0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,18 +396,6 @@ impl Portfolio {
|
||||||
"/usr/share/fonts/TTF/FiraCode-Regular.ttf"
|
"/usr/share/fonts/TTF/FiraCode-Regular.ttf"
|
||||||
))));
|
))));
|
||||||
let (buffer_size, name_buffers) = make_buffers(&mut font_system, 1.0);
|
let (buffer_size, name_buffers) = make_buffers(&mut font_system, 1.0);
|
||||||
let mut click_anywhere_buffer =
|
|
||||||
egui_glyphon::glyphon::Buffer::new(&mut font_system, Metrics::new(16.0, 18.0));
|
|
||||||
click_anywhere_buffer.set_size(&mut font_system, f32::MAX, f32::MAX);
|
|
||||||
click_anywhere_buffer.set_text(
|
|
||||||
&mut font_system,
|
|
||||||
"Click anywhere to return to home page",
|
|
||||||
Attrs::new()
|
|
||||||
.family(glyphon::Family::SansSerif)
|
|
||||||
.weight(Weight::LIGHT),
|
|
||||||
glyphon::Shaping::Basic,
|
|
||||||
);
|
|
||||||
click_anywhere_buffer.shape_until_scroll(&mut font_system, true);
|
|
||||||
let font_system = Arc::new(Mutex::new(font_system));
|
let font_system = Arc::new(Mutex::new(font_system));
|
||||||
GlyphonRenderer::insert(
|
GlyphonRenderer::insert(
|
||||||
cc.wgpu_render_state.as_ref().unwrap(),
|
cc.wgpu_render_state.as_ref().unwrap(),
|
||||||
|
@ -418,10 +416,6 @@ impl Portfolio {
|
||||||
to_beamwidth: 2.0,
|
to_beamwidth: 2.0,
|
||||||
font_system,
|
font_system,
|
||||||
name_buffers,
|
name_buffers,
|
||||||
click_anywhere_buffer: (
|
|
||||||
measure_buffer(&click_anywhere_buffer, Vec2::INFINITY).size(),
|
|
||||||
Arc::new(RwLock::new(click_anywhere_buffer)),
|
|
||||||
),
|
|
||||||
buffer_size,
|
buffer_size,
|
||||||
window: ContextWindow::default(),
|
window: ContextWindow::default(),
|
||||||
max_size: Rect::ZERO,
|
max_size: Rect::ZERO,
|
||||||
|
@ -689,38 +683,13 @@ impl eframe::App for Portfolio {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ContextBlock::Image { image, size, .. } => {
|
ContextBlock::Image { image, .. } => {
|
||||||
image
|
image
|
||||||
.clone()
|
.clone()
|
||||||
.tint(Color32::WHITE.gamma_multiply(zoom_view_opacity))
|
.tint(Color32::WHITE.gamma_multiply(zoom_view_opacity))
|
||||||
.paint_at(
|
.paint_at(ui, context_block.0.translate(rect.min.to_vec2()));
|
||||||
ui,
|
|
||||||
Rect::from_min_size(
|
|
||||||
context_block.0.translate(rect.min.to_vec2()).min,
|
|
||||||
if size.x > rect.width() {
|
|
||||||
let max_size = Vec2::new(rect.width(), size.y);
|
|
||||||
ImageSize {
|
|
||||||
max_size,
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
.calc_size(max_size, *size)
|
|
||||||
} else {
|
|
||||||
*size
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buffers.push(BufferWithTextArea::new(
|
|
||||||
self.click_anywhere_buffer.1.clone(),
|
|
||||||
Rect::from_min_size(
|
|
||||||
Pos2::new(rect.min.x + 4.0, rect.max.y - 8.0),
|
|
||||||
self.click_anywhere_buffer.0,
|
|
||||||
),
|
|
||||||
zoom_view_opacity,
|
|
||||||
egui_glyphon::glyphon::Color::rgb(255, 255, 255),
|
|
||||||
ui.ctx(),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
let mut hovered = false;
|
let mut hovered = false;
|
||||||
if self.zoomed {
|
if self.zoomed {
|
||||||
|
|
Loading…
Reference in a new issue