コード例 #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);
}
コード例 #2
0
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());
}
コード例 #3
0
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);
}
コード例 #4
0
void PaintPlugin::drawCleanPlugin(ANPCanvas* canvas) {
    NPP instance = this->inst();
    PluginObject *obj = (PluginObject*) instance->pdata;

    // if no canvas get a locked canvas
    if (!canvas)
        canvas = getCanvas();

    if (!canvas)
        return;

    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_paintSurface, &fontMetrics);

    // draw the input toggle button
    m_inputToggle.left = 5;
    m_inputToggle.top = H - buttonHeight - 5;
    m_inputToggle.right = m_inputToggle.left + buttonWidth;
    m_inputToggle.bottom = m_inputToggle.top + buttonHeight;
    gCanvasI.drawRect(canvas, &m_inputToggle, m_paintButton);
    const char* inputText = m_isTouchCurrentInput ? "Touch" : "Mouse";
    gCanvasI.drawText(canvas, inputText, strlen(inputText), m_inputToggle.left + 5,
                      m_inputToggle.top - fontMetrics.fTop, m_paintSurface);

    // draw the color selector button
    m_colorToggle.left = (W/3) - (buttonWidth/2);
    m_colorToggle.top = H - buttonHeight - 5;
    m_colorToggle.right = m_colorToggle.left + buttonWidth;
    m_colorToggle.bottom = m_colorToggle.top + buttonHeight;
    gCanvasI.drawRect(canvas, &m_colorToggle, m_paintButton);
    const char* colorText = getColorText();
    gCanvasI.drawText(canvas, colorText, strlen(colorText), m_colorToggle.left + 5,
                      m_colorToggle.top - fontMetrics.fTop, m_paintSurface);

    // draw the full-screen toggle button
    m_fullScreenToggle.left = ((W*2)/3) - (buttonWidth/2);
    m_fullScreenToggle.top = H - buttonHeight - 5;
    m_fullScreenToggle.right = m_fullScreenToggle.left + buttonWidth;
    m_fullScreenToggle.bottom = m_fullScreenToggle.top + buttonHeight;
    gCanvasI.drawRect(canvas, &m_fullScreenToggle, m_paintButton);
    const char* fullScreenText = "Full";
    gCanvasI.drawText(canvas, fullScreenText, strlen(fullScreenText),
                      m_fullScreenToggle.left + 5,
                      m_fullScreenToggle.top - fontMetrics.fTop, m_paintSurface);

    // draw the clear canvas button
    m_clearSurface.left = W - buttonWidth - 5;
    m_clearSurface.top = H - buttonHeight - 5;
    m_clearSurface.right = m_clearSurface.left + buttonWidth;
    m_clearSurface.bottom = m_clearSurface.top + buttonHeight;
    gCanvasI.drawRect(canvas, &m_clearSurface, m_paintButton);
    const char* clearText = "Clear";
    gCanvasI.drawText(canvas, clearText, strlen(clearText), m_clearSurface.left + 5,
                      m_clearSurface.top - fontMetrics.fTop, m_paintSurface);

    // draw the drawing surface box (5 px from the edge)
    m_drawingSurface.left = 5;
    m_drawingSurface.top = 5;
    m_drawingSurface.right = W - 5;
    m_drawingSurface.bottom = m_colorToggle.top - 5;
    gCanvasI.drawRect(canvas, &m_drawingSurface, m_paintSurface);

    // release the canvas
    releaseCanvas(canvas);
}