Пример #1
0
void PhotoWidget::setContentImage(const QPixmap &pixmap)
{
    mContentPixmap = pixmap;
    QRectF pixmapRect = pixmap.rect();

    /*calculate the new height for the content rect width */
    float pixmapHeight = (pixmapRect.height() / pixmapRect.width() ) * contentRect().width();
    pixmapRect.setHeight(pixmapHeight);
    pixmapRect.setWidth(contentRect().width());
    setContentRect(pixmapRect);

    update();
}
Пример #2
0
void ClockWidget::preRenderClockImages()
{
    PlexyDesk::SvgProvider *svg = new PlexyDesk::SvgProvider();

    mClockBackFace = svg->get(QLatin1String("clock#ClockFace"));
    mClockSecondHand = svg->get(QLatin1String("clock#SecondHand"));
    mClockMinuteHand = svg->get(QLatin1String("clock#MinuteHand"));
    mClockHourHand = svg->get(QLatin1String("clock#HourHand"));
    mClockScrew = svg->get(QLatin1String("clock#HandCenterScrew"));
    mClockGlass = svg->get(QLatin1String("clock#Glass"));

    setContentRect(mClockBackFace.rect());

    delete svg;
}
Пример #3
0
void Animate::setCollisionRect()
{
	if (!anim_frame_list.empty())
	{
		unsigned int anim_size = anim_frame_list.size();
		if (ani_index < anim_size)
		{
			cocos2d::CCRect image_rect = anim_frame_list.at(ani_index)->getRect();
			int image_width = image_rect.getMaxX() - image_rect.getMinX();
			int image_height = image_rect.getMaxY() - image_rect.getMinY();
			cocos2d::CCPoint spr_pos = draw_spr->getPosition();
			cocos2d::CCRect collision_rect = cocos2d::CCRect(spr_pos.x - (image_width / 2), spr_pos.y, image_width, image_height);
			setContentRect(collision_rect);
		}
	}
}
Пример #4
0
YouTubeWidget::YouTubeWidget(const QRectF &rect) :
     ScrollWidget(rect)
{
    mSearchButton = new PlexyDesk::Button(this);
    mSearchButton->show();
    mSearchButton->setPos(rect.width() - 110 , rect.height() - 40);

    connect(mSearchButton, SIGNAL(clicked()), this, SLOT(buttonClicked()));

    setContentRect(rect);

    this->enableDefaultBackground(true);
    //this->enableShadow(false);

    mSearchButton->setLabel("Search");

    mLineEdit = new PlexyDesk::LineEdit(this);
    mLineEdit->show();
    mLineEdit->setSize(QSizeF(rect.width() - mSearchButton->boundingRect().width(), 30));
    mLineEdit->setPos(10 , rect.height() - 40);

}
Пример #5
0
PlexyDayWidget::PlexyDayWidget(const QRectF &rect)
    : Widget(rect), d(new PlexyDayWidgetPrivate) {
  setContentRect(rect);

  this->setWidgetFlag(PlexyDesk::Widget::kRenderBackground, false);

#ifdef Q_WS_QPA
  setFlag(QGraphicsItem::ItemIsMovable, false);
#endif

  mTableView = new PlexyDesk::TableView(rect, this);
  mTableView->show();
  /// mTableView->setLabelName("TableView");

  CellsProvider *cellFactory = new CellsProvider(rect, this);
  mTableView->setDelegate(cellFactory);

  float headerHight = 74.0;
#ifdef Q_WS_QPA
  headerHight = (64.0 * 2) + 20;
#endif
  // Leave a margin of 74px for the ck_ck_widget.header. and a 5px left margin
  mTableView->setPos(cellFactory->leftMargin(), headerHight);
}
Пример #6
0
int SkiaAndroidApp::message_callback(int fd, int events, void* data) {
    auto skiaAndroidApp = (SkiaAndroidApp*)data;
    Message message;
    skiaAndroidApp->readMessage(&message);
    SkDebugf("message_callback %d", message.fType);
    SkASSERT(message.fType != kUndefined);

    switch (message.fType) {
        case kDestroyApp: {
            delete skiaAndroidApp;
            pthread_exit(nullptr);
            return 0;
        }
        case kContentInvalidated: {
            ((Window_android*)skiaAndroidApp->fWindow)->paintIfNeeded();
            break;
        }
        case kSurfaceCreated: {
            SkASSERT(!skiaAndroidApp->fNativeWindow && message.fNativeWindow);
            skiaAndroidApp->fNativeWindow = message.fNativeWindow;
            auto window_android = (Window_android*)skiaAndroidApp->fWindow;
            window_android->initDisplay(skiaAndroidApp->fNativeWindow);
            ((Window_android*)skiaAndroidApp->fWindow)->paintIfNeeded();
            break;
        }
        case kSurfaceChanged: {
            SkASSERT(message.fNativeWindow);
            int width = ANativeWindow_getWidth(skiaAndroidApp->fNativeWindow);
            int height = ANativeWindow_getHeight(skiaAndroidApp->fNativeWindow);
            auto window_android = (Window_android*)skiaAndroidApp->fWindow;
            if (message.fNativeWindow != skiaAndroidApp->fNativeWindow) {
                window_android->onDisplayDestroyed();
                ANativeWindow_release(skiaAndroidApp->fNativeWindow);
                skiaAndroidApp->fNativeWindow = message.fNativeWindow;
                window_android->initDisplay(skiaAndroidApp->fNativeWindow);
            }
            window_android->onResize(width, height);
            window_android->setContentRect(0, 0, width, height);
            window_android->paintIfNeeded();
            break;
        }
        case kSurfaceDestroyed: {
            if (skiaAndroidApp->fNativeWindow) {
                auto window_android = (Window_android*)skiaAndroidApp->fWindow;
                window_android->onDisplayDestroyed();
                ANativeWindow_release(skiaAndroidApp->fNativeWindow);
                skiaAndroidApp->fNativeWindow = nullptr;
            }
            break;
        }
        case kKeyPressed: {
            auto it = ANDROID_TO_WINDOW_KEYMAP.find(message.fKeycode);
            SkASSERT(it != ANDROID_TO_WINDOW_KEYMAP.end());
            // No modifier is supported so far
            skiaAndroidApp->fWindow->onKey(it->second, Window::kDown_InputState, 0);
            skiaAndroidApp->fWindow->onKey(it->second, Window::kUp_InputState, 0);
            break;
        }
        case kTouched: {
            auto it = ANDROID_TO_WINDOW_STATEMAP.find(message.fTouchState);
            SkASSERT(it != ANDROID_TO_WINDOW_STATEMAP.end());
            skiaAndroidApp->fWindow->onTouch(message.fTouchOwner, it->second, message.fTouchX,
                                             message.fTouchY);
            break;
        }
        case kUIStateChanged: {
            skiaAndroidApp->fWindow->onUIStateChanged(*message.stateName, *message.stateValue);
            delete message.stateName;
            delete message.stateValue;
            break;
        }
        default: {
            // do nothing
        }
    }

    return 1;  // continue receiving callbacks
}