diff --git a/mp/src/app.rs b/mp/src/app.rs
index dc4e350..b32f8ed 100644
--- a/mp/src/app.rs
+++ b/mp/src/app.rs
@@ -178,6 +178,7 @@ impl LiveRegister for App {
crate::widgets::area::live_design(_cx);
crate::widgets::renderer::live_design(_cx);
crate::widgets::selector_modal::live_design(_cx);
+ crate::widgets::background_text::live_design(_cx);
}
}
diff --git a/mp/src/app_ui.rs b/mp/src/app_ui.rs
index 25556e6..a07bc11 100644
--- a/mp/src/app_ui.rs
+++ b/mp/src/app_ui.rs
@@ -1,3 +1,4 @@
+use makepad_widgets::Dock;
use makepad_widgets::*;
live_design! {
import makepad_widgets::base::*;
@@ -7,6 +8,7 @@ live_design! {
import makepad_draw::shader::std::*;
import crate::widgets::selector_modal::SelectorItem;
+ import crate::widgets::background_text::BackgroundLabel;
HELLO = "Hello, World!";
@@ -128,10 +130,26 @@ live_design! {
{ text: "Input"}
- {
- text: "PPI"
+ {
+ flow: Right
+ width: Fill
+ height: Fit
+
+ {
+ text: "Holy Shit",
+ }
+
+ {
+ text: "Holy Shit",
+ }
+
+ {
+ text: "Holy Shit",
+ }
}
+
+
{
{
diff --git a/mp/src/widgets/background_text.rs b/mp/src/widgets/background_text.rs
new file mode 100644
index 0000000..cada4ba
--- /dev/null
+++ b/mp/src/widgets/background_text.rs
@@ -0,0 +1,136 @@
+use makepad_widgets::*;
+
+live_design! {
+ import makepad_draw::shader::std::*;
+ import makepad_widgets::base::*;
+ import makepad_widgets::theme_desktop_dark::*;
+
+ BackgroundIcon = {{BackgroundIcon}} {
+ draw_icon: {
+ color: #fff
+ }
+
+ draw_bg: {
+ instance color: #3c3c3c
+ instance radius: 3.0
+
+ fn get_color(self) -> vec4 {
+ return self.color;
+ }
+
+ fn pixel(self) -> vec4 {
+ let sdf = Sdf2d::viewport(self.pos * self.rect_size)
+ sdf.box(
+ 0.0,0.0,
+ self.rect_size.x,
+ self.rect_size.y,
+ max(1.0, self.radius)
+ )
+ sdf.fill_keep(self.get_color())
+ return sdf.result;
+ }
+ }
+ }
+
+ BackgroundLabel = {{BackgroundLabel}} {
+ draw_text: {
+ color: #fff
+ text_style: {
+ font_size: 8.0
+ }
+ }
+
+ draw_bg: {
+ instance color: #3c3c3c
+ instance radius: 3.0
+
+ fn get_color(self) -> vec4 {
+ return self.color;
+ }
+
+ fn pixel(self) -> vec4 {
+ let sdf = Sdf2d::viewport(self.pos * self.rect_size)
+ sdf.box(
+ 0.0,0.0,
+ self.rect_size.x,
+ self.rect_size.y,
+ max(1.0, self.radius)
+ )
+ sdf.fill_keep(self.get_color())
+ return sdf.result;
+ }
+ }
+ }
+}
+
+#[derive(LiveHook, Live, Widget)]
+pub struct BackgroundLabel {
+ #[redraw]
+ #[live]
+ draw_bg: DrawQuad,
+ #[live]
+ draw_text: DrawText,
+ #[live]
+ text: ArcStringMut,
+ #[live]
+ padding: Padding,
+ #[live]
+ align: Align,
+ #[rust]
+ selected: bool,
+}
+
+impl Widget for BackgroundLabel {
+ fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {
+ let walk = Walk::fit();
+ self.draw_bg.begin(cx, walk, Layout::default());
+ self.draw_text.draw_walk(
+ cx,
+ Walk::fit().with_margin_all(5.0),
+ Align { x: 0.5, y: 0.5 },
+ self.text.as_ref(),
+ );
+ self.draw_bg.end(cx);
+ DrawStep::done()
+ }
+
+ fn text(&self) -> String {
+ self.text.as_ref().to_string()
+ }
+
+ fn set_text(&mut self, _v: &str) {
+ self.text.as_mut_empty().push_str(_v);
+ self.label(id!(lb)).set_text(_v);
+ }
+}
+
+#[derive(LiveHook, Live, Widget)]
+pub struct BackgroundIcon {
+ #[redraw]
+ #[live]
+ draw_bg: DrawQuad,
+ #[live]
+ draw_icon: DrawIcon,
+ #[live]
+ text: ArcStringMut,
+ #[live]
+ padding: Padding,
+ #[live]
+ align: Align,
+ #[rust]
+ selected: bool,
+}
+
+impl Widget for BackgroundIcon {
+ fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {
+ let walk = Walk::fit();
+ self.draw_bg.begin(
+ cx,
+ walk,
+ Layout::default().with_align_x(0.5).with_align_y(0.5),
+ );
+ self.draw_icon.draw_walk(cx, Walk::fixed(64.0, 64.0));
+ self.draw_bg.end(cx);
+ DrawStep::done()
+ }
+}
diff --git a/mp/src/widgets/mod.rs b/mp/src/widgets/mod.rs
index 8c22130..9daaafe 100644
--- a/mp/src/widgets/mod.rs
+++ b/mp/src/widgets/mod.rs
@@ -1,3 +1,4 @@
pub mod area;
+pub mod background_text;
pub mod renderer;
pub mod selector_modal;
diff --git a/mp/src/widgets/selector_modal.rs b/mp/src/widgets/selector_modal.rs
index 8a02208..62d56cc 100644
--- a/mp/src/widgets/selector_modal.rs
+++ b/mp/src/widgets/selector_modal.rs
@@ -1,194 +1,193 @@
+use makepad_derive_widget::*;
+use makepad_micro_serde::*;
+use makepad_micro_serde::{DeRon, SerRon};
+use makepad_widgets::Dock;
use makepad_widgets::*;
live_design! {
import makepad_draw::shader::std::*;
import makepad_widgets::base::*;
import makepad_widgets::theme_desktop_dark::*;
-
ICO_SEARCH = dep("crate://self/resources/icons/Icon_Search.svg")
-
- SelectorModal = {
- content: {
- height: 600,
- width: 300,
- show_bg: true,
- draw_bg: {
- color: #3c3c3c
- }
- align: {
- x: 0.5,
- y: 0.5
- }
- {
-
- show_bg: true,
- draw_bg: {
- color: #3c3c3c
- radius: 3.0
- }
-
- notifacion_title =