Compare commits
11
Commits
d4844a303a
..
v0.7.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6272f6cc21 | ||
|
|
bc6cc6cabc | ||
|
|
f732720c31 | ||
|
|
b988571674 | ||
|
|
c52c33ce67 | ||
|
|
7ecb248407 | ||
|
|
fdd71f582b | ||
|
|
83b567cfd4 | ||
|
|
6687b1f12f | ||
|
|
af2df78809 | ||
|
|
89dfeeeb2d |
Generated
+171
-170
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -4,7 +4,7 @@ description = "An emulator for the Virtual Boy."
|
|||||||
repository = "https://git.virtual-boy.com/PVB/lemur"
|
repository = "https://git.virtual-boy.com/PVB/lemur"
|
||||||
publish = false
|
publish = false
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
version = "0.7.1"
|
version = "0.7.3"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@@ -30,6 +30,7 @@ num-derive = "0.4"
|
|||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
oneshot = "0.1"
|
oneshot = "0.1"
|
||||||
pollster = "0.4"
|
pollster = "0.4"
|
||||||
|
rand = "0.9"
|
||||||
rfd = { version = "0.15", default-features = false, features = ["xdg-portal", "async-std"]}
|
rfd = { version = "0.15", default-features = false, features = ["xdg-portal", "async-std"]}
|
||||||
rtrb = "0.3"
|
rtrb = "0.3"
|
||||||
rubato = "0.16"
|
rubato = "0.16"
|
||||||
|
|||||||
+26
-10
@@ -1,24 +1,39 @@
|
|||||||
# This Dockerfile produces a base image for builds.
|
# This Dockerfile produces a base image for builds.
|
||||||
# It includes all dependencies necessary to cross-compile for Windows/MacOS/Linux.
|
# It includes all dependencies necessary to cross-compile for Windows/MacOS/Linux.
|
||||||
|
|
||||||
FROM crazymax/osxcross:latest-ubuntu AS osxcross
|
FROM debian:bookworm AS osxcross
|
||||||
|
ADD --chmod=644 "https://apt.llvm.org/llvm-snapshot.gpg.key" /etc/apt/trusted.gpg.d/apt.llvm.org.asc
|
||||||
|
WORKDIR /build/osxcross
|
||||||
|
ADD "https://github.com/tpoechtrager/osxcross.git#47936a512273bb3b414b5a2e83043c92eabc7ae7" .
|
||||||
|
ADD "https://github.com/joseluisq/macosx-sdks/releases/download/14.5/MacOSX14.5.sdk.tar.xz" ./tarballs/MacOSX14.5.sdk.tar.xz
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y ca-certificates
|
||||||
|
COPY llvm.sources /etc/apt/sources.list.d/llvm.sources
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y bash bzip2 clang-20 git lld-20 llvm-20 make patch xz-utils && \
|
||||||
|
ln -s $(which clang-20) /usr/bin/clang && \
|
||||||
|
ln -s $(which clang++-20) /usr/bin/clang++ && \
|
||||||
|
ln -s $(which ld64.lld-20) /usr/bin/ld64.lld && \
|
||||||
|
SDK_VERSION=14.5 UNATTENDED=1 ENABLE_COMPILER_RT_INSTALL=1 TARGET_DIR=/osxcross ./build.sh
|
||||||
|
|
||||||
FROM rust:latest
|
FROM rust:1.89-bookworm
|
||||||
|
ADD --chmod=644 "https://apt.llvm.org/llvm-snapshot.gpg.key" /etc/apt/trusted.gpg.d/apt.llvm.org.asc
|
||||||
|
COPY llvm.sources /etc/apt/sources.list.d/llvm.sources
|
||||||
RUN rustup target add x86_64-pc-windows-msvc && \
|
RUN rustup target add x86_64-pc-windows-msvc && \
|
||||||
rustup target add x86_64-apple-darwin && \
|
rustup target add x86_64-apple-darwin && \
|
||||||
rustup target add aarch64-apple-darwin && \
|
rustup target add aarch64-apple-darwin && \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install -y clang-19 lld-19 libc6-dev libasound2-dev libudev-dev genisoimage mingw-w64 && \
|
apt-get install -y clang-20 lld-20 libc6-dev libasound2-dev libudev-dev genisoimage mingw-w64 && \
|
||||||
cargo install cargo-bundle xwin && \
|
cargo install cargo-bundle xwin && \
|
||||||
xwin --accept-license splat --output xwin && \
|
xwin --accept-license splat --output xwin && \
|
||||||
rm -rf .xwin-cache && \
|
rm -rf .xwin-cache && \
|
||||||
ln -s $(which clang-19) /usr/bin/clang && \
|
ln -s $(which clang-20) /usr/bin/clang && \
|
||||||
ln -s $(which clang++-19) /usr/bin/clang++
|
ln -s $(which clang++-20) /usr/bin/clang++
|
||||||
COPY --from=osxcross /osxcross /osxcross
|
COPY --from=osxcross /osxcross /osxcross
|
||||||
|
|
||||||
ENV PATH="/osxcross/bin:$PATH" \
|
ENV PATH="/osxcross/bin:$PATH" \
|
||||||
LD_LIBRARY_PATH="/osxcross/lib" \
|
LD_LIBRARY_PATH="/osxcross/lib" \
|
||||||
CC="clang-19" CXX="clang++-19" AR="llvm-ar-19" \
|
CC="clang-20" CXX="clang++-20" AR="llvm-ar-20" \
|
||||||
CC_x86_64-apple-darwin="o64-clang" \
|
CC_x86_64-apple-darwin="o64-clang" \
|
||||||
CXX_x86_64-apple-darwin="o64-clang++" \
|
CXX_x86_64-apple-darwin="o64-clang++" \
|
||||||
CC_aarch64-apple-darwin="oa64-clang" \
|
CC_aarch64-apple-darwin="oa64-clang" \
|
||||||
@@ -27,10 +42,11 @@ ENV PATH="/osxcross/bin:$PATH" \
|
|||||||
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=lld" \
|
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=lld" \
|
||||||
SHROOMS_CFLAGS_x86_64-pc-windows-msvc="-flto" \
|
SHROOMS_CFLAGS_x86_64-pc-windows-msvc="-flto" \
|
||||||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS="-Lnative=/xwin/crt/lib/x86_64 -Lnative=/xwin/sdk/lib/um/x86_64 -Lnative=/xwin/sdk/lib/ucrt/x86_64 -Clinker-plugin-lto -Clink-arg=-fuse-ld=lld" \
|
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS="-Lnative=/xwin/crt/lib/x86_64 -Lnative=/xwin/sdk/lib/um/x86_64 -Lnative=/xwin/sdk/lib/ucrt/x86_64 -Clinker-plugin-lto -Clink-arg=-fuse-ld=lld" \
|
||||||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER="lld-link-19" \
|
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER="lld-link-20" \
|
||||||
CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER="o64-clang" \
|
CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER="o64-clang" \
|
||||||
CARGO_TARGET_X86_64_APPLE_DARWIN_AR="llvm-ar-19" \
|
CARGO_TARGET_X86_64_APPLE_DARWIN_AR="llvm-ar-20" \
|
||||||
CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER="oa64-clang" \
|
CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER="oa64-clang" \
|
||||||
CARGO_TARGET_AARCH64_APPLE_DARWIN_AR="llvm-ar-19" \
|
CARGO_TARGET_AARCH64_APPLE_DARWIN_AR="llvm-ar-20" \
|
||||||
RC_PATH="llvm-rc-19" \
|
RC_PATH="llvm-rc-20" \
|
||||||
MACOSX_DEPLOYMENT_TARGET="14.5"
|
MACOSX_DEPLOYMENT_TARGET="14.5"
|
||||||
|
ENTRYPOINT ["bash"]
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
Types: deb deb-src
|
||||||
|
URIs: http://apt.llvm.org/bookworm/
|
||||||
|
Suites: llvm-toolchain-bookworm-20
|
||||||
|
Components: main
|
||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
set -e
|
||||||
|
|
||||||
|
docker build --pull -f build.Dockerfile -t lemur-build .
|
||||||
|
MSYS_NO_PATHCONV=1 docker run -it --rm -v .:/app -w /app lemur-build /app/scripts/do-bundle.sh
|
||||||
+1
-2
@@ -24,8 +24,7 @@ if ! command -v docker 2>&1 >/dev/null; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker build -f build.Dockerfile -t lemur-build .
|
./scripts/bundle.sh
|
||||||
MSYS_NO_PATHCONV=1 docker run -it --rm -v .:/app -w /app --entrypoint bash lemur-build /app/scripts/do-bundle.sh
|
|
||||||
|
|
||||||
body=$(cat <<EOF
|
body=$(cat <<EOF
|
||||||
## How to install
|
## How to install
|
||||||
|
|||||||
+1
-1
Submodule shrooms-vb-core updated: ecbd103917...8598eab087
+6
-7
@@ -209,10 +209,9 @@ impl ApplicationHandler<UserEvent> for Application {
|
|||||||
.focused
|
.focused
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|id| self.viewports.get_mut(id))
|
.and_then(|id| self.viewports.get_mut(id))
|
||||||
|
&& viewport.app.handle_gamepad_event(&event)
|
||||||
{
|
{
|
||||||
if viewport.app.handle_gamepad_event(&event) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self.controllers.handle_gamepad_event(&event);
|
self.controllers.handle_gamepad_event(&event);
|
||||||
}
|
}
|
||||||
@@ -289,10 +288,10 @@ impl ApplicationHandler<UserEvent> for Application {
|
|||||||
|
|
||||||
fn exiting(&mut self, _event_loop: &ActiveEventLoop) {
|
fn exiting(&mut self, _event_loop: &ActiveEventLoop) {
|
||||||
let (sender, receiver) = oneshot::channel();
|
let (sender, receiver) = oneshot::channel();
|
||||||
if self.client.send_command(EmulatorCommand::Exit(sender)) {
|
if self.client.send_command(EmulatorCommand::Exit(sender))
|
||||||
if let Err(error) = receiver.recv_timeout(Duration::from_secs(5)) {
|
&& let Err(error) = receiver.recv_timeout(Duration::from_secs(5))
|
||||||
error!(%error, "could not gracefully exit.");
|
{
|
||||||
}
|
error!(%error, "could not gracefully exit.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-49
@@ -1,8 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
fs::{self, File},
|
|
||||||
io::{Read, Seek, SeekFrom, Write},
|
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::{
|
sync::{
|
||||||
Arc, Weak,
|
Arc, Weak,
|
||||||
@@ -20,6 +18,7 @@ use tracing::{error, warn};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
audio::Audio,
|
audio::Audio,
|
||||||
|
emulator::cart::Cart,
|
||||||
graphics::TextureSink,
|
graphics::TextureSink,
|
||||||
memory::{MemoryRange, MemoryRegion},
|
memory::{MemoryRange, MemoryRegion},
|
||||||
};
|
};
|
||||||
@@ -27,6 +26,7 @@ use shrooms_vb_core::{EXPECTED_FRAME_SIZE, Sim, StopReason};
|
|||||||
pub use shrooms_vb_core::{VBKey, VBRegister, VBWatchpointType};
|
pub use shrooms_vb_core::{VBKey, VBRegister, VBWatchpointType};
|
||||||
|
|
||||||
mod address_set;
|
mod address_set;
|
||||||
|
mod cart;
|
||||||
mod shrooms_vb_core;
|
mod shrooms_vb_core;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
||||||
@@ -61,43 +61,6 @@ impl Display for SimId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Cart {
|
|
||||||
rom_path: PathBuf,
|
|
||||||
rom: Vec<u8>,
|
|
||||||
sram_file: File,
|
|
||||||
sram: Vec<u8>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Cart {
|
|
||||||
fn load(rom_path: &Path, sim_id: SimId) -> Result<Self> {
|
|
||||||
let rom = fs::read(rom_path)?;
|
|
||||||
|
|
||||||
let mut sram_file = File::options()
|
|
||||||
.read(true)
|
|
||||||
.write(true)
|
|
||||||
.create(true)
|
|
||||||
.truncate(false)
|
|
||||||
.open(sram_path(rom_path, sim_id))?;
|
|
||||||
sram_file.set_len(8 * 1024)?;
|
|
||||||
|
|
||||||
let mut sram = vec![];
|
|
||||||
sram_file.read_to_end(&mut sram)?;
|
|
||||||
Ok(Cart {
|
|
||||||
rom_path: rom_path.to_path_buf(),
|
|
||||||
rom,
|
|
||||||
sram_file,
|
|
||||||
sram,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sram_path(rom_path: &Path, sim_id: SimId) -> PathBuf {
|
|
||||||
match sim_id {
|
|
||||||
SimId::Player1 => rom_path.with_extension("p1.sram"),
|
|
||||||
SimId::Player2 => rom_path.with_extension("p2.sram"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct EmulatorBuilder {
|
pub struct EmulatorBuilder {
|
||||||
rom: Option<PathBuf>,
|
rom: Option<PathBuf>,
|
||||||
commands: mpsc::Receiver<EmulatorCommand>,
|
commands: mpsc::Receiver<EmulatorCommand>,
|
||||||
@@ -219,12 +182,12 @@ impl Emulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_second_sim(&mut self, rom: Option<PathBuf>) -> Result<()> {
|
pub fn start_second_sim(&mut self, rom: Option<PathBuf>) -> Result<()> {
|
||||||
let rom_path = if let Some(path) = rom {
|
let file_path = if let Some(path) = rom {
|
||||||
Some(path)
|
Some(path)
|
||||||
} else {
|
} else {
|
||||||
self.carts[0].as_ref().map(|c| c.rom_path.clone())
|
self.carts[0].as_ref().map(|c| c.file_path.clone())
|
||||||
};
|
};
|
||||||
let cart = match rom_path {
|
let cart = match file_path {
|
||||||
Some(rom_path) => Some(Cart::load(&rom_path, SimId::Player2)?),
|
Some(rom_path) => Some(Cart::load(&rom_path, SimId::Player2)?),
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
@@ -337,8 +300,7 @@ impl Emulator {
|
|||||||
let cart = self.carts[sim_id.to_index()].as_mut();
|
let cart = self.carts[sim_id.to_index()].as_mut();
|
||||||
if let (Some(sim), Some(cart)) = (sim, cart) {
|
if let (Some(sim), Some(cart)) = (sim, cart) {
|
||||||
sim.read_sram(&mut cart.sram);
|
sim.read_sram(&mut cart.sram);
|
||||||
cart.sram_file.seek(SeekFrom::Start(0))?;
|
cart.save_sram()?;
|
||||||
cart.sram_file.write_all(&cart.sram)?;
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -493,11 +455,11 @@ impl Emulator {
|
|||||||
let Some(sim) = self.sims.get_mut(sim_id.to_index()) else {
|
let Some(sim) = self.sims.get_mut(sim_id.to_index()) else {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
if let Some(text) = sim.take_stdout() {
|
if let Some(text) = sim.take_stdout()
|
||||||
if stdout.send(text).is_err() {
|
&& stdout.send(text).is_err()
|
||||||
sim.watch_stdout(false);
|
{
|
||||||
return false;
|
sim.watch_stdout(false);
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
use anyhow::Result;
|
||||||
|
use rand::Rng;
|
||||||
|
use std::{
|
||||||
|
fs::{self, File},
|
||||||
|
io::{Read, Seek as _, SeekFrom, Write as _},
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::emulator::SimId;
|
||||||
|
|
||||||
|
pub struct Cart {
|
||||||
|
pub file_path: PathBuf,
|
||||||
|
pub rom: Vec<u8>,
|
||||||
|
sram_file: File,
|
||||||
|
pub sram: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Cart {
|
||||||
|
pub fn load(file_path: &Path, sim_id: SimId) -> Result<Self> {
|
||||||
|
let rom = fs::read(file_path)?;
|
||||||
|
|
||||||
|
let mut sram_file = File::options()
|
||||||
|
.read(true)
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.truncate(false)
|
||||||
|
.open(sram_path(file_path, sim_id))?;
|
||||||
|
|
||||||
|
let sram = if sram_file.metadata()?.len() == 0 {
|
||||||
|
// new SRAM file, randomize the contents
|
||||||
|
let mut sram = vec![0; 16 * 1024];
|
||||||
|
let mut rng = rand::rng();
|
||||||
|
for dst in sram.iter_mut().step_by(2) {
|
||||||
|
*dst = rng.random();
|
||||||
|
}
|
||||||
|
sram
|
||||||
|
} else {
|
||||||
|
let mut sram = Vec::with_capacity(16 * 1024);
|
||||||
|
sram_file.read_to_end(&mut sram)?;
|
||||||
|
sram
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Cart {
|
||||||
|
file_path: file_path.to_path_buf(),
|
||||||
|
rom,
|
||||||
|
sram_file,
|
||||||
|
sram,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn save_sram(&mut self) -> Result<()> {
|
||||||
|
self.sram_file.seek(SeekFrom::Start(0))?;
|
||||||
|
self.sram_file.write_all(&self.sram)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sram_path(file_path: &Path, sim_id: SimId) -> PathBuf {
|
||||||
|
match sim_id {
|
||||||
|
SimId::Player1 => file_path.with_extension("p1.sram"),
|
||||||
|
SimId::Player2 => file_path.with_extension("p2.sram"),
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -169,7 +169,7 @@ impl MemoryRef<'_> {
|
|||||||
T::from_bytes(&self.inner[from..to])
|
T::from_bytes(&self.inner[from..to])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn range<T: MemoryValue>(&self, start: usize, count: usize) -> MemoryIter<T> {
|
pub fn range<T: MemoryValue>(&self, start: usize, count: usize) -> MemoryIter<'_, T> {
|
||||||
let from = start * size_of::<T>();
|
let from = start * size_of::<T>();
|
||||||
let to = from + (count * size_of::<T>());
|
let to = from + (count * size_of::<T>());
|
||||||
MemoryIter::new(&self.inner[from..to])
|
MemoryIter::new(&self.inner[from..to])
|
||||||
|
|||||||
+1
-1
@@ -457,7 +457,7 @@ impl GameWindow {
|
|||||||
self.config = new_config;
|
self.config = new_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn button_for(&self, ctx: &Context, text: &str, command: Command) -> Button {
|
fn button_for(&self, ctx: &Context, text: &str, command: Command) -> Button<'_> {
|
||||||
let button = Button::new(text);
|
let button = Button::new(text);
|
||||||
match self.shortcuts.shortcut_for(command) {
|
match self.shortcuts.shortcut_for(command) {
|
||||||
Some(shortcut) => button.shortcut_text(ctx.format_shortcut(&shortcut)),
|
Some(shortcut) => button.shortcut_text(ctx.format_shortcut(&shortcut)),
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ impl HotkeysWindow {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if let Some(command) = self.now_binding {
|
if let Some(command) = self.now_binding
|
||||||
if let Some(shortcut) = ui.input_mut(|i| {
|
&& let Some(shortcut) = ui.input_mut(|i| {
|
||||||
i.events.iter().find_map(|event| match event {
|
i.events.iter().find_map(|event| match event {
|
||||||
Event::Key {
|
Event::Key {
|
||||||
key,
|
key,
|
||||||
@@ -73,10 +73,10 @@ impl HotkeysWindow {
|
|||||||
} => Some(KeyboardShortcut::new(*modifiers, *key)),
|
} => Some(KeyboardShortcut::new(*modifiers, *key)),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
}) {
|
})
|
||||||
self.shortcuts.set(command, shortcut);
|
{
|
||||||
self.now_binding = None;
|
self.shortcuts.set(command, shortcut);
|
||||||
}
|
self.now_binding = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -86,10 +86,10 @@ impl UiExt for Ui {
|
|||||||
let (rect, _) = ui.allocate_at_least(Vec2::new(100.0, 100.0), Sense::hover());
|
let (rect, _) = ui.allocate_at_least(Vec2::new(100.0, 100.0), Sense::hover());
|
||||||
ui.painter().rect_filled(rect, 0.0, *color);
|
ui.painter().rect_filled(rect, 0.0, *color);
|
||||||
let resp = ui.text_edit_singleline(hex);
|
let resp = ui.text_edit_singleline(hex);
|
||||||
if resp.changed() {
|
if resp.changed()
|
||||||
if let Ok(new_color) = HexColor::from_str_without_hash(hex) {
|
&& let Ok(new_color) = HexColor::from_str_without_hash(hex)
|
||||||
*color = new_color.color();
|
{
|
||||||
}
|
*color = new_color.color();
|
||||||
}
|
}
|
||||||
resp
|
resp
|
||||||
},
|
},
|
||||||
@@ -301,11 +301,11 @@ impl<T: Number> Widget for NumberEdit<'_, T> {
|
|||||||
|
|
||||||
let mut delta = None;
|
let mut delta = None;
|
||||||
if self.arrows {
|
if self.arrows {
|
||||||
let arrow_left = res.rect.max.x + 4.0;
|
let arrow_left = res.rect.max.x - 16.0;
|
||||||
let arrow_right = res.rect.max.x + 20.0;
|
let arrow_right = res.rect.max.x;
|
||||||
let arrow_top = res.rect.min.y - 2.0;
|
let arrow_top = res.rect.min.y;
|
||||||
let arrow_middle = (res.rect.min.y + res.rect.max.y) / 2.0;
|
let arrow_middle = (res.rect.min.y + res.rect.max.y) / 2.0;
|
||||||
let arrow_bottom = res.rect.max.y + 2.0;
|
let arrow_bottom = res.rect.max.y;
|
||||||
|
|
||||||
let top_arrow_rect = Rect {
|
let top_arrow_rect = Rect {
|
||||||
min: (arrow_left, arrow_top).into(),
|
min: (arrow_left, arrow_top).into(),
|
||||||
|
|||||||
Reference in New Issue
Block a user