Fresco/Berlin/modules/Layout GridImpl.cc,1.31,1.32 StageImpl.cc,1.53,1.54 StageImpl.hh,1.26,1.27 ViewportImpl.cc,1.33,1.34 ViewportImpl.hh,1.18,1.19
Tobias Hunger <[email protected]> Mon, 27 Oct 2003 17:09:13 +0000
| Newsgroups | gmane.comp.video.fresco.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/fresco/Fresco/Berlin/modules/Layout In directory purcel:/tmp/cvs-serv5328/Berlin/modules/Layout Modified Files: GridImpl.cc StageImpl.cc StageImpl.hh ViewportImpl.cc ViewportImpl.hh Log Message: Make sure all classes defined by Kits are in the Kit's namespace. Do some coding style fixups while touching the files anyway. Index: GridImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Layout/GridImpl.cc,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- GridImpl.cc 18 Oct 2003 13:59:54 -0000 1.31 +++ GridImpl.cc 27 Oct 2003 17:08:37 -0000 1.32 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -68,182 +68,195 @@ r->upper.y += dy; } -class LayoutAlignRequest -{ -public: - LayoutAlignRequest(); - - void margin(Coord margin); - - void accumulate(const Graphic::Requirement &r); - void requirement(Graphic::Requirement &r) const; - -protected: - Coord natural_lead; - Coord min_lead; - Coord max_lead; - Coord natural_trail; - Coord min_trail; - Coord max_trail; -}; - -LayoutAlignRequest::LayoutAlignRequest() - : natural_lead(0), min_lead(-GraphicImpl::infinity), max_lead(GraphicImpl::infinity), - natural_trail(0), min_trail(-GraphicImpl::infinity), max_trail(GraphicImpl::infinity) -{ -} - -void LayoutAlignRequest::margin(Coord margin) -{ - natural_lead += margin; - min_lead -= margin; - max_lead += margin; - natural_trail += margin; - min_trail -= margin; - max_trail += margin; -} - -void LayoutAlignRequest::accumulate(const Graphic::Requirement &r) +namespace Berlin { - if (r.defined) + namespace LayoutKit + { + class LayoutAlignRequest { - Coord r_nat = r.natural; - Coord r_max = r.maximum; - Coord r_min = r.minimum; - Coord r_align = r.align; - Coord r_inv_align = Coord(1) - r_align; - natural_lead = Math::max(natural_lead, Coord(r_nat * r_align)); - max_lead = Math::min(max_lead, Coord(r_max * r_align)); - min_lead = Math::max(min_lead, Coord(r_min * r_align)); - natural_trail = Math::max(natural_trail, Coord(r_nat * r_inv_align)); - max_trail = Math::min(max_trail, Coord(r_max * r_inv_align)); - min_trail = Math::max(min_trail, Coord(r_min * r_inv_align)); + public: + LayoutAlignRequest(); + + void margin(Coord margin); + + void accumulate(const Graphic::Requirement &r); + void requirement(Graphic::Requirement &r) const; + + protected: + Coord natural_lead; + Coord min_lead; + Coord max_lead; + Coord natural_trail; + Coord min_trail; + Coord max_trail; + }; + + LayoutAlignRequest::LayoutAlignRequest() : + natural_lead(0), + min_lead(-GraphicImpl::infinity), + max_lead(GraphicImpl::infinity), + natural_trail(0), + min_trail(-GraphicImpl::infinity), + max_trail(GraphicImpl::infinity) + { } + + void LayoutAlignRequest::margin(Coord margin) + { + natural_lead += margin; + min_lead -= margin; + max_lead += margin; + natural_trail += margin; + min_trail -= margin; + max_trail += margin; } -} - -void LayoutAlignRequest::requirement(Graphic::Requirement &r) const -{ - GraphicImpl::require_lead_trail(r, natural_lead, max_lead, min_lead, natural_trail, max_trail, min_trail); -} - -class LayoutTileRequest -{ -public: - LayoutTileRequest(); - - void space(Coord space); - void flexible(); - - void accumulate(const Graphic::Requirement &r); - void requirement(Graphic::Requirement &r) const; - - Coord natural; - Coord min_size; - Coord max_size; -}; - -LayoutTileRequest::LayoutTileRequest() : natural(0), min_size(0), max_size(0) {} -void LayoutTileRequest::space(Coord space) -{ - natural += space; - max_size += space; - min_size += space; -} - -void LayoutTileRequest::flexible() -{ - max_size = GraphicImpl::infinity; -} - -void LayoutTileRequest::accumulate(const Graphic::Requirement &r) -{ - if (r.defined) + void LayoutAlignRequest::accumulate(const Graphic::Requirement &r) { - natural += r.natural; - max_size += r.maximum; - min_size += r.minimum; + if (!r.defined) return; + + Coord r_nat = r.natural; + Coord r_max = r.maximum; + Coord r_min = r.minimum; + Coord r_align = r.align; + Coord r_inv_align = Coord(1) - r_align; + natural_lead = Math::max(natural_lead, Coord(r_nat * r_align)); + max_lead = Math::min(max_lead, Coord(r_max * r_align)); + min_lead = Math::max(min_lead, Coord(r_min * r_align)); + natural_trail = Math::max(natural_trail, Coord(r_nat * r_inv_align)); + max_trail = Math::min(max_trail, Coord(r_max * r_inv_align)); + min_trail = Math::max(min_trail, Coord(r_min * r_inv_align)); } -} - -void LayoutTileRequest::requirement(Graphic::Requirement &r) const -{ - r.defined = true; - r.natural = natural; - r.maximum = max_size; - r.minimum = min_size; - r.align = 0.; -} -class LayoutTileAllocate -{ -public: - LayoutTileAllocate(Axis, Graphic::Requisition &, bool, Region_ptr); + void LayoutAlignRequest::requirement(Graphic::Requirement &r) const + { + GraphicImpl::require_lead_trail(r, + natural_lead, max_lead, min_lead, + natural_trail, max_trail, min_trail); + } - static Coord compute_length(const Graphic::Requirement &, const Region::Allotment &); - static double compute_squeeze(const Graphic::Requirement &, Coord); + class LayoutTileRequest + { + public: + LayoutTileRequest(); - void next_span(const Graphic::Requirement &, GridImpl::Span &); + void space(Coord space); + void flexible(); -private: - bool first_aligned; - bool growing; - bool shrinking; - Coord f; - Coord p; - long i; -}; + void accumulate(const Graphic::Requirement &r); + void requirement(Graphic::Requirement &r) const; -LayoutTileAllocate::LayoutTileAllocate(Axis axis, Graphic::Requisition &total, bool fa, Region_ptr given) -{ - first_aligned = fa; - Graphic::Requirement *r; - Region::Allotment a; - r = GraphicImpl::requirement(total, axis); - given->span(axis, a); - Coord length = compute_length(*r, a); - growing = length > r->natural; - shrinking = length < r->natural; - f = compute_squeeze(*r, length); - p = a.begin + a.align * (a.end - a.begin); - i = 0; -} + Coord natural; + Coord min_size; + Coord max_size; + }; -Coord LayoutTileAllocate::compute_length(const Graphic::Requirement &r, const Region::Allotment &a) -{ - Coord length = a.end - a.begin; - Coord a_a = a.align; - Coord r_a = r.align; - if (r_a == 0) length *= (1 - a_a); - else if (r_a == 1) length *= a_a; - else length *= Math::min(a_a / r_a, (1 - a_a) / (1 - r_a)); - return length; -} - -double LayoutTileAllocate::compute_squeeze(const Graphic::Requirement &r, Coord length) -{ - double f; - Coord nat = r.natural; - if (length > nat && r.maximum > nat) f = (length - nat) / (r.maximum - nat); - else if (length < nat && r.minimum < nat) f = (nat - length) / (nat - r.minimum); - else f = 0.0; - return f; -} + LayoutTileRequest::LayoutTileRequest() : natural(0), min_size(0), max_size(0) { } -void LayoutTileAllocate::next_span(const Graphic::Requirement &r, GridImpl::Span &s) -{ - if (r.defined) + void LayoutTileRequest::space(Coord space) { - Coord cspan = r.natural; - if (growing) cspan += f * (r.maximum - r.natural); - else if (shrinking) cspan -= f * (r.natural - r.minimum); - if (first_aligned && (i == 0)) p -= r.align * cspan; - set_span(s, p + cspan * r.align, cspan, r.align); - p += cspan; - } - else set_span(s, p, Coord(0), Alignment(0)); - ++i; -} + natural += space; + max_size += space; + min_size += space; + } + + void LayoutTileRequest::flexible() { max_size = GraphicImpl::infinity; } + + void LayoutTileRequest::accumulate(const Graphic::Requirement &r) + { + if (!r.defined) return; + + natural += r.natural; + max_size += r.maximum; + min_size += r.minimum; + } + + void LayoutTileRequest::requirement(Graphic::Requirement &r) const + { + r.defined = true; + r.natural = natural; + r.maximum = max_size; + r.minimum = min_size; + r.align = 0.; + } + + class LayoutTileAllocate + { + public: + LayoutTileAllocate(Axis, Graphic::Requisition &, bool, Region_ptr); + + static Coord compute_length(const Graphic::Requirement &, + const Region::Allotment &); + static double compute_squeeze(const Graphic::Requirement &, Coord); + + void next_span(const Graphic::Requirement &, GridImpl::Span &); + + private: + bool first_aligned; + bool growing; + bool shrinking; + Coord f; + Coord p; + long i; + }; + + LayoutTileAllocate::LayoutTileAllocate(Axis axis, + Graphic::Requisition &total, bool fa, + Region_ptr given) + { + first_aligned = fa; + Graphic::Requirement *r; + Region::Allotment a; + r = GraphicImpl::requirement(total, axis); + given->span(axis, a); + Coord length = compute_length(*r, a); + growing = length > r->natural; + shrinking = length < r->natural; + f = compute_squeeze(*r, length); + p = a.begin + a.align * (a.end - a.begin); + i = 0; + } + + Coord LayoutTileAllocate::compute_length(const Graphic::Requirement &r, + const Region::Allotment &a) + { + Coord length = a.end - a.begin; + Coord a_a = a.align; + Coord r_a = r.align; + if (r_a == 0) length *= (1 - a_a); + else if (r_a == 1) length *= a_a; + else length *= Math::min(a_a / r_a, (1 - a_a) / (1 - r_a)); + return length; + } + + double LayoutTileAllocate::compute_squeeze(const Graphic::Requirement &r, + Coord length) + { + double f; + Coord nat = r.natural; + if (length > nat && r.maximum > nat) f = (length - nat) / (r.maximum - nat); + else if (length < nat && r.minimum < nat) + f = (nat - length) / (nat - r.minimum); + else f = 0.0; + return f; + } + + void LayoutTileAllocate::next_span(const Graphic::Requirement &r, + GridImpl::Span &s) + { + if (r.defined) + { + Coord cspan = r.natural; + if (growing) cspan += f * (r.maximum - r.natural); + else if (shrinking) cspan -= f * (r.natural - r.minimum); + if (first_aligned && (i == 0)) p -= r.align * cspan; + set_span(s, p + cspan * r.align, cspan, r.align); + p += cspan; + } + else set_span(s, p, Coord(0), Alignment(0)); + ++i; + } + } // namespace +} // namespace GridImpl::GridImpl(const Layout::Grid::Index &upper) { @@ -259,7 +272,7 @@ void GridImpl::append_graphic(Graphic_ptr g) { replace(g, _cursor); - + if (++_cursor.col >= _dimensions[xaxis].size()) { long count = _dimensions[yaxis].size(); @@ -292,7 +305,7 @@ range.upper.col = _dimensions[xaxis].size(); range.lower.row = 0; range.upper.row = _dimensions[yaxis].size(); - + traverse_range(traversal, range); } @@ -323,7 +336,7 @@ range.upper.col = _dimensions[xaxis].size(); range.lower.row = 0; range.upper.row = _dimensions[yaxis].size(); - + return find_range(traversal, range); } @@ -342,7 +355,7 @@ void GridImpl::request_range(Fresco::Graphic::Requisition &r, const Layout::Grid::Range &a) { cache_request(); - + partial_request(xaxis, a.lower.col, a.upper.col, r.x); partial_request(yaxis, a.lower.row, a.upper.row, r.y); } @@ -353,7 +366,7 @@ if (!CORBA::is_nil(given)) { if (traversal->intersects_allocation()) - traverse_with_allocation(traversal, given, a); + traverse_with_allocation(traversal, given, a); } else traverse_without_allocation(traversal, a); @@ -442,14 +455,14 @@ { LayoutAlignRequest align; for (std::vector<Graphic_var>::iterator j = d.children[i].begin(); j != d.children[i].end(); ++j) - if (!CORBA::is_nil(*j)) - { - Fresco::Graphic::Requisition r; - GraphicImpl::init_requisition(r); - GraphicImpl::default_requisition(r); - (*j)->request(r); - align.accumulate(axis == xaxis ? r.x : r.y); - } + if (!CORBA::is_nil(*j)) + { + Fresco::Graphic::Requisition r; + GraphicImpl::init_requisition(r); + GraphicImpl::default_requisition(r); + (*j)->request(r); + align.accumulate(axis == xaxis ? r.x : r.y); + } Fresco::Graphic::Requirement &r = d.requirements[i]; align.requirement(r); tile.accumulate(r); @@ -482,16 +495,16 @@ for (i.row = range.lower.row; i.row != range.upper.row && t->ok(); i.row++) for (i.col = range.lower.col; i.col != range.upper.col && t->ok(); i.col++) { - Graphic_var child = d.children [i.row][i.col]; - if (CORBA::is_nil(child)) continue; - tx->load_identity(); - spans_to_region(xspans[i.col], yspans[i.row], region); - offset_region(region, dx, dy); - region->normalize(Transform_var(tx->_this())); - try { t->traverse_child (child, index_to_tag(i), Region_var(region->_this()), Transform_var(tx->_this()));} - catch (const CORBA::OBJECT_NOT_EXIST &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} - catch (const CORBA::COMM_FAILURE &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} - catch (const CORBA::TRANSIENT &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} + Graphic_var child = d.children [i.row][i.col]; + if (CORBA::is_nil(child)) continue; + tx->load_identity(); + spans_to_region(xspans[i.col], yspans[i.row], region); + offset_region(region, dx, dy); + region->normalize(Transform_var(tx->_this())); + try { t->traverse_child (child, index_to_tag(i), Region_var(region->_this()), Transform_var(tx->_this()));} + catch (const CORBA::OBJECT_NOT_EXIST &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} + catch (const CORBA::COMM_FAILURE &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} + catch (const CORBA::TRANSIENT &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} } delete [] xspans; delete [] yspans; @@ -504,12 +517,12 @@ for (i.row = range.lower.row; i.row != range.upper.row && t->ok(); i.row++) for (i.col = range.lower.col; i.col != range.upper.col && t->ok(); i.col++) { - Graphic_var child = d.children [i.row][i.col]; - if (CORBA::is_nil (child)) continue; - try { t->traverse_child (child, index_to_tag(i), Region::_nil(), Transform::_nil());} - catch (const CORBA::OBJECT_NOT_EXIST &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} - catch (const CORBA::COMM_FAILURE &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} - catch (const CORBA::TRANSIENT &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} + Graphic_var child = d.children [i.row][i.col]; + if (CORBA::is_nil (child)) continue; + try { t->traverse_child (child, index_to_tag(i), Region::_nil(), Transform::_nil());} + catch (const CORBA::OBJECT_NOT_EXIST &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} + catch (const CORBA::COMM_FAILURE &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} + catch (const CORBA::TRANSIENT &) { d.children [i.row][i.col] = Fresco::Graphic::_nil();} } } Index: StageImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Layout/StageImpl.cc,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- StageImpl.cc 26 Feb 2003 00:19:06 -0000 1.53 +++ StageImpl.cc 27 Oct 2003 17:08:38 -0000 1.54 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -42,960 +42,950 @@ using namespace Berlin::LayoutKit; [...1588 lines suppressed...] + } } - else + else { - _xalign = 0.; - _yalign = 0.; - _bbox.l = _position.x; - _bbox.r = _position.x; - _bbox.t = _position.y; - _bbox.b = _position.y; + _xalign = 0.; + _yalign = 0.; + _bbox.l = _position.x; + _bbox.r = _position.x; + _bbox.t = _position.y; + _bbox.b = _position.y; } } - Index: StageImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Layout/StageImpl.hh,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- StageImpl.hh 26 Feb 2003 00:19:07 -0000 1.26 +++ StageImpl.hh 27 Oct 2003 17:08:38 -0000 1.27 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * Copyright (C) 1999 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -31,114 +31,122 @@ #include <Berlin/RegionImpl.hh> #include <Berlin/Geometry.hh> -namespace Berlin { -namespace LayoutKit { +namespace Berlin +{ + namespace LayoutKit + { -class StageHandleImpl; + class StageHandleImpl; -class StageImpl : public virtual POA_Layout::Stage, - public GraphicImpl -{ - class Iterator; - friend class Iterator; + class StageImpl : public virtual POA_Layout::Stage, + public GraphicImpl + { + class Iterator; + friend class Iterator; - class Sequence; - class QuadTree; - public: - StageImpl(); - ~StageImpl(); + class Sequence; + class QuadTree; + public: + StageImpl(); + ~StageImpl(); - Fresco::GraphicIterator_ptr first_child_graphic(); - Fresco::GraphicIterator_ptr last_child_graphic(); + Fresco::GraphicIterator_ptr first_child_graphic(); + Fresco::GraphicIterator_ptr last_child_graphic(); - virtual void request(Fresco::Graphic::Requisition &); + virtual void request(Fresco::Graphic::Requisition &); - virtual void traverse(Fresco::Traversal_ptr); + virtual void traverse(Fresco::Traversal_ptr); - virtual void allocate(Fresco::Tag, const Fresco::Allocation::Info &); - virtual void need_redraw(); - virtual void need_redraw_region(Fresco::Region_ptr); - //. relayout the children. If the bounding box changes call need_resize on the parent - virtual void need_resize(); - - virtual Fresco::Region_ptr bbox(); - virtual CORBA::Long layers(); - virtual Layout::StageHandle_ptr layer(Layout::Stage::Index); - virtual void lock(); - virtual void unlock(); - virtual Layout::StageHandle_ptr insert(Fresco::Graphic_ptr, const Fresco::Vertex &, const Fresco::Vertex &, Layout::Stage::Index); - virtual void remove(Layout::StageHandle_ptr); + virtual void allocate(Fresco::Tag, const Fresco::Allocation::Info &); + virtual void need_redraw(); + virtual void need_redraw_region(Fresco::Region_ptr); + //. relayout the children. If the bounding box changes call + //. need_resize on the parent + virtual void need_resize(); - void move(StageHandleImpl *, const Fresco::Vertex &); - void resize(StageHandleImpl *, const Fresco::Vertex &); - void relayer(StageHandleImpl *, Layout::Stage::Index); + virtual Fresco::Region_ptr bbox(); + virtual CORBA::Long layers(); + virtual Layout::StageHandle_ptr layer(Layout::Stage::Index); + virtual void lock(); + virtual void unlock(); + virtual Layout::StageHandle_ptr insert(Fresco::Graphic_ptr, + const Fresco::Vertex &, + const Fresco::Vertex &, + Layout::Stage::Index); + virtual void remove(Layout::StageHandle_ptr); - virtual const char *object_name() { return "Layout/StageImpl";} -private: - //. Return a new unique tag in the scope of this parent - Fresco::Tag unique_tag(); - //. Return a handle to the child of the Stage that has the given tag. - //. It returns 0 if no child has the given tag. - StageHandleImpl *tag_to_handle(Fresco::Tag); - //. Mark the region occupied by the given StageHandle as damaged. - //. This is done by either merging that region with the one allready - //. damaged or by creating a new onw - void damage(StageHandleImpl *); + void move(StageHandleImpl *, const Fresco::Vertex &); + void resize(StageHandleImpl *, const Fresco::Vertex &); + void relayer(StageHandleImpl *, Layout::Stage::Index); - Sequence *_children; - QuadTree *_tree; - long _nesting; - Impl_var<RegionImpl> _damage; - Impl_var<RegionImpl> _bbregion; - bool _need_redraw : 1; - bool _need_resize : 1; - Prague::Mutex _mutex; -}; + virtual const char *object_name() { return "Layout/StageImpl";} + private: + //. Return a new unique tag in the scope of this parent + Fresco::Tag unique_tag(); + //. Return a handle to the child of the Stage that has the given tag. + //. It returns 0 if no child has the given tag. + StageHandleImpl *tag_to_handle(Fresco::Tag); + //. Mark the region occupied by the given StageHandle as damaged. + //. This is done by either merging that region with the one allready + //. damaged or by creating a new onw + void damage(StageHandleImpl *); -class StageHandleImpl : public virtual POA_Layout::StageHandle -{ - public: - StageHandleImpl(StageImpl *, Fresco::Graphic_ptr, Fresco::Tag, const Fresco::Vertex &, const Fresco::Vertex &, Layout::Stage::Index); - virtual Layout::Stage_ptr parent(); - virtual Fresco::Graphic_ptr child(); - virtual void remove(); - virtual Fresco::Vertex position(); - virtual void position(const Fresco::Vertex &); - virtual Fresco::Vertex size(); - virtual void size(const Fresco::Vertex &); - virtual Layout::Stage::Index layer(); - virtual void layer(Layout::Stage::Index); + Sequence *_children; + QuadTree *_tree; + long _nesting; + Impl_var<RegionImpl> _damage; + Impl_var<RegionImpl> _bbregion; + bool _need_redraw : 1; + bool _need_resize : 1; + Prague::Mutex _mutex; + }; - const Geometry::Rectangle<Fresco::Coord> &bbox(); - void bbox(RegionImpl &); -// private: - //. Calculate the bounding box of the graphic in this StageHandle and - //. stores the result in _bbox. - void cache_bbox(); - //. The stage this StageHandle belongs into. - StageImpl *_parent; - //. The graphic forming this StageHandle. - Fresco::Graphic_var _child; - //. This tag is unique for the parent-Stage and identifies this StageHandle. - Fresco::Tag _tag; - //. The position of the graphic forming this StageHandle. - Fresco::Vertex _position; - //. The size of the graphic forming this StageHandle - Fresco::Vertex _size; - //. The layer this StageHandle has. - Layout::Stage::Index _layer; - //. The bounding box of the graphic of this StageHandle as calculated - //. by cache_bbox(). - Geometry::Rectangle<Fresco::Coord> _bbox; - //. The alignment along the x-axis. - Fresco::Alignment _xalign; - //. The alignment along the y-axis. - Fresco::Alignment _yalign; - //. A mutex for thread safety. - Prague::Mutex _mutex; -}; + class StageHandleImpl : public virtual POA_Layout::StageHandle + { + public: + StageHandleImpl(StageImpl *, Fresco::Graphic_ptr, Fresco::Tag, + const Fresco::Vertex &, const Fresco::Vertex &, + Layout::Stage::Index); + virtual Layout::Stage_ptr parent(); + virtual Fresco::Graphic_ptr child(); + virtual void remove(); + virtual Fresco::Vertex position(); + virtual void position(const Fresco::Vertex &); + virtual Fresco::Vertex size(); + virtual void size(const Fresco::Vertex &); + virtual Layout::Stage::Index layer(); + virtual void layer(Layout::Stage::Index); -} // namespace + const Geometry::Rectangle<Fresco::Coord> &bbox(); + void bbox(RegionImpl &); + // private: + //. Calculate the bounding box of the graphic in this StageHandle and + //. stores the result in _bbox. + void cache_bbox(); + //. The stage this StageHandle belongs into. + StageImpl *_parent; + //. The graphic forming this StageHandle. + Fresco::Graphic_var _child; + //. This tag is unique for the parent-Stage and identifies this StageHandle. + Fresco::Tag _tag; + //. The position of the graphic forming this StageHandle. + Fresco::Vertex _position; + //. The size of the graphic forming this StageHandle + Fresco::Vertex _size; + //. The layer this StageHandle has. + Layout::Stage::Index _layer; + //. The bounding box of the graphic of this StageHandle as calculated + //. by cache_bbox(). + Geometry::Rectangle<Fresco::Coord> _bbox; + //. The alignment along the x-axis. + Fresco::Alignment _xalign; + //. The alignment along the y-axis. + Fresco::Alignment _yalign; + //. A mutex for thread safety. + Prague::Mutex _mutex; + }; + + } // namespace } // namespace #endif Index: ViewportImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Layout/ViewportImpl.cc,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- ViewportImpl.cc 18 Dec 2002 06:00:06 -0000 1.33 +++ ViewportImpl.cc 27 Oct 2003 17:08:38 -0000 1.34 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -37,493 +37,519 @@ static const double epsilon = 10e-6; -class ViewportImpl::Adjustment : public virtual POA_Fresco::BoundedRange, - public SubjectImpl +namespace Berlin { - public: - Adjustment(); - virtual ~Adjustment(); - virtual Fresco::BoundedRange::Settings state(); - virtual void state(const Fresco::BoundedRange::Settings &); - virtual Coord lower(); - virtual void lower(Coord); - virtual Coord upper(); - virtual void upper(Coord); - virtual Coord step(); - virtual void step(Coord); - virtual Coord page(); - virtual void page(Coord); - virtual Coord lvalue(); - virtual void lvalue(Coord); - virtual Coord uvalue(); - virtual void uvalue(Coord); - virtual void forward(); - virtual void backward(); - virtual void fastforward(); - virtual void fastbackward(); - virtual void begin(); - virtual void end(); - virtual void adjust(Coord); - virtual const char *object_name() { return "ViewportImpl::Adjustment";} - private: - Fresco::BoundedRange::Settings _settings; - Coord _s; - Coord _p; - Mutex _mutex; -}; + namespace LayoutKit + { + class ViewportImpl::Adjustment : public virtual POA_Fresco::BoundedRange, + public SubjectImpl + { + public: + Adjustment(); + virtual ~Adjustment(); + virtual Fresco::BoundedRange::Settings state(); + virtual void state(const Fresco::BoundedRange::Settings &); + virtual Coord lower(); + virtual void lower(Coord); + virtual Coord upper(); + virtual void upper(Coord); + virtual Coord step(); + virtual void step(Coord); + virtual Coord page(); + virtual void page(Coord); + virtual Coord lvalue(); + virtual void lvalue(Coord); + virtual Coord uvalue(); + virtual void uvalue(Coord); + virtual void forward(); + virtual void backward(); + virtual void fastforward(); + virtual void fastbackward(); + virtual void begin(); + virtual void end(); + virtual void adjust(Coord); + virtual const char *object_name() { return "ViewportImpl::Adjustment";} + private: + Fresco::BoundedRange::Settings _settings; + Coord _s; + Coord _p; + Mutex _mutex; + }; -ViewportImpl::Adjustment::Adjustment() - : _s(10.), _p(10.) -{ - _settings.lower = _settings.upper = _settings.lvalue = _settings.uvalue = 0.; -} + ViewportImpl::Adjustment::Adjustment() : _s(10.), _p(10.) + { _settings.lower = _settings.upper = _settings.lvalue = _settings.uvalue = 0.; } -ViewportImpl::Adjustment::~Adjustment() -{ -} + ViewportImpl::Adjustment::~Adjustment() { } -Fresco::BoundedRange::Settings ViewportImpl::Adjustment::state() -{ - Prague::Guard<Mutex> guard(_mutex); - return _settings; -} + Fresco::BoundedRange::Settings ViewportImpl::Adjustment::state() + { + Prague::Guard<Mutex> guard(_mutex); + return _settings; + } -void ViewportImpl::Adjustment::state(const Fresco::BoundedRange::Settings &s) -{ - Prague::Guard<Mutex> guard(_mutex); - _settings = s; -} + void ViewportImpl::Adjustment::state(const Fresco::BoundedRange::Settings &s) + { + Prague::Guard<Mutex> guard(_mutex); + _settings = s; + } -Coord ViewportImpl::Adjustment::lower() -{ - Prague::Guard<Mutex> guard(_mutex); - return _settings.lower; -} + Coord ViewportImpl::Adjustment::lower() + { + Prague::Guard<Mutex> guard(_mutex); + return _settings.lower; + } -void ViewportImpl::Adjustment::lower(Coord l) -{ - CORBA::Any any; - { - Prague::Guard<Mutex> guard(_mutex); - if (l == _settings.lower) return; - _settings.lower = l; - _settings.lvalue = std::max(_settings.lvalue, _settings.lower); - _settings.uvalue = std::max(_settings.uvalue, _settings.lower); - any <<= _settings; - } - notify(any); -} + void ViewportImpl::Adjustment::lower(Coord l) + { + CORBA::Any any; + { + Prague::Guard<Mutex> guard(_mutex); + if (l == _settings.lower) return; + _settings.lower = l; + _settings.lvalue = std::max(_settings.lvalue, _settings.lower); + _settings.uvalue = std::max(_settings.uvalue, _settings.lower); + any <<= _settings; + } + notify(any); + } -Coord ViewportImpl::Adjustment::upper() -{ - Prague::Guard<Mutex> guard(_mutex); - return _settings.upper; -} + Coord ViewportImpl::Adjustment::upper() + { + Prague::Guard<Mutex> guard(_mutex); + return _settings.upper; + } -void ViewportImpl::Adjustment::upper(Coord u) -{ - CORBA::Any any; - { - Prague::Guard<Mutex> guard(_mutex); - if (_settings.upper == u) return; - _settings.upper = u; - _settings.lvalue = std::min(_settings.lvalue, _settings.upper); - _settings.uvalue = std::min(_settings.uvalue, _settings.upper); - any <<= _settings; - } - notify(any); -} + void ViewportImpl::Adjustment::upper(Coord u) + { + CORBA::Any any; + { + Prague::Guard<Mutex> guard(_mutex); + if (_settings.upper == u) return; + _settings.upper = u; + _settings.lvalue = std::min(_settings.lvalue, _settings.upper); + _settings.uvalue = std::min(_settings.uvalue, _settings.upper); + any <<= _settings; + } + notify(any); + } -Coord ViewportImpl::Adjustment::step() -{ - Prague::Guard<Mutex> guard(_mutex); - return _s; -} + Coord ViewportImpl::Adjustment::step() + { + Prague::Guard<Mutex> guard(_mutex); + return _s; + } -void ViewportImpl::Adjustment::step(Coord s) -{ - Prague::Guard<Mutex> guard(_mutex); - _s = s; -} + void ViewportImpl::Adjustment::step(Coord s) + { + Prague::Guard<Mutex> guard(_mutex); + _s = s; + } -Coord ViewportImpl::Adjustment::page() -{ - Prague::Guard<Mutex> guard(_mutex); - return _p; -} + Coord ViewportImpl::Adjustment::page() + { + Prague::Guard<Mutex> guard(_mutex); + return _p; + } -void ViewportImpl::Adjustment::page(Coord p) -{ - Prague::Guard<Mutex> guard(_mutex); - _p = p; -} + void ViewportImpl::Adjustment::page(Coord p) + { + Prague::Guard<Mutex> guard(_mutex); + _p = p; + } -void ViewportImpl::Adjustment::forward() -{ - CORBA::Any any; - { - Prague::Guard<Mutex> guard(_mutex); - Coord t = std::min(_s, _settings.upper - _settings.uvalue); - if (t <= 0.) return; - _settings.lvalue += t; - _settings.uvalue += t; - any <<= _settings; - } - notify(any); -} + void ViewportImpl::Adjustment::forward() + { + CORBA::Any any; + { + Prague::Guard<Mutex> guard(_mutex); + Coord t = std::min(_s, _settings.upper - _settings.uvalue); + if (t <= 0.) return; + _settings.lvalue += t; + _settings.uvalue += t; + any <<= _settings; + } + notify(any); + } -void ViewportImpl::Adjustment::backward() -{ - CORBA::Any any; - { - Prague::Guard<Mutex> guard(_mutex); - Coord t = std::min(_s, _settings.lvalue - _settings.lower); - if (t <= 0.) return; - _settings.lvalue -= t; - _settings.uvalue -= t; - any <<= _settings; - } - notify(any); -} + void ViewportImpl::Adjustment::backward() + { + CORBA::Any any; + { + Prague::Guard<Mutex> guard(_mutex); + Coord t = std::min(_s, _settings.lvalue - _settings.lower); + if (t <= 0.) return; + _settings.lvalue -= t; + _settings.uvalue -= t; + any <<= _settings; + } + notify(any); + } -void ViewportImpl::Adjustment::fastforward() -{ - CORBA::Any any; - { - Prague::Guard<Mutex> guard(_mutex); - Coord t = std::min(_p, _settings.upper - _settings.uvalue); - if (t <= 0.) return; - _settings.lvalue += t; - _settings.uvalue += t; - any <<= _settings; - } - notify(any); -} + void ViewportImpl::Adjustment::fastforward() + { + CORBA::Any any; + { + Prague::Guard<Mutex> guard(_mutex); + Coord t = std::min(_p, _settings.upper - _settings.uvalue); + if (t <= 0.) return; + _settings.lvalue += t; + _settings.uvalue += t; + any <<= _settings; + } + notify(any); + } -void ViewportImpl::Adjustment::fastbackward() -{ - CORBA::Any any; - { - Prague::Guard<Mutex> guard(_mutex); - Coord t = std::min(_p, _settings.lvalue - _settings.lower); - if (t <= 0.) return; - _settings.lvalue -= t; - _settings.uvalue -= t; - any <<= _settings; - } - notify(any); -} + void ViewportImpl::Adjustment::fastbackward() + { + CORBA::Any any; + { + Prague::Guard<Mutex> guard(_mutex); + Coord t = std::min(_p, _settings.lvalue - _settings.lower); + if (t <= 0.) return; + _settings.lvalue -= t; + _settings.uvalue -= t; + any <<= _settings; + } + notify(any); + } -void ViewportImpl::Adjustment::begin() -{ - CORBA::Any any; - { - Prague::Guard<Mutex> guard(_mutex); - Coord t = _settings.lvalue - _settings.lower; - if (t == 0.) return; - _settings.lvalue -= t; - _settings.uvalue -= t; - any <<= _settings; - } - notify(any); -} + void ViewportImpl::Adjustment::begin() + { + CORBA::Any any; + { + Prague::Guard<Mutex> guard(_mutex); + Coord t = _settings.lvalue - _settings.lower; + if (t == 0.) return; + _settings.lvalue -= t; + _settings.uvalue -= t; + any <<= _settings; + } + notify(any); + } -void ViewportImpl::Adjustment::end() -{ - CORBA::Any any; - { - Prague::Guard<Mutex> guard(_mutex); - Coord t = _settings.upper - _settings.uvalue; - if (t == 0.) return; - _settings.lvalue += t; - _settings.uvalue += t; - any <<= _settings; - } - notify(any); -} + void ViewportImpl::Adjustment::end() + { + CORBA::Any any; + { + Prague::Guard<Mutex> guard(_mutex); + Coord t = _settings.upper - _settings.uvalue; + if (t == 0.) return; + _settings.lvalue += t; + _settings.uvalue += t; + any <<= _settings; + } + notify(any); + } -void ViewportImpl::Adjustment::lvalue(Coord lv) -{ - CORBA::Any any; - { - lv = std::min(std::max(_settings.lower, lv), _settings.upper); - Prague::Guard<Mutex> guard(_mutex); - if (lv == _settings.lvalue) return; - _settings.lvalue = lv; - any <<= _settings; - } - notify(any); -} + void ViewportImpl::Adjustment::lvalue(Coord lv) + { + CORBA::Any any; + { + lv = std::min(std::max(_settings.lower, lv), _settings.upper); + Prague::Guard<Mutex> guard(_mutex); + if (lv == _settings.lvalue) return; + _settings.lvalue = lv; + any <<= _settings; + } + notify(any); + } -Coord ViewportImpl::Adjustment::lvalue() -{ - Prague::Guard<Mutex> guard(_mutex); - return _settings.lvalue; -} + Coord ViewportImpl::Adjustment::lvalue() + { + Prague::Guard<Mutex> guard(_mutex); + return _settings.lvalue; + } -void ViewportImpl::Adjustment::uvalue(Coord uv) -{ - CORBA::Any any; - { - uv = std::min(std::max(_settings.lower, uv), _settings.upper); - Prague::Guard<Mutex> guard(_mutex); - if (_settings.uvalue == uv) return; - _settings.uvalue = uv; - any <<= _settings; - } - notify(any); -} + void ViewportImpl::Adjustment::uvalue(Coord uv) + { + CORBA::Any any; + { + uv = std::min(std::max(_settings.lower, uv), _settings.upper); + Prague::Guard<Mutex> guard(_mutex); + if (_settings.uvalue == uv) return; + _settings.uvalue = uv; + any <<= _settings; + } + notify(any); + } -Coord ViewportImpl::Adjustment::uvalue() -{ - Prague::Guard<Mutex> guard(_mutex); - return _settings.uvalue; -} + Coord ViewportImpl::Adjustment::uvalue() + { + Prague::Guard<Mutex> guard(_mutex); + return _settings.uvalue; + } -void ViewportImpl::Adjustment::adjust(Coord d) -{ - CORBA::Any any; - { - Prague::Guard<Mutex> guard(_mutex); - Coord t = std::min(std::max(d, _settings.lower - _settings.lvalue), _settings.upper - _settings.uvalue); - if (t == 0.) return; - _settings.lvalue += t; - _settings.uvalue += t; - any <<= _settings; - } - notify(any); -} + void ViewportImpl::Adjustment::adjust(Coord d) + { + CORBA::Any any; + { + Prague::Guard<Mutex> guard(_mutex); + Coord t = std::min(std::max(d, _settings.lower - _settings.lvalue), + _settings.upper - _settings.uvalue); + if (t == 0.) return; + _settings.lvalue += t; + _settings.uvalue += t; + any <<= _settings; + } + notify(any); + } -ViewportImpl::ViewportImpl() : _requested(false) -{ - init_requisition(_requisition); - _settings[xaxis].lower = _settings[xaxis].upper = - _settings[xaxis].lvalue = _settings[xaxis].uvalue = 0; - _settings[yaxis].lower = _settings[yaxis].upper = - _settings[yaxis].lvalue = _settings[yaxis].uvalue = 0; -} -ViewportImpl::~ViewportImpl() {} + ViewportImpl::ViewportImpl() : _requested(false) + { + init_requisition(_requisition); + _settings[xaxis].lower = _settings[xaxis].upper = + _settings[xaxis].lvalue = _settings[xaxis].uvalue = 0; + _settings[yaxis].lower = _settings[yaxis].upper = + _settings[yaxis].lvalue = _settings[yaxis].uvalue = 0; + } -void ViewportImpl::body(Graphic_ptr g) -{ - MonoGraphic::body(g); - need_resize(); - MonoGraphic::need_resize(); -} + ViewportImpl::~ViewportImpl() { } -Transform_ptr ViewportImpl::transformation() { return Transform::_nil();} + void ViewportImpl::body(Graphic_ptr g) + { + MonoGraphic::body(g); + need_resize(); + MonoGraphic::need_resize(); + } -void ViewportImpl::request(Fresco::Graphic::Requisition &r) -{ - cache_requisition(); - GraphicImpl::require(r.x, _requisition.x.natural, 0., _requisition.x.natural, _requisition.x.align); - GraphicImpl::require(r.y, _requisition.y.natural, 0., _requisition.y.natural, _requisition.y.align); - if(_requisition.z.defined) - GraphicImpl::require(r.z, _requisition.z.natural, 0., _requisition.z.natural, _requisition.z.align); -} + Transform_ptr ViewportImpl::transformation() { return Transform::_nil(); } -void ViewportImpl::traverse(Traversal_ptr traversal) -{ - Graphic_var child = body(); - if (!CORBA::is_nil(child) && traversal->intersects_allocation()) + void ViewportImpl::request(Fresco::Graphic::Requisition &r) { - /* - * first update the cached allocation and the adjustments - */ - Region_var allocation = traversal->current_allocation(); - cache_allocation(allocation); - traversal->visit(Graphic_var(_this())); + cache_requisition(); + GraphicImpl::require(r.x, _requisition.x.natural, 0., + _requisition.x.natural, _requisition.x.align); + GraphicImpl::require(r.y, _requisition.y.natural, 0., + _requisition.y.natural, _requisition.y.align); + if(_requisition.z.defined) + GraphicImpl::require(r.z, _requisition.z.natural, 0., + _requisition.z.natural, _requisition.z.align); } -} -void ViewportImpl::draw(DrawTraversal_ptr traversal) -{ - /* - * now simply traverse the child with it's desired allocation - * and a suitable offset - */ - Region_var allocation = traversal->current_allocation(); - Transform_var transformation = traversal->current_transformation(); + void ViewportImpl::traverse(Traversal_ptr traversal) + { + Graphic_var child = body(); + if (!CORBA::is_nil(child) && traversal->intersects_allocation()) + { + /* + * first update the cached allocation and the adjustments + */ + Region_var allocation = traversal->current_allocation(); + cache_allocation(allocation); + traversal->visit(Graphic_var(_this())); + } + } - Lease_var<RegionImpl> clipping(Provider<RegionImpl>::provide()); - clipping->copy(allocation); - if (!CORBA::is_nil(transformation) && !transformation->identity()) - clipping->apply_transform(transformation); + void ViewportImpl::draw(DrawTraversal_ptr traversal) + { + /* + * now simply traverse the child with it's desired allocation + * and a suitable offset + */ + Region_var allocation = traversal->current_allocation(); + Transform_var transformation = traversal->current_transformation(); - DrawingKit_var drawing = traversal->drawing(); - drawing->save(); - clipping->merge_intersect(drawing->clipping()); - drawing->clipping(Region_var(clipping->_this())); + Lease_var<RegionImpl> clipping(Provider<RegionImpl>::provide()); + clipping->copy(allocation); + if (!CORBA::is_nil(transformation) && !transformation->identity()) + clipping->apply_transform(transformation); - Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); - Lease_var<RegionImpl> b(Provider<RegionImpl>::provide()); - body_allocation(allocation, b); - region->copy(Region_var(b->_this())); + DrawingKit_var drawing = traversal->drawing(); + drawing->save(); + clipping->merge_intersect(drawing->clipping()); + drawing->clipping(Region_var(clipping->_this())); - Lease_var<TransformImpl> transform(Provider<TransformImpl>::provide()); - transform->load_identity(); + Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); + Lease_var<RegionImpl> b(Provider<RegionImpl>::provide()); + body_allocation(allocation, b); + region->copy(Region_var(b->_this())); - region->normalize(Transform_var(transform->_this())); - try { traversal->traverse_child (_child.peer, _child.localId, Region_var(region->_this()), Transform_var(transform->_this()));} - catch (const CORBA::OBJECT_NOT_EXIST &) { body(Fresco::Graphic::_nil());} - catch (const CORBA::COMM_FAILURE &) { body(Fresco::Graphic::_nil());} - catch (const CORBA::TRANSIENT &) { body(Fresco::Graphic::_nil());} - drawing->restore(); -} + Lease_var<TransformImpl> transform(Provider<TransformImpl>::provide()); + transform->load_identity(); -void ViewportImpl::pick(PickTraversal_ptr traversal) -{ - /* - * now simply traverse the child with it's desired allocation - * and a suitable offset - */ - Region_var allocation = traversal->current_allocation(); - Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); - Lease_var<RegionImpl> b(Provider<RegionImpl>::provide()); - body_allocation(allocation, b); - region->copy(Region_var(b->_this())); + region->normalize(Transform_var(transform->_this())); + try + { + traversal->traverse_child(_child.peer, _child.localId, + Region_var(region->_this()), + Transform_var(transform->_this())); + } + catch (const CORBA::OBJECT_NOT_EXIST &) { body(Fresco::Graphic::_nil()); } + catch (const CORBA::COMM_FAILURE &) { body(Fresco::Graphic::_nil()); } + catch (const CORBA::TRANSIENT &) { body(Fresco::Graphic::_nil()); } + drawing->restore(); + } - Lease_var<TransformImpl> transform(Provider<TransformImpl>::provide()); - transform->load_identity(); + void ViewportImpl::pick(PickTraversal_ptr traversal) + { + /* + * now simply traverse the child with it's desired allocation + * and a suitable offset + */ + Region_var allocation = traversal->current_allocation(); + Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); + Lease_var<RegionImpl> b(Provider<RegionImpl>::provide()); + body_allocation(allocation, b); + region->copy(Region_var(b->_this())); - region->normalize(Transform_var(transform->_this())); - try { traversal->traverse_child (_child.peer, _child.localId, Region_var(region->_this()), Transform_var(transform->_this()));} - catch (const CORBA::OBJECT_NOT_EXIST &) { body(Fresco::Graphic::_nil());} - catch (const CORBA::COMM_FAILURE &) { body(Fresco::Graphic::_nil());} - catch (const CORBA::TRANSIENT &) { body(Fresco::Graphic::_nil());} -} + Lease_var<TransformImpl> transform(Provider<TransformImpl>::provide()); + transform->load_identity(); -void ViewportImpl::need_resize() -{ - /* - * set adjustment's outer range according to the body size - */ - _requested = false; - cache_requisition(); - need_redraw(); -} + region->normalize(Transform_var(transform->_this())); + try + { + traversal->traverse_child (_child.peer, _child.localId, + Region_var(region->_this()), + Transform_var(transform->_this())); + } + catch (const CORBA::OBJECT_NOT_EXIST &) { body(Fresco::Graphic::_nil()); } + catch (const CORBA::COMM_FAILURE &) { body(Fresco::Graphic::_nil()); } + catch (const CORBA::TRANSIENT &) { body(Fresco::Graphic::_nil()); } + } -void ViewportImpl::update(const CORBA::Any &) -{ - /* - * we are only interested in changes concerning the outer range (body) - * or the offset - */ - Fresco::BoundedRange::Settings x = _xadjustment->state(); - Fresco::BoundedRange::Settings y = _yadjustment->state(); - bool damage = (x.lower != _settings[xaxis].lower || - y.lower != _settings[yaxis].lower || - x.upper != _settings[xaxis].upper || - y.upper != _settings[yaxis].upper || - x.lvalue != _settings[xaxis].lvalue || - y.lvalue != _settings[yaxis].lvalue); - _settings[xaxis].lvalue = x.lvalue; - _settings[xaxis].uvalue = x.uvalue; - _settings[yaxis].lvalue = y.lvalue; - _settings[yaxis].uvalue = y.uvalue; - if (damage) need_redraw(); -} + void ViewportImpl::need_resize() + { + /* + * set adjustment's outer range according to the body size + */ + _requested = false; + cache_requisition(); + need_redraw(); + } -void ViewportImpl::activate_composite() -{ - Adjustment *adjustment = new Adjustment; - activate(adjustment); - _xadjustment = RefCount_var<BoundedRange>::increment(adjustment->_this(), false); - _xadjustment->attach(Observer_var(_this())); - adjustment = new Adjustment; - activate(adjustment); - _yadjustment = RefCount_var<BoundedRange>::increment(adjustment->_this(), false); - _yadjustment->attach(Observer_var(_this())); -} + void ViewportImpl::update(const CORBA::Any &) + { + /* + * we are only interested in changes concerning the outer range (body) + * or the offset + */ + Fresco::BoundedRange::Settings x = _xadjustment->state(); + Fresco::BoundedRange::Settings y = _yadjustment->state(); + bool damage = (x.lower != _settings[xaxis].lower || + y.lower != _settings[yaxis].lower || + x.upper != _settings[xaxis].upper || + y.upper != _settings[yaxis].upper || + x.lvalue != _settings[xaxis].lvalue || + y.lvalue != _settings[yaxis].lvalue); + _settings[xaxis].lvalue = x.lvalue; + _settings[xaxis].uvalue = x.uvalue; + _settings[yaxis].lvalue = y.lvalue; + _settings[yaxis].uvalue = y.uvalue; + if (damage) need_redraw(); + } -void ViewportImpl::allocate_child(Allocation::Info &info) -{ - scroll_transform(info.transformation); - Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); - Lease_var<RegionImpl> b(Provider<RegionImpl>::provide()); - body_allocation(info.allocation, b); - region->copy(Region_var(b->_this())); - info.allocation->copy(Region_var(region->_this())); -} + void ViewportImpl::activate_composite() + { + Adjustment *adjustment = new Adjustment; + activate(adjustment); + _xadjustment = RefCount_var<BoundedRange>::increment(adjustment->_this(), false); + _xadjustment->attach(Observer_var(_this())); + adjustment = new Adjustment; + activate(adjustment); + _yadjustment = RefCount_var<BoundedRange>::increment(adjustment->_this(), false); + _yadjustment->attach(Observer_var(_this())); + } -BoundedRange_ptr ViewportImpl::adjustment(Axis a) -{ - // FIXME: What about the zaxis? I know... it is not really useful - // but it is allowed for input and should not just return - // the value for the yaxis. -- tobias - return a == xaxis ? RefCount_var<BoundedRange>::increment(_xadjustment) : RefCount_var<BoundedRange>::increment(_yadjustment); -} + void ViewportImpl::allocate_child(Allocation::Info &info) + { + scroll_transform(info.transformation); + Lease_var<RegionImpl> region(Provider<RegionImpl>::provide()); + Lease_var<RegionImpl> b(Provider<RegionImpl>::provide()); + body_allocation(info.allocation, b); + region->copy(Region_var(b->_this())); + info.allocation->copy(Region_var(region->_this())); + } -void ViewportImpl::cache_requisition() -//. retrieves requisition from body and updates adjustments -{ - if (!_requested) + BoundedRange_ptr ViewportImpl::adjustment(Axis a) { - _requested = true; - MonoGraphic::request(_requisition); - Fresco::Graphic::Requirement &rx = _requisition.x; - Fresco::Graphic::Requirement &ry = _requisition.y; + // FIXME: What about the zaxis? I know... it is not really useful + // but it is allowed for input and should not just return + // the value for the yaxis. -- tobias + return a == xaxis ? RefCount_var<BoundedRange>::increment(_xadjustment) : + RefCount_var<BoundedRange>::increment(_yadjustment); + } - _settings[xaxis].lvalue = _settings[xaxis].lower = rx.defined ? - rx.natural * rx.align : 0.; - _settings[xaxis].uvalue = _settings[xaxis].upper = rx.defined ? _settings[xaxis].lvalue + rx.natural : 0.; - if (rx.defined) - { - _xadjustment->lower(_settings[xaxis].lower); - _xadjustment->upper(_settings[xaxis].upper); - } - _settings[yaxis].lvalue = _settings[yaxis].lower = ry.defined ? - ry.natural * ry.align : 0.; - _settings[yaxis].uvalue = _settings[yaxis].upper = ry.defined ? _settings[yaxis].lvalue + ry.natural : 0.; - if (ry.defined) - { - _yadjustment->lower(_settings[yaxis].lower); - _yadjustment->upper(_settings[yaxis].upper); - } + void ViewportImpl::cache_requisition() + //. retrieves requisition from body and updates adjustments + { + if (!_requested) + { + _requested = true; + MonoGraphic::request(_requisition); + Fresco::Graphic::Requirement &rx = _requisition.x; + Fresco::Graphic::Requirement &ry = _requisition.y; + + _settings[xaxis].lvalue = _settings[xaxis].lower = + rx.defined ? - rx.natural * rx.align : 0.; + _settings[xaxis].uvalue = _settings[xaxis].upper = + rx.defined ? _settings[xaxis].lvalue + rx.natural : 0.; + if (rx.defined) + { + _xadjustment->lower(_settings[xaxis].lower); + _xadjustment->upper(_settings[xaxis].upper); + } + _settings[yaxis].lvalue = _settings[yaxis].lower = + ry.defined ? - ry.natural * ry.align : 0.; + _settings[yaxis].uvalue = _settings[yaxis].upper = + ry.defined ? _settings[yaxis].lvalue + ry.natural : 0.; + if (ry.defined) + { + _yadjustment->lower(_settings[yaxis].lower); + _yadjustment->upper(_settings[yaxis].upper); + } + } } -} -void ViewportImpl::cache_allocation(Region_ptr allocation) -{ - if (!CORBA::is_nil(allocation)) + void ViewportImpl::cache_allocation(Region_ptr allocation) { - Region::Allotment xa, ya; - allocation->span(xaxis, xa); - allocation->span(yaxis, ya); + if (!CORBA::is_nil(allocation)) + { + Region::Allotment xa, ya; + allocation->span(xaxis, xa); + allocation->span(yaxis, ya); - if (! Math::equal(xa.end - xa.begin, _settings[xaxis].uvalue - _settings[xaxis].lvalue, epsilon)) - { - _settings[xaxis].uvalue = _settings[xaxis].lvalue + xa.end - xa.begin; - _xadjustment->uvalue(_settings[xaxis].uvalue); - } - if (! Math::equal(ya.end - ya.begin, _settings[yaxis].uvalue - _settings[yaxis].lvalue, epsilon)) - { - _settings[yaxis].uvalue = ya.end - ya.begin; - _yadjustment->uvalue(_settings[yaxis].uvalue); - } + if (! Math::equal(xa.end - xa.begin, + _settings[xaxis].uvalue - _settings[xaxis].lvalue, + epsilon)) + { + _settings[xaxis].uvalue = _settings[xaxis].lvalue + xa.end - xa.begin; + _xadjustment->uvalue(_settings[xaxis].uvalue); + } + if (! Math::equal(ya.end - ya.begin, + _settings[yaxis].uvalue - _settings[yaxis].lvalue, + epsilon)) + { + _settings[yaxis].uvalue = ya.end - ya.begin; + _yadjustment->uvalue(_settings[yaxis].uvalue); + } + } } -} -void ViewportImpl::body_allocation(Region_ptr, RegionImpl *ca) -{ - /* - * FIXME!! : this implementation ignores completely the body alignment... - */ - ca->valid = true; - ca->lower.x = -(_settings[xaxis].lvalue - _settings[xaxis].lower); - ca->lower.y = -(_settings[yaxis].lvalue - _settings[yaxis].lower); - ca->lower.z = 0.; - ca->upper.x = -(_settings[xaxis].lvalue - _settings[xaxis].upper); - ca->upper.y = -(_settings[yaxis].lvalue - _settings[yaxis].upper); - ca->upper.z = 0.; - ca->xalign = ca->yalign = ca->yalign = 0.; -} + void ViewportImpl::body_allocation(Region_ptr, RegionImpl *ca) + { + /* + * FIXME!! : this implementation ignores completely the body alignment... + */ + ca->valid = true; + ca->lower.x = -(_settings[xaxis].lvalue - _settings[xaxis].lower); + ca->lower.y = -(_settings[yaxis].lvalue - _settings[yaxis].lower); + ca->lower.z = 0.; + ca->upper.x = -(_settings[xaxis].lvalue - _settings[xaxis].upper); + ca->upper.y = -(_settings[yaxis].lvalue - _settings[yaxis].upper); + ca->upper.z = 0.; + ca->xalign = ca->yalign = ca->yalign = 0.; + } -void ViewportImpl::scroll_transform(Transform_ptr tx) -{ - Vertex v; - v.x = _settings[xaxis].lvalue - _settings[xaxis].lower; - v.y = _settings[yaxis].lvalue - _settings[yaxis].lower; - v.z = 0.; - tx->translate(v); -} + void ViewportImpl::scroll_transform(Transform_ptr tx) + { + Vertex v; + v.x = _settings[xaxis].lvalue - _settings[xaxis].lower; + v.y = _settings[yaxis].lvalue - _settings[yaxis].lower; + v.z = 0.; + tx->translate(v); + } + + } // namespace +} // namespace Index: ViewportImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Layout/ViewportImpl.hh,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- ViewportImpl.hh 29 May 2002 06:49:39 -0000 1.18 +++ ViewportImpl.hh 27 Oct 2003 17:08:38 -0000 1.19 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -31,45 +31,52 @@ class RegionImpl; -class ViewportImpl : public virtual POA_Layout::Viewport, - public virtual ViewImpl, - public MonoGraphic +namespace Berlin { - class Adjustment; - public: - ViewportImpl(); - ~ViewportImpl(); - virtual void body(Fresco::Graphic_ptr); - virtual Fresco::Graphic_ptr body() { return MonoGraphic::body();} + namespace LayoutKit + { + class ViewportImpl : public virtual POA_Layout::Viewport, + public virtual ViewImpl, + public MonoGraphic + { + class Adjustment; + public: + ViewportImpl(); + ~ViewportImpl(); + virtual void body(Fresco::Graphic_ptr); + virtual Fresco::Graphic_ptr body() { return MonoGraphic::body();} - virtual Fresco::Transform_ptr transformation(); - virtual void request(Fresco::Graphic::Requisition &); + virtual Fresco::Transform_ptr transformation(); + virtual void request(Fresco::Graphic::Requisition &); - virtual void traverse(Fresco::Traversal_ptr); - virtual void draw(Fresco::DrawTraversal_ptr); - virtual void pick(Fresco::PickTraversal_ptr); + virtual void traverse(Fresco::Traversal_ptr); + virtual void draw(Fresco::DrawTraversal_ptr); + virtual void pick(Fresco::PickTraversal_ptr); - virtual void need_resize(); + virtual void need_resize(); - virtual Fresco::BoundedRange_ptr adjustment(Fresco::Axis); + virtual Fresco::BoundedRange_ptr adjustment(Fresco::Axis); - virtual void update(const CORBA::Any &); + virtual void update(const CORBA::Any &); - virtual const char *object_name() { return "Layout/ViewportImpl";} + virtual const char *object_name() { return "Layout/ViewportImpl";} -private: - virtual void activate_composite(); - void allocate_child(Fresco::Allocation::Info &); - void cache_requisition(); - void cache_allocation(Fresco::Region_ptr); - void body_allocation(Fresco::Region_ptr, RegionImpl *); - void scroll_transform(Fresco::Transform_ptr); + private: + virtual void activate_composite(); + void allocate_child(Fresco::Allocation::Info &); + void cache_requisition(); + void cache_allocation(Fresco::Region_ptr); + void body_allocation(Fresco::Region_ptr, RegionImpl *); + void scroll_transform(Fresco::Transform_ptr); - Fresco::BoundedRange::Settings _settings[2]; - RefCount_var<Fresco::BoundedRange> _xadjustment; - RefCount_var<Fresco::BoundedRange> _yadjustment; - bool _requested; - Fresco::Graphic::Requisition _requisition; -}; + Fresco::BoundedRange::Settings _settings[2]; + RefCount_var<Fresco::BoundedRange> _xadjustment; + RefCount_var<Fresco::BoundedRange> _yadjustment; + bool _requested; + Fresco::Graphic::Requisition _requisition; + }; + + } // namespace +} // namespace #endif