MCPcopy Create free account
hub / github.com/davisking/dlib / set_length

Method set_length

dlib/gui_widgets/base_widgets.cpp:690–743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

688// ----------------------------------------------------------------------------------------
689
690 void scroll_bar::
691 set_length (
692 unsigned long length
693 )
694 {
695 auto_mutex M(m);
696 // make the min length be at least 1
697 if (length == 0)
698 {
699 length = 1;
700 }
701
702
703 parent.invalidate_rectangle(rect);
704
705 if (ori == HORIZONTAL)
706 {
707 rect.set_right(rect.left() + length - 1);
708 rect.set_bottom(rect.top() + style->get_width() - 1);
709
710 const long btn_size = style->get_button_length(rect.width(), max_pos);
711
712 b1.set_size(btn_size,style->get_width());
713 b2.set_size(btn_size,style->get_width());
714
715 slider.set_size(get_slider_size(),style->get_width());
716 }
717 else
718 {
719 rect.set_right(rect.left() + style->get_width() - 1);
720 rect.set_bottom(rect.top() + length - 1);
721
722 const long btn_size = style->get_button_length(rect.height(), max_pos);
723
724 b1.set_size(style->get_width(),btn_size);
725 b2.set_size(style->get_width(),btn_size);
726
727 slider.set_size(style->get_width(),get_slider_size());
728 }
729
730 // call this to put everything is in the right spot.
731 set_pos (rect.left(),rect.top());
732
733 if ((b2.get_rect().top() - b1.get_rect().bottom() - 1 <= 8 && ori == VERTICAL) ||
734 (b2.get_rect().left() - b1.get_rect().right() - 1 <= 8 && ori == HORIZONTAL) ||
735 max_pos == 0)
736 {
737 hide_slider();
738 }
739 else if (enabled && !hidden)
740 {
741 show_slider();
742 }
743 }
744
745// ----------------------------------------------------------------------------------------
746

Callers

nothing calls this directly

Calls 11

set_rightMethod · 0.80
set_bottomMethod · 0.80
leftMethod · 0.45
topMethod · 0.45
get_widthMethod · 0.45
widthMethod · 0.45
set_sizeMethod · 0.45
heightMethod · 0.45
get_rectMethod · 0.45
bottomMethod · 0.45
rightMethod · 0.45

Tested by

no test coverage detected