当前位置: 首页>>代码示例>>C++>>正文


C++ rtl函数代码示例

本文整理汇总了C++中rtl函数的典型用法代码示例。如果您正苦于以下问题:C++ rtl函数的具体用法?C++ rtl怎么用?C++ rtl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rtl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ASSERT

int ShapeResult::RunInfo::characterIndexForXPosition(float targetX) const
{
    ASSERT(targetX <= m_width);
    float currentX = 0;
    float currentAdvance = m_glyphData[0].advance;
    unsigned glyphIndex = 0;

    // Sum up advances that belong to the first character.
    while (glyphIndex < m_numGlyphs - 1 && m_glyphData[glyphIndex].characterIndex == m_glyphData[glyphIndex + 1].characterIndex)
        currentAdvance += m_glyphData[++glyphIndex].advance;
    currentAdvance = currentAdvance / 2.0;
    if (targetX <= currentAdvance)
        return rtl() ? m_numCharacters : 0;

    currentX = currentAdvance;
    ++glyphIndex;
    while (glyphIndex < m_numGlyphs) {
        unsigned prevCharacterIndex = m_glyphData[glyphIndex - 1].characterIndex;
        float prevAdvance = currentAdvance;
        currentAdvance = m_glyphData[glyphIndex].advance;
        while (glyphIndex < m_numGlyphs - 1 && m_glyphData[glyphIndex].characterIndex == m_glyphData[glyphIndex + 1].characterIndex)
            currentAdvance += m_glyphData[++glyphIndex].advance;
        currentAdvance = currentAdvance / 2.0;
        float nextX = currentX + prevAdvance + currentAdvance;
        if (currentX <= targetX && targetX <= nextX)
            return rtl() ? prevCharacterIndex : m_glyphData[glyphIndex].characterIndex;
        currentX = nextX;
        ++glyphIndex;
    }

    return rtl() ? 0 : m_numCharacters;
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:32,代码来源:ShapeResult.cpp

示例2: itemPressed

void Menu::handleKeyPress(int key) {
	if (key == Qt::Key_Enter || key == Qt::Key_Return) {
		itemPressed(TriggeredSource::Keyboard);
		return;
	}
	if (key == (rtl() ? Qt::Key_Left : Qt::Key_Right)) {
		if (_selected >= 0 && _actionsData[_selected].hasSubmenu) {
			itemPressed(TriggeredSource::Keyboard);
			return;
		} else if (_selected < 0 && !_actions.isEmpty()) {
			_mouseSelection = false;
			setSelected(0);
		}
	}
	if ((key != Qt::Key_Up && key != Qt::Key_Down) || _actions.size() < 1) return;

	auto delta = (key == Qt::Key_Down ? 1 : -1), start = _selected;
	if (start < 0 || start >= _actions.size()) {
		start = (delta > 0) ? (_actions.size() - 1) : 0;
	}
	auto newSelected = start;
	do {
		newSelected += delta;
		if (newSelected < 0) {
			newSelected += _actions.size();
		} else if (newSelected >= _actions.size()) {
			newSelected -= _actions.size();
		}
	} while (newSelected != start && (!_actions[newSelected]->isEnabled() || _actions[newSelected]->isSeparator()));

	if (_actions[newSelected]->isEnabled() && !_actions[newSelected]->isSeparator()) {
		_mouseSelection = false;
		setSelected(newSelected);
	}
}
开发者ID:Federated-Blockchains-Initiative,项目名称:tdesktop,代码行数:35,代码来源:menu.cpp

示例3: mapFromGlobal

void PeerListWidget::updateSelection() {
	auto selected = -1;
	auto selectedKick = false;

	auto mouse = mapFromGlobal(_mousePosition);
	if (rtl()) mouse.setX(width() - mouse.x());
	auto left = getListLeft();
	auto top = getListTop();
	auto memberRowWidth = rowWidth();
	if (mouse.x() >= left && mouse.x() < left + memberRowWidth && mouse.y() >= top) {
		selected = (mouse.y() - top) / _st.height;
		if (selected >= _items.size()) {
			selected = -1;
		} else if (_items[selected]->hasRemoveLink) {
			int skip = _st.photoPosition.x();
			int nameLeft = left + _st.namePosition.x();
			int nameTop = top + _selected * _st.height + _st.namePosition.y();
			int nameWidth = memberRowWidth - _st.namePosition.x() - skip;
			if (mouse.x() >= nameLeft + nameWidth - _removeWidth && mouse.x() < nameLeft + nameWidth) {
				if (mouse.y() >= nameTop && mouse.y() < nameTop + st::normalFont->height) {
					selectedKick = true;
				}
			}
		}
	}

	setSelected(selected, selectedKick);
}
开发者ID:Emadpres,项目名称:tdesktop,代码行数:28,代码来源:profile_block_peer_list.cpp

示例4: ASSERT

int HarfBuzzShaper::HarfBuzzRun::characterIndexForXPosition(int targetX)
{
    ASSERT(static_cast<unsigned>(targetX) <= m_width);
    int currentX = 0;
    float prevAdvance = 0;
    for (unsigned i = 0; i < m_numGlyphs; ++i) {
        float currentAdvance = m_advances[i] / 2.0;
        int nextX = currentX + roundf(prevAdvance + currentAdvance);
        if (currentX <= targetX && targetX <= nextX)
            return m_glyphToCharacterIndex[i] + (rtl() ? 1 : 0);
        currentX = nextX;
        prevAdvance = currentAdvance;
    }

    return rtl() ? 0 : m_numCharacters;
}
开发者ID:victusfate,项目名称:webkit-graphics,代码行数:16,代码来源:HarfBuzzShaper.cpp

示例5: setupFontForScriptRun

// Advance to the next script run, returning false when the end of the
// TextRun has been reached.
bool ComplexTextController::nextScriptRun()
{
    // Ensure we're not pointing at the small caps buffer.
    m_item.string = m_run.characters();

    if (!hb_utf16_script_run_next(0, &m_item.item, m_run.characters(), m_run.length(), &m_indexOfNextScriptRun))
        return false;

    // It is actually wrong to consider script runs at all in this code.
    // Other WebKit code (e.g. Mac) segments complex text just by finding
    // the longest span of text covered by a single font.
    // But we currently need to call hb_utf16_script_run_next anyway to fill
    // in the harfbuzz data structures to e.g. pick the correct script's shaper.
    // So we allow that to run first, then do a second pass over the range it
    // found and take the largest subregion that stays within a single font.
    m_currentFontData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos], false).fontData;
    unsigned endOfRun;
    for (endOfRun = 1; endOfRun < m_item.item.length; ++endOfRun) {
        const SimpleFontData* nextFontData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos + endOfRun], false).fontData;
        if (nextFontData != m_currentFontData)
            break;
    }
    m_item.item.length = endOfRun;
    m_indexOfNextScriptRun = m_item.item.pos + endOfRun;

    setupFontForScriptRun();
    shapeGlyphs();
    setGlyphXPositions(rtl());

    return true;
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:33,代码来源:ComplexTextControllerLinux.cpp

