MCPcopy Create free account
hub / github.com/angular-rust/ux-components / init

Method init

src/rendering/backend/native/button.rs:80–149  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

78 }
79
80 fn init(&self) {
81 println!("INIT BUTTON");
82
83 self.inner.set_reactive(true);
84
85 self.inner.set_background_color(Some(color::PINK_9));
86
87 // g_signal_connect (button, "style-changed",
88 // G_CALLBACK (button_style_changed), NULL);
89 // g_signal_connect (button, "actor-added",
90 // G_CALLBACK (button_actor_added), NULL);
91 // g_signal_connect (button, "actor-removed",
92 // G_CALLBACK (button_actor_removed), NULL);
93
94 let mut props = self.props.borrow_mut();
95 props.icon_visible = true;
96 props.label_visible = true;
97 props.icon_position = Position::Left;
98
99 // take an extra reference to the hbox
100 // priv->hbox = g_object_ref (box_layout_new ());
101 // clutter_actor_add_child (CLUTTER_ACTOR (button), priv->hbox);
102
103 if let Some(name) = &props.icon_name {
104 println!("ADD ICON TO BUTTON [{}]", name);
105 let icon = Icon::new();
106 // priv->icon = icon_new ();
107 // clutter_actor_add_child (priv->hbox, priv->icon);
108
109 self.inner.add_child(&icon);
110 }
111
112 if let Some(text) = &props.text {
113 let style = Theme::global().get(StyleClass::MdcButton).unwrap();
114 let mut fontfamily = if let Some(fontfamily) = style.fontfamily {
115 fontfamily
116 } else {
117 "Roboto".into()
118 };
119
120 fontfamily.push_str(" Normal 14px");
121
122 println!("ADD TEXT TO BUTTON [{}] [{}]", text, fontfamily);
123 let label = Text::with_text(Some(fontfamily.as_str()), text.as_str());
124 // priv->label = g_object_new (CLUTTER_TYPE_TEXT,
125 // "line-alignment", PANGO_ALIGN_CENTER,
126 // "ellipsize", PANGO_ELLIPSIZE_END,
127 // NULL);
128 // clutter_actor_add_child (priv->hbox, priv->label);
129 // let actor: &Actor = label.as_ref();
130 // self.inner.add_child(&label);
131 }
132
133 // box_layout_child_set_expand (BOX_LAYOUT (priv->hbox),
134 // priv->label, TRUE);
135 // box_layout_child_set_y_fill (BOX_LAYOUT (priv->hbox),
136 // priv->label, FALSE);
137 // box_layout_child_set_x_fill (BOX_LAYOUT (priv->hbox),

Callers 3

newMethod · 0.45
with_labelMethod · 0.45
with_iconMethod · 0.45

Calls 3

set_background_colorMethod · 0.80
add_childMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected