Skip to content

Commit c8c1b90

Browse files
committed
Add shim DOM for scroll bar wrapper
1 parent 76f1d30 commit c8c1b90

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

azul-core/src/styled_dom.rs

+68
Original file line numberDiff line numberDiff line change
@@ -1536,8 +1536,12 @@ impl StyledDom {
15361536
}
15371537

15381538
/// Inject scroll bar DIVs with relevant event handlers into the DOM
1539+
///
1540+
/// This function essentially takes
15391541
pub fn inject_scroll_bars(&mut self) {
15401542

1543+
use azul_css_parser::CssApiWrapper;
1544+
15411545
// allocate 14 nodes for every node
15421546
//
15431547
// 0: root component
@@ -1557,6 +1561,70 @@ impl StyledDom {
15571561
// 14: |- self.root
15581562
// |- ... self.children
15591563

1564+
let dom_to_inject = Dom::div()
1565+
// .with_class("__azul-native-scroll-root-component".into())
1566+
.with_inline_style("display:flex; flex-grow:1; flex-direction:column;".into())
1567+
.with_children(vec![
1568+
1569+
Dom::div()
1570+
// .with_class("__azul-native-scroll-vertical-container".into())
1571+
.with_inline_style("display:flex; flex-grow:1; flex-direction:column-reverse;".into())
1572+
.with_children(vec![
1573+
1574+
Dom::div()
1575+
// .with_class("__azul-native-scroll-horizontal-scrollbar".into())
1576+
.with_inline_style("display:flex; flex-grow:1; flex-direction:row; height:15px; background:grey;".into())
1577+
.with_children(vec![
1578+
Dom::div(),
1579+
// .with_class("__azul-native-scroll-horizontal-scrollbar-track-left".into()),
1580+
Dom::div()
1581+
// .with_class("__azul-native-scroll-horizontal-scrollbar-track-middle".into())
1582+
.with_children(vec![
1583+
Dom::div()
1584+
// .with_class("__azul-native-scroll-horizontal-scrollbar-track-thumb".into())
1585+
].into()),
1586+
Dom::div()
1587+
// .with_class("__azul-native-scroll-horizontal-scrollbar-track-right".into()),
1588+
].into()),
1589+
1590+
Dom::div()
1591+
// .with_class("__azul-native-scroll-content-container-1".into())
1592+
.with_inline_style("display:flex; flex-grow:1; flex-direction:row-reverse;".into())
1593+
.with_children(vec![
1594+
1595+
Dom::div()
1596+
// .with_class("__azul-native-scroll-vertical-scrollbar".into())
1597+
.with_inline_style("display:flex; flex-grow:1; flex-direction:column; width:15px; background:grey;".into())
1598+
.with_children(vec![
1599+
Dom::div(),
1600+
// .with_class("__azul-native-scroll-vertical-scrollbar-track-top".into()),
1601+
Dom::div()
1602+
// .with_class("__azul-native-scroll-vertical-scrollbar-track-middle".into())
1603+
.with_children(vec![
1604+
Dom::div()
1605+
// .with_class("__azul-native-scroll-vertical-scrollbar-track-thumb".into())
1606+
].into()),
1607+
Dom::div()
1608+
// .with_class("__azul-native-scroll-vertical-scrollbar-track-bottom".into()),
1609+
].into()),
1610+
1611+
Dom::div()
1612+
// .with_class("__azul-native-scroll-content-container-1".into())
1613+
.with_inline_style("display:flex; flex-grow:1; flex-direction:column;".into())
1614+
.with_children(vec![
1615+
Dom::div() // <- this div is where the new children will be injected into
1616+
].into())
1617+
].into())
1618+
].into())
1619+
].into())
1620+
.style(CssApiWrapper::empty());
1621+
1622+
// pre-allocate a new DOM tree with self.nodes.len() * dom_to_inject.nodes.len() nodes
1623+
1624+
// inject self.root as the nth node
1625+
let inject_as_id = 0;
1626+
1627+
println!("inject scroll bars:\r\n{}", dom_to_inject.get_html_string("", "", true));
15601628
}
15611629

15621630
/// Inject a menu bar into the root component

0 commit comments

Comments
 (0)