Ejemplo n.º 1
0
void FormPlugin::draw(ANPCanvas* canvas) {
    NPP instance = this->inst();
    PluginObject *obj = (PluginObject*) instance->pdata;

    const float inputWidth = 60;
    const float inputHeight = 30;
    const int W = obj->window->width;
    const int H = obj->window->height;

    // color the plugin canvas
    gCanvasI.drawColor(canvas, (m_hasFocus) ? 0xFFCDCDCD : 0xFF545454);

    // draw the username box (5 px from the top edge)
    m_usernameInput.rect.left = 5;
    m_usernameInput.rect.top = 5;
    m_usernameInput.rect.right = W - 5;
    m_usernameInput.rect.bottom = m_usernameInput.rect.top + inputHeight;
    gCanvasI.drawRect(canvas, &m_usernameInput.rect, getPaint(&m_usernameInput));
    drawText(canvas, m_usernameInput);

    // draw the password box (5 px from the bottom edge)
    m_passwordInput.rect.left = 5;
    m_passwordInput.rect.top = H - (inputHeight + 5);
    m_passwordInput.rect.right = W - 5;
    m_passwordInput.rect.bottom = m_passwordInput.rect.top + inputHeight;
    gCanvasI.drawRect(canvas, &m_passwordInput.rect, getPaint(&m_passwordInput));
    drawPassword(canvas, m_passwordInput);

    //invalidate the canvas
    //inval(instance);
}
void NavigationPlugin::draw(ANPCanvas* canvas) {
    NPP instance = this->inst();
    PluginObject *obj = (PluginObject*) instance->pdata;

    const int W = obj->window->width;
    const int H = obj->window->height;
    const int Wm = W/2;
    const int Hm = H/2;

    // color the plugin canvas
    gCanvasI.drawColor(canvas, (m_hasFocus) ? 0xFFCDCDCD : 0xFF545454);

    // draw the nav up box (5 px from the top edge)
    m_navUp.left = Wm - 15;
    m_navUp.top = 5;
    m_navUp.right = m_navUp.left + 30;
    m_navUp.bottom = m_navUp.top + 30;
    gCanvasI.drawRect(canvas, &m_navUp, getPaint(&m_navUp));

    // draw the nav down box (5 px from the bottom edge)
    m_navDown.left = Wm - 15;
    m_navDown.top = H - (30 + 5);
    m_navDown.right = m_navDown.left + 30;
    m_navDown.bottom = m_navDown.top + 30;
    gCanvasI.drawRect(canvas, &m_navDown, getPaint(&m_navDown));

    // draw the nav left box (5 px from the left edge)
    m_navLeft.left = 5;
    m_navLeft.top = Hm - 15;
    m_navLeft.right = m_navLeft.left + 30;
    m_navLeft.bottom = m_navLeft.top + 30;
    gCanvasI.drawRect(canvas, &m_navLeft, getPaint(&m_navLeft));

    // draw the nav right box (5 px from the right edge)
    m_navRight.left = W - (30 + 5);
    m_navRight.top = Hm - 15;
    m_navRight.right = m_navRight.left + 30;
    m_navRight.bottom = m_navRight.top + 30;
    gCanvasI.drawRect(canvas, &m_navRight, getPaint(&m_navRight));

    // draw the nav center box
    m_navCenter.left = Wm - 15;
    m_navCenter.top = Hm - 15;
    m_navCenter.right = m_navCenter.left + 30;
    m_navCenter.bottom = m_navCenter.top + 30;
    gCanvasI.drawRect(canvas, &m_navCenter, getPaint(&m_navCenter));

    gLogI.log(kDebug_ANPLogType, "----%p Drawing Plugin", inst());
}
Ejemplo n.º 3
0
bool PlayerIntention::operator == (const PlayerIntention &other) const {
    return getAccel() == other.getAccel()
        && getTurn() == other.getTurn()
        && getJump() == other.getJump()
        && getReset() == other.getReset()
        && getPaint() == other.getPaint()
        && getErase() == other.getErase();
}
void AudioPlugin::draw(ANPCanvas* canvas) {
    NPP instance = this->inst();
    PluginObject *obj = (PluginObject*) instance->pdata;

    gLogI.log(instance, kError_ANPLogType, "Drawing");

    const float trackHeight = 30;
    const float buttonWidth = 60;
    const float buttonHeight = 30;
    const int W = obj->window->width;
    const int H = obj->window->height;

    // color the plugin canvas
    gCanvasI.drawColor(canvas, 0xFFCDCDCD);

    // get font metrics
    ANPFontMetrics fontMetrics;
    gPaintI.getFontMetrics(m_paintText, &fontMetrics);

    // draw the track box (1 px from the edge)
    m_trackRect.left = 1;
    m_trackRect.top = 1;
    m_trackRect.right = W - 2;
    m_trackRect.bottom = 1 + trackHeight;
    gCanvasI.drawRect(canvas, &m_trackRect, m_paintTrack);

    // draw the progress bar
    if (m_soundPlay->progress > 0) {
        // TODO need to draw progress bar to cover the proper percentage of the track bar
        gCanvasI.drawRect(canvas, &m_trackRect, m_paintTrackProgress);
    }

    // draw the play box (under track box)
    m_playRect.left = m_trackRect.left + 5;
    m_playRect.top = m_trackRect.bottom + 10;
    m_playRect.right = m_playRect.left + buttonWidth;
    m_playRect.bottom = m_playRect.top + buttonHeight;
    gCanvasI.drawRect(canvas, &m_playRect, getPaint(&m_playRect));
    // draw the play box (under track box)
    const char playText[] = "Play";
    gCanvasI.drawText(canvas, playText, sizeof(playText)-1, m_playRect.left + 5,
                      m_playRect.top - fontMetrics.fTop, m_paintText);

    // draw the pause box (under track box)
    m_pauseRect.left = m_playRect.right + 20;
    m_pauseRect.top = m_trackRect.bottom + 10;
    m_pauseRect.right = m_pauseRect.left + buttonWidth;
    m_pauseRect.bottom = m_pauseRect.top + buttonHeight;
    gCanvasI.drawRect(canvas, &m_pauseRect, getPaint(&m_pauseRect));
    // draw the text in the pause box
    const char pauseText[] = "Pause";
    gCanvasI.drawText(canvas, pauseText, sizeof(pauseText)-1, m_pauseRect.left + 5,
                      m_pauseRect.top - fontMetrics.fTop, m_paintText);

    // draw the stop box (under track box)
    m_stopRect.left = m_pauseRect.right + 20;
    m_stopRect.top = m_trackRect.bottom + 10;
    m_stopRect.right = m_stopRect.left + buttonWidth;
    m_stopRect.bottom = m_stopRect.top + buttonHeight;
    gCanvasI.drawRect(canvas, &m_stopRect, getPaint(&m_stopRect));
    // draw the text in the pause box
    const char stopText[] = "Stop";
    gCanvasI.drawText(canvas, stopText, sizeof(stopText)-1, m_stopRect.left + 5,
                      m_stopRect.top - fontMetrics.fTop, m_paintText);
}