ImageRef Scene::parallelRaytrace(CameraRef camera, RenderOption option) { Rect leftRect(0.0f, 0.0f, camera->width(), floor(camera->height() / 2.0f)); Rect rightRect(0.0f, leftRect.maxY(), camera->width(), camera->height() - leftRect.size.height); p1.scene = this; p1.camera = camera; p1.rect = leftRect; p1.option = option; p1.image = new Image(leftRect.size.width, leftRect.size.height); p2.scene = this; p2.camera = camera; p2.rect = rightRect; p2.option = option; p2.image = new Image(rightRect.size.width, rightRect.size.height); pthread_t thread1, thread2; int iret1, iret2; std::cout << this; iret1 = pthread_create(&thread1, NULL, raytraceThread, &p1); iret2 = pthread_create(&thread2, NULL, raytraceThread, &p2); pthread_join(thread1, NULL); pthread_join(thread2, NULL); ImageRef image = new Image(camera->width(), camera->height()); image->drawImageAtPoint(p1.image, p1.rect.origin); image->drawImageAtPoint(p2.image, p2.rect.origin); delete p1.image; delete p2.image; return image; }
// Diagonally displays new screen starting from center - works on _picRect area // only. Assumes that height of rect is larger than width. void GfxTransitions::diagonalRollFromCenter(bool blackoutFlag) { int16 halfHeight = _picRect.height() / 2; Common::Rect upperRect(_picRect.left + halfHeight - 2, _picRect.top + halfHeight, _picRect.right - halfHeight + 1, _picRect.top + halfHeight + 1); Common::Rect lowerRect(upperRect.left, upperRect.top, upperRect.right, upperRect.bottom); Common::Rect leftRect(upperRect.left, upperRect.top, upperRect.left + 1, lowerRect.bottom); Common::Rect rightRect(upperRect.right, upperRect.top, upperRect.right + 1, lowerRect.bottom); uint32 msecCount = 0; while ((upperRect.top >= _picRect.top) || (lowerRect.bottom <= _picRect.bottom)) { if (upperRect.top < _picRect.top) { upperRect.translate(0, 1); leftRect.top++; rightRect.top++; } if (lowerRect.bottom > _picRect.bottom) { lowerRect.translate(0, -1); leftRect.bottom--; rightRect.bottom--; } if (leftRect.left < _picRect.left) { leftRect.translate(1, 0); upperRect.left++; lowerRect.left++; } if (rightRect.right > _picRect.right) { rightRect.translate(-1, 0); upperRect.right--; lowerRect.right--; } copyRectToScreen(upperRect, blackoutFlag); upperRect.translate(0, -1); upperRect.left--; upperRect.right++; copyRectToScreen(lowerRect, blackoutFlag); lowerRect.translate(0, 1); lowerRect.left--; lowerRect.right++; copyRectToScreen(leftRect, blackoutFlag); leftRect.translate(-1, 0); leftRect.top--; leftRect.bottom++; copyRectToScreen(rightRect, blackoutFlag); rightRect.translate(1, 0); rightRect.top--; rightRect.bottom++; msecCount += 4; if (doCreateFrame(msecCount)) { updateScreenAndWait(msecCount); } } }
void KDoor::drawPreImageEffect(QPainter &painter,const QImage &preImage, const float& frame) { float switchAreaWidth = preImage.width(); float switchAreaHeight = preImage.height(); float halfRectWidth = switchAreaWidth / 2; float halfRectHeight = switchAreaHeight / 2; float m_fIncreasedAngle = 10 * frame / m_fImageMeetScale; float m_fAlpha = (-frame / m_fImageMeetScale) + 1; float m_fPreImageScaleWidth = halfRectWidth * frame / m_fImageMeetScale; float m_fPreImageScaleHeight = halfRectHeight * frame / m_fImageMeetScale; painter.save(); painter.setOpacity(m_fAlpha); //左边的门 QImage leftImage = preImage.copy(0, 0, halfRectWidth, switchAreaHeight); QTransform leftTransform; leftTransform.rotate(-m_fIncreasedAngle, Qt::YAxis); leftImage = leftImage.transformed(leftTransform); QRect leftRect(m_fPreImageScaleWidth, leftImage.rect().y() + m_fPreImageScaleHeight / 2, halfRectWidth - m_fPreImageScaleWidth, leftImage.rect().height() - m_fPreImageScaleHeight); QRect tLeftRect = QRect(preImage.rect().x(), preImage.rect().y(), halfRectWidth - m_fPreImageScaleWidth, preImage.height()); painter.drawImage(tLeftRect, leftImage, leftRect); //右边的门 QImage rightImage = preImage.copy(halfRectWidth, 0, halfRectWidth, switchAreaHeight); QTransform rightTransform; rightTransform.rotate(m_fIncreasedAngle, Qt::YAxis); rightImage = rightImage.transformed(rightTransform); QRect rightRect(0, m_fPreImageScaleHeight / 2, halfRectWidth - m_fPreImageScaleWidth, rightImage.height() - m_fPreImageScaleHeight); QRect tRightRect = QRect(preImage.rect().x() + halfRectWidth + m_fPreImageScaleWidth, preImage.rect().y(), halfRectWidth - m_fPreImageScaleWidth, preImage.rect().height()); painter.drawImage(tRightRect,rightImage,rightRect); painter.restore(); }
// Diagonally displays new screen starting from edges - works on _picRect area // only. Assumes that height of rect is larger than width. void GfxTransitions::diagonalRollToCenter(bool blackoutFlag) { Common::Rect upperRect(_picRect.left, _picRect.top, _picRect.right, _picRect.top + 1); Common::Rect lowerRect(_picRect.left, _picRect.bottom - 1, _picRect.right, _picRect.bottom); Common::Rect leftRect(_picRect.left, _picRect.top, _picRect.left + 1, _picRect.bottom); Common::Rect rightRect(_picRect.right - 1, _picRect.top, _picRect.right, _picRect.bottom); uint32 msecCount = 0; while (upperRect.top < lowerRect.bottom) { copyRectToScreen(upperRect, blackoutFlag); upperRect.translate(0, 1); upperRect.left++; upperRect.right--; copyRectToScreen(lowerRect, blackoutFlag); lowerRect.translate(0, -1); lowerRect.left++; lowerRect.right--; copyRectToScreen(leftRect, blackoutFlag); leftRect.translate(1, 0); copyRectToScreen(rightRect, blackoutFlag); rightRect.translate(-1, 0); msecCount += 4; updateScreenAndWait(msecCount); } }
void CGUIListGroup::UpdateInfo(const CGUIListItem *item) { for (iControls it = m_children.begin(); it != m_children.end(); it++) (*it)->UpdateInfo(item); // now we have to check our overlapping label pairs for (unsigned int i = 0; i < m_children.size(); i++) { if (m_children[i]->GetControlType() == CGUIControl::GUICONTROL_LISTLABEL && m_children[i]->IsVisible()) { CGUIListLabel &label1 = *(CGUIListLabel *)m_children[i]; CRect rect1(label1.GetRenderRect()); for (unsigned int j = i + 1; j < m_children.size(); j++) { if (m_children[j]->GetControlType() == CGUIControl::GUICONTROL_LISTLABEL && m_children[j]->IsVisible()) { // ok, now check if they overlap CGUIListLabel &label2 = *(CGUIListLabel *)m_children[j]; if (!rect1.Intersect(label2.GetRenderRect()).IsEmpty()) { // overlap vertically and horizontally - check alignment CGUIListLabel &left = label1.GetRenderRect().x1 < label2.GetRenderRect().x1 ? label1 : label2; CGUIListLabel &right = label1.GetRenderRect().x1 < label2.GetRenderRect().x1 ? label2 : label1; if ((left.GetLabelInfo().align & 3) == 0 && right.GetLabelInfo().align & XBFONT_RIGHT) { float chopPoint = (left.GetXPosition() + left.GetWidth() + right.GetXPosition() - right.GetWidth()) * 0.5f; // [1 [2...[2 1].|..........1] 2] // [1 [2.....[2 | 1]..1] 2] // [1 [2..........|.[2 1]..1] 2] CRect leftRect(left.GetRenderRect()); CRect rightRect(right.GetRenderRect()); if (rightRect.x1 > chopPoint) chopPoint = rightRect.x1 - 5; else if (leftRect.x2 < chopPoint) chopPoint = leftRect.x2 + 5; leftRect.x2 = chopPoint - 5; rightRect.x1 = chopPoint + 5; left.SetRenderRect(leftRect); right.SetRenderRect(rightRect); } } } } } } }
FileTypesWindow::FileTypesWindow(const BMessage& settings) : BWindow(_Frame(settings), "FileTypes", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS), fNewTypeWindow(NULL) { bool showIcons; bool showRule; if (settings.FindBool("show_icons", &showIcons) != B_OK) showIcons = true; if (settings.FindBool("show_rule", &showRule) != B_OK) showRule = false; // add the menu BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL); AddChild(menuBar); BMenu* menu = new BMenu("File"); BMenuItem* item; menu->AddItem(item = new BMenuItem("New resource file" B_UTF8_ELLIPSIS, NULL, 'N', B_COMMAND_KEY)); item->SetEnabled(false); BMenu* recentsMenu = BRecentFilesList::NewFileListMenu("Open" B_UTF8_ELLIPSIS, NULL, NULL, be_app, 10, false, NULL, kSignature); item = new BMenuItem(recentsMenu, new BMessage(kMsgOpenFilePanel)); item->SetShortcut('O', B_COMMAND_KEY); menu->AddItem(item); menu->AddItem(new BMenuItem("Application types" B_UTF8_ELLIPSIS, new BMessage(kMsgOpenApplicationTypesWindow))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("About FileTypes" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q', B_COMMAND_KEY)); menu->SetTargetForItems(be_app); menuBar->AddItem(menu); menu = new BMenu("Settings"); item = new BMenuItem("Show icons in list", new BMessage(kMsgToggleIcons)); item->SetMarked(showIcons); item->SetTarget(this); menu->AddItem(item); item = new BMenuItem("Show recognition rule", new BMessage(kMsgToggleRule)); item->SetMarked(showRule); item->SetTarget(this); menu->AddItem(item); menuBar->AddItem(menu); // MIME Types list BRect rect = Bounds(); rect.top = menuBar->Bounds().Height() + 1.0f; BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW); topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(topView); BButton* button = new BButton(rect, "add", "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddType), B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveTo(8.0f, topView->Bounds().bottom - 8.0f - button->Bounds().Height()); topView->AddChild(button); rect = button->Frame(); rect.OffsetBy(rect.Width() + 8.0f, 0.0f); fRemoveTypeButton = new BButton(rect, "remove", "Remove", new BMessage(kMsgRemoveType), B_FOLLOW_BOTTOM); fRemoveTypeButton->ResizeToPreferred(); topView->AddChild(fRemoveTypeButton); rect.bottom = rect.top - 10.0f; rect.top = 10.0f; rect.left = 10.0f; rect.right -= B_V_SCROLL_BAR_WIDTH + 2.0f; if (rect.right < 180) rect.right = 180; fTypeListView = new MimeTypeListView(rect, "typeview", NULL, showIcons, false, B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM); fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected)); BScrollView* scrollView = new BScrollView("scrollview", fTypeListView, B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true); topView->AddChild(scrollView); // "Icon" group font_height plainHeight; be_plain_font->GetHeight(&plainHeight); float height = ceilf(plainHeight.ascent + plainHeight.descent + plainHeight.leading) + 2.0f; BFont font(be_bold_font); float labelWidth = font.StringWidth("Icon"); font_height boldHeight; font.GetHeight(&boldHeight); BRect innerRect; fIconView = new TypeIconView(innerRect, "icon", B_FOLLOW_LEFT | B_FOLLOW_V_CENTER); fIconView->ResizeToPreferred(); rect.left = rect.right + 12.0f + B_V_SCROLL_BAR_WIDTH; rect.right = rect.left + max_c(fIconView->Bounds().Width(), labelWidth) + 16.0f; rect.bottom = rect.top + ceilf(boldHeight.ascent) + max_c(fIconView->Bounds().Height(), button->Bounds().Height() * 2.0f + height + 4.0f) + 12.0f; rect.top -= 2.0f; fIconBox = new BBox(rect); fIconBox->SetLabel("Icon"); topView->AddChild(fIconBox); innerRect.left = 8.0f; innerRect.top = plainHeight.ascent + 3.0f + (rect.Height() - boldHeight.ascent - fIconView->Bounds().Height()) / 2.0f; if (innerRect.top + fIconView->Bounds().Height() > fIconBox->Bounds().Height() - 6.0f) innerRect.top = fIconBox->Bounds().Height() - 6.0f - fIconView->Bounds().Height(); fIconView->MoveTo(innerRect.LeftTop()); fIconBox->AddChild(fIconView); // "File Recognition" group BRect rightRect(rect); rightRect.left = rect.right + 8.0f; rightRect.right = topView->Bounds().Width() - 8.0f; fRecognitionBox = new BBox(rightRect, NULL, B_FOLLOW_LEFT_RIGHT); fRecognitionBox->SetLabel("File recognition"); topView->AddChild(fRecognitionBox); innerRect = fRecognitionBox->Bounds().InsetByCopy(8.0f, 4.0f); innerRect.top += ceilf(boldHeight.ascent); fExtensionLabel = new StringView(innerRect, "extension", "Extensions:", NULL); fExtensionLabel->SetAlignment(B_ALIGN_LEFT, B_ALIGN_LEFT); fExtensionLabel->ResizeToPreferred(); fRecognitionBox->AddChild(fExtensionLabel); innerRect.top += fExtensionLabel->Bounds().Height() + 2.0f; innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f; innerRect.bottom = innerRect.top + button->Bounds().Height(); fAddExtensionButton = new BButton(innerRect, "add ext", "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddExtension), B_FOLLOW_RIGHT); fRecognitionBox->AddChild(fAddExtensionButton); innerRect.OffsetBy(0, innerRect.Height() + 4.0f); fRemoveExtensionButton = new BButton(innerRect, "remove ext", "Remove", new BMessage(kMsgRemoveExtension), B_FOLLOW_RIGHT); fRecognitionBox->AddChild(fRemoveExtensionButton); innerRect.right = innerRect.left - 10.0f - B_V_SCROLL_BAR_WIDTH; innerRect.left = 10.0f; innerRect.top = fAddExtensionButton->Frame().top + 2.0f; innerRect.bottom = innerRect.bottom - 2.0f; // take scrollview border into account fExtensionListView = new ExtensionListView(innerRect, "listview ext", B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT_RIGHT); fExtensionListView->SetSelectionMessage(new BMessage(kMsgExtensionSelected)); fExtensionListView->SetInvocationMessage(new BMessage(kMsgExtensionInvoked)); scrollView = new BScrollView("scrollview ext", fExtensionListView, B_FOLLOW_LEFT_RIGHT, B_FRAME_EVENTS | B_WILL_DRAW, false, true); fRecognitionBox->AddChild(scrollView); innerRect.left = 8.0f; innerRect.top = innerRect.bottom + 10.0f; innerRect.right = fRecognitionBox->Bounds().right - 8.0f; innerRect.bottom = innerRect.top + 20.0f; fRuleControl = new BTextControl(innerRect, "rule", "Rule:", "", new BMessage(kMsgRuleEntered), B_FOLLOW_LEFT_RIGHT); //fRuleControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fRuleControl->SetDivider(fRuleControl->StringWidth(fRuleControl->Label()) + 6.0f); fRuleControl->Hide(); fRecognitionBox->AddChild(fRuleControl); // "Description" group rect.top = rect.bottom + 8.0f; rect.bottom = rect.top + ceilf(boldHeight.ascent) + 24.0f; rect.right = rightRect.right; fDescriptionBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); fDescriptionBox->SetLabel("Description"); topView->AddChild(fDescriptionBox); innerRect = fDescriptionBox->Bounds().InsetByCopy(8.0f, 6.0f); innerRect.top += ceilf(boldHeight.ascent); innerRect.bottom = innerRect.top + button->Bounds().Height(); fInternalNameView = new StringView(innerRect, "internal", "Internal name:", "", B_FOLLOW_LEFT_RIGHT); labelWidth = fInternalNameView->StringWidth(fInternalNameView->Label()) + 2.0f; fInternalNameView->SetDivider(labelWidth); fInternalNameView->SetEnabled(false); fInternalNameView->ResizeToPreferred(); fDescriptionBox->AddChild(fInternalNameView); innerRect.OffsetBy(0, fInternalNameView->Bounds().Height() + 5.0f); fTypeNameControl = new BTextControl(innerRect, "type", "Type name:", "", new BMessage(kMsgTypeEntered), B_FOLLOW_LEFT_RIGHT); fTypeNameControl->SetDivider(labelWidth); fTypeNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fDescriptionBox->ResizeBy(0, fInternalNameView->Bounds().Height() + fTypeNameControl->Bounds().Height() * 2.0f); fDescriptionBox->AddChild(fTypeNameControl); innerRect.OffsetBy(0, fTypeNameControl->Bounds().Height() + 5.0f); fDescriptionControl = new BTextControl(innerRect, "description", "Description:", "", new BMessage(kMsgDescriptionEntered), B_FOLLOW_LEFT_RIGHT); fDescriptionControl->SetDivider(labelWidth); fDescriptionControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fDescriptionBox->AddChild(fDescriptionControl); // "Preferred Application" group rect = fDescriptionBox->Frame(); rect.top = rect.bottom + 8.0f; rect.bottom = rect.top + ceilf(boldHeight.ascent) + button->Bounds().Height() + 14.0f; fPreferredBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); fPreferredBox->SetLabel("Preferred application"); topView->AddChild(fPreferredBox); innerRect = fPreferredBox->Bounds().InsetByCopy(8.0f, 6.0f); innerRect.top += ceilf(boldHeight.ascent); innerRect.left = innerRect.right - button->StringWidth( "Same as" B_UTF8_ELLIPSIS) - 24.0f; innerRect.bottom = innerRect.top + button->Bounds().Height(); fSameAsButton = new BButton(innerRect, "same as", "Same as" B_UTF8_ELLIPSIS, new BMessage(kMsgSamePreferredAppAs), B_FOLLOW_RIGHT); fPreferredBox->AddChild(fSameAsButton); innerRect.OffsetBy(-innerRect.Width() - 6.0f, 0.0f); fSelectButton = new BButton(innerRect, "select", "Select" B_UTF8_ELLIPSIS, new BMessage(kMsgSelectPreferredApp), B_FOLLOW_RIGHT); fPreferredBox->AddChild(fSelectButton); menu = new BPopUpMenu("preferred"); menu->AddItem(item = new BMenuItem("None", new BMessage(kMsgPreferredAppChosen))); item->SetMarked(true); innerRect.right = innerRect.left - 6.0f; innerRect.left = 8.0f; fPreferredField = new BMenuField(innerRect, "preferred", NULL, menu, true, B_FOLLOW_LEFT_RIGHT); float width; fPreferredField->GetPreferredSize(&width, &height); fPreferredField->ResizeTo(innerRect.Width(), height); fPreferredField->MoveBy(0.0f, (innerRect.Height() - height) / 2.0f); fPreferredBox->AddChild(fPreferredField); // "Extra Attributes" group rect.top = rect.bottom + 8.0f; rect.bottom = topView->Bounds().Height() - 8.0f; fAttributeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM); fAttributeBox->SetLabel("Extra attributes"); topView->AddChild(fAttributeBox); innerRect = fAttributeBox->Bounds().InsetByCopy(8.0f, 6.0f); innerRect.top += ceilf(boldHeight.ascent); innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f; innerRect.bottom = innerRect.top + button->Bounds().Height(); fAddAttributeButton = new BButton(innerRect, "add attr", "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddAttribute), B_FOLLOW_RIGHT); fAttributeBox->AddChild(fAddAttributeButton); innerRect.OffsetBy(0, innerRect.Height() + 4.0f); fRemoveAttributeButton = new BButton(innerRect, "remove attr", "Remove", new BMessage(kMsgRemoveAttribute), B_FOLLOW_RIGHT); fAttributeBox->AddChild(fRemoveAttributeButton); /* innerRect.OffsetBy(0, innerRect.Height() + 4.0f); button = new BButton(innerRect, "push attr", "Push Up", new BMessage(kMsgRemoveAttribute), B_FOLLOW_RIGHT); fAttributeBox->AddChild(button); */ innerRect.right = innerRect.left - 10.0f - B_V_SCROLL_BAR_WIDTH; innerRect.left = 10.0f; innerRect.top = 8.0f + ceilf(boldHeight.ascent); innerRect.bottom = fAttributeBox->Bounds().bottom - 10.0f; // take scrollview border into account fAttributeListView = new AttributeListView(innerRect, "listview attr", B_FOLLOW_ALL); fAttributeListView->SetSelectionMessage(new BMessage(kMsgAttributeSelected)); fAttributeListView->SetInvocationMessage(new BMessage(kMsgAttributeInvoked)); scrollView = new BScrollView("scrollview attr", fAttributeListView, B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true); fAttributeBox->AddChild(scrollView); SetSizeLimits(rightRect.left + 72.0f + font.StringWidth("jpg") + font.StringWidth(fRecognitionBox->Label()), 32767.0f, rect.top + 2.0f * button->Bounds().Height() + boldHeight.ascent + 32.0f + menuBar->Bounds().Height(), 32767.0f); _SetType(NULL); _ShowSnifferRule(showRule); BMimeType::StartWatching(this); }
void TouchpadView::DrawSliders() { BView* view; if (fOffScreenView != NULL) view = fOffScreenView; else view = this; if (!LockLooper()) return; if (fOffScreenBitmap->Lock()) { view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->FillRect(Bounds()); view->SetHighColor(100, 100, 100); view->FillRoundRect(fPadRect, 4, 4); int32 dragSize = 3; // half drag size // scroll areas view->SetHighColor(145, 100, 100); BRect rightRect(fPadRect.left + fXScrollRange, fPadRect.top, fPadRect.right, fPadRect.bottom); view->FillRoundRect(rightRect, 4, 4); BRect bottomRect(fPadRect.left, fPadRect.top + fYScrollRange, fPadRect.right, fPadRect.bottom); view->FillRoundRect(bottomRect, 4, 4); // Stroke Rect view->SetHighColor(100, 100, 100); view->SetPenSize(2); view->StrokeRoundRect(fPadRect, 4, 4); // x scroll range line view->SetHighColor(200, 0, 0); view->StrokeLine(BPoint(fPadRect.left + fXScrollRange, fPadRect.top), BPoint(fPadRect.left + fXScrollRange, fPadRect.bottom)); fXScrollDragZone = BRect(fPadRect.left + fXScrollRange - dragSize, fPadRect.top - dragSize, fPadRect.left + fXScrollRange + dragSize, fPadRect.bottom + dragSize); fXScrollDragZone1 = BRect(fPadRect.left + fXScrollRange - dragSize, fPadRect.top - dragSize, fPadRect.left + fXScrollRange + dragSize, fPadRect.top + dragSize); view->FillRect(fXScrollDragZone1); fXScrollDragZone2 = BRect(fPadRect.left + fXScrollRange - dragSize, fPadRect.bottom - dragSize, fPadRect.left + fXScrollRange + dragSize, fPadRect.bottom + dragSize); view->FillRect(fXScrollDragZone2); // y scroll range line view->StrokeLine(BPoint(fPadRect.left, fPadRect.top + fYScrollRange), BPoint(fPadRect.right, fPadRect.top + fYScrollRange)); fYScrollDragZone = BRect(fPadRect.left - dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.right + dragSize, fPadRect.top + fYScrollRange + dragSize); fYScrollDragZone1 = BRect(fPadRect.left - dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.left + dragSize, fPadRect.top + fYScrollRange + dragSize); view->FillRect(fYScrollDragZone1); fYScrollDragZone2 = BRect(fPadRect.right - dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.right + dragSize, fPadRect.top + fYScrollRange + dragSize); view->FillRect(fYScrollDragZone2); fOffScreenView->Sync(); fOffScreenBitmap->Unlock(); DrawBitmap(fOffScreenBitmap, B_ORIGIN); } UnlockLooper(); }
void MScene::drawForeground(QPainter *painter, const QRectF &rect) { Q_D(MScene); /* Overlay information on the widgets in development mode */ if (MApplication::showBoundingRect() || MApplication::showSize() || MApplication::showPosition() || MApplication::showMargins() || MApplication::showObjectNames() || MApplication::showStyleNames()) { QList<QGraphicsItem *> itemList = items(rect); QList<QGraphicsItem *>::iterator item; painter->setFont(TextFont); int fontHeight = d->metrics.height(); QTransform rotationMatrix; painter->setTransform(rotationMatrix); QList<QGraphicsItem *>::iterator end = itemList.end(); for (item = itemList.begin(); item != end; ++item) { QRectF br = (*item)->boundingRect(); QPolygonF bp = (*item)->mapToScene(br); if (MApplication::showBoundingRect()) { if (!dynamic_cast<MApplicationPage *>(*item)) { // filter out page for clarity painter->setOpacity(BoundingRectOpacity); painter->setPen(d->boundingRectLinePen); painter->setBrush(d->boundingRectFillBrush); painter->drawPolygon(bp); } } if (MApplication::showMargins()) { // Draw content margins QGraphicsLayoutItem *layoutItem = dynamic_cast<QGraphicsLayoutItem *>(*item); if (layoutItem) { qreal left, top, right, bottom; layoutItem->getContentsMargins(&left, &top, &right, &bottom); QRectF outerRect = (*item)->mapRectToScene(br); QRectF innerRect = (*item)->mapRectToScene(br.adjusted(left, top, -right, -bottom)); QRectF leftRect(outerRect.x(), outerRect.y(), innerRect.x() - outerRect.x(), outerRect.height()); QRectF topRect(innerRect.x(), outerRect.y(), innerRect.width(), innerRect.y() - outerRect.y()); QRectF rightRect(innerRect.bottomRight().x(), outerRect.y(), outerRect.bottomRight().x() - innerRect.bottomRight().x(), outerRect.height()); QRectF bottomRect(innerRect.x(), innerRect.bottomRight().y(), innerRect.width(), outerRect.bottomRight().y() - innerRect.bottomRight().y()); painter->setOpacity(0.5); d->fillMarginRectWithPattern(painter, leftRect, leftRect.width()); d->fillMarginRectWithPattern(painter, topRect, topRect.height()); d->fillMarginRectWithPattern(painter, rightRect, rightRect.width()); d->fillMarginRectWithPattern(painter, bottomRect, bottomRect.height()); } painter->setOpacity(1.0); } if (MApplication::showPosition()) { QPointF topLeft = ((*item)->mapToScene(br.topLeft())); QString posStr = QString("(%1, %2)").arg(topLeft.x()).arg(topLeft.y()); painter->setPen(Qt::black); painter->drawText(topLeft += QPointF(5, fontHeight), posStr); painter->setPen(Qt::white); painter->drawText(topLeft -= QPointF(1, 1), posStr); } if (MApplication::showSize()) { QPointF bottomRight = ((*item)->mapToScene(br.bottomRight())); QPointF pos = (*item)->mapToScene(br.topLeft()); QString sizeStr = QString("%1x%2 (%3,%4)").arg(br.width()).arg(br.height()).arg(pos.x()).arg(pos.y()); painter->setPen(Qt::black); painter->drawText(bottomRight -= QPointF(d->metrics.width(sizeStr), 2), sizeStr); painter->setPen(Qt::white); painter->drawText(bottomRight -= QPointF(1, 1), sizeStr); } if (MApplication::showObjectNames()) { d->drawObjectNames(painter, item); } if (MApplication::showStyleNames()) { d->drawStyleNames(painter, item); } } } bool countingFps = MApplication::logFps() || MApplication::showFps(); if (countingFps) { if (d->fps.frameCount < 0) { d->fps.time.restart(); d->fps.frameCount = 0; } ++d->fps.frameCount; int ms = d->fps.time.elapsed(); if (ms > FpsRefreshInterval) { float fps = d->fps.frameCount * 1000.0f / ms; d->fps.time.restart(); d->fps.frameCount = 0; if (MApplication::logFps()) { QTime time = d->fps.time.currentTime(); d->logFpsCounter(&time, fps); } d->fps.fps = fps; } if (MApplication::showFps()) { d->showFpsCounter(painter, d->fps.fps); } // this update call makes repainting work as fast // as possible, and by that prints useful fps numbers QTimer::singleShot(0, this, SLOT(update())); } else { d->fps.frameCount = -1; } if (MApplication::emulateTwoFingerGestures() && d->pinchEmulationEnabled) { static const QPixmap *tapPixmap = MTheme::pixmap("meegotouch-tap"); QPointF pixmapCenterDelta(tapPixmap->width() / 2, tapPixmap->height() / 2); painter->drawPixmap(d->emuPoint1.scenePos() - pixmapCenterDelta, *tapPixmap); painter->drawPixmap(d->emuPoint2.scenePos() - pixmapCenterDelta, *tapPixmap); } }