mirror of
https://github.com/danbulant/mangui
synced 2026-05-19 03:58:34 +00:00
make it build on nix
This commit is contained in:
parent
8875cbb6ff
commit
ec5b7de1b5
6 changed files with 473 additions and 181 deletions
9
.envrc
Normal file
9
.envrc
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
# the shebang is ignored, but nice for editors
|
||||
|
||||
if type -P lorri &>/dev/null; then
|
||||
eval "$(lorri direnv)"
|
||||
else
|
||||
echo 'while direnv evaluated .envrc, could not find the command "lorri" [https://github.com/nix-community/lorri]'
|
||||
use nix
|
||||
fi
|
||||
578
Cargo.lock
generated
578
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
39
shell.nix
Normal file
39
shell.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
let
|
||||
# rust-rover things
|
||||
rust-toolchain =
|
||||
pkgs.symlinkJoin {
|
||||
name = "rust-toolchain";
|
||||
paths = with pkgs; [rustc cargo rustPlatform.rustcSrc clippy rustfmt gcc rust-analyzer];
|
||||
};
|
||||
in
|
||||
pkgs.mkShell rec {
|
||||
buildInputs = with pkgs;[
|
||||
openssl
|
||||
pkg-config
|
||||
cmake
|
||||
zlib
|
||||
rust-toolchain
|
||||
|
||||
# common glutin
|
||||
libxkbcommon
|
||||
libGL
|
||||
|
||||
# winit wayland
|
||||
wayland
|
||||
|
||||
# winit x11
|
||||
xorg.libXcursor
|
||||
xorg.libXrandr
|
||||
xorg.libXi
|
||||
xorg.libX11
|
||||
];
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkg-config
|
||||
fontconfig
|
||||
];
|
||||
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
|
||||
OPENSSL_DIR="${pkgs.openssl.dev}";
|
||||
OPENSSL_LIB_DIR="${pkgs.openssl.out}/lib";
|
||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
}
|
||||
|
|
@ -7,10 +7,10 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
femtovg = { path = "../femtovg" }
|
||||
glutin = "0.31.3"
|
||||
raw-window-handle = "0.5.0"
|
||||
winit = { version = "0.29.10" }
|
||||
glutin-winit = "0.4.2"
|
||||
glutin = "0.32.0"
|
||||
raw-window-handle = "0.5.2"
|
||||
winit = { version = "0.30.4", default-features = false, features = ["wayland", "rwh_05", "wayland-csd-adwaita"] }
|
||||
glutin-winit = "0.5.0"
|
||||
taffy = "0.4.0"
|
||||
weak-table = "0.3.2"
|
||||
cosmic-text = "0.11.2"
|
||||
|
|
|
|||
|
|
@ -11,10 +11,8 @@ use glutin::surface::Surface;
|
|||
use glutin::{context::PossiblyCurrentContext, display::Display};
|
||||
use glutin_winit::DisplayBuilder;
|
||||
use nodes::{get_element_at, run_event_handlers, run_single_event_handlers};
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
use winit::event::{Event, WindowEvent, Modifiers, DeviceId};
|
||||
use winit::event_loop::EventLoop;
|
||||
use winit::window::WindowBuilder;
|
||||
use winit::{dpi::PhysicalSize, window::Window};
|
||||
|
||||
use glutin::{
|
||||
|
|
@ -36,6 +34,7 @@ pub use taffy;
|
|||
pub use femtovg;
|
||||
pub use cosmic_text;
|
||||
pub use winit::dpi;
|
||||
use winit::raw_window_handle::HasRawWindowHandle;
|
||||
|
||||
pub type CurrentRenderer = OpenGl;
|
||||
pub type SharedNode = Arc<Mutex<dyn Node>>;
|
||||
|
|
@ -365,13 +364,14 @@ fn convert_vec_option_to_option_vec<T>(vec: Vec<Option<T>>) -> Option<Vec<T>> {
|
|||
}
|
||||
|
||||
fn create_window(event_loop: &EventLoop<()>) -> (PossiblyCurrentContext, Display, Window, Surface<WindowSurface>) {
|
||||
let window_builder = WindowBuilder::new()
|
||||
.with_inner_size(PhysicalSize::new(1000., 600.))
|
||||
.with_title("Mangui test");
|
||||
// let window_builder = WindowBuilder::new()
|
||||
// .with_inner_size(PhysicalSize::new(1000., 600.))
|
||||
// .with_title("Mangui test");
|
||||
|
||||
|
||||
let template = ConfigTemplateBuilder::new().with_alpha_size(8);
|
||||
|
||||
let display_builder = DisplayBuilder::new().with_window_builder(Some(window_builder));
|
||||
let display_builder = DisplayBuilder::new().with_window_attributes(Some(Window::default_attributes().with_title("Mangui test")));
|
||||
|
||||
let (window, gl_config) = display_builder
|
||||
.build(event_loop, template, |mut configs| configs.next().unwrap())
|
||||
|
|
@ -381,13 +381,13 @@ fn create_window(event_loop: &EventLoop<()>) -> (PossiblyCurrentContext, Display
|
|||
|
||||
let gl_display = gl_config.display();
|
||||
|
||||
let context_attributes = ContextAttributesBuilder::new().build(Some(window.raw_window_handle()));
|
||||
let context_attributes = ContextAttributesBuilder::new().build(Some(window.raw_window_handle().unwrap()));
|
||||
|
||||
let mut not_current_gl_context =
|
||||
Some(unsafe { gl_display.create_context(&gl_config, &context_attributes).unwrap() });
|
||||
|
||||
let attrs = SurfaceAttributesBuilder::<WindowSurface>::new().build(
|
||||
window.raw_window_handle(),
|
||||
window.raw_window_handle().unwrap(),
|
||||
NonZeroU32::new(1000).unwrap(),
|
||||
NonZeroU32::new(600).unwrap(),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
pub mod layout;
|
||||
pub mod empty;
|
||||
// pub mod empty;
|
||||
pub mod primitives;
|
||||
pub mod image;
|
||||
pub mod text;
|
||||
|
|
@ -141,7 +141,7 @@ pub trait Node: Debug + Send {
|
|||
/// Return style.
|
||||
///insert
|
||||
/// If you're using [`Style`] in your struct directly, your implementation can be as simple as:
|
||||
/// ```rust
|
||||
///```rust
|
||||
/// fn style(&self) -> &Style { &self.style }
|
||||
/// ```
|
||||
fn style(&self) -> &Style;
|
||||
|
|
|
|||
Loading…
Reference in a new issue