diff --git a/src/GuiComponent.h b/src/GuiComponent.h index 99841b592..d695b38c8 100644 --- a/src/GuiComponent.h +++ b/src/GuiComponent.h @@ -58,6 +58,8 @@ public: unsigned char getOpacity() const; void setOpacity(unsigned char opacity); + const Eigen::Affine3f getTransform(); + protected: void renderChildren(const Eigen::Affine3f& transform) const; @@ -70,8 +72,6 @@ protected: Eigen::Vector3f mPosition; Eigen::Vector2f mSize; - const Eigen::Affine3f getTransform(); - private: Eigen::Affine3f mTransform; //Don't access this directly! Use getTransform()! }; diff --git a/src/components/ComponentListComponent.cpp b/src/components/ComponentListComponent.cpp index b40c4b1b1..69f978018 100644 --- a/src/components/ComponentListComponent.cpp +++ b/src/components/ComponentListComponent.cpp @@ -101,9 +101,11 @@ Eigen::Vector3f ComponentListComponent::getCellOffset(Eigen::Vector2i pos) for(int x = 0; x < pos.x(); x++) offset[0] += getColumnWidth(x); + //LOG(LogInfo) << "total offsets up to " << pos.x() << ", " << pos.y() << ": " << offset.x() << ", " << offset.y(); + ComponentEntry* entry = getCell(pos.x(), pos.y()); - Eigen::Vector2i gridSize; + Eigen::Vector2i gridSize(0, 0); for(int x = pos.x(); x < pos.x() + entry->dim[0]; x++) gridSize[0] += getColumnWidth(x); for(int y = pos.y(); y < pos.y() + entry->dim[1]; y++) @@ -273,6 +275,7 @@ void ComponentListComponent::update(int deltaTime) void ComponentListComponent::render(const Eigen::Affine3f& parentTrans) { Eigen::Affine3f trans = parentTrans * getTransform(); + Renderer::setMatrix(trans); Renderer::drawRect(0, 0, (int)getSize().x(), (int)getSize().y(), 0xFFFFFFAA); @@ -281,30 +284,35 @@ void ComponentListComponent::render(const Eigen::Affine3f& parentTrans) iter->component->render(trans); } + //draw cell outlines - /*Vector2i pos; - for(unsigned int x = 0; x < mGridSize.x; x++) + /*Renderer::setMatrix(trans); + Eigen::Vector2i pos(0, 0); + for(int x = 0; x < mGridSize.x(); x++) { - for(unsigned int y = 0; y < mGridSize.y; y++) + for(int y = 0; y < mGridSize.y(); y++) { - Renderer::drawRect(pos.x, pos.y, getColumnWidth(x), 2, 0x000000AA); - Renderer::drawRect(pos.x, pos.y, 2, getRowHeight(y), 0x000000AA); - Renderer::drawRect(pos.x + getColumnWidth(x), pos.y, 2, getRowHeight(y), 0x000000AA); - Renderer::drawRect(pos.x, pos.y + getRowHeight(y) - 2, getColumnWidth(x), 2, 0x000000AA); + Renderer::drawRect(pos.x(), pos.y(), getColumnWidth(x), 2, 0x000000AA); + Renderer::drawRect(pos.x(), pos.y(), 2, getRowHeight(y), 0x000000AA); + Renderer::drawRect(pos.x() + getColumnWidth(x), pos.y(), 2, getRowHeight(y), 0x000000AA); + Renderer::drawRect(pos.x(), pos.y() + getRowHeight(y) - 2, getColumnWidth(x), 2, 0x000000AA); - pos.y += getRowHeight(y); + pos[1] += getRowHeight(y); } - pos.y = 0; - pos.x += getColumnWidth(x); + pos[1] = 0; + pos[0] += getColumnWidth(x); }*/ //draw cursor if(cursorValid()) { ComponentEntry* entry = getCell(mCursor.x(), mCursor.y()); - Renderer::drawRect((int)entry->component->getPosition().x(), (int)entry->component->getPosition().y(), 4, 4, 0xFF0000FF); - Renderer::drawRect((int)entry->component->getPosition().x(), (int)entry->component->getPosition().y(), (int)entry->component->getSize().x(), (int)entry->component->getSize().y(), 0x0000AA88); + Eigen::Affine3f entryTrans = trans * entry->component->getTransform(); + Renderer::setMatrix(entryTrans); + + Renderer::drawRect(0, 0, 4, 4, 0xFF0000FF); + Renderer::drawRect(0, 0, (int)entry->component->getSize().x(), (int)entry->component->getSize().y(), 0x0000AA88); } } diff --git a/src/components/GuiMenu.cpp b/src/components/GuiMenu.cpp index 3b4bf93b9..b5963790b 100644 --- a/src/components/GuiMenu.cpp +++ b/src/components/GuiMenu.cpp @@ -95,6 +95,7 @@ void GuiMenu::update(int deltaTime) void GuiMenu::render(const Eigen::Affine3f& parentTrans) { Eigen::Affine3f trans = parentTrans; + Renderer::setMatrix(trans); Renderer::drawRect(Renderer::getScreenWidth() / 4, 0, Renderer::getScreenWidth() / 2, Renderer::getScreenHeight(), 0x999999); mList->render(trans); diff --git a/src/components/SliderComponent.cpp b/src/components/SliderComponent.cpp index 622daefbd..68a1e17b1 100644 --- a/src/components/SliderComponent.cpp +++ b/src/components/SliderComponent.cpp @@ -68,6 +68,7 @@ void SliderComponent::update(int deltaTime) void SliderComponent::render(const Eigen::Affine3f& parentTrans) { Eigen::Affine3f trans = parentTrans * getTransform(); + Renderer::setMatrix(trans); //render line const int lineWidth = 2;