SliderView::SliderView() : impl(std::make_shared<SliderViewImpl>()) { impl->slider = this; impl->track = std::make_shared<View>(); impl->thumb = std::make_shared<View>(); add_subview(impl->track); add_subview(impl->thumb); slots.connect(sig_pointer_press(), impl.get(), &SliderViewImpl::on_pointer_track_press); slots.connect(sig_pointer_release(), impl.get(), &SliderViewImpl::on_pointer_track_release); slots.connect(impl->thumb->sig_pointer_press(), impl.get(), &SliderViewImpl::on_pointer_thumb_press); slots.connect(impl->thumb->sig_pointer_release(), impl.get(), &SliderViewImpl::on_pointer_thumb_release); slots.connect(impl->thumb->sig_pointer_enter(), [&](PointerEvent &e) {impl->_state_hot = true; impl->update_state(); }); slots.connect(impl->thumb->sig_pointer_leave(), [&](PointerEvent &e) {impl->_state_hot = false; impl->update_state(); }); slots.connect(impl->thumb->sig_pointer_move(), impl.get(), &SliderViewImpl::on_pointer_move); slots.connect(sig_focus_gained(), impl.get(), &SliderViewImpl::on_focus_gained); slots.connect(sig_focus_lost(), impl.get(), &SliderViewImpl::on_focus_lost); slots.connect(sig_activated(), impl.get(), &SliderViewImpl::on_activated); slots.connect(sig_activated(), impl.get(), &SliderViewImpl::on_deactivated); impl->scroll_timer.func_expired() = clan::bind_member(impl.get(), &SliderViewImpl::scroll_timer_expired); set_vertical(); }
// Constructor to set the parameters for finding aligned and ragged tabs. // Vertical_x and vertical_y are the current estimates of the true vertical // direction (up) in the image. Height is the height of the starter blob. // v_gap_multiple is the multiple of height that will be used as a limit // on vertical gap before giving up and calling the line ended. // resolution is the original image resolution, and align0 indicates the // type of tab stop to be found. AlignedBlobParams::AlignedBlobParams(int vertical_x, int vertical_y, int height, int v_gap_multiple, int resolution, TabAlignment align0) : right_tab(align0 == TA_RIGHT_RAGGED || align0 == TA_RIGHT_ALIGNED), ragged(align0 == TA_LEFT_RAGGED || align0 == TA_RIGHT_RAGGED), alignment(align0), confirmed_type(TT_CONFIRMED), min_length(0) { // Set the tolerances according to the type of line sought. // For tab search, these are based on the image resolution for most, or // the height of the starting blob for the maximum vertical gap. max_v_gap = height * v_gap_multiple; if (ragged) { // In the case of a ragged edge, we are much more generous with the // inside alignment fraction, but also require a much bigger gutter. gutter_fraction = kRaggedGapFraction; if (alignment == TA_RIGHT_RAGGED) { l_align_tolerance = static_cast<int>(resolution * kRaggedFraction + 0.5); r_align_tolerance = static_cast<int>(resolution * kAlignedFraction + 0.5); } else { l_align_tolerance = static_cast<int>(resolution * kAlignedFraction + 0.5); r_align_tolerance = static_cast<int>(resolution * kRaggedFraction + 0.5); } min_points = kMinRaggedTabs; } else { gutter_fraction = kAlignedGapFraction; l_align_tolerance = static_cast<int>(resolution * kAlignedFraction + 0.5); r_align_tolerance = static_cast<int>(resolution * kAlignedFraction + 0.5); min_points = kMinAlignedTabs; } min_gutter = static_cast<int>(height * gutter_fraction + 0.5); // Fit the vertical vector into an ICOORD, which is 16 bit. set_vertical(vertical_x, vertical_y); }
// Constructor to set the parameters for finding vertical lines. // Vertical_x and vertical_y are the current estimates of the true vertical // direction (up) in the image. Width is the width of the starter blob. AlignedBlobParams::AlignedBlobParams(int vertical_x, int vertical_y, int width) : gutter_fraction(0.0), right_tab(false), ragged(false), alignment(TA_SEPARATOR), confirmed_type(TT_VLINE), max_v_gap(kVLineSearchSize), min_gutter(kVLineGutter), min_points(1), min_length(kVLineMinLength) { // Compute threshold for left and right alignment. l_align_tolerance = std::max(kVLineAlignment, width); r_align_tolerance = std::max(kVLineAlignment, width); // Fit the vertical vector into an ICOORD, which is 16 bit. set_vertical(vertical_x, vertical_y); }
ScrollBarView::ScrollBarView(bool render_button_arrows) : impl(std::make_shared<ScrollBarViewImpl>()) { impl->scrollbar = this; impl->button_decrement = std::make_shared<ScrollBarButtonView>(render_button_arrows); impl->button_increment = std::make_shared<ScrollBarButtonView>(render_button_arrows); impl->track = std::make_shared<View>(); impl->thumb = std::make_shared<View>(); impl->thumb_grip = std::make_shared<View>(); auto spacer1 = std::make_shared<View>(); auto spacer2 = std::make_shared<View>(); add_child(impl->button_decrement); add_child(impl->track); add_child(impl->button_increment); impl->track->add_child(impl->thumb); impl->thumb->add_child(spacer1); impl->thumb->add_child(impl->thumb_grip); impl->thumb->add_child(spacer2); impl->button_decrement->style()->set("flex: 0 0 auto"); impl->button_increment->style()->set("flex: 0 0 auto"); impl->track->style()->set("flex: 1 1 auto"); impl->thumb->style()->set("position: absolute"); spacer1->style()->set("flex: 1 1 auto"); spacer2->style()->set("flex: 1 1 auto"); impl->button_decrement->style()->set("width: 17px; height: 17px"); impl->button_increment->style()->set("width: 17px; height: 17px"); slots.connect(impl->track->sig_pointer_press(), impl.get(), &ScrollBarViewImpl::on_pointer_track_press); slots.connect(impl->track->sig_pointer_double_click(), impl.get(), &ScrollBarViewImpl::on_pointer_track_press); slots.connect(impl->track->sig_pointer_release(), impl.get(), &ScrollBarViewImpl::on_pointer_track_release); slots.connect(impl->thumb->sig_pointer_press(), impl.get(), &ScrollBarViewImpl::on_pointer_thumb_press); slots.connect(impl->thumb->sig_pointer_double_click(), impl.get(), &ScrollBarViewImpl::on_pointer_thumb_press); slots.connect(impl->thumb->sig_pointer_release(), impl.get(), &ScrollBarViewImpl::on_pointer_thumb_release); slots.connect(impl->button_decrement->sig_pointer_press(), impl.get(), &ScrollBarViewImpl::on_pointer_decrement_press); slots.connect(impl->button_decrement->sig_pointer_double_click(), impl.get(), &ScrollBarViewImpl::on_pointer_decrement_press); slots.connect(impl->button_decrement->sig_pointer_release(), impl.get(), &ScrollBarViewImpl::on_pointer_decrement_release); slots.connect(impl->button_increment->sig_pointer_press(), impl.get(), &ScrollBarViewImpl::on_pointer_increment_press); slots.connect(impl->button_increment->sig_pointer_double_click(), impl.get(), &ScrollBarViewImpl::on_pointer_increment_press); slots.connect(impl->button_increment->sig_pointer_release(), impl.get(), &ScrollBarViewImpl::on_pointer_increment_release); slots.connect(impl->thumb->sig_pointer_move(), impl.get(), &ScrollBarViewImpl::on_pointer_move); slots.connect(sig_focus_gained(), impl.get(), &ScrollBarViewImpl::on_focus_gained); slots.connect(sig_focus_lost(), impl.get(), &ScrollBarViewImpl::on_focus_lost); slots.connect(sig_activated(), impl.get(), &ScrollBarViewImpl::on_activated); slots.connect(sig_activated(), impl.get(), &ScrollBarViewImpl::on_deactivated); slots.connect(impl->track->sig_pointer_enter(), [&](PointerEvent &e) {impl->_state_track_hot = true; impl->update_track_state(); }); slots.connect(impl->track->sig_pointer_leave(), [&](PointerEvent &e) {impl->_state_track_hot = false; impl->update_track_state(); }); slots.connect(impl->thumb->sig_pointer_enter(), [&](PointerEvent &e) {impl->_state_thumb_hot = true; impl->update_thumb_state(); }); slots.connect(impl->thumb->sig_pointer_leave(), [&](PointerEvent &e) {impl->_state_thumb_hot = false; impl->update_thumb_state(); }); slots.connect(impl->thumb_grip->sig_pointer_enter(), [&](PointerEvent &e) {impl->_state_thumb_hot = true; impl->update_thumb_state(); }); slots.connect(impl->thumb_grip->sig_pointer_leave(), [&](PointerEvent &e) {impl->_state_thumb_hot = false; impl->update_thumb_state(); }); slots.connect(spacer1->sig_pointer_enter(), [&](PointerEvent &e) {impl->_state_thumb_hot = true; impl->update_thumb_state(); }); slots.connect(spacer1->sig_pointer_leave(), [&](PointerEvent &e) {impl->_state_thumb_hot = false; impl->update_thumb_state(); }); slots.connect(spacer2->sig_pointer_enter(), [&](PointerEvent &e) {impl->_state_thumb_hot = true; impl->update_thumb_state(); }); slots.connect(spacer2->sig_pointer_leave(), [&](PointerEvent &e) {impl->_state_thumb_hot = false; impl->update_thumb_state(); }); slots.connect(impl->button_decrement->sig_pointer_enter(), [&](PointerEvent &e) {impl->_state_decrement_hot = true; impl->update_decrement_state(); }); slots.connect(impl->button_decrement->sig_pointer_leave(), [&](PointerEvent &e) {impl->_state_decrement_hot = false; impl->update_decrement_state(); }); slots.connect(impl->button_increment->sig_pointer_enter(), [&](PointerEvent &e) {impl->_state_increment_hot = true; impl->update_increment_state(); }); slots.connect(impl->button_increment->sig_pointer_leave(), [&](PointerEvent &e) {impl->_state_increment_hot = false; impl->update_increment_state(); }); impl->scroll_timer.func_expired() = clan::bind_member(impl.get(), &ScrollBarViewImpl::scroll_timer_expired); set_vertical(); }