Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions benchmark/benches/size_probe_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl ObjectImpl for TestWidget {}
impl WidgetImpl for TestWidget {}

impl TestWidget {
pub fn new() -> Box<Self> {
Object::new(&[])
pub fn new() -> Tr<Self> {
Self::new_alloc()
}
}
4 changes: 2 additions & 2 deletions examples/async_task/async_task_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl WidgetImpl for AsyncTaskWidget {}

impl AsyncTaskWidget {
#[inline]
pub fn new() -> Box<Self> {
Object::new(&[])
pub fn new() -> Tr<Self> {
Self::new_alloc()
}
}
4 changes: 2 additions & 2 deletions examples/border/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ fn main() {

fn build_ui(window: &mut ApplicationWindow) {
let mut hbox = HBox::new();
let mut widget1: Box<Widget> = Object::new(&[]);
let mut widget2: Box<Widget> = Object::new(&[]);
let mut widget1 = Widget::new_alloc();
let mut widget2 = Widget::new_alloc();

widget1.set_background(Color::CYAN);
widget1.width_request(400);
Expand Down
6 changes: 3 additions & 3 deletions examples/box_layout/hbox_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use tmui::{label::Label, prelude::*};
#[derive(Childrenable)]
pub struct HBoxLayout {
#[children]
label_1: Box<Label>,
label_1: Tr<Label>,

#[children]
label_2: Box<Label>,
label_2: Tr<Label>,

#[children]
label_3: Box<Label>,
label_3: Tr<Label>,
}

impl ObjectSubclass for HBoxLayout {
Expand Down
10 changes: 5 additions & 5 deletions examples/box_layout/vbox_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use crate::hbox_layout::HBoxLayout;
#[derive(Childrenable)]
pub struct VBoxLayout {
#[children]
hbox_1: Box<HBoxLayout>,
hbox_1: Tr<HBoxLayout>,

#[children]
hbox_2: Box<HBoxLayout>,
hbox_2: Tr<HBoxLayout>,

#[children]
hbox_3: Box<HBoxLayout>,
hbox_3: Tr<HBoxLayout>,
}

impl ObjectSubclass for VBoxLayout {
Expand All @@ -39,7 +39,7 @@ impl ObjectImpl for VBoxLayout {
impl WidgetImpl for VBoxLayout {}

impl VBoxLayout {
pub fn new() -> Box<Self> {
Object::new(&[])
pub fn new() -> Tr<Self> {
Self::new_alloc()
}
}
2 changes: 1 addition & 1 deletion examples/box_shadow/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
}

fn build_ui(window: &mut ApplicationWindow) {
let mut widget: Box<Widget> = Object::new(&[]);
let mut widget = Widget::new_alloc();
widget.width_request(400);
widget.height_request(200);
widget.set_hexpand(true);
Expand Down
6 changes: 3 additions & 3 deletions examples/child_attr_widget/child_attr_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tmui::{
#[derive(Childable)]
pub struct ChildAttrWidget {
#[child]
label: Box<Label>,
label: Tr<Label>,
}

impl ObjectSubclass for ChildAttrWidget {
Expand All @@ -28,7 +28,7 @@ impl ObjectImpl for ChildAttrWidget {
impl WidgetImpl for ChildAttrWidget {}

impl ChildAttrWidget {
pub fn new() -> Box<Self> {
Object::new(&[])
pub fn new() -> Tr<Self> {
Self::new_alloc()
}
}
6 changes: 3 additions & 3 deletions examples/complex_layout/ctx_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tmui::{
#[derive(Childable)]
pub struct CtxMenu {
#[child]
list: Box<ListView>,
list: Tr<ListView>,
}

impl ObjectSubclass for CtxMenu {
Expand Down Expand Up @@ -75,8 +75,8 @@ impl PopupImpl for CtxMenu {

impl CtxMenu {
#[inline]
pub fn new() -> Box<Self> {
Object::new(&[])
pub fn new() -> Tr<Self> {
Self::new_alloc()
}
}

Expand Down
6 changes: 3 additions & 3 deletions examples/complex_layout/layouts/central_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use super::{right_panel::RightPanel, LeftPanel};
#[derive(Childrenable)]
pub struct CentralPanel {
#[children]
widget1: Box<LeftPanel>,
widget1: Tr<LeftPanel>,

#[children]
widget2: Box<RightPanel>,
widget2: Tr<RightPanel>,
}

impl ObjectSubclass for CentralPanel {
Expand All @@ -33,4 +33,4 @@ impl ObjectImpl for CentralPanel {
}
}

impl WidgetImpl for CentralPanel {}
impl WidgetImpl for CentralPanel {}
6 changes: 3 additions & 3 deletions examples/complex_layout/layouts/left_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use super::{ActivityBar, WorkspacePanel};
#[derive(Childrenable)]
pub struct LeftPanel {
#[children]
activity_bar: Box<ActivityBar>,
activity_bar: Tr<ActivityBar>,

#[children]
workspace_panel: Box<WorkspacePanel>,
workspace_panel: Tr<WorkspacePanel>,
}

impl ObjectSubclass for LeftPanel {
Expand All @@ -38,4 +38,4 @@ impl LeftPanel {
self.show()
}
}
}
}
4 changes: 2 additions & 2 deletions examples/complex_layout/layouts/right_panel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use self::split_pane::MySplitPane;
#[derive(Childrenable)]
pub struct RightPanel {
#[children]
split_pane: Box<MySplitPane>,
split_pane: Tr<MySplitPane>,
}

impl ObjectSubclass for RightPanel {
Expand All @@ -27,4 +27,4 @@ impl ObjectImpl for RightPanel {
}
}

impl WidgetImpl for RightPanel {}
impl WidgetImpl for RightPanel {}
4 changes: 2 additions & 2 deletions examples/complex_layout/layouts/right_panel/split_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ impl ObjectImpl for MySplitPane {
self.set_hexpand(true);
self.set_vexpand(true);

let mut widget: Box<MyStack> = Object::new(&[]);
let mut widget = MyStack::new_alloc();
widget.set_background(Color::CYAN);
widget.set_vexpand(true);
widget.set_hexpand(true);

let mut scroll_area: Box<ScrollArea> = Object::new(&[]);
let mut scroll_area = ScrollArea::new_alloc();
scroll_area.set_scroll_bar_position(ScrollBarPosition::End);
scroll_area.set_orientation(Orientation::Vertical);
scroll_area.set_hexpand(true);
Expand Down
11 changes: 7 additions & 4 deletions examples/complex_layout/layouts/right_panel/stack.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use tmui::{
label::Label, prelude::*, tlib::object::{ObjectImpl, ObjectSubclass}, widget::WidgetImpl
label::Label,
prelude::*,
tlib::object::{ObjectImpl, ObjectSubclass},
widget::WidgetImpl,
};

#[extends(Widget, Layout(Stack))]
#[derive(Childrenable)]
pub struct MyStack {
#[children]
label_1: Box<Label>,
label_1: Tr<Label>,

#[children]
label_2: Box<Label>,
label_2: Tr<Label>,
}

impl ObjectSubclass for MyStack {
Expand All @@ -29,4 +32,4 @@ impl ObjectImpl for MyStack {
}
}

impl WidgetImpl for MyStack {}
impl WidgetImpl for MyStack {}
8 changes: 4 additions & 4 deletions examples/complex_layout/layouts/title_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use super::{app_icon::AppIcon, WinCtrlBtns};
#[derive(Childrenable)]
pub struct TitleBar {
#[children]
app_icon: Box<AppIcon>,
app_icon: Tr<AppIcon>,

#[children]
widget2: Box<Widget>,
widget2: Tr<Widget>,

#[children]
win_ctrl_btns: Box<WinCtrlBtns>
win_ctrl_btns: Tr<WinCtrlBtns>,
}

impl ObjectSubclass for TitleBar {
Expand All @@ -43,4 +43,4 @@ impl ObjectImpl for TitleBar {
}
}

impl WidgetImpl for TitleBar {}
impl WidgetImpl for TitleBar {}
10 changes: 5 additions & 5 deletions examples/complex_layout/layouts/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use super::{CentralPanel, StatusBar, TitleBar};
#[global_watch(MouseMove, MousePressed, MouseReleased)]
pub struct View {
#[children]
title_bar: Box<TitleBar>,
title_bar: Tr<TitleBar>,

#[children]
central_panel: Box<CentralPanel>,
central_panel: Tr<CentralPanel>,

#[children]
status_bar: Box<StatusBar>,
status_bar: Tr<StatusBar>,

resize_zone: bool,
resize_pressed: bool,
Expand All @@ -40,8 +40,8 @@ impl WidgetImpl for View {}

impl View {
#[inline]
pub fn new() -> Box<Self> {
Object::new(&[])
pub fn new() -> Tr<Self> {
Self::new_alloc()
}
}

Expand Down
6 changes: 3 additions & 3 deletions examples/complex_layout/layouts/win_ctrl_btns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ pub struct WinCtrlBtns {
SvgIcon::from_bytes(file.data.as_ref())
}"))]
#[children]
minimize: Box<SvgIcon>,
minimize: Tr<SvgIcon>,

#[derivative(Default(value = "{
let maximize = Asset::get(\"large.svg\").unwrap();
let restore = Asset::get(\"restore.svg\").unwrap();
SvgToggleIcon::from_bytes(&[maximize.data.as_ref(), restore.data.as_ref()])
}"))]
#[children]
large_restore: Box<SvgToggleIcon>,
large_restore: Tr<SvgToggleIcon>,

#[derivative(Default(value = "{
let file = Asset::get(\"close.svg\").unwrap();
SvgIcon::from_bytes(file.data.as_ref())
}"))]
#[children]
close: Box<SvgIcon>,
close: Tr<SvgIcon>,
}

impl ObjectSubclass for WinCtrlBtns {
Expand Down
2 changes: 1 addition & 1 deletion examples/complex_layout/layouts/workspace_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl ObjectImpl for WorkspacePanel {
fn construct(&mut self) {
self.parent_construct();

self.add_popup(CtxMenu::new());
self.add_popup(CtxMenu::new().to_dyn_popup_tr());
}

fn initialize(&mut self) {
Expand Down
4 changes: 2 additions & 2 deletions examples/custom_diff_handle/my_diff_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl WidgetImpl for MyDiffWidget {}

impl MyDiffWidget {
#[inline]
pub fn new() -> Box<Self> {
Object::new(&[])
pub fn new() -> Tr<Self> {
Self::new_alloc()
}
}
6 changes: 3 additions & 3 deletions examples/custom_diff_handle/my_split_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl WidgetImpl for MySplitPane {}

impl MySplitPane {
#[inline]
pub fn new() -> Box<Self> {
Object::new(&[])
pub fn new() -> Tr<Self> {
Self::new_alloc()
}
}
}
8 changes: 4 additions & 4 deletions examples/custom_popup/my_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use tmui::{
#[derive(Childrenable)]
pub struct MyBox {
#[children]
content_widget: Box<Widget>,
content_widget: Tr<Widget>,

#[children]
bottom_bar: Box<MyWidget>,
bottom_bar: Tr<MyWidget>,
}

impl ObjectSubclass for MyBox {
Expand Down Expand Up @@ -42,7 +42,7 @@ impl WidgetImpl for MyBox {}

impl MyBox {
#[inline]
pub fn new() -> Box<Self> {
Object::new(&[])
pub fn new() -> Tr<Self> {
Self::new_alloc()
}
}
Loading