示例#1
0
void StatusBar::onPaint(ui::PaintEvent& ev)
{
  SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
  gfx::Color textColor = theme->getColorById(kStatusBarText);
  Rect rc = getClientBounds();
  Graphics* g = ev.getGraphics();

  g->fillRect(getBgColor(), rc);

  rc.shrink(Border(2, 1, 2, 2)*guiscale());

  int x = rc.x + 4*guiscale();

  // Color
  if (m_state == SHOW_COLOR) {
    // Draw eyedropper icon
    she::Surface* icon = theme->get_toolicon("eyedropper");
    if (icon) {
      g->drawRgbaSurface(icon, x, rc.y + rc.h/2 - icon->height()/2);
      x += icon->width() + 4*guiscale();
    }

    // Draw color
    draw_color_button(g, gfx::Rect(x, rc.y, 32*guiscale(), rc.h),
      m_color, false, false);

    x += (32+4)*guiscale();

    // Draw color description
    std::string str = m_color.toHumanReadableString(app_get_current_pixel_format(),
      app::Color::LongHumanReadableString);
    if (m_alpha < 255) {
      char buf[256];
      sprintf(buf, " \xCE\xB1%d", m_alpha);
      str += buf;
    }

    g->drawString(str, textColor, ColorNone,
      gfx::Point(x, rc.y + rc.h/2 - getFont()->height()/2));

    x += getFont()->textLength(str.c_str()) + 4*guiscale();
  }

  // Show tool
  if (m_state == SHOW_TOOL) {
    // Draw eyedropper icon
    she::Surface* icon = theme->get_toolicon(m_tool->getId().c_str());
    if (icon) {
      g->drawRgbaSurface(icon, x, rc.y + rc.h/2 - icon->height()/2);
      x += icon->width() + 4*guiscale();
    }
  }

  // Status bar text
  if (getTextLength() > 0) {
    g->drawString(getText(), textColor, ColorNone,
      gfx::Point(x, rc.y + rc.h/2 - getFont()->height()/2));

    x += getFont()->textLength(getText().c_str()) + 4*guiscale();
  }
}
示例#2
0
StatusBar::StatusBar()
  : Widget(statusbar_type())
  , m_color(app::Color::fromMask())
  , m_hasDoc(false)
{
  m_instance = this;

  setDoubleBuffered(true);

  SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
  setBgColor(theme->getColorById(kStatusBarFace));

  this->setFocusStop(true);

  m_timeout = 0;
  m_state = SHOW_TEXT;
  m_tipwindow = NULL;

  // The extra pixel in left and right borders are necessary so
  // m_commandsBox and m_movePixelsBox do not overlap the upper-left
  // and upper-right pixels drawn in onPaint() event (see putpixels)
  setBorder(gfx::Border(1*guiscale(), 0, 1*guiscale(), 0));

  // Construct the commands box
  {
    Box* box1 = new Box(JI_HORIZONTAL);
    Box* box4 = new Box(JI_HORIZONTAL);

    m_frameLabel = new Label("Frame:");
    m_currentFrame = new GotoFrameEntry();
    m_newFrame = new Button("+");
    m_newFrame->Click.connect(Bind<void>(&StatusBar::newFrame, this));
    m_slider = new Slider(0, 255, 255);

    setup_mini_look(m_currentFrame);
    setup_mini_look(m_newFrame);
    setup_mini_look(m_slider);

    m_slider->Change.connect(Bind<void>(&StatusBar::onCelOpacityChange, this));
    m_slider->setMinSize(gfx::Size(ui::display_w()/5, 0));

    box1->setBorder(gfx::Border(2, 1, 2, 2)*guiscale());

    box4->addChild(m_currentFrame);
    box4->addChild(m_newFrame);

    box1->addChild(m_frameLabel);
    box1->addChild(box4);
    box1->addChild(m_slider);

    m_commandsBox = box1;
    addChild(m_commandsBox);
    m_commandsBox->setVisible(false);
  }

  // Tooltips manager
  TooltipManager* tooltipManager = new TooltipManager();
  addChild(tooltipManager);
  tooltipManager->addTooltipFor(m_currentFrame, "Current Frame", JI_BOTTOM);
  tooltipManager->addTooltipFor(m_slider, "Cel Opacity", JI_BOTTOM);

  Preferences::instance().toolBox.activeTool.AfterChange.connect(
    Bind<void>(&StatusBar::onCurrentToolChange, this));

  UIContext::instance()->addObserver(this);
}
示例#3
0
StatusBar::StatusBar()
  : Widget(statusbar_type())
  , m_color(app::Color::fromMask())
{
  m_instance = this;

  setDoubleBuffered(true);

  SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
  setBgColor(theme->getColorById(kStatusBarFace));

#define BUTTON_NEW(name, text, action)                                  \
  {                                                                     \
    (name) = new Button(text);                                          \
    (name)->user_data[0] = this;                                        \
    setup_mini_look(name);                                              \
    (name)->Click.connect(Bind<void>(&ani_button_command, (name), action)); \
  }

#define ICON_NEW(name, icon, action)                                    \
  {                                                                     \
    BUTTON_NEW((name), "", (action));                                   \
    set_gfxicon_to_button((name), icon, icon##_SELECTED, icon##_DISABLED, JI_CENTER | JI_MIDDLE); \
  }

  this->setFocusStop(true);

  m_timeout = 0;
  m_state = SHOW_TEXT;
  m_tipwindow = NULL;

  // The extra pixel in left and right borders are necessary so
  // m_commandsBox and m_movePixelsBox do not overlap the upper-left
  // and upper-right pixels drawn in onPaint() event (see putpixels)
  setBorder(gfx::Border(1*jguiscale(), 0, 1*jguiscale(), 0));

  // Construct the commands box
  {
    Box* box1 = new Box(JI_HORIZONTAL);
    Box* box2 = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS);
    Box* box3 = new Box(JI_HORIZONTAL);
    Box* box4 = new Box(JI_HORIZONTAL);
    m_slider = new Slider(0, 255, 255);
    m_currentFrame = new GotoFrameEntry();
    m_newFrame = new Button("+");
    m_newFrame->Click.connect(Bind<void>(&StatusBar::newFrame, this));

    setup_mini_look(m_slider);
    setup_mini_look(m_currentFrame);
    setup_mini_look(m_newFrame);

    ICON_NEW(m_b_first, PART_ANI_FIRST, ACTION_FIRST);
    ICON_NEW(m_b_prev, PART_ANI_PREVIOUS, ACTION_PREV);
    ICON_NEW(m_b_play, PART_ANI_PLAY, ACTION_PLAY);
    ICON_NEW(m_b_next, PART_ANI_NEXT, ACTION_NEXT);
    ICON_NEW(m_b_last, PART_ANI_LAST, ACTION_LAST);

    m_slider->Change.connect(Bind<void>(&slider_change_hook, m_slider));
    jwidget_set_min_size(m_slider, JI_SCREEN_W/5, 0);

    box1->setBorder(gfx::Border(2, 1, 2, 2)*jguiscale());
    box2->noBorderNoChildSpacing();
    box3->noBorderNoChildSpacing();
    box3->setExpansive(true);

    box4->addChild(m_currentFrame);
    box4->addChild(m_newFrame);

    box2->addChild(m_b_first);
    box2->addChild(m_b_prev);
    box2->addChild(m_b_play);
    box2->addChild(m_b_next);
    box2->addChild(m_b_last);

    box1->addChild(box3);
    box1->addChild(box4);
    box1->addChild(box2);
    box1->addChild(m_slider);

    m_commandsBox = box1;
  }

  // Create the box to show notifications.
  {
    Box* box1 = new Box(JI_HORIZONTAL);
    Box* box2 = new Box(JI_VERTICAL);

    box1->setBorder(gfx::Border(2, 1, 2, 2)*jguiscale());
    box2->noBorderNoChildSpacing();
    box2->setExpansive(true);

    m_linkLabel = new LinkLabel((std::string(WEBSITE) + "donate/").c_str(), "Support This Project");

    box1->addChild(box2);
    box1->addChild(m_linkLabel);
    m_notificationsBox = box1;
  }

  addChild(m_notificationsBox);

  App::instance()->CurrentToolChange.connect(&StatusBar::onCurrentToolChange, this);
}
示例#4
0
void StatusBar::onPaint(ui::PaintEvent& ev)
{
  SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
  ui::Color textColor = theme->getColorById(kStatusBarText);
  Rect rc = getClientBounds();
  Graphics* g = ev.getGraphics();

  g->fillRect(getBgColor(), rc);

  rc.shrink(Border(2, 1, 2, 2)*jguiscale());

  int x = rc.x + 4*jguiscale();

  // Color
  if (m_state == SHOW_COLOR) {
    // Draw eyedropper icon
    BITMAP* icon = theme->get_toolicon("eyedropper");
    if (icon) {
      g->drawAlphaBitmap(icon, x, rc.y + rc.h/2 - icon->h/2);
      x += icon->w + 4*jguiscale();
    }

    // Draw color
    draw_color_button(g, gfx::Rect(x, rc.y, 32*jguiscale(), rc.h),
      true, true, true, true,
      true, true, true, true,
      app_get_current_pixel_format(), m_color,
      false, false);

    x += (32+4)*jguiscale();

    // Draw color description
    std::string str = m_color.toHumanReadableString(app_get_current_pixel_format(),
      app::Color::LongHumanReadableString);
    if (m_alpha < 255) {
      char buf[512];
      usprintf(buf, ", Alpha %d", m_alpha);
      str += buf;
    }

    g->drawString(str, textColor, ColorNone, false,
      gfx::Point(x, rc.y + rc.h/2 - text_height(getFont())/2));

    x += ji_font_text_len(getFont(), str.c_str()) + 4*jguiscale();
  }

  // Show tool
  if (m_state == SHOW_TOOL) {
    // Draw eyedropper icon
    BITMAP* icon = theme->get_toolicon(m_tool->getId().c_str());
    if (icon) {
      g->drawAlphaBitmap(icon, x, rc.y + rc.h/2 - icon->h/2);
      x += icon->w + 4*jguiscale();
    }
  }

  // Status bar text
  if (getTextLength() > 0) {
    g->drawString(getText(), textColor, ColorNone, false,
      gfx::Point(x, rc.y + rc.h/2 - text_height(getFont())/2));

    x += ji_font_text_len(getFont(), getText().c_str()) + 4*jguiscale();
  }

  // Draw progress bar
  if (!m_progress.empty()) {
    int width = 64;
    int x = rc.x2() - (width+4);

    for (ProgressList::iterator it = m_progress.begin(); it != m_progress.end(); ++it) {
      Progress* progress = *it;

      theme->paintProgressBar(g,
        gfx::Rect(x, rc.y, width, rc.h),
        progress->getPos());

      x -= width+4;
    }
  }

  updateSubwidgetsVisibility();
}
示例#5
0
void Tabs::onPaint(PaintEvent& ev)
{
  SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
  Graphics* g = ev.getGraphics();
  gfx::Rect rect = getClientBounds();
  gfx::Rect box(rect.x-m_scrollX, rect.y,
    2*jguiscale(),
    m_list_of_tabs.empty() ? 0: theme->get_part(PART_TAB_FILLER)->height());

  g->fillRect(theme->getColorById(kWindowFaceColorId), g->getClipBounds());

  theme->draw_part_as_hline(g, box, PART_TAB_FILLER);
  theme->draw_part_as_hline(g, gfx::Rect(box.x, box.y2(), box.w, rect.y2()-box.y2()), PART_TAB_BOTTOM_NORMAL);

  box.x = box.x2();

  // For each tab...
  TabsListIterator it, end = m_list_of_tabs.end();

  for (it = m_list_of_tabs.begin(); it != end; ++it) {
    Tab* tab = *it;

    box.w = tab->width;

    int x_delta = 0;
    int y_delta = 0;

    // Y-delta for animating tabs (intros and outros)
    if (m_ani == ANI_ADDING_TAB && m_selected == tab) {
      y_delta = box.h * (ANI_ADDING_TAB_TICKS - m_ani_t) / ANI_ADDING_TAB_TICKS;
    }
    else if (m_ani == ANI_REMOVING_TAB && m_nextTabOfTheRemovedOne == tab) {
      x_delta += m_removedTab->width - m_removedTab->width*(1.0-std::exp(-10.0 * m_ani_t / (double)ANI_REMOVING_TAB_TICKS));
      x_delta = MID(0, x_delta, m_removedTab->width);

      // Draw deleted tab
      if (m_removedTab) {
        gfx::Rect box2(box.x, box.y, x_delta, box.h);
        drawTab(g, box2, m_removedTab, 0, false);
      }
    }

    box.x += x_delta;
    drawTab(g, box, tab, y_delta, (tab == m_selected));

    box.x = box.x2();
  }

  if (m_ani == ANI_REMOVING_TAB && m_nextTabOfTheRemovedOne == NULL) {
    // Draw deleted tab
    if (m_removedTab) {
      int x_delta = m_removedTab->width - m_removedTab->width*(1.0-std::exp(-10.0 * m_ani_t / (double)ANI_REMOVING_TAB_TICKS));
      x_delta = MID(0, x_delta, m_removedTab->width);

      gfx::Rect box2(box.x, box.y, x_delta, box.h);
      drawTab(g, box2, m_removedTab, 0, false);

      box.x += x_delta;
      box.w = 0;
    }
  }

  // Fill the gap to the right-side
  if (box.x < rect.x2()) {
    theme->draw_part_as_hline(g, gfx::Rect(box.x, box.y, rect.x2()-box.x, box.h), PART_TAB_FILLER);
    theme->draw_part_as_hline(g, gfx::Rect(box.x, box.y2(), rect.x2()-box.x, rect.y2()-box.y2()), PART_TAB_BOTTOM_NORMAL);
  }
}