ColorBar::ColorBar(int align) : Box(align) , m_paletteButton("Edit Palette", JI_BUTTON) , m_paletteView(false) , m_fgColor(Color::fromIndex(15), IMAGE_INDEXED) , m_bgColor(Color::fromIndex(0), IMAGE_INDEXED) , m_lock(false) { setBorder(gfx::Border(1*jguiscale())); child_spacing = 1*jguiscale(); m_paletteView.setBoxSize(6*jguiscale()); m_paletteView.setColumns(4); m_fgColor.setPreferredSize(0, m_fgColor.getPreferredSize().h); m_bgColor.setPreferredSize(0, m_bgColor.getPreferredSize().h); m_scrollableView.attachToView(&m_paletteView); int w = (m_scrollableView.getBorder().getSize().w + m_scrollableView.getViewport()->getBorder().getSize().w + m_paletteView.getPreferredSize().w + getTheme()->scrollbar_size); jwidget_set_min_size(&m_scrollableView, w, 0); m_scrollableView.setExpansive(true); addChild(&m_paletteButton); addChild(&m_scrollableView); addChild(&m_fgColor); addChild(&m_bgColor); this->border_width.l = 2*jguiscale(); this->border_width.t = 2*jguiscale(); this->border_width.r = 2*jguiscale(); this->border_width.b = 2*jguiscale(); this->child_spacing = 2*jguiscale(); m_paletteView.IndexChange.connect(&ColorBar::onPaletteIndexChange, this); m_fgColor.Change.connect(&ColorBar::onFgColorButtonChange, this); m_bgColor.Change.connect(&ColorBar::onBgColorButtonChange, this); // Set background color reading its value from the configuration. setBgColor(get_config_color("ColorBar", "BG", getBgColor())); // Clear the selection of the BG color in the palette. m_paletteView.clearSelection(); // Set foreground color reading its value from the configuration. setFgColor(get_config_color("ColorBar", "FG", getFgColor())); // Change color-bar background color (not ColorBar::setBgColor) Widget::setBgColor(((SkinTheme*)getTheme())->get_tab_selected_face_color()); m_paletteView.setBgColor(((SkinTheme*)getTheme())->get_tab_selected_face_color()); // Change labels foreground color setup_mini_look(&m_paletteButton); m_paletteButton.setFont(((SkinTheme*)getTheme())->getMiniFont()); m_paletteButton.Click.connect(Bind<void>(&ColorBar::onPaletteButtonClick, this)); setDoubleBuffered(true); onColorButtonChange(getFgColor()); }
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); }