void WidgetGridBox::unlock() { assert(_locked); _locked = false; if (_items.empty()) { GfxMan.unlockFrame(); return; } _itemsByRow = MIN<uint>(_contentWidth / _items.front()->getWidth(), _items.size()); uint vCount = MIN<uint>(_contentHeight / _items.front()->getHeight(), _items.size()) * _itemsByRow; if ((vCount == 0) || (vCount == _visibleItems.size())) { GfxMan.unlockFrame(); return; } assert(_visibleItems.size() < vCount); _visibleItems.reserve(vCount); uint start = _startItem + _visibleItems.size(); float itemHeight = _items.front()->getHeight(); float itemWidth = _items.front()->getWidth(); uint row = 0; uint column = 0; // If we reach the last row, compute the items that remains. if (_items.size() - _startItem <= _visibleItems.size()) vCount -= _items.size() % _itemsByRow; while (_visibleItems.size() < vCount) { WidgetListItem *item = _items[start++]; // WORKAROUND: The x axis is shifted by 2 pixels in order to correctly render in // the charportrait widget. float itemY = _contentY - (row + 1) * (itemHeight + _innerVSpace) + _innerVSpace; float itemX = _contentX + (column * (itemWidth + _innerHSpace)) - 2.0; item->setPosition(itemX, itemY, _contentZ - 5.0); _visibleItems.push_back(item); if (isVisible()) _visibleItems.back()->show(); ++column; if (column == _itemsByRow) { ++row; column = 0; } } updateScrollbarLength(); updateScrollbarPosition(); GfxMan.unlockFrame(); }
void WidgetListBox::clear() { assert(_locked); for (std::vector<WidgetListItem *>::iterator v = _visibleItems.begin(); v != _visibleItems.end(); ++v) (*v)->hide(); _visibleItems.clear(); for (std::vector<WidgetListItem *>::iterator i = _items.begin(); i != _items.end(); ++i) (*i)->remove(); _items.clear(); _startItem = 0; _selectedItem = 0xFFFFFFFF; updateScrollbarLength(); }
void ConsoleWindow::printLine(const Common::UString &line) { if (_redirect.isOpen()) { _redirect.writeString(line); _redirect.writeByte('\n'); return; } _history.push_back(line); if (_historySizeCurrent >= _historySizeMax) _history.pop_front(); else _historySizeCurrent++; updateScrollbarLength(); redrawLines(); }
void ConsoleWindow::clear() { GfxMan.lockFrame(); _history.clear(); _historySizeCurrent = 0; _historyStart = 0; updateScrollbarLength(); updateScrollbarPosition(); for (std::vector<Graphics::Aurora::Text *>::iterator l = _lines.begin(); l != _lines.end(); ++l) (*l)->set(""); GfxMan.unlockFrame(); }
ConsoleWindow::ConsoleWindow(const Common::UString &font, uint32 lines, uint32 history, int fontHeight) : _font(FontMan.get(font, fontHeight)), _historySizeMax(history), _historySizeCurrent(0), _historyStart(0), _cursorPosition(0), _overwrite(false), _cursorBlinkState(false), _lastCursorBlink(0) { assert(lines >= 2); assert(history >= lines); setTag("ConsoleWindow"); setClickable(true); _lineHeight = _font.getFont().getHeight() + _font.getFont().getLineSpacing(); _height = floorf(lines * _lineHeight); _prompt = new Graphics::Aurora::Text(_font, ""); _input = new Graphics::Aurora::Text(_font, ""); const float cursorHeight = _font.getFont().getHeight(); _cursor = new Graphics::Aurora::GUIQuad("", 0.0, 1.0, 0.0, cursorHeight); _cursor->setXOR(true); _highlight = new Graphics::Aurora::GUIQuad("", 0.0, 0.0, 0.0, cursorHeight); _highlight->setColor(1.0, 1.0, 1.0, 0.0); _highlight->setXOR(true); _lines.reserve(lines - 1); for (uint32 i = 0; i < (lines - 1); i++) _lines.push_back(new Graphics::Aurora::Text(_font, "")); notifyResized(0, 0, GfxMan.getScreenWidth(), GfxMan.getScreenHeight()); updateScrollbarLength(); updateScrollbarPosition(); clearHighlight(); calculateDistance(); }
void WidgetListBox::unlock() { assert(_locked); _locked = false; if (_items.empty()) { GfxMan.unlockFrame(); return; } size_t count = MIN<size_t>(_contentHeight / _items.front()->getHeight(), _items.size()); if ((count == 0) || (count == _visibleItems.size())) { GfxMan.unlockFrame(); return; } assert(_visibleItems.size() < count); _visibleItems.reserve(count); size_t start = _startItem + _visibleItems.size(); float itemHeight = _items.front()->getHeight(); while (_visibleItems.size() < count) { WidgetListItem *item = _items[start++]; float itemY = _contentY - (_visibleItems.size() + 1) * itemHeight; item->setPosition(_contentX, itemY, _contentZ - 5.0f); _visibleItems.push_back(item); if (isVisible()) _visibleItems.back()->show(); } updateScrollbarLength(); updateScrollbarPosition(); GfxMan.unlockFrame(); }