first commit

This commit is contained in:
andodeki 2025-06-18 10:07:14 +03:00
commit 8f34249a8b
8 changed files with 1272 additions and 0 deletions

6
.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
## Cargo generated directory
/target
## cargo-packager generated directory
/dist
.DS_Store

1111
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

10
Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "testpane"
version = "1.0.0"
edition = "2021"
license = "MIT OR Apache-2.0"
metadata.makepad-auto-version = "EVyKRfOGV339Re5CS45PMHHxw_M="
[dependencies]
# makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "dev" }
makepad-widgets = { git = "https://github.com/kevinaboos/makepad", branch = "emit_key_down_unhandled_on_unused_hit" }

1
README.md Normal file
View file

@ -0,0 +1 @@
# test sliding pane

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_copy"
android:title="Copy" />
<item
android:id="@+id/menu_cut"
android:title="Cut" />
<item
android:id="@+id/menu_paste"
android:title="Paste" />
</menu>

121
src/app.rs Normal file
View file

@ -0,0 +1,121 @@
use makepad_widgets::*;
live_design!{
use link::theme::*;
use link::shaders::*;
use link::widgets::*;
App = {{App}} {
ui: <Root>{
main_window = <Window>{
body = <View>{
flow: Down,
spacing:30,
align: {
x: 0.5,
y: 0.5
},
show_bg: true,
draw_bg:{
fn pixel(self) -> vec4 {
let center = vec2(0.5, 0.5);
let uv = self.pos - center;
let radius = length(uv);
let angle = atan(uv.y, uv.x);
let color1 = mix(#f00, #00f, 0.5 + 10.5 * cos(angle + self.time));
let color2 = mix(#0f0, #ff0, 0.5 + 0.5 * sin(angle + self.time));
let color = mix(color1, color2, radius);
return depth_clip(self.world, color, self.depth_clip);
}
}
<Rotary>{
text:"Slide"
}
button_1 = <Button> {
text: "Click 福 me 😊"
draw_text:{text_style:{font_size:18}}
}
text_input = <TextInput> {
width: 100,
flow: RightWrap,
text: "Lorem ipsum"
draw_text:{text_style:{font_size:18}}
}
/*
md = <Markdown> {
font_size:10
draw_normal:{
font_scale: 20.0
}
body: ""
}*/
/*
button_2 = <Button> {
text: "Click me 345 1234"
draw_text:{color:#fff, text_style:{font_size:18}}
}*/
/*
<SliderRound> {
text: "Short label",
draw_bg: {
val_color_1: #FFCC00
val_color_1_hover: #FF9944
val_color_1_focus: #FFCC44
val_color_1_drag: #FFAA00
val_color_2: #F00
val_color_2_hover: #F00
val_color_2_focus: #F00
val_color_2_drag: #F00
handle_color: #0000
handle_color_hover: #0008
handle_color_focus: #000C
handle_color_drag: #000F
}
}*/
}
}
}
}
}
app_main!(App);
#[derive(Live, LiveHook)]
pub struct App {
#[live] ui: WidgetRef,
#[rust] counter: usize,
}
impl LiveRegister for App {
fn live_register(cx: &mut Cx) {
crate::makepad_widgets::live_design(cx);
}
}
impl MatchEvent for App{
fn handle_startup(&mut self, _cx:&mut Cx){
}
fn handle_actions(&mut self, cx: &mut Cx, actions:&Actions){
if self.ui.button(id!(button_1)).clicked(&actions) {
self.ui.button(id!(button_1)).set_text(cx, "Clicked 😀");
log!("hi");
self.counter += 1;
}
}
}
impl AppMain for App {
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
if let Event::XrUpdate(_e) = event{
//log!("{:?}", e.now.left.trigger.analog);
}
self.match_event(cx, event);
self.ui.handle_event(cx, event, &mut Scope::empty());
}
}

2
src/lib.rs Normal file
View file

@ -0,0 +1,2 @@
pub use makepad_widgets;
pub mod app;

7
src/main.rs Normal file
View file

@ -0,0 +1,7 @@
// this stub is necessary because some platforms require building
// as dll (mobile / wasm) and some require to be built as executable
// unfortunately cargo doesn't facilitate this without a main.rs stub
fn main() {
testpane::app::app_main()
}