예제 #1
0
void DebugGlyph::print(Printer* p, const Allocation& a) const {
    if ((flags_ & trace_print) != 0) {
	heading("print ");
	print_allotment(a.allotment(Dimension_X));
	printf(", ");
	print_allotment(a.allotment(Dimension_Y));
	printf("\n");
    }
    MonoGlyph::print(p, a);
}
예제 #2
0
void DebugGlyph::allocate(Canvas* c, const Allocation& a, Extension& ext) {
    if ((flags_ & trace_allocate) != 0) {
	heading("allocate ");
	print_allotment(a.allotment(Dimension_X));
	printf(", ");
	print_allotment(a.allotment(Dimension_Y));
	printf("\n");
    }
    MonoGlyph::allocate(c, a, ext);
}
예제 #3
0
void DebugGlyph::pick(Canvas* c, const Allocation& a, int depth, Hit& h) {
    if ((flags_ & trace_pick) != 0) {
	heading("pick ");
	printf(
	    "at (%.2f,%.2f,%.2f,%.2f) ",
	    h.left(), h.bottom(), h.right(), h.top()
	);
	print_allotment(a.allotment(Dimension_X));
	printf(", ");
	print_allotment(a.allotment(Dimension_Y));
	printf("\n");
    }
    MonoGlyph::pick(c, a, depth, h);
}
예제 #4
0
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);
}
예제 #5
0
void DebugGlyph::draw(Canvas* c, const Allocation& a) const {
    if ((flags_ & trace_draw) != 0) {
	heading("draw ");
	print_allotment(a.allotment(Dimension_X));
	printf(", ");
	print_allotment(a.allotment(Dimension_Y));
	if (c != nil) {
	    Extension e;
	    c->damage_area(e);
	    printf(
		" [%.2f,%.2f %.2f,%.2f]",
		e.left(), e.bottom(), e.right(), e.top()
	    );
	}
	printf("\n");
    }
    MonoGlyph::draw(c, a);
}