inline boolean AllocationTableImpl::same_size( const Allotment& a1, const Allotment& a2 ) { return ( Math::equal(a1.span(), a2.span(), epsilon_) && Math::equal(a1.alignment(), a2.alignment(), epsilon_) ); }
void Slider::allot_thumb_major_axis( const Allocation& slider, DimensionName d, Adjustable* adj, Coord min_thumb_size, float& scale, Allotment& new_a ) { const Allotment& a = slider.allotment(d); Coord length = adj->length(d); Coord cur_length = adj->cur_length(d); Coord slider_size = a.span(); Coord thumb_size; Coord thumb_start; if (Math::equal(length, float(0.0), float(1e-3)) || Math::equal(length, cur_length, float(1e-3)) ) { thumb_size = slider_size; thumb_start = 0.0; scale = 1.0; } else { thumb_size = slider_size * cur_length / length; if (thumb_size > slider_size) { thumb_size = slider_size; thumb_start = 0.0; scale = 1.0; } else { if (thumb_size < min_thumb_size) { thumb_size = min_thumb_size; } scale = (slider_size - thumb_size) / (length - cur_length); thumb_start = scale * (adj->cur_lower(d) - adj->lower(d)); } } new_a.origin(a.begin() + thumb_start); new_a.span(thumb_size); new_a.alignment(0.0); }
void Slider::allot_thumb_minor_axis(const Allotment& a, Allotment& new_a) { new_a.origin(a.begin()); new_a.span(a.span()); new_a.alignment(0.0); }