Commit ff504666 authored by Florian Blasius's avatar Florian Blasius 🤘

working on scrollviewer

parent 7bc59a7c
......@@ -53,7 +53,7 @@ fn main() {
.bounds(Bounds::new(100.0, 100.0, 420.0, 730.0))
.title("OrbTk - minimal example")
.root(MainView::create())
.debug_flag(false)
.debug_flag(true)
.build();
application.run();
}
......@@ -114,7 +114,7 @@ impl Layout for ScrollLayout {
}
for child in &tree.children[&entity] {
let child_margin = get_margin(*child, ecm);
// let child_margin = get_margin(*child, ecm);
let mut child_size = old_child_size;
if let Some(child_layout) = layouts.borrow().get(child) {
......
......@@ -13,7 +13,7 @@ pub use self::padding::{Padding, PaddingProperty};
pub use self::point::Point;
pub use self::row::{GridRow, Row, RowBuilder, RowHeight, RowSpan, Rows, RowsBuilder, RowsProperty};
pub use self::scroll_mode::*;
pub use self::scroll_viewer_mode::ScrollViewerMode;
pub use self::scroll_viewer_mode::*;
pub use self::vertical_alignment::{VerticalAlignment, VerticalAlignmentProperty};
mod bounds;
......
......@@ -10,6 +10,8 @@ pub struct ScrollViewerMode {
pub horizontal: ScrollMode,
}
property!(ScrollViewerMode, ScrollViewerModeProperty, scroll_viewer_mode, shared_scroll_viewer_mode);
impl ScrollViewerMode {
/// Creates a new scroll viewer mode.
pub fn new(vertical: ScrollMode, horizontal: ScrollMode) -> Self {
......
......@@ -30,6 +30,7 @@ pub use self::container::*;
pub use self::font_icon_block::*;
pub use self::grid::*;
pub use self::image_widget::*;
pub use self::scroll_viewer::ScrollViewer;
pub use self::switch::*;
pub use self::stack::*;
pub use self::text_block::*;
......@@ -46,6 +47,7 @@ mod container;
mod font_icon_block;
mod grid;
mod image_widget;
mod scroll_viewer;
mod switch;
mod stack;
mod text_block;
......
use crate::{
enums::ParentType,
layout::ScrollLayout,
properties::{Offset, ScrollViewerMode},
properties::{Offset, OffsetProperty, ScrollViewerMode, ScrollViewerModeProperty},
widget::{Template, Widget},
};
......@@ -20,12 +20,18 @@ use crate::{
pub struct ScrollViewer;
impl Widget for ScrollViewer {
fn create() -> Template {
Template::new()
.parent_type(ParentType::Single)
.property(Offset::default())
.property(ScrollViewerMode::default())
type Template = ScrollViewerTemplate;
fn create() -> Self::Template {
ScrollViewerTemplate::new()
.offset(0.0)
.scroll_viewer_mode(ScrollViewerMode::default())
.layout(ScrollLayout::default())
.debug_name("ScrollViewer")
}
}
template!(
ScrollViewerTemplate,
[OffsetProperty, ScrollViewerModeProperty]
);
......@@ -7,11 +7,11 @@ use crate::{
event::{Key, KeyEventHandler, MouseEventHandler},
properties::{ ScrollMode,
Bounds, Constraint, Focused, FocusedProperty, Offset, Point, ScrollViewerMode, Text,
TextProperty, TextSelection, WaterMark, PaddingProperty, WaterMarkProperty
TextProperty, TextSelection, WaterMark, PaddingProperty, WaterMarkProperty, OffsetProperty, ScrollViewerModeProperty
},
structs::{Position, Size},
theme::Selector,
widget::{Container, Context, Grid, SharedProperty, State, Template, TextBlock, Widget, WaterMarkTextBlock},
widget::{Container, Context, Grid, SharedProperty, State, Template, TextBlock, Widget, WaterMarkTextBlock, ScrollViewer},
};
/// The `TextBoxState` handles the text processing of the `TextBox` widget.
......@@ -200,7 +200,7 @@ impl Widget for TextBox {
.child(
Grid::create()
.child(
Grid::create()
ScrollViewer::create()
.child(
WaterMarkTextBlock::create()
.vertical_alignment("Center")
......@@ -209,11 +209,11 @@ impl Widget for TextBox {
.attach_shared_property(focused.clone())
.selector(selector.clone().id("TextBoxTextBlock")),
)
// .shared_property(offset.clone())
// .property(ScrollViewerMode::new(
// ScrollMode::None,
// ScrollMode::None,
// ))
.shared_offset(offset.clone())
.scroll_viewer_mode(ScrollViewerMode::new(
ScrollMode::None,
ScrollMode::None,
))
.selector(Selector::from("scrollviewer").id("TextBoxScrollViewer")),
)
// .child(
......@@ -238,7 +238,7 @@ impl Widget for TextBox {
.selector(selector)
.shared_water_mark(water_mark)
// .shared_property(selection)
.attach_property(offset)
.attach_shared_property(offset)
.shared_focused(focused)
.event_handler(
KeyEventHandler::default()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment