From bde5b6888f30253a71048f2a837a2ad3668f40f8 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Wed, 21 Aug 2013 15:59:11 -0500 Subject: [PATCH] Properly fill in display_width and display_height for 0 now. --- src/Renderer_init_sdlgl.cpp | 7 +++++++ src/components/ComponentListComponent.cpp | 7 ++++++- src/components/GuiGameEd.cpp | 5 ++--- src/components/TextEditComponent.cpp | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Renderer_init_sdlgl.cpp b/src/Renderer_init_sdlgl.cpp index 6a362c7ac..6065eb392 100644 --- a/src/Renderer_init_sdlgl.cpp +++ b/src/Renderer_init_sdlgl.cpp @@ -40,6 +40,13 @@ namespace Renderer SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); //SDL_GL_SetSwapInterval(1); //0 for immediate updates, 1 for updates synchronized with the vertical retrace, -1 for late swap tearing + SDL_DisplayMode dispMode; + SDL_GetDisplayMode(0, 0, &dispMode); + if(display_width == 0) + display_width = dispMode.w; + if(display_height == 0) + display_height = dispMode.h; + sdlWindow = SDL_CreateWindow("EmulationStation", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, display_width, display_height, diff --git a/src/components/ComponentListComponent.cpp b/src/components/ComponentListComponent.cpp index e2f706428..225525225 100644 --- a/src/components/ComponentListComponent.cpp +++ b/src/components/ComponentListComponent.cpp @@ -84,6 +84,8 @@ void ComponentListComponent::setEntry(Eigen::Vector2i pos, Eigen::Vector2i size, updateCellSize(&mEntries.back(), autoFit.x(), autoFit.y()); component->setPosition(getCellOffset(pos)); + + updateSize(); } void ComponentListComponent::forceRowHeight(int row, unsigned int size) @@ -91,6 +93,7 @@ void ComponentListComponent::forceRowHeight(int row, unsigned int size) mRowHeights[row] = size; mRowHeightForced[row] = true; updateSize(); + updateComponentOffsets(); } void ComponentListComponent::forceColumnWidth(int col, unsigned int size) @@ -98,6 +101,7 @@ void ComponentListComponent::forceColumnWidth(int col, unsigned int size) mColumnWidths[col] = size; mRowHeightForced[col] = true; updateSize(); + updateComponentOffsets(); } unsigned int ComponentListComponent::getRowHeight(int row) { return mRowHeights[row]; } @@ -218,6 +222,7 @@ void ComponentListComponent::updateCellSize(ComponentEntry* e, bool updWidth, bo } updateComponentOffsets(); + updateSize(); } void ComponentListComponent::updateComponent(GuiComponent* cmp) @@ -405,7 +410,7 @@ void ComponentListComponent::render(const Eigen::Affine3f& parentTrans) 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); + Renderer::drawRect(0, 0, (int)entry->component->getSize().x(), (int)entry->component->getSize().y(), 0x0000AA22); } } diff --git a/src/components/GuiGameEd.cpp b/src/components/GuiGameEd.cpp index 0d0c73099..f420d741f 100644 --- a/src/components/GuiGameEd.cpp +++ b/src/components/GuiGameEd.cpp @@ -37,9 +37,8 @@ GuiGameEd::GuiGameEd(Window* window, GameData* game, const std::vector& mdd) mGeneratedComponents.push_back(label); GuiComponent* ed = MetaDataList::makeEditor(mWindow, iter->type); - ed->setSize(ed->getSize().x(), 256); + ed->setSize(mSize.x() / 2, ed->getSize().y()); ed->setValue(mGame->metadata()->get(iter->key)); mList.setEntry(Vector2i(1, y), Vector2i(1, 1), ed, true, ComponentListComponent::AlignRight); mGeneratedComponents.push_back(ed); diff --git a/src/components/TextEditComponent.cpp b/src/components/TextEditComponent.cpp index 945ba4b10..f8c5e4475 100644 --- a/src/components/TextEditComponent.cpp +++ b/src/components/TextEditComponent.cpp @@ -73,7 +73,7 @@ void TextEditComponent::onTextChanged() { float y = getFont()->sizeWrappedText(mText, mSize.x()).y(); if(y == 0) - y = getFont()->getHeight(); + y = (float)getFont()->getHeight(); setSize(mSize.x(), y); }