Expand Up
@@ -505,7 +505,7 @@ void MythUIType::SetPosition(const MythPoint &point)
MythPoint pos (point);
if (m_Parent)
pos.CalculatePoint (m_Parent->GetArea ());
pos.CalculatePoint (m_Parent->GetFullArea ());
else
pos.CalculatePoint (GetMythMainWindow ()->GetUIScreenRect ());
Expand Down
Expand Up
@@ -552,7 +552,7 @@ void MythUIType::SetMinSize(const MythPoint &minsize)
MythPoint point (minsize);
if (m_Parent)
point.CalculatePoint (m_Parent->GetArea ());
point.CalculatePoint (m_Parent->GetFullArea ());
m_MinSize = point;
}
Expand All
@@ -573,13 +573,6 @@ void MythUIType::SetArea(const MythRect &rect)
m_DirtyRegion = QRegion (m_Area.toQRect ());
m_Area = rect;
if (m_Area.width () > m_NormalSize.width ())
m_NormalSize.setWidth (m_Area.width ());
if (m_Area.height () > m_NormalSize.height ())
m_NormalSize.setHeight (m_Area.height ());
RecalculateArea ();
if (m_Parent)
Expand All
@@ -591,39 +584,58 @@ void MythUIType::SetArea(const MythRect &rect)
/* *
* Adjust the size of a sibling.
*/
void MythUIType::AdjustMinArea (int delta_x, int delta_y)
void MythUIType::AdjustMinArea (int delta_x, int delta_y,
int delta_w, int delta_h)
{
// If a minsize is not set, don't use MinArea
if (!m_MinSize.isValid ())
return ;
if (m_Area.width () < m_NormalSize.width ())
m_Area.setWidth (m_NormalSize.width ());
// Delta's are negative values; knock down the area
QRect bounded (m_Area.x () - delta_x,
m_Area.y () - delta_y,
m_Area.width () + delta_w,
m_Area.height () + delta_h);
if (m_Area.height () < m_NormalSize.height ())
m_Area.setHeight (m_NormalSize.height ());
// Make sure we have not violated the min size
if (!bounded.isNull () || !m_Vanish)
{
QPoint center = bounded.center ();
QSize size (m_Area.size ());
if (bounded.isNull ())
bounded.setSize (GetMinSize ());
else
bounded.setSize (bounded.size ().expandedTo (GetMinSize ()));
size.setWidth (size.width () + delta_x);
size.setHeight (size.height () + delta_y);
m_MinArea.setSize (size);
m_MinArea.moveLeft (m_Area.x ());
m_MinArea.moveTop (m_Area.y ());
bounded.moveCenter (center);
}
QSize bound (m_MinArea.width (), m_MinArea.height ());
bound = bound.expandedTo (GetMinSize ());
if (bounded.x () + bounded.width () > m_Area.x () + m_Area.width ())
bounded.moveRight (m_Area.x () + m_Area.width ());
if (bounded.y () + bounded.height () > m_Area.y () + m_Area.height ())
bounded.moveBottom (m_Area.x () + m_Area.height ());
if (bounded.x () < m_Area.x ())
{
bounded.moveLeft (m_Area.x ());
if (bounded.width () > m_Area.width ())
bounded.setWidth (m_Area.width ());
}
if (bounded.y () < m_Area.y ())
{
bounded.moveTop (m_Area.y ());
if (bounded.height () > m_Area.height ())
bounded.setHeight (m_Area.height ());
}
m_MinArea.setWidth (bound.width ());
m_MinArea.setHeight (bound.height ());
m_MinArea = bounded;
m_Vanished = false ;
QList<MythUIType *>::iterator it;
for (it = m_ChildrenList.begin (); it != m_ChildrenList.end (); ++it)
{
if (!(*it)->m_Initiator )
(*it)->AdjustMinArea (delta_x, delta_y);
(*it)->AdjustMinArea (delta_x, delta_y, delta_w, delta_h );
}
}
Expand Down
Expand Up
@@ -651,23 +663,15 @@ void MythUIType::VanishSibling(void)
* Adjust the size of sibling objects within the button.
*/
void MythUIType::SetMinAreaParent (MythRect actual_area, MythRect allowed_area,
const MythUIType *calling_child)
MythUIType *calling_child)
{
int delta_x = 0 , delta_y = 0 ;
int delta_x = 0 , delta_y = 0 , delta_w = 0 , delta_h = 0 ;
MythRect area;
// If a minsize is not set, don't use MinArea
if (!m_MinSize.isValid ())
return ;
m_MinArea.setWidth (0 );
if (m_Area.width () < m_NormalSize.width ())
m_Area.setWidth (m_NormalSize.width ());
if (m_Area.height () < m_NormalSize.height ())
m_Area.setHeight (m_NormalSize.height ());
if (calling_child->m_Vanished )
{
actual_area.moveLeft (0 );
Expand All
@@ -676,8 +680,8 @@ void MythUIType::SetMinAreaParent(MythRect actual_area, MythRect allowed_area,
allowed_area.moveTop (0 );
}
actual_area.translate (m_Area.topLeft ());
allowed_area.translate (m_Area.topLeft ());
actual_area.translate (m_Area.x (), m_Area. y ());
allowed_area.translate (m_Area.x (), m_Area. y ());
QList<MythUIType *>::iterator it;
Expand All
@@ -686,14 +690,17 @@ void MythUIType::SetMinAreaParent(MythRect actual_area, MythRect allowed_area,
if (*it == calling_child || !(*it)->m_Initiator )
continue ;
// Find union of area(s)
area = (*it)->GetArea ();
area.translate (m_Area.topLeft ());
actual_area = actual_area.united (area);
area = (*it)->m_Area ;
area.translate (m_Area.topLeft ());
allowed_area = allowed_area.united (area);
if (!(*it)->m_Vanished )
{
// Find union of area(s)
area = (*it)->GetArea ();
area.translate (m_Area.x (), m_Area.y ());
actual_area = actual_area.united (area);
area = (*it)->m_Area ;
area.translate (m_Area.x (), m_Area.y ());
allowed_area = allowed_area.united (area);
}
}
// Make sure it is not larger than the area allowed
Expand All
@@ -708,17 +715,17 @@ void MythUIType::SetMinAreaParent(MythRect actual_area, MythRect allowed_area,
{
if (calling_child->m_Vanished )
{
delta_x = (actual_area .x () + actual_area.width ()) -
( m_Area.x () + m_Area. width () );
delta_y = ( actual_area.y () + actual_area. height ()) -
(m_Area. y () + m_Area.height () );
delta_x = m_Area .x () - actual_area.x ();
delta_y = m_Area.y () - actual_area. y ( );
delta_w = actual_area.width () - m_Area. width ();
delta_h = actual_area. height () - m_Area.height ();
}
else
{
delta_x = (actual_area .x () + actual_area.width ()) -
( allowed_area.x () + allowed_area. width () );
delta_y = ( actual_area.y () + actual_area. height ()) -
(allowed_area. y () + allowed_area.height () );
delta_x = allowed_area .x () - actual_area.x ();
delta_y = allowed_area.y () - actual_area. y ( );
delta_w = actual_area.width () - allowed_area. width ();
delta_h = actual_area. height () - allowed_area.height ();
}
m_Vanished = false ;
Expand All
@@ -734,26 +741,29 @@ void MythUIType::SetMinAreaParent(MythRect actual_area, MythRect allowed_area,
if (m_Vanished)
(*it)->VanishSibling ();
else
(*it)->AdjustMinArea (delta_x, delta_y);
(*it)->AdjustMinArea (delta_x, delta_y, delta_w, delta_h );
}
area = (*it)->GetArea ();
area.translate (m_Area.topLeft ());
actual_area = actual_area.united (area);
}
QSize bound (actual_area.width (), actual_area.height ());
if (m_Vanished)
{
m_MinArea.moveLeft ( 0 );
m_MinArea. moveTop ( 0 );
m_MinArea.setRect ( 0 , 0 , 0 , 0 );
actual_area. setRect ( 0 , 0 , 0 , 0 );
}
else
bound = bound.expandedTo (GetMinSize ());
{
QSize bound (actual_area.width (), actual_area.height ());
m_MinArea.setWidth (bound.width ());
m_MinArea.setHeight (bound.height ());
bound = bound.expandedTo (GetMinSize ());
m_MinArea.setRect (actual_area.x (),
actual_area.y (),
actual_area.x () + bound.width (),
actual_area.y () + bound.height ());
}
if (m_Parent)
m_Parent->SetMinAreaParent (actual_area, m_Area, this );
Expand All
@@ -762,54 +772,51 @@ void MythUIType::SetMinAreaParent(MythRect actual_area, MythRect allowed_area,
/* *
* Set the minimum area based on the given size
*/
void MythUIType::SetMinArea (const QSize &size )
void MythUIType::SetMinArea (const MythRect &rect )
{
// If a minsize is not set, don't use MinArea
if (!m_Initiator || !m_MinSize.isValid ())
return ;
m_MinArea.setWidth (0 );
if (m_Area.width () < m_NormalSize.width ())
m_Area.setWidth (m_NormalSize.width ());
if (m_Area.height () < m_NormalSize.height ())
m_Area.setHeight (m_NormalSize.height ());
/* *
* The MinArea will have the same origin as the normal Area,
* but can have a smaller size.
*/
QSize bounded (size);
if (!bounded.isNull () || !m_Vanish)
{
if (bounded.isNull ())
bounded = GetMinSize ();
else
bounded = bounded.expandedTo (GetMinSize ());
bounded = bounded.boundedTo (m_Area.size ());
}
if (m_Vanish == m_Vanished && bounded == m_MinArea.size ())
return ;
m_MinArea.setWidth (bounded.width ());
m_MinArea.setHeight (bounded.height ());
m_Vanished = (m_Vanish && m_MinArea.size ().isNull ());
QRect bounded (rect);
bool vanish = (m_Vanish && rect.isNull ());
if (m_Vanished )
if (vanish )
{
m_MinArea .moveLeft (0 );
m_MinArea .moveTop (0 );
bounded .moveLeft (0 );
bounded .moveTop (0 );
}
else
{
m_MinArea.moveLeft (m_Area.x ());
m_MinArea.moveTop (m_Area.y ());
QPoint center = bounded.center ();
if (bounded.isNull ())
bounded.setSize (GetMinSize ());
else
bounded.setSize (bounded.size ().expandedTo (GetMinSize ()));
bounded.moveCenter (center);
if (bounded.x () + bounded.width () > m_Area.x () + m_Area.width ())
bounded.moveRight (m_Area.x () + m_Area.width ());
if (bounded.y () + bounded.height () > m_Area.y () + m_Area.height ())
bounded.moveBottom (m_Area.x () + m_Area.height ());
if (bounded.x () < m_Area.x ())
{
bounded.moveLeft (m_Area.x ());
if (bounded.width () > m_Area.width ())
bounded.setWidth (m_Area.width ());
}
if (bounded.y () < m_Area.y ())
{
bounded.moveTop (m_Area.y ());
if (bounded.height () > m_Area.height ())
bounded.setHeight (m_Area.height ());
}
}
m_MinArea = bounded;
m_Vanished = vanish;
if (m_Parent)
m_Parent->SetMinAreaParent (m_MinArea, m_Area, this );
}
Expand Down
Expand Up
@@ -838,6 +845,11 @@ MythRect MythUIType::GetArea(void) const
return m_Area;
}
MythRect MythUIType::GetFullArea (void ) const
{
return m_Area;
}
QRegion MythUIType::GetDirtyArea (void ) const
{
return m_DirtyRegion;
Expand Down
Expand Up
@@ -1032,10 +1044,8 @@ void MythUIType::CopyFrom(MythUIType *base)
SetArea (base->m_Area );
m_MinSize = base->m_MinSize ;
m_Initiator = base->m_Initiator ;
m_Vanish = base->m_Vanish ;
m_Vanished = base->m_Vanished ;
m_NormalSize = base->m_NormalSize ;
m_Vanished = false ;
m_Alpha = base->m_Alpha ;
m_AlphaChangeMode = base->m_AlphaChangeMode ;
m_AlphaChange = base->m_AlphaChange ;
Expand All
@@ -1060,8 +1070,7 @@ void MythUIType::CopyFrom(MythUIType *base)
(*it)->CreateCopy (this );
}
if (m_Initiator)
SetMinArea (base->m_MinArea .size ());
SetMinArea (base->m_MinArea );
}
/* *
Expand Down
Expand Up
@@ -1166,16 +1175,10 @@ bool MythUIType::AddFont(const QString &text, MythFontProperties *fontProp)
void MythUIType::RecalculateArea (bool recurse)
{
if (m_Parent)
m_Area.CalculateArea (m_Parent->GetArea ());
m_Area.CalculateArea (m_Parent->GetFullArea ());
else
m_Area.CalculateArea (GetMythMainWindow ()->GetUIScreenRect ());
if (m_Area.width () > m_NormalSize.width ())
m_NormalSize.setWidth (m_Area.width ());
if (m_Area.height () > m_NormalSize.height ())
m_NormalSize.setHeight (m_Area.height ());
if (recurse)
{
QList<MythUIType *>::iterator it;
Expand Down