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); }
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 Page::allocate(Canvas* c, const Allocation& allocation, Extension& ext) { canvas_ = c; allocation_ = allocation; if (background_ != nil) { background_->allocate(c, allocation, ext); } GlyphIndex count = info_->count(); for (GlyphIndex index = 0; index < count; ++index) { PageInfo& info = info_->item_ref(index); if (info.glyph_ != nil) { Allocation& a = info.allocation_; Extension& b = info.extension_; Requisition s; info.glyph_->request(s); Allotment ax = Allotment( allocation.x() + info.x_, s.requirement(Dimension_X).natural(), s.requirement(Dimension_X).alignment() ); Allotment ay = Allotment( allocation.y() + info.y_, s.requirement(Dimension_Y).natural(), s.requirement(Dimension_Y).alignment() ); if ( !(info.status_ & PageInfoAllocated) || !ax.equals(a.allotment(Dimension_X), epsilon) || !ay.equals(a.allotment(Dimension_Y), epsilon) ) { if (c != nil && (info.status_ & PageInfoExtended)) { c->damage(b); } a.allot(Dimension_X, ax); a.allot(Dimension_Y, ay); b.clear(); info.glyph_->allocate(c, a, b); if (c != nil) { c->damage(b); } } info.status_ |= PageInfoAllocated|PageInfoExtended; ext.merge(b); } } }
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); }
void DebugGlyph::print_allotment(const Allotment& a) { printf( "%.2f,%.2f @ %.2f", a.begin(), a.end(), a.alignment() ); }