boolean JListBox::lostFocus(JEvent& e, JObject* arg) { if (e.target == this) { beforePaint(); focusOn = false; afterPaint(); } return false; }
void PhGraphicView::paintGL() { //PHDEBUG << "PhGraphicView::paintGL" ; // Update the clock time taking into account the time elapsed since the last paint event // In the particular case of V-sync enabled and no dropped frames, this is equivalent // to using the screen refresh rate to compute the elapsed time. // If V-sync is not enabled, using the screen refresh rate is plain wrong // (the refreshTimer period would be ok though). // If frames are dropped, it is mandatory to refer to a timer to be correct. // We rasterized the elapsed value to the theorical value // (based on the screen frequency) in order to keep a // constant value in most of the case. // Ex: given a 60Hz screen refresh rate // - 400 ticks / 16.6ms in normal case // - 0 ticks / 0ms if VSYNC is not enabled and the timer // - a multiple of 400 ticks / 16.6ms if frame were dropped qint64 nsecsElapsed = _timer.nsecsElapsed(); PhTime trueElapsedTime = (nsecsElapsed - _previousNsecsElapsed) * 24000 / 1000000000; PhTime expectedElapsedTime = 24000 / _screenFrequency; int numberOfScreenRefresh = (trueElapsedTime + expectedElapsedTime / 2) / expectedElapsedTime; PhTime rasterizedElapsedTime = numberOfScreenRefresh * expectedElapsedTime; if(rasterizedElapsedTime > 0) _previousNsecsElapsed = nsecsElapsed; emit beforePaint(rasterizedElapsedTime); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); QTime timer; timer.start(); int ratio = this->windowHandle()->devicePixelRatio(); emit paint(this->width() * ratio, this->height() * ratio); if(timer.elapsed() > _maxPaintDuration) _maxPaintDuration = timer.elapsed(); addInfo(QString("draw: %1 %2").arg(_maxPaintDuration).arg(timer.elapsed())); if(_settings) { if(_settings->resetInfo()) { _dropDetected = 0; _maxRefreshRate = 0; _maxPaintDuration = 0; _maxUpdateDuration = 0; } if(_settings->displayInfo()) { _infoFont.setFamily(_settings->infoFontFamily()); int y = 0; foreach(QString info, _infos) { PhGraphicText gInfo(&_infoFont, info, 0, y); gInfo.setSize(_infoFont.getNominalWidth(info) / 2, 50); gInfo.setZ(10); gInfo.setColor(Qt::red); gInfo.draw(); y += gInfo.height(); } }
//--------------------------------------------------------------------------------------------------------------- // paint //--------------------------------------------------------------------------------------------------------------- void NWEBaseGraphicsItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget){ if(!paintHasBeenInitialized_) { initializePaintSettings(); layoutChildItems(); paintHasBeenInitialized_ = true; } NWEItemSettings setting = beforePaint(painter,option); mainPaint(painter,option,widget,setting); }
boolean JListBox::setCursor(int _cursor) { _cursor = max(0, min(content.size()-1, _cursor)); if (cursor == _cursor) return false; beforePaint(); cursor = _cursor; makeVisible(cursor); afterPaint(); return true; }
void JListBox::resetScroller() { beforePaint(); int sz = content.size(); adjust = (((height-d2-d) % getBaseH()) != 0); section = ((height-d2-d)/getBaseH())+1; scroller->setValue(base, section-adjust, 0, sz, true); base = min(sz, base); cursor = min(sz, cursor); afterPaint(); }
boolean JListBox::setBase(int _base) { _base = max(0, min(content.size()-1, _base)); if (base == _base) return false; int delta = base-_base; updateInvalidArea(); beforePaint(); base = _base; ScrollWindow(d, d, width-scroller->width-d2, height-d2, 0, delta*getBaseH()); afterPaint(); scroller->setValue(base); return true; }