void QVistaHelper::drawTitleBar(QPainter *painter) { Q_ASSERT(backButton_); QPoint origin; const bool isWindow = wizard->isWindow(); const HDC hdc = QVistaHelper::backingStoreDC(wizard, &origin); if (vistaState() == VistaAero && isWindow) drawBlackRect(QRect(0, 0, wizard->width(), titleBarSize() + topOffset()), hdc); // The button is positioned in QWizardPrivate::handleAeroStyleChange(), // all calculation is relative to it. const int btnTop = backButton_->mapToParent(QPoint()).y(); const int btnHeight = backButton_->size().height(); const int verticalCenter = (btnTop + btnHeight / 2) - 1; const QString text = wizard->window()->windowTitle(); QFont font; if (!isWindow || !getCaptionQFont(wizard->logicalDpiY() * wizard->devicePixelRatio(), &font)) font = QApplication::font("QMdiSubWindowTitleBar"); const QFontMetrics fontMetrics(font); const QRect brect = fontMetrics.boundingRect(text); int textHeight = brect.height(); int textWidth = brect.width(); int glowOffset = 0; if (vistaState() == VistaAero) { textHeight += 2 * glowSize(); textWidth += 2 * glowSize(); glowOffset = glowSize(); } const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight ? titleOffset() - glowOffset : wizard->width() - titleOffset() - textWidth + glowOffset); const QRect textRectangle(titleLeft, verticalCenter - textHeight / 2, textWidth, textHeight); if (isWindow) { drawTitleText(painter, text, textRectangle, hdc); } else { painter->save(); painter->setFont(font); painter->drawText(textRectangle, Qt::AlignVCenter | Qt::AlignHCenter, text); painter->restore(); } const QIcon windowIcon = wizard->windowIcon(); if (!windowIcon.isNull()) { const int size = QVistaHelper::iconSize(); const int iconLeft = (wizard->layoutDirection() == Qt::LeftToRight ? leftMargin() : wizard->width() - leftMargin() - size); const QPoint pos(origin.x() + iconLeft, origin.y() + verticalCenter - size / 2); const QPoint posDp = pos * QVistaHelper::m_devicePixelRatio; const HICON hIcon = qt_pixmapToWinHICON(windowIcon.pixmap(size * QVistaHelper::m_devicePixelRatio)); DrawIconEx(hdc, posDp.x(), posDp.y(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT); DestroyIcon(hIcon); } }
void CTornado::UpdateParticleEmitters() { Vec3 pos(0,0,0); pos.z = (GetEntity()->GetWorldPos()).z; Vec3 cloudOffset(pos); if (m_pCloudConnectEffect) { cloudOffset.z = m_cloudHeight - pos.z; Matrix34 tm(IParticleEffect::ParticleLoc(cloudOffset)); GetEntity()->SetSlotLocalTM(1, tm); GetEntity()->SetSlotFlags(1, GetEntity()->GetSlotFlags(1)|ENTITY_SLOT_RENDER); } if (m_pTopEffect) { Vec3 topOffset(cloudOffset); topOffset.z -= 140.0f; Matrix34 tm(IParticleEffect::ParticleLoc(topOffset)); GetEntity()->SetSlotLocalTM(2, tm); GetEntity()->SetSlotFlags(2, GetEntity()->GetSlotFlags(2)|ENTITY_SLOT_RENDER); } m_pGroundEffect->Update(); }
void HudItemDesc::onDraw(Renderer2D &out) const { HudLayer::onDraw(out); FRect rect = this->rect(); if(!m_item.isDummy()) { float ypos = topOffset() + rect.y(); FRect uv_rect; auto texture = m_item.guiImage(false, uv_rect); float2 size(texture->width() * uv_rect.width(), texture->height() * uv_rect.height()); float2 pos = (float2)(int2)(float2(rect.center().x - size.x * 0.5f, ypos)); out.addFilledRect(FRect(pos, pos + size), uv_rect, {texture, mulAlpha(ColorId::white, alpha())}); ypos += size.y + 10.0f; FRect desc_rect(rect.x() + 5.0f, ypos, rect.ex() - 5.0f, rect.ey() - 5.0f); // TODO: fix drawing of text that does not fit string params_desc; if(m_item.type() == ItemType::weapon) params_desc = Weapon(m_item).paramDesc(); else if(m_item.type() == ItemType::ammo) params_desc = Ammo(m_item).paramDesc(); else if(m_item.type() == ItemType::armour) params_desc = Armour(m_item).paramDesc(); m_font->draw(out, float2(rect.x() + 5.0f, ypos), {titleColor(), titleShadowColor()}, params_desc); } }
//----------------------------------------------------------------------------// void VerticalLayoutContainer::layout() { // used to compare UDims const float absWidth = getChildContentArea().get().getWidth(); // this is where we store the top offset // we continually increase this number as we go through the windows UDim topOffset(0, 0); UDim layoutWidth(0, 0); for (ChildList::iterator it = d_children.begin(); it != d_children.end(); ++it) { Window* window = static_cast<Window*>(*it); const UVector2 offset = getOffsetForWindow(window); const UVector2 boundingSize = getBoundingSizeForWindow(window); // full child window width, including margins const UDim& childWidth = boundingSize.d_x; if (CoordConverter::asAbsolute(layoutWidth, absWidth) < CoordConverter::asAbsolute(childWidth, absWidth)) { layoutWidth = childWidth; } window->setPosition(offset + UVector2(UDim(0, 0), topOffset)); topOffset += boundingSize.d_y; } setSize(USize(layoutWidth, topOffset)); }
void QVistaHelper::drawTitleBar(QPainter *painter) { if (vistaState() == VistaAero) drawBlackRect( QRect(0, 0, wizard->width(), titleBarSize() + topOffset()), painter->paintEngine()->getDC()); Q_ASSERT(backButton_); const int btnTop = backButton_->mapToParent(QPoint()).y(); const int btnHeight = backButton_->size().height(); const int verticalCenter = (btnTop + btnHeight / 2); wizard->windowIcon().paint( painter, QRect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize())); const QString text = wizard->window()->windowTitle(); const QFont font = QApplication::font("QWorkspaceTitleBar"); const QFontMetrics fontMetrics(font); const QRect brect = fontMetrics.boundingRect(text); int textHeight = brect.height(); int textWidth = brect.width(); if (vistaState() == VistaAero) { textHeight += 2 * glowSize(); textWidth += 2 * glowSize(); } drawTitleText( painter, text, QRect(titleOffset(), verticalCenter - textHeight / 2, textWidth, textHeight), painter->paintEngine()->getDC()); }
void QVistaHelper::resizeEvent(QResizeEvent * event) { Q_UNUSED(event); rtTop = QRect (0, 0, wizard->width(), frameSize()); int height = captionSize() + topOffset(); if (vistaState() == VistaBasic) height -= titleBarSize(); rtTitle = QRect (0, frameSize(), wizard->width(), height); }
void QVistaHelper::drawTitleBar(QPainter *painter) { Q_ASSERT(backButton_); QPoint origin; const bool isWindow = wizard->isWindow(); const HDC hdc = QVistaHelper::backingStoreDC(wizard, &origin); if (vistaState() == VistaAero && isWindow) drawBlackRect(QRect(0, 0, wizard->width(), titleBarSize() + topOffset()), hdc); const int btnTop = backButton_->mapToParent(QPoint()).y(); const int btnHeight = backButton_->size().height(); const int verticalCenter = (btnTop + btnHeight / 2) - 1; const QString text = wizard->window()->windowTitle(); const QFont font = QApplication::font("QMdiSubWindowTitleBar"); const QFontMetrics fontMetrics(font); const QRect brect = fontMetrics.boundingRect(text); int textHeight = brect.height(); int textWidth = brect.width(); int glowOffset = 0; if (vistaState() == VistaAero) { textHeight += 2 * glowSize(); textWidth += 2 * glowSize(); glowOffset = glowSize(); } const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight ? titleOffset() - glowOffset : wizard->width() - titleOffset() - textWidth + glowOffset); const QRect textRectangle(titleLeft, verticalCenter - textHeight / 2, textWidth, textHeight); if (isWindow) { drawTitleText(painter, text, textRectangle, hdc); } else { painter->save(); painter->setFont(font); painter->drawText(textRectangle, Qt::AlignVCenter | Qt::AlignHCenter, text); painter->restore(); } const QIcon windowIcon = wizard->windowIcon(); if (!windowIcon.isNull()) { const int iconLeft = (wizard->layoutDirection() == Qt::LeftToRight ? leftMargin() : wizard->width() - leftMargin() - iconSize()); const QRect rect(origin.x() + iconLeft, origin.y() + verticalCenter - iconSize() / 2, iconSize(), iconSize()); const HICON hIcon = qt_pixmapToWinHICON(windowIcon.pixmap(iconSize())); DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT); DestroyIcon(hIcon); } }
bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type) { bool value = false; if (vistaState() == VistaAero) { WIZ_MARGINS mar = {0}; if (type == NormalTitleBar) mar.cyTopHeight = 0; else mar.cyTopHeight = titleBarSize() + topOffset(); HRESULT hr = pDwmExtendFrameIntoClientArea(wizard->winId(), &mar); value = SUCCEEDED(hr); } return value; }
bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type) { bool value = false; if (vistaState() == VistaAero) { WIZ_MARGINS mar = {0, 0, 0, 0}; if (type == NormalTitleBar) mar.cyTopHeight = 0; else mar.cyTopHeight = (titleBarSize() + topOffset()) * QVistaHelper::m_devicePixelRatio; if (const HWND wizardHandle = wizardHWND()) if (SUCCEEDED(pDwmExtendFrameIntoClientArea(wizardHandle, &mar))) value = true; } return value; }
HudStats::HudStats(const FRect &target_rect) :HudLayer(target_rect) { setTitle("Statistics:"); FRect sub_rect(rect().size()); sub_rect = {{sub_rect.x(), sub_rect.y() + topOffset()}, sub_rect.max()}; sub_rect = sub_rect.inset(float2(layer_spacing, layer_spacing)); sub_rect = {sub_rect.min(), {sub_rect.ex(), sub_rect.y() + 300.0f}}; m_grid = make_shared<HudGrid>(sub_rect); m_grid->addColumn("Nick name", 120.0f); m_grid->addColumn("Kills", 40.0f); m_grid->addColumn("Deaths", 40.0f); attach(m_grid); }
void QVistaHelper::drawTitleBar(QPainter *painter) { HDC hdc = painter->paintEngine()->getDC(); if (vistaState() == VistaAero) drawBlackRect(QRect(0, 0, wizard->width(), titleBarSize() + topOffset()), hdc); Q_ASSERT(backButton_); const int btnTop = backButton_->mapToParent(QPoint()).y(); const int btnHeight = backButton_->size().height(); const int verticalCenter = (btnTop + btnHeight / 2) - 1; const QString text = wizard->window()->windowTitle(); const QFont font = QApplication::font("QWorkspaceTitleBar"); const QFontMetrics fontMetrics(font); const QRect brect = fontMetrics.boundingRect(text); int textHeight = brect.height(); int textWidth = brect.width(); int glowOffset = 0; if (vistaState() == VistaAero) { textHeight += 2 * glowSize(); textWidth += 2 * glowSize(); glowOffset = glowSize(); } drawTitleText( painter, text, QRect(titleOffset() - glowOffset, verticalCenter - textHeight / 2, textWidth, textHeight), hdc); if (!wizard->windowIcon().isNull()) { QRect rect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize()); HICON hIcon = wizard->windowIcon().pixmap(iconSize()).toWinHICON(); DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT); DestroyIcon(hIcon); } }
MultiPlayerMenu::MultiPlayerMenu(const FRect &rect, int2 window_size) :HudLayer(rect, HudLayer::slide_top), m_please_refresh(true), m_window_size(window_size) { enum { spacing = layer_spacing }; setTitle("Connecting to server:"); m_visible_time = 0.0f; m_waiting_for_refresh = false; m_waiting_to_connect = false; m_last_refresh_time = -1.0; m_last_connect_time = -1.0; FRect button_rect(s_button_size); button_rect += float2(rect.width() - spacing, rect.height() - spacing) - button_rect.size(); PHudButton button_close = make_shared<HudClickButton>(button_rect); button_close->setIcon(HudIcon::close); button_rect -= float2(s_button_size.x + spacing * 2, 0.0f); PHudButton button_down = make_shared<HudClickButton>(button_rect); button_down->setIcon(HudIcon::down_arrow); button_down->setAccelerator(InputKey::pagedown); button_rect -= float2(s_button_size.x + spacing * 2, 0.0f); PHudButton button_up = make_shared<HudClickButton>(button_rect); button_up->setIcon(HudIcon::up_arrow); button_up->setAccelerator(InputKey::pageup); button_rect -= float2(s_button_size.x + spacing * 2, 0.0f); button_rect = button_rect.enlarge({50, 0}, {}); PHudButton button_refresh = make_shared<HudClickButton>(button_rect); button_refresh->setLabel("refresh"); button_rect -= float2(button_rect.width() + spacing * 2, 0.0f); button_rect = button_rect.enlarge({20, 0}, {}); PHudButton button_connect = make_shared<HudClickButton>(button_rect); button_connect->setLabel("connect"); button_connect->setAccelerator(InputKey::enter); button_rect = FRect(float2(185, s_button_size.y)); button_rect += float2(rect.width() - button_rect.width() - spacing, spacing + topOffset()); m_password = make_shared<HudEditBox>(button_rect, net::limits::max_password_size); m_password->setLabel("Pass: "******"Nick: "); m_nick_name->setText("random_dude"); FRect sub_rect(rect.size()); sub_rect = sub_rect.inset(float2(spacing, spacing * 2 + topOffset() + s_button_size.y), float2(spacing, spacing * 2 + s_button_size.y)); m_grid = make_shared<HudGrid>(sub_rect); m_grid->addColumn("Server name", 150.0f); m_grid->addColumn("Map name", 150.0f); m_grid->addColumn("Num players", 80.0f); m_grid->addColumn("Game mode", 80.0f); m_grid->addColumn("Ping", 50.0f); attach(m_grid); m_buttons.push_back(button_close); m_buttons.push_back(button_up); m_buttons.push_back(button_down); m_buttons.push_back(button_refresh); m_buttons.push_back(button_connect); m_buttons.push_back(m_password); m_buttons.push_back(m_nick_name); for(auto &button : m_buttons) { button->setButtonStyle(HudButtonStyle::small); attach(button); } m_client.reset(new net::Client()); }
HudInventory::HudInventory(const FRect &target_rect) :HudLayer(target_rect), m_out_of_item_time(s_desc_visible_time), m_row_offset(0) { setTitle("Inventory:"); for(int y = 0; y < s_grid_size.y; y++) for(int x = 0; x < s_grid_size.x; x++) { float2 pos(s_item_size.x * x + item_spacing * (x + 1), s_item_size.y * y + item_spacing * (y + 1) + topOffset()); PHudItemButton item(new HudItemButton(FRect(pos, pos + s_item_size))); attach(item); m_buttons.emplace_back(std::move(item)); } m_button_up = make_shared<HudClickButton>(FRect(s_button_size), -1); m_button_up->setIcon(HudIcon::up_arrow); m_button_up->setAccelerator(InputKey::pageup); m_button_up->setButtonStyle(HudButtonStyle::small); m_button_down = make_shared<HudClickButton>(FRect(s_button_size), 1); m_button_down->setIcon(HudIcon::down_arrow); m_button_down->setAccelerator(InputKey::pagedown); m_button_down->setButtonStyle(HudButtonStyle::small); attach(m_button_up); attach(m_button_down); m_item_desc = make_shared<HudItemDesc>(FRect(s_item_desc_size) + float2(layer_spacing, layer_spacing)); m_item_desc->setVisible(false, false); }