Properly fill in display_width and display_height for 0 now.

This commit is contained in:
Aloshi 2013-08-21 15:59:11 -05:00
parent bed9c1fbb5
commit bde5b6888f
4 changed files with 16 additions and 5 deletions

View file

@ -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,

View file

@ -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);
}
}

View file

@ -37,9 +37,8 @@ GuiGameEd::GuiGameEd(Window* window, GameData* game, const std::vector<MetaDataD
//initialize metadata list
addChild(&mList);
mList.setPosition(0, mPathDisp.getSize().y() + 4);
mList.setSize(mSize.x(), mSize.y() - mList.getPosition().y());
populateList(mdd);
mList.setPosition((mSize.x() - mList.getSize().x()) / 2, mPathDisp.getSize().y() + 4);
}
GuiGameEd::~GuiGameEd()
@ -83,7 +82,7 @@ void GuiGameEd::populateList(const std::vector<MetaDataDecl>& 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);

View file

@ -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);
}