/* * DISTRHO Plugin Toolkit (DPT) * Copyright (C) 2012-2013 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * For a full copy of the license see the LGPL.txt file */ #include "../Geometry.hpp" START_NAMESPACE_DISTRHO // ------------------------------------------------- // Point template Point::Point() : fX(0), fY(0) { } template Point::Point(T x, T y) : fX(x), fY(y) { } template Point::Point(const Point& pos) : fX(pos.fX), fY(pos.fY) { } template T Point::getX() const { return fX; } template T Point::getY() const { return fY; } template void Point::setX(T x) { fX = x; } template void Point::setY(T y) { fY = y; } template void Point::move(T x, T y) { fX += x; fY += y; } template void Point::move(const Point& pos) { fX += pos.fX; fY += pos.fY; } template Point& Point::operator=(const Point& pos) { fX = pos.fX; fY = pos.fY; return *this; } template Point& Point::operator+=(const Point& pos) { fX += pos.fX; fY += pos.fY; return *this; } template Point& Point::operator-=(const Point& pos) { fX -= pos.fX; fY -= pos.fY; return *this; } template bool Point::operator==(const Point& pos) const { return (fX == pos.fX && fY== pos.fY); } template bool Point::operator!=(const Point& pos) const { return !operator==(pos); } // ------------------------------------------------- // Size template Size::Size() : fWidth(0), fHeight(0) { } template Size::Size(T width, T height) : fWidth(width), fHeight(height) { } template Size::Size(const Size& size) : fWidth(size.fWidth), fHeight(size.fHeight) { } template T Size::getWidth() const { return fWidth; } template T Size::getHeight() const { return fHeight; } template void Size::setWidth(T width) { fWidth = width; } template void Size::setHeight(T height) { fHeight = height; } template Size& Size::operator=(const Size& size) { fWidth = size.fWidth; fHeight = size.fHeight; return *this; } template Size& Size::operator+=(const Size& size) { fWidth += size.fWidth; fHeight += size.fHeight; return *this; } template Size& Size::operator-=(const Size& size) { fWidth -= size.fWidth; fHeight -= size.fHeight; return *this; } template Size& Size::operator*=(T m) { fWidth *= m; fHeight *= m; return *this; } template Size& Size::operator/=(T d) { fWidth /= d; fHeight /= d; return *this; } template bool Size::operator==(const Size& size) const { return (fWidth == size.fWidth && fHeight == size.fHeight); } template bool Size::operator!=(const Size& size) const { return !operator==(size); } // ------------------------------------------------- // Rectangle template Rectangle::Rectangle() : fPos(0, 0), fSize(0, 0) { } template Rectangle::Rectangle(T x, T y, T width, T height) : fPos(x, y), fSize(width, height) { } template Rectangle::Rectangle(T x, T y, const Size& size) : fPos(x, y), fSize(size) { } template Rectangle::Rectangle(const Point& pos, T width, T height) : fPos(pos), fSize(width, height) { } template Rectangle::Rectangle(const Point& pos, const Size& size) : fPos(pos), fSize(size) { } template Rectangle::Rectangle(const Rectangle& rect) : fPos(rect.fPos), fSize(rect.fSize) { } template T Rectangle::getX() const { return fPos.fX; } template T Rectangle::getY() const { return fPos.fY; } template T Rectangle::getWidth() const { return fSize.fWidth; } template T Rectangle::getHeight() const { return fSize.fHeight; } template const Point& Rectangle::getPos() const { return fPos; } template const Size& Rectangle::getSize() const { return fSize; } template bool Rectangle::contains(T x, T y) const { return (x >= fPos.fX && y >= fPos.fY && x <= fPos.fX+fSize.fWidth && y <= fPos.fY+fSize.fHeight); } template bool Rectangle::contains(const Point& pos) const { return contains(pos.fX, pos.fY); } template bool Rectangle::containsX(T x) const { return (x >= fPos.fX && x <= fPos.fX + fSize.fWidth); } template bool Rectangle::containsY(T y) const { return (y >= fPos.fY && y <= fPos.fY + fSize.fHeight); } template void Rectangle::setX(T x) { fPos.fX = x; } template void Rectangle::setY(T y) { fPos.fY = y; } template void Rectangle::setPos(T x, T y) { fPos.fX = x; fPos.fY = y; } template void Rectangle::setPos(const Point& pos) { fPos = pos; } template void Rectangle::move(T x, T y) { fPos.fX += x; fPos.fY += y; } template void Rectangle::move(const Point& pos) { fPos += pos; } template void Rectangle::setWidth(T width) { fSize.fWidth = width; } template void Rectangle::setHeight(T height) { fSize.fHeight = height; } template void Rectangle::setSize(T width, T height) { fSize.fWidth = width; fSize.fHeight = height; } template void Rectangle::setSize(const Size& size) { fSize = size; } template Rectangle& Rectangle::operator=(const Rectangle& rect) { fPos = rect.fPos; fSize = rect.fSize; return *this; } // ------------------------------------------------- // Possible template data types template class Point; template class Point; template class Point; template class Point; template class Size; template class Size; template class Size; template class Size; template class Rectangle; template class Rectangle; template class Rectangle; template class Rectangle; // ------------------------------------------------- END_NAMESPACE_DISTRHO