Esempio n. 1
0
	void ListBoxView::layout_children(Canvas &canvas)
	{
		// Call parent.
		ScrollView::layout_children(canvas);

		// Content of the ListBoxView.
		auto items(content_view()->children());

		// Scroll to selected item if it needs.
		if (needScrollToSelected) {

			// Geometry of the selected item.
			const Rectf boxOfSelected = items.at(impl->selected_item)->geometry().margin_box();


			// Scroll position.
			double scrollPos = scrollbar_y_view()->position();

			// If the selected item above the visible area, scroll up to selected.
			if (boxOfSelected.top < scrollPos)
				scrollbar_y_view()->set_position(boxOfSelected.top);
			else {
				// If the lower part of selected item below the visible area, scroll down.
				if (boxOfSelected.bottom > scrollPos + geometry().content_height)
					scrollbar_y_view()->set_position(boxOfSelected.bottom - geometry().content_height);
			}

			// Clear the flag.
			needScrollToSelected = false;

			// Call parent again to update the scrolled positions.
			ScrollView::layout_children(canvas);
		}

		// Set line_step size equal to the height of first item.
		if (!items.empty()) {
			float height = items.front()->geometry().margin_box().get_height();
			scrollbar_y_view()->set_line_step(height);
		}
	}
Esempio n. 2
0
ThemeScrollView::ThemeScrollView()
{
	scrollbar_x_view()->style()->set("flex: 0 0 main-size");
	scrollbar_x_view()->style()->set("background: rgb(232, 232, 236)");
	scrollbar_x_view()->track()->style()->set("border-image-slice: 4 0 3 0 fill;");
	scrollbar_x_view()->track()->style()->set("border-image-width:4px 0px 3px 0px;");
	scrollbar_x_view()->track()->style()->set("border-image-repeat:stretch;");
	scrollbar_x_view()->track()->style()->set("border-image-source:url('Theme/scrollbar_hori_track_normal.png');");
	scrollbar_x_view()->track()->style("hot")->set("border-image-source:url('Theme/scrollbar_hori_track_hot.png');");
	scrollbar_x_view()->track()->style("pressed")->set("border-image-source:url('Theme/scrollbar_hori_track_pressed.png');");
	scrollbar_x_view()->track()->style("disabled")->set("border-image-source:url('Theme/scrollbar_hori_track_disabled.png');");

	scrollbar_x_view()->thumb()->style()->set("border-image-slice: 5 5 5 5 fill;");
	scrollbar_x_view()->thumb()->style()->set("border-image-width:5px 5px 5px 5px;");
	scrollbar_x_view()->thumb()->style()->set("border-image-repeat:stretch;");
	scrollbar_x_view()->thumb()->style()->set("border-image-source:url('Theme/scrollbar_hori_thumb_normal.png');");
	scrollbar_x_view()->thumb()->style("hot")->set("border-image-source:url('Theme/scrollbar_hori_thumb_hot.png');");
	scrollbar_x_view()->thumb()->style("pressed")->set("border-image-source:url('Theme/scrollbar_hori_thumb_pressed.png');");
	scrollbar_x_view()->thumb()->style("disabled")->set("border-image-source:url('Theme/scrollbar_hori_thumb_disabled.png');");

	scrollbar_x_view()->thumb_grip()->style()->set("background-position:center center;");
	scrollbar_x_view()->thumb_grip()->style()->set("background-repeat:no-repeat;");
	scrollbar_x_view()->thumb_grip()->style()->set("background-attachment:scroll; ");
	scrollbar_x_view()->thumb_grip()->style()->set("background-image:url('Theme/scrollbar_hori_thumb_gripper_normal.png');");
	scrollbar_x_view()->thumb_grip()->style("hot")->set("background-image:url('Theme/scrollbar_hori_thumb_gripper_hot.png');");
	scrollbar_x_view()->thumb_grip()->style("pressed")->set("background-image:url('Theme/scrollbar_hori_thumb_gripper_pressed.png');");
	scrollbar_x_view()->thumb_grip()->style("disabled")->set("background-image:url('Theme/scrollbar_hori_thumb_gripper_disabled.png');");

	scrollbar_x_view()->button_decrement()->style()->set("width:17px; height:17px");
	scrollbar_x_view()->button_decrement()->style()->set("border-image-slice: 3 3 3 3 fill;");
	scrollbar_x_view()->button_decrement()->style()->set("border-image-width:3px 3px 3px 3px;");
	scrollbar_x_view()->button_decrement()->style()->set("border-image-repeat:stretch;");
	scrollbar_x_view()->button_decrement()->style()->set("border-image-source:url('Theme/scrollbar_hori_button_left_normal_withglyph.png');");
	scrollbar_x_view()->button_decrement()->style("hot")->set("border-image-source:url('Theme/scrollbar_hori_button_left_hot_withglyph.png');");
	scrollbar_x_view()->button_decrement()->style("pressed")->set("border-image-source:url('Theme/scrollbar_hori_button_left_pressed_withglyph.png');");
	scrollbar_x_view()->button_decrement()->style("disabled")->set("border-image-source:url('Theme/scrollbar_hori_button_left_disabled_withglyph.png');");

	scrollbar_x_view()->button_increment()->style()->set("width:17px; height:17px");
	scrollbar_x_view()->button_increment()->style()->set("border-image-slice: 3 3 3 3 fill;");
	scrollbar_x_view()->button_increment()->style()->set("border-image-width:3px 3px 3px 3px;");
	scrollbar_x_view()->button_increment()->style()->set("border-image-repeat:stretch;");
	scrollbar_x_view()->button_increment()->style()->set("border-image-source:url('Theme/scrollbar_hori_button_right_normal_withglyph.png');");
	scrollbar_x_view()->button_increment()->style("hot")->set("border-image-source:url('Theme/scrollbar_hori_button_right_hot_withglyph.png');");
	scrollbar_x_view()->button_increment()->style("pressed")->set("border-image-source:url('Theme/scrollbar_hori_button_right_pressed_withglyph.png');");
	scrollbar_x_view()->button_increment()->style("disabled")->set("border-image-source:url('Theme/scrollbar_hori_button_right_disabled_withglyph.png');");

	scrollbar_y_view()->style()->set("flex: 0 0 main-size");
	scrollbar_y_view()->style()->set("background: rgb(232, 232, 236)");
	scrollbar_y_view()->track()->style()->set("border-image-slice: 4 0 3 0 fill;");
	scrollbar_y_view()->track()->style()->set("border-image-width:4px 0px 3px 0px;");
	scrollbar_y_view()->track()->style()->set("border-image-repeat:stretch;");
	scrollbar_y_view()->track()->style()->set("border-image-source:url('Theme/scrollbar_vert_track_normal.png');");
	scrollbar_y_view()->track()->style("hot")->set("border-image-source:url('Theme/scrollbar_vert_track_hot.png');");
	scrollbar_y_view()->track()->style("pressed")->set("border-image-source:url('Theme/scrollbar_vert_track_pressed.png');");
	scrollbar_y_view()->track()->style("disabled")->set("border-image-source:url('Theme/scrollbar_vert_track_disabled.png');");

	scrollbar_y_view()->thumb()->style()->set("border-image-slice: 5 5 5 5 fill;");
	scrollbar_y_view()->thumb()->style()->set("border-image-width:5px 5px 5px 5px;");
	scrollbar_y_view()->thumb()->style()->set("border-image-repeat:stretch;");
	scrollbar_y_view()->thumb()->style()->set("border-image-source:url('Theme/scrollbar_vert_thumb_normal.png');");
	scrollbar_y_view()->thumb()->style("hot")->set("border-image-source:url('Theme/scrollbar_vert_thumb_hot.png');");
	scrollbar_y_view()->thumb()->style("pressed")->set("border-image-source:url('Theme/scrollbar_vert_thumb_pressed.png');");
	scrollbar_y_view()->thumb()->style("disabled")->set("border-image-source:url('Theme/scrollbar_vert_thumb_disabled.png');");

	scrollbar_y_view()->thumb_grip()->style()->set("background-position:center center;");
	scrollbar_y_view()->thumb_grip()->style()->set("background-repeat:no-repeat;");
	scrollbar_y_view()->thumb_grip()->style()->set("background-attachment:scroll; ");
	scrollbar_y_view()->thumb_grip()->style()->set("background-image:url('Theme/scrollbar_vert_thumb_gripper_normal.png');");
	scrollbar_y_view()->thumb_grip()->style("hot")->set("background-image:url('Theme/scrollbar_vert_thumb_gripper_hot.png');");
	scrollbar_y_view()->thumb_grip()->style("pressed")->set("background-image:url('Theme/scrollbar_vert_thumb_gripper_pressed.png');");
	scrollbar_y_view()->thumb_grip()->style("disabled")->set("background-image:url('Theme/scrollbar_vert_thumb_gripper_disabled.png');");

	scrollbar_y_view()->button_decrement()->style()->set("width:17px; height:17px");
	scrollbar_y_view()->button_decrement()->style()->set("border-image-slice: 3 3 3 3 fill;");
	scrollbar_y_view()->button_decrement()->style()->set("border-image-width:3px 3px 3px 3px;");
	scrollbar_y_view()->button_decrement()->style()->set("border-image-repeat:stretch;");
	scrollbar_y_view()->button_decrement()->style()->set("border-image-source:url('Theme/scrollbar_vert_button_left_normal_withglyph.png');");
	scrollbar_y_view()->button_decrement()->style("hot")->set("border-image-source:url('Theme/scrollbar_vert_button_left_hot_withglyph.png');");
	scrollbar_y_view()->button_decrement()->style("pressed")->set("border-image-source:url('Theme/scrollbar_vert_button_left_pressed_withglyph.png');");
	scrollbar_y_view()->button_decrement()->style("disabled")->set("border-image-source:url('Theme/scrollbar_vert_button_left_disabled_withglyph.png');");

	scrollbar_y_view()->button_increment()->style()->set("width:17px; height:17px");
	scrollbar_y_view()->button_increment()->style()->set("border-image-slice: 3 3 3 3 fill;");
	scrollbar_y_view()->button_increment()->style()->set("border-image-width:3px 3px 3px 3px;");
	scrollbar_y_view()->button_increment()->style()->set("border-image-repeat:stretch;");
	scrollbar_y_view()->button_increment()->style()->set("border-image-source:url('Theme/scrollbar_vert_button_right_normal_withglyph.png');");
	scrollbar_y_view()->button_increment()->style("hot")->set("border-image-source:url('Theme/scrollbar_vert_button_right_hot_withglyph.png');");
	scrollbar_y_view()->button_increment()->style("pressed")->set("border-image-source:url('Theme/scrollbar_vert_button_right_pressed_withglyph.png');");
	scrollbar_y_view()->button_increment()->style("disabled")->set("border-image-source:url('Theme/scrollbar_vert_button_right_disabled_withglyph.png');");
}