static int MakeBottomRow(const InfoBoxLayout::Layout &layout, PixelRect *p, unsigned n, int left, int right, int bottom) { int top = bottom - layout.control_size.cy; MakeTopRow(layout, p, n, left, right, top); return top; }
static int MakeBottomRow(const InfoBoxLayout::Layout &layout, PixelRect *p, unsigned n, PixelScalar left, PixelScalar bottom) { PixelScalar top = bottom - layout.control_height; MakeTopRow(layout, p, n, left, top); return top; }
InfoBoxLayout::Layout InfoBoxLayout::Calculate(PixelRect rc, InfoBoxSettings::Geometry geometry) { const PixelSize screen_size = rc.GetSize(); geometry = ValidateGeometry(geometry, screen_size); Layout layout; layout.geometry = geometry; layout.landscape = screen_size.cx > screen_size.cy; layout.count = geometry_counts[(unsigned)geometry]; assert(layout.count <= InfoBoxSettings::Panel::MAX_CONTENTS); CalcInfoBoxSizes(layout, screen_size, geometry); layout.ClearVario(); unsigned right = rc.right; switch (geometry) { case InfoBoxSettings::Geometry::SPLIT_8: case InfoBoxSettings::Geometry::OBSOLETE_SPLIT_8: if (layout.landscape) { rc.left = MakeLeftColumn(layout, layout.positions, 4, rc.left, rc.top, rc.bottom); rc.right = MakeRightColumn(layout, layout.positions + 4, 4, rc.right, rc.top, rc.bottom); } else { rc.top = MakeTopRow(layout, layout.positions, 4, rc.left, rc.right, rc.top); rc.bottom = MakeBottomRow(layout, layout.positions + 4, 4, rc.left, rc.right, rc.bottom); } break; case InfoBoxSettings::Geometry::BOTTOM_8_VARIO: layout.vario.left = rc.right - layout.control_size.cx; layout.vario.right = rc.right; layout.vario.top = rc.bottom - layout.control_size.cy * 2; layout.vario.bottom = rc.bottom; right = layout.vario.left; /* fall through */ case InfoBoxSettings::Geometry::BOTTOM_RIGHT_8: case InfoBoxSettings::Geometry::OBSOLETE_BOTTOM_RIGHT_8: if (layout.landscape) { rc.right = MakeRightColumn(layout, layout.positions + 4, 4, rc.right, rc.top, rc.bottom); rc.right = MakeRightColumn(layout, layout.positions, 4, rc.right, rc.top, rc.bottom); } else { rc.bottom = MakeBottomRow(layout, layout.positions + 4, 4, rc.left, right, rc.bottom); rc.bottom = MakeBottomRow(layout, layout.positions, 4, rc.left, right, rc.bottom); } break; case InfoBoxSettings::Geometry::TOP_8_VARIO: layout.vario.left = rc.right - layout.control_size.cx; layout.vario.right = rc.right; layout.vario.top = rc.top; layout.vario.bottom = rc.top + layout.control_size.cy * 2; right = layout.vario.left; /* fall through */ case InfoBoxSettings::Geometry::TOP_LEFT_8: case InfoBoxSettings::Geometry::OBSOLETE_TOP_LEFT_8: if (layout.landscape) { rc.left = MakeLeftColumn(layout, layout.positions, 4, rc.left, rc.top, rc.bottom); rc.left = MakeLeftColumn(layout, layout.positions + 4, 4, rc.left, rc.top, rc.bottom); } else { rc.top = MakeTopRow(layout, layout.positions, 4, rc.left, right, rc.top); rc.top = MakeTopRow(layout, layout.positions + 4, 4, rc.left, right, rc.top); } break; case InfoBoxSettings::Geometry::LEFT_6_RIGHT_3_VARIO: layout.vario.left = rc.right - layout.control_size.cx; layout.vario.right = rc.right; layout.vario.top = 0; layout.vario.bottom = layout.vario.top + layout.control_size.cy * 3; rc.left = MakeLeftColumn(layout, layout.positions, 6, rc.left, rc.top, rc.bottom); rc.right = MakeRightColumn(layout, layout.positions + 6, 3, rc.right, rc.top + 3 * layout.control_size.cy, rc.bottom); break; case InfoBoxSettings::Geometry::LEFT_12_RIGHT_3_VARIO: layout.vario.left = rc.right - layout.control_size.cx; layout.vario.right = rc.right; layout.vario.top = 0; layout.vario.bottom = layout.vario.top + layout.control_size.cy * 3; rc.right = MakeRightColumn(layout, layout.positions + 6, 3, rc.right, rc.top + 3 * layout.control_size.cy, rc.bottom); layout.control_size.cx = layout.control_size.cy * 1.1; rc.left = MakeLeftColumn(layout, layout.positions, 6, rc.left, rc.top, rc.bottom); rc.left = MakeLeftColumn(layout, layout.positions + 9, 6, rc.left, rc.top, rc.bottom); break; case InfoBoxSettings::Geometry::BOTTOM_RIGHT_12: case InfoBoxSettings::Geometry::OBSOLETE_BOTTOM_RIGHT_12: if (layout.landscape) { rc.right = MakeRightColumn(layout, layout.positions + 6, 6, rc.right, rc.top, rc.bottom); rc.right = MakeRightColumn(layout, layout.positions, 6, rc.right, rc.top, rc.bottom); } else { rc.bottom = MakeBottomRow(layout, layout.positions + 6, 6, rc.left, rc.right, rc.bottom); rc.bottom = MakeBottomRow(layout, layout.positions, 6, rc.left, rc.right, rc.bottom); } break; case InfoBoxSettings::Geometry::TOP_LEFT_12: if (layout.landscape) { rc.left = MakeLeftColumn(layout, layout.positions, 6, rc.left, rc.top, rc.bottom); rc.left = MakeLeftColumn(layout, layout.positions + 6, 6, rc.left, rc.top, rc.bottom); } else { rc.top = MakeTopRow(layout, layout.positions, 6, rc.left, rc.right, rc.top); rc.top = MakeTopRow(layout, layout.positions + 6, 6, rc.left, rc.right, rc.top); } break; case InfoBoxSettings::Geometry::RIGHT_16: rc.right = MakeRightColumn(layout, layout.positions + 8, 8, rc.right, rc.top, rc.bottom); rc.right = MakeRightColumn(layout, layout.positions, 8, rc.right, rc.top, rc.bottom); break; case InfoBoxSettings::Geometry::RIGHT_24: rc.right = MakeRightColumn(layout, layout.positions + 16, 8, rc.right, rc.top, rc.bottom); rc.right = MakeRightColumn(layout, layout.positions + 8, 8, rc.right, rc.top, rc.bottom); rc.right = MakeRightColumn(layout, layout.positions, 8, rc.right, rc.top, rc.bottom); break; case InfoBoxSettings::Geometry::RIGHT_9_VARIO: layout.vario.left = rc.right - layout.control_size.cx; layout.vario.right = rc.right; layout.vario.top = 0; layout.vario.bottom = layout.vario.top + layout.control_size.cy * 3; rc.right = MakeRightColumn(layout, layout.positions + 6, 3, rc.right, rc.top + 3 * layout.control_size.cy, rc.bottom); rc.right = MakeRightColumn(layout, layout.positions, 6, rc.right, rc.top, rc.bottom); break; case InfoBoxSettings::Geometry::RIGHT_5: rc.right = MakeRightColumn(layout, layout.positions, 5, rc.right, rc.top, rc.bottom); break; case InfoBoxSettings::Geometry::TOP_LEFT_4: case InfoBoxSettings::Geometry::OBSOLETE_TOP_LEFT_4: if (layout.landscape) rc.left = MakeLeftColumn(layout, layout.positions, 4, rc.left, rc.top, rc.bottom); else rc.top = MakeTopRow(layout, layout.positions, 4, rc.left, rc.right, rc.top); break; case InfoBoxSettings::Geometry::BOTTOM_RIGHT_4: case InfoBoxSettings::Geometry::OBSOLETE_BOTTOM_RIGHT_4: if (layout.landscape) rc.right = MakeRightColumn(layout, layout.positions, 4, rc.right, rc.top, rc.bottom); else rc.bottom = MakeBottomRow(layout, layout.positions, 4, rc.left, rc.right, rc.bottom); break; }; layout.remaining = rc; return layout; }
InfoBoxLayout::Layout InfoBoxLayout::Calculate(PixelRect rc, InfoBoxSettings::Geometry geometry) { geometry = ValidateGeometry(geometry, rc.right - rc.left, rc.bottom - rc.top); Layout layout; layout.geometry = geometry; layout.count = geometry_counts[(unsigned)geometry]; assert(layout.count <= InfoBoxSettings::Panel::MAX_CONTENTS); CalcInfoBoxSizes(layout, rc, geometry); layout.ClearVario(); switch (geometry) { case InfoBoxSettings::Geometry::TOP_4_BOTTOM_4: rc.top = MakeTopRow(layout, layout.positions, 4, rc.left, rc.top); rc.bottom = MakeBottomRow(layout, layout.positions + 4, 4, rc.left, rc.bottom); break; case InfoBoxSettings::Geometry::BOTTOM_8_VARIO: layout.vario.left = rc.right - layout.control_width; layout.vario.right = rc.right; layout.vario.top = rc.bottom - layout.control_height * 2; layout.vario.bottom = rc.bottom; /* fall through */ case InfoBoxSettings::Geometry::BOTTOM_8: rc.bottom = MakeBottomRow(layout, layout.positions + 4, 4, rc.left, rc.bottom); rc.bottom = MakeBottomRow(layout, layout.positions, 4, rc.left, rc.bottom); break; case InfoBoxSettings::Geometry::TOP_8: rc.top = MakeTopRow(layout, layout.positions, 4, rc.left, rc.top); rc.top = MakeTopRow(layout, layout.positions + 4, 4, rc.left, rc.top); break; case InfoBoxSettings::Geometry::LEFT_4_RIGHT_4: rc.left = MakeLeftColumn(layout, layout.positions, 4, rc.left, rc.top); rc.right = MakeRightColumn(layout, layout.positions + 4, 4, rc.right, rc.top); break; case InfoBoxSettings::Geometry::LEFT_6_RIGHT_3_VARIO: layout.vario.left = rc.right - layout.control_width; layout.vario.right = rc.right; layout.vario.top = 0; layout.vario.bottom = layout.vario.top + layout.control_height * 3; rc.left = MakeLeftColumn(layout, layout.positions, 6, rc.left, rc.top); rc.right = MakeRightColumn(layout, layout.positions + 6, 3, rc.right, rc.top + 3 * layout.control_height); break; case InfoBoxSettings::Geometry::LEFT_8: rc.left = MakeLeftColumn(layout, layout.positions, 4, rc.left, rc.top); rc.left = MakeLeftColumn(layout, layout.positions + 4, 4, rc.left, rc.top); break; case InfoBoxSettings::Geometry::RIGHT_8: rc.right = MakeRightColumn(layout, layout.positions + 4, 4, rc.right, rc.top); rc.right = MakeRightColumn(layout, layout.positions, 4, rc.right, rc.top); break; case InfoBoxSettings::Geometry::RIGHT_12: rc.right = MakeRightColumn(layout, layout.positions + 6, 6, rc.right, rc.top); rc.right = MakeRightColumn(layout, layout.positions, 6, rc.right, rc.top); break; case InfoBoxSettings::Geometry::BOTTOM_12: rc.bottom = MakeBottomRow(layout, layout.positions + 6, 6, rc.left, rc.bottom); rc.bottom = MakeBottomRow(layout, layout.positions, 6, rc.left, rc.bottom); break; case InfoBoxSettings::Geometry::TOP_12: rc.top = MakeTopRow(layout, layout.positions, 6, rc.left, rc.top); rc.top = MakeTopRow(layout, layout.positions + 6, 6, rc.left, rc.top); break; case InfoBoxSettings::Geometry::RIGHT_24: rc.right = MakeRightColumn(layout, layout.positions + 16, 8, rc.right, rc.top); rc.right = MakeRightColumn(layout, layout.positions + 8, 8, rc.right, rc.top); rc.right = MakeRightColumn(layout, layout.positions, 8, rc.right, rc.top); break; case InfoBoxSettings::Geometry::RIGHT_9_VARIO: layout.vario.left = rc.right - layout.control_width; layout.vario.right = rc.right; layout.vario.top = 0; layout.vario.bottom = layout.vario.top + layout.control_height * 3; rc.right = MakeRightColumn(layout, layout.positions + 6, 3, rc.right, rc.top + 3 * layout.control_height); rc.right = MakeRightColumn(layout, layout.positions, 6, rc.right, rc.top); break; case InfoBoxSettings::Geometry::RIGHT_5: rc.right = MakeRightColumn(layout, layout.positions, 5, rc.right, rc.top); break; case InfoBoxSettings::Geometry::TOP_4: rc.top = MakeTopRow(layout, layout.positions, 4, rc.left, rc.top); break; case InfoBoxSettings::Geometry::BOTTOM_4: rc.bottom = MakeBottomRow(layout, layout.positions, 4, rc.left, rc.bottom); break; case InfoBoxSettings::Geometry::LEFT_4: rc.left = MakeLeftColumn(layout, layout.positions, 4, rc.left, rc.top); break; case InfoBoxSettings::Geometry::RIGHT_4: rc.right = MakeRightColumn(layout, layout.positions, 4, rc.right, rc.top); break; }; layout.remaining = rc; return layout; }