CutInWindow::CutInWindow() : Window("", Modal_false, nullptr, "cutin.xml"), mImage(nullptr), mOldTitleBarHeight(mTitleBarHeight) { setWindowName("CutIn"); setShowTitle(false); setResizable(false); setDefaultVisible(false); setSaveVisible(false); setVisible(Visible_false); enableVisibleSound(false); }
ShortcutWindow::ShortcutWindow(const std::string &title, ShortcutContainer *content) { setWindowName(title); // no title presented, title bar is padding so window can be moved. gcn::Window::setTitleBarHeight(gcn::Window::getPadding()); setShowTitle(false); setResizable(true); setDefaultVisible(false); setSaveVisible(true); setupWindow->registerWindowForReset(this); mItems = content; const int border = SCROLL_PADDING * 2 + getPadding() * 2; setMinWidth(mItems->getBoxWidth() + border); setMinHeight(mItems->getBoxHeight() + border); setMaxWidth(mItems->getBoxWidth() * mItems->getMaxItems() + border); setMaxHeight(mItems->getBoxHeight() * mItems->getMaxItems() + border); setDefaultSize(mItems->getBoxWidth() + border, mItems->getBoxHeight() * mItems->getMaxItems() + border, ImageRect::LOWER_RIGHT, mBoxesWidth, 0); mBoxesWidth += mItems->getBoxWidth() + border; mScrollArea = new ScrollArea(mItems); mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mScrollArea->setOpaque(false); place(0, 0, mScrollArea, 5, 5).setPadding(0); Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); layout.setMargin(0); loadWindowState(); }
EmoteWindow::EmoteWindow() : // TRANSLATORS: emotes window name Window(_("Emotes"), Modal_false, nullptr, "emotes.xml"), mTabs(CREATEWIDGETR(TabbedArea, this)), mEmotePage(new EmotePage(this)), mColorModel(ColorModel::createDefault(this)), mColorPage(CREATEWIDGETR(ColorPage, this, mColorModel, "colorpage.xml")), mScrollColorPage(new ScrollArea(this, mColorPage, Opaque_false, "emotepage.xml")), mFontModel(new NamesModel), mFontPage(CREATEWIDGETR(ListBox, this, mFontModel, "")), mScrollFontPage(new ScrollArea(this, mFontPage, Opaque_false, "fontpage.xml")), mImageSet(Theme::getImageSetFromThemeXml("emotetabs.xml", "", 17, 16)) { setShowTitle(false); setResizable(true); if (setupWindow) setupWindow->registerWindowForReset(this); addMouseListener(this); }
ShortcutWindow::ShortcutWindow(ShortcutContainer *content): Window("", false, NULL, "graphics/gui/gui.xml", true) { // no title presented, title bar is padding so window can be moved. gcn::Window::setTitleBarHeight(gcn::Window::getPadding()); setWindowName(content->getShortcutHandler()->getPrefix()); setShowTitle(false); setResizable(true); mItems = content; const int border = SCROLL_PADDING * 2 + getPadding() * 2; setMinWidth(mItems->getBoxWidth() + border); setMinHeight(mItems->getBoxHeight() + border); setMaxWidth(mItems->getBoxWidth() * mItems->getMaxShortcuts() + border); setMaxHeight(mItems->getBoxHeight() * mItems->getMaxShortcuts() + border); setDefaultSize(mItems->getBoxWidth() + border, (mItems->getBoxHeight() * mItems->getMaxShortcuts()) + border, ImageRect::LOWER_RIGHT, -mInstances * (mItems->getBoxWidth() + 2 * getPadding()), 0); mInstances++; mScrollArea = new ScrollArea(mItems); mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mScrollArea->setOpaque(false); place(0, 0, mScrollArea, 5, 5).setPadding(0); Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); layout.setMargin(0); loadWindowState(); }
void CutInWindow::show(const std::string &name, const CutInT cutin) { delete2(mImage); if (name.empty()) { setVisible(Visible_false); } else { mImage = AnimatedSprite::load( std::string(paths.getStringValue("cutInsDir")).append( "/").append( name).append( ".xml")); if (mImage) { mImage->update(1); const bool showTitle = (cutin == CutIn::MovableClose); if (showTitle) mTitleBarHeight = mOldTitleBarHeight; else mTitleBarHeight = mPadding; const int width = mImage->getWidth() + 2 * mPadding; const int height = mImage->getHeight() + mTitleBarHeight + mPadding; const int screenWidth = mainGraphics->mWidth; const int screenHeight = mainGraphics->mHeight; if (width * 2 > screenWidth || height * 2 > screenHeight) { return; } const int padding = 100; int x = 0; const int y = screenHeight - height - padding; switch (cutin) { case CutIn::BottomRight: x = screenWidth - width - padding; break; case CutIn::BottomCenter: case CutIn::Movable: case CutIn::MovableClose: x = (screenWidth - width) / 2; break; case CutIn::BottomLeft: default: x = padding; break; } setCloseButton(false); setVisible(Visible_true); setPosition(x, y); setCloseButton(showTitle); setShowTitle(showTitle); setSize(width, height); setVisible(Visible_true); requestMoveToTop(); } } }