示例6: singleChar

void RoundButton::Numbers::paint(Painter &p, int x, int y, int outerWidth) {
	auto digitsCount = _digits.size();
	if (!digitsCount) return;

	auto progress = anim::easeOutCirc(1., _a_ready.current(1.));
	auto width = anim::interpolate(_fromWidth, _toWidth, progress);

	QString singleChar('0');
	if (rtl()) x = outerWidth - x - width;
	x += width - _digits.size() * _digitWidth;
	auto fromTop = anim::interpolate(0, _st.font->height, progress) * (_growing ? 1 : -1);
	auto toTop = anim::interpolate(_st.font->height, 0, progress) * (_growing ? -1 : 1);
	for (auto i = 0; i != digitsCount; ++i) {
		auto &digit = _digits[i];
		auto from = digit.from;
		auto to = digit.to;
		if (from.unicode()) {
			p.setOpacity(1. - progress);
			singleChar[0] = from;
			p.drawText(x + (_digitWidth - digit.fromWidth) / 2, y + fromTop + _st.font->ascent, singleChar);
		}
		if (to.unicode()) {
			p.setOpacity(progress);
			singleChar[0] = to;
			p.drawText(x + (_digitWidth - digit.toWidth) / 2, y + toTop + _st.font->ascent, singleChar);
		}
		x += _digitWidth;
	}
	p.setOpacity(1.);
}
开发者ID:Igevorse,项目名称:tdesktop,代码行数:30,代码来源:buttons.cpp

示例7: m_numCharacters

HarfBuzzShaper::HarfBuzzRun::HarfBuzzRun(unsigned numCharacters, TextDirection direction, hb_buffer_t* harfbuzzBuffer)
    : m_numCharacters(numCharacters)
    , m_direction(direction)
{
    m_numGlyphs = hb_buffer_get_length(harfbuzzBuffer);
    m_glyphs.resize(m_numGlyphs);
    m_advances.resize(m_numGlyphs);
    m_offsets.resize(m_numGlyphs);
    m_glyphToCharacterIndex.resize(m_numGlyphs);
    m_logClusters.resize(m_numCharacters);

    hb_glyph_info_t* infos = hb_buffer_get_glyph_infos(harfbuzzBuffer, 0);
    for (unsigned i = 0; i < m_numGlyphs; ++i)
        m_glyphToCharacterIndex[i] = infos[i].cluster;

    // Fill logical clusters
    unsigned index = 0;
    while (index < m_numGlyphs) {
        unsigned nextIndex = index + 1;
        while (nextIndex < m_numGlyphs && infos[index].cluster == infos[nextIndex].cluster)
            ++nextIndex;
        if (rtl()) {
            int nextCluster = nextIndex < m_numGlyphs ? infos[nextIndex].cluster : -1;
            for (int j = infos[index].cluster; j > nextCluster; --j)
                m_logClusters[j] = index;
        } else {
            unsigned nextCluster = nextIndex < m_numGlyphs ? infos[nextIndex].cluster : m_numCharacters;
            for (unsigned j = infos[index].cluster; j < nextCluster; ++j)
                m_logClusters[j] = index;
        }
        index = nextIndex;
    }
}
开发者ID:victusfate,项目名称:webkit-graphics,代码行数:33,代码来源:HarfBuzzShaper.cpp

示例8: rtl

void testObj::test<4>(void)
{
  WaitingLockData    wld;
  ReadTryLock        rtl(mutexRW_);
  wld.setPtr( leaf_.shared_ptr() );
  ensure("locking for read only failed", rtl.ownsLock()==true );
  ensure("invalid pointer", wld.getWhenDifferOrLocked( leaf_.shared_ptr(), rtl)==leaf_ );
}
开发者ID:el-bart,项目名称:ACARM-ng,代码行数:8,代码来源:WaitingLockData.t.cpp

示例9: itemPressed

void PopupMenu::keyPressEvent(QKeyEvent *e) {
    if (_childMenuIndex >= 0) {
        return _menus.at(_childMenuIndex)->keyPressEvent(e);
    }

    if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
        itemPressed(PressSourceKeyboard);
        return;
    } else if (e->key() == Qt::Key_Escape) {
        hideMenu(_parent ? true : false);
        return;
    }
    if (e->key() == (rtl() ? Qt::Key_Left : Qt::Key_Right)) {
        if (_selected >= 0 && _menus.at(_selected)) {
            itemPressed(PressSourceKeyboard);
            return;
        } else if (_selected < 0 && _parent && !_actions.isEmpty()) {
            _mouseSelection = false;
            setSelected(0);
        }
    } else if (e->key() == (rtl() ? Qt::Key_Right : Qt::Key_Left)) {
        if (_parent) {
            hideMenu(true);
        }
    }
    if ((e->key() != Qt::Key_Up && e->key() != Qt::Key_Down) || _actions.size() < 1) return;

    int32 delta = (e->key() == Qt::Key_Down ? 1 : -1), start = _selected;
    if (start < 0 || start >= _actions.size()) {
        start = (delta > 0) ? (_actions.size() - 1) : 0;
    }
    int32 newSelected = start;
    do {
        newSelected += delta;
        if (newSelected < 0) {
            newSelected += _actions.size();
        } else if (newSelected >= _actions.size()) {
            newSelected -= _actions.size();
        }
    } while (newSelected != start && (!_actions.at(newSelected)->isEnabled() || _actions.at(newSelected)->isSeparator()));

    if (_actions.at(newSelected)->isEnabled() && !_actions.at(newSelected)->isSeparator()) {
        _mouseSelection = false;
        setSelected(newSelected);
    }
}
开发者ID:MobinRanjbar,项目名称:tdesktop,代码行数:46,代码来源:popupmenu.cpp

示例10: width

void Inner::paintInlineItems(Painter &p, const QRect &r) {
	if (_restrictedLabel) {
		return;
	}
	if (_rows.isEmpty() && !_switchPmButton) {
		p.setFont(st::normalFont);
		p.setPen(st::noContactsColor);
		p.drawText(QRect(0, 0, width(), (height() / 3) * 2 + st::normalFont->height), lang(lng_inline_bot_no_results), style::al_center);
		return;
	}
	auto gifPaused = _controller->isGifPausedAtLeastFor(Window::GifPauseReason::InlineResults);
	InlineBots::Layout::PaintContext context(getms(), false, gifPaused, false);

	auto top = st::stickerPanPadding;
	if (_switchPmButton) {
		top += _switchPmButton->height() + st::inlineResultsSkip;
	}

	auto fromx = rtl() ? (width() - r.x() - r.width()) : r.x();
	auto tox = rtl() ? (width() - r.x()) : (r.x() + r.width());
	for (auto row = 0, rows = _rows.size(); row != rows; ++row) {
		auto &inlineRow = _rows[row];
		if (top >= r.top() + r.height()) break;
		if (top + inlineRow.height > r.top()) {
			auto left = st::inlineResultsLeft - st::buttonRadius;
			if (row == rows - 1) context.lastRow = true;
			for (int col = 0, cols = inlineRow.items.size(); col < cols; ++col) {
				if (left >= tox) break;

				auto item = inlineRow.items.at(col);
				auto w = item->width();
				if (left + w > fromx) {
					p.translate(left, top);
					item->paint(p, r.translated(-left, -top), &context);
					p.translate(-left, -top);
				}
				left += w;
				if (item->hasRightSkip()) {
					left += st::inlineResultsSkip;
				}
			}
		}
		top += inlineRow.height;
	}
}
开发者ID:zhangsoledad,项目名称:tdesktop,代码行数:45,代码来源:inline_results_widget.cpp

示例11: p

void StickersBox::CounterWidget::paintEvent(QPaintEvent *e) {
	Painter p(this);

	if (!_text.isEmpty()) {
		auto unreadRight = rtl() ? 0 : width();
		auto unreadTop = 0;
		Dialogs::Layout::paintUnreadCount(p, _text, unreadRight, unreadTop, _st);
	}
}
开发者ID:VBelozyorov,项目名称:tdesktop,代码行数:9,代码来源:stickers_box.cpp

示例12: update

void SplittedWidget::update(const QRegion &r) {
	if (rtl()) {
		TWidget::update(r.translated(-otherWidth(), 0).intersected(rect()));
		emit updateOther(r);
	} else {
		TWidget::update(r.intersected(rect()));
		emit updateOther(r.translated(-width(), 0));
	}
}
开发者ID:3ngineer,项目名称:tdesktop,代码行数:9,代码来源:scrollarea.cpp

示例13: p

void SplittedWidget::paintEvent(QPaintEvent *e) {
	Painter p(this);
	if (rtl()) {
		p.translate(-otherWidth(), 0);
		paintRegion(p, e->region().translated(otherWidth(), 0), false);
	} else {
		paintRegion(p, e->region(), false);
	}
}
开发者ID:3ngineer,项目名称:tdesktop,代码行数:9,代码来源:scrollarea.cpp

示例14: lock

void testObj::test<3>(void)
{
  WriteLock       lock(mutexRW_);
  WaitingLockData wld;
  GraphNodePtrNN  leaf2=makeLeaf();
  wld.setPtr( leaf_.shared_ptr() );
  ReadTryLock     rtl(mutexRW_);
  ensure("locking for read only didn't failed", rtl.ownsLock()==false );
  ensure("invalid pointer", wld.getWhenDifferOrLocked( makeLeaf().shared_ptr(), rtl)==leaf_ );
}
开发者ID:el-bart,项目名称:ACARM-ng,代码行数:10,代码来源:WaitingLockData.t.cpp

示例15: QPoint

void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource source) {
	_parent = parent;

	auto origin = PanelAnimation::Origin::TopLeft;
	auto w = p - QPoint(0, _padding.top());
	auto r = Sandbox::screenGeometry(p);
	_useTransparency = Platform::TransparentWindowsSupported(p);
	handleCompositingUpdate();
	if (rtl()) {
		if (w.x() - width() < r.x() - _padding.left()) {
			if (_parent && w.x() + _parent->width() - _padding.left() - _padding.right() + width() - _padding.right() <= r.x() + r.width()) {
				w.setX(w.x() + _parent->width() - _padding.left() - _padding.right());
			} else {
				w.setX(r.x() - _padding.left());
			}
		} else {
			w.setX(w.x() - width());
		}
	} else {
		if (w.x() + width() - _padding.right() > r.x() + r.width()) {
			if (_parent && w.x() - _parent->width() + _padding.left() + _padding.right() - width() + _padding.right() >= r.x() - _padding.left()) {
				w.setX(w.x() + _padding.left() + _padding.right() - _parent->width() - width() + _padding.left() + _padding.right());
			} else {
				w.setX(p.x() - width() + _padding.right());
			}
			origin = PanelAnimation::Origin::TopRight;
		}
	}
	if (w.y() + height() - _padding.bottom() > r.y() + r.height()) {
		if (_parent) {
			w.setY(r.y() + r.height() - height() + _padding.bottom());
		} else {
			w.setY(p.y() - height() + _padding.bottom());
			origin = (origin == PanelAnimation::Origin::TopRight) ? PanelAnimation::Origin::BottomRight : PanelAnimation::Origin::BottomLeft;
		}
	}
	if (w.x() < r.x()) {
		w.setX(r.x());
	}
	if (w.y() < r.y()) {
		w.setY(r.y());
	}
	move(w);

	setOrigin(origin);
	_menu->setShowSource(source);

	startShowAnimation();

	psUpdateOverlayed(this);
	show();
	psShowOverAll(this);
	windowHandle()->requestActivate();
	activateWindow();
}
开发者ID:i-rinat,项目名称:tdesktop,代码行数:55,代码来源:popup_menu.cpp


注:本文中的rtl函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。