void UISelector::setSelectionIndex(const int &index) { if(getWrapSelection()) { if(index < 0) { mSelectedIndex = mChildren.size() - 1; } else if(index >= (int)mChildren.size()) { mSelectedIndex = 0; } else { mSelectedIndex = index; } } else { if(index < -1) { mSelectedIndex = -1; } else if(index >= (int)mChildren.size()) { mSelectedIndex = mChildren.size() - 1; } else { mSelectedIndex = index; } } updateScroll(); }
void ListBox::setScrollVisible(bool _visible) { if (mNeedVisibleScroll == _visible) return; mNeedVisibleScroll = _visible; updateScroll(); }
// LLView functionality void LLScrollContainer::reshape(S32 width, S32 height, BOOL called_from_parent) { LLUICtrl::reshape( width, height, called_from_parent ); mInnerRect = getLocalRect(); mInnerRect.stretch( -getBorderWidth() ); if (mScrolledView) { const LLRect& scrolled_rect = mScrolledView->getRect(); S32 visible_width = 0; S32 visible_height = 0; BOOL show_v_scrollbar = FALSE; BOOL show_h_scrollbar = FALSE; calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar ); mScrollbar[VERTICAL]->setDocSize( scrolled_rect.getHeight() ); mScrollbar[VERTICAL]->setPageSize( visible_height ); mScrollbar[HORIZONTAL]->setDocSize( scrolled_rect.getWidth() ); mScrollbar[HORIZONTAL]->setPageSize( visible_width ); updateScroll(); } }
void ListBox::setCoord(const IntCoord& _coord) { Base::setCoord(_coord); updateScroll(); updateLine(); }
void ListBox::setSize(const IntSize& _size) { Base::setSize(_size); updateScroll(); updateLine(); }
/* ---------------------------------------------------------------------- * Author: Julian * Date: 27 January 2014 * Description: Submits a command * ---------------------------------------------------------------------- */ void Console::submitCommand() { // Adds the text to the console! log("> " + consoleTextList[0].getString()); // Adds the command to the commandList commandList.push_back(consoleTextList[0]); iCommand = commandList.end(); // Check for commands (and maybe a values) std::string inputLine = consoleTextList[0].getString(); size_t pos = inputLine.find(' ', 0); // The two strings, one for the command and one for the value std::string command = inputLine.substr(0, pos); std::string values = inputLine.substr(pos + 1); // Searches for the right command and triggers it newCommand(command, values); // Clears the text ;) consoleTextList[0].setString(""); // Sets the scrollbar down again ;) scrollBar[0].setPosition(scrollBar[0].getPosition().x, line[0].position.y - scrollBar[0].getGlobalBounds().height); updateScroll(); }
void UISelector::selectPrevItem(char c) { if(mChildren.empty()) { return; } int i = mSelectedIndex - 1; c = tolower(c); while(i != mSelectedIndex) { if(i < 0) { i = mChildren.size() - 1; } UIText *text = dynamic_cast<UIText *>(mChildren[i]); if(text != NULL) { char f = tolower(text->getFirstUnformatted()); if(c == f) { mSelectedIndex = i; break; } } i--; } updateScroll(); }
/* ---------------------------------------------------------------------- * Author: Julian * Date: 27 January 2014 * Description: Constructor of the console class * ---------------------------------------------------------------------- */ Console::Console(State::Context context) : context(context) , scrollCoordinates(0, 0) , dragCoordinates(0, 0) , minBarHeight(10.0f) , characterSize(13) , currentAmount(-1) , scrollIndex(0) , scrollY(0.0f) , visible(false) , isMoving(false) , flag_moved(false) , moveScroll(false) { // Creates the console window consoleWindow = sf::RectangleShape(sf::Vector2f(600, 405)); consoleWindow.setFillColor(sf::Color(35, 35, 35)); consoleWindow.setOutlineThickness(1); consoleWindow.setOutlineColor(sf::Color(51, 51, 51)); consoleWindow.setPosition(sf::Vector2f(200, 100)); // Creates the moveBar moveBar = sf::RectangleShape(sf::Vector2f(consoleWindow.getSize().x, 20.0f)); moveBar.setFillColor(sf::Color(30, 30, 30)); moveBar.setPosition(consoleWindow.getPosition()); // Make the line line = sf::VertexArray(sf::Lines, 2); line[0] = sf::Vertex(sf::Vector2f(consoleWindow.getPosition().x, consoleWindow.getPosition().y + consoleWindow.getSize().y - characterSize - 10)); line[1] = sf::Vertex(sf::Vector2f(consoleWindow.getPosition().x + consoleWindow.getSize().x, consoleWindow.getPosition().y + consoleWindow.getSize().y - characterSize - 10)); line[0].color = sf::Color(51, 51, 51); line[1].color = sf::Color(51, 51, 51); // Creates the standard texts for the console! sf::Text tempText("", context.contentManager->getFont(Fonts::ARIAL), characterSize); tempText.setPosition(sf::Vector2f(consoleWindow.getPosition().x + 20, consoleWindow.getPosition().y + consoleWindow.getSize().y - characterSize - 6)); consoleTextList.push_back(tempText); tempText.setString("Console"); tempText.setPosition(sf::Vector2f(consoleWindow.getPosition().x + 5, consoleWindow.getPosition().y + 2)); consoleTextList.push_back(tempText); tempText.setPosition(sf::Vector2f(consoleWindow.getPosition().x + 5, consoleWindow.getPosition().y + consoleWindow.getSize().y - characterSize - 6)); tempText.setString(">"); tempText.setColor(sf::Color(91, 91, 91)); consoleTextList.push_back(tempText); // Creates the scrollbars scrollBar[1] = sf::RectangleShape(sf::Vector2f(16.0f, consoleWindow.getSize().y - moveBar.getSize().y - characterSize - 10)); scrollBar[1].setFillColor(sf::Color(80, 80, 80)); scrollBar[1].setPosition(consoleWindow.getPosition().x + consoleWindow.getGlobalBounds().width - scrollBar[1].getGlobalBounds().width - 2, consoleWindow.getPosition().y + moveBar.getSize().y); scrollBar[0] = sf::RectangleShape(sf::Vector2f(12.0f, scrollBar[1].getSize().y)); scrollBar[0].setFillColor(sf::Color(200, 200, 200)); scrollBar[0].setPosition(scrollBar[1].getPosition().x + 2, scrollBar[1].getPosition().y); updateScroll(); iCommand = commandList.begin(); }
LLRect LLScrollContainer::getVisibleContentRect() { updateScroll(); LLRect visible_rect = getContentWindowRect(); LLRect contents_rect = mScrolledView->getRect(); visible_rect.translate(-contents_rect.mLeft, -contents_rect.mBottom); return visible_rect; }
void STSimpleEditView::setSize(const QSize &sz){ if(m_size==sz)return; prepareGeometryChange(); m_size=sz; m_scrollBar->setPos(m_size.width()-10,1); m_scrollBar->setSize(QSize(9, m_size.height()-2)); updateScroll(); }
/* ---------------------------------------------------------------------- * Author: Julian * Date: 27 January 2014 * Description: Clears all commands * ---------------------------------------------------------------------- */ void Console::clearAll() { currentAmount = -1; consoleStrings.clear(); commandList.clear(); scrollBar[0].setSize(sf::Vector2f(scrollBar[0].getSize().x, scrollBar[1].getSize().y)); updateScroll(); log("Cleared the console.", success_color); }
void CanvasNavigator::updateCanvasPosition(int x, int y) { if(m_canvas) { int pos = ((m_canvas->mapx(sceneToTick(x))+m_canvas->xOffsetDev())-(m_canvas->width()/2)); int ypos = sceneToCanvas(y)-200; //int ypos = sceneToCanvas(y); emit updateScroll(pos, ypos); } }
/*--------------------------------------------------------------------display-+ | | +----------------------------------------------------------------------------*/ void display(char const * text, int len) { FormPtr frm = FrmGetActiveForm(); FieldPtr field = (FieldPtr)FrmGetObjectPtr( frm, FrmGetObjectIndex(frm, MainConsoleField) ); FldInsert(field, text, len); updateScroll(); FldDrawField(field); }
ItemBox::ItemBox(const IntCoord& _coord, char _align, const WidgetSkinInfoPtr _info, CroppedRectanglePtr _parent, const Ogre::String & _name) : Widget(_coord, _align, _info, _parent, _name), mWidgetScroll(null), mWidgetClient(null), mTopIndex(0), mOffsetTop(0), mRangeIndex(-1), //mLastRedrawLine(0), //mIndexSelect(ITEM_NONE), mIsFocus(false), mCountItems(0) { // нам нужен фокус клавы mNeedKeyFocus = true; for (VectorWidgetPtr::iterator iter=mWidgetChild.begin(); iter!=mWidgetChild.end(); ++iter) { if ((*iter)->_getInternalString() == "VScroll") { mWidgetScroll = castWidget<VScroll>(*iter); mWidgetScroll->eventScrollChangePosition = newDelegate(this, &ItemBox::notifyScrollChangePosition); //mWidgetScroll->eventMouseButtonPressed = newDelegate(this, &ItemBox::notifyMousePressed); } else if ((*iter)->_getInternalString() == "Client") { mWidgetClient = (*iter); //mWidgetClient->eventMouseButtonPressed = newDelegate(this, &ItemBox::notifyMousePressed); mWidgetClient->eventMouseWheel = newDelegate(this, &ItemBox::notifyMouseWheel); } } MYGUI_ASSERT(null != mWidgetScroll, "Child VScroll not found in skin (ItemBox must have VScroll)"); MYGUI_ASSERT(null != mWidgetClient, "Child Widget Client not found in skin (ItemBox must have Client)"); // парсим свойства /*const MapString & param = _info->getParams(); MapString::const_iterator iter = param.find("SkinLine"); if (iter != param.end()) mSkinLine = iter->second; MYGUI_ASSERT(false == mSkinLine.empty(), "SkinLine property or skin not found (ItemBox must have SkinLine property)"); iter = param.find("HeightLine"); if (iter != param.end()) mHeightLine = utility::parseInt(iter->second); if (mHeightLine < 1) mHeightLine = 1; */ mWidgetScroll->setScrollPage((size_t)mSizeItem.height); mSizeItem.set(50, 50); mCountItems = 200; updateMetrics(); updateScroll(); _redrawAllVisible(); //updateLine(); }
// rect is in document coordinates, constraint is in display coordinates relative to content window rect void LLScrollContainer::scrollToShowRect(const LLRect& rect, const LLRect& constraint) { if (!mScrolledView) { llwarns << "LLScrollContainer::scrollToShowRect with no view!" << llendl; return; } LLRect content_window_rect = getContentWindowRect(); // get document rect LLRect scrolled_rect = mScrolledView->getRect(); // shrink target rect to fit within constraint region, biasing towards top left LLRect rect_to_constrain = rect; rect_to_constrain.mBottom = llmax(rect_to_constrain.mBottom, rect_to_constrain.mTop - constraint.getHeight()); rect_to_constrain.mRight = llmin(rect_to_constrain.mRight, rect_to_constrain.mLeft + constraint.getWidth()); // calculate allowable positions for scroller window in document coordinates LLRect allowable_scroll_rect(rect_to_constrain.mRight - constraint.mRight, rect_to_constrain.mBottom - constraint.mBottom, rect_to_constrain.mLeft - constraint.mLeft, rect_to_constrain.mTop - constraint.mTop); // translate from allowable region for lower left corner to upper left corner allowable_scroll_rect.translate(0, content_window_rect.getHeight()); S32 vert_pos = llclamp(mScrollbar[VERTICAL]->getDocPos(), mScrollbar[VERTICAL]->getDocSize() - allowable_scroll_rect.mTop, // min vertical scroll mScrollbar[VERTICAL]->getDocSize() - allowable_scroll_rect.mBottom); // max vertical scroll mScrollbar[VERTICAL]->setDocSize( scrolled_rect.getHeight() ); mScrollbar[VERTICAL]->setPageSize( content_window_rect.getHeight() ); mScrollbar[VERTICAL]->setDocPos( vert_pos ); S32 horizontal_pos = llclamp(mScrollbar[HORIZONTAL]->getDocPos(), allowable_scroll_rect.mLeft, allowable_scroll_rect.mRight); mScrollbar[HORIZONTAL]->setDocSize( scrolled_rect.getWidth() ); mScrollbar[HORIZONTAL]->setPageSize( content_window_rect.getWidth() ); mScrollbar[HORIZONTAL]->setDocPos( horizontal_pos ); // propagate scroll to document updateScroll(); // In case we are in accordion tab notify parent to show selected rectangle LLRect screen_rc; localRectToScreen(rect_to_constrain, &screen_rc); notifyParent(LLSD().with("scrollToShowRect",screen_rc.getValue())); }
void ItemBox::updateFromResize(const IntSize& _size) { int old_count = mCountItemInLine; updateMetrics(); updateScroll(); // если колличество айтемов в строке изменилось, то перерисовываем все if (old_count == mCountItemInLine) { // если строк стало меньшн то ничего не нужно if (_size.height >= mCoord.height) return; } notifyScrollChangePosition(null, mWidgetScroll->getScrollPosition()); _redrawAllVisible(); }
BOOL LLScrollContainer::handleScrollWheel( S32 x, S32 y, S32 clicks ) { // Give event to my child views - they may have scroll bars // (Bad UI design, but technically possible.) if (LLUICtrl::handleScrollWheel(x,y,clicks)) return TRUE; // When the vertical scrollbar is visible, scroll wheel // only affects vertical scrolling. It's confusing to have // scroll wheel perform both vertical and horizontal in a // single container. LLScrollbar* vertical = mScrollbar[VERTICAL]; if (vertical->getVisible() && vertical->getEnabled()) { // Pretend the mouse is over the scrollbar if (vertical->handleScrollWheel( 0, 0, clicks ) ) { updateScroll(); } // Always eat the event return TRUE; } LLScrollbar* horizontal = mScrollbar[HORIZONTAL]; // Test enablement and visibility for consistency with // LLView::childrenHandleScrollWheel(). if (horizontal->getVisible() && horizontal->getEnabled() && horizontal->handleScrollWheel( 0, 0, clicks ) ) { updateScroll(); return TRUE; } return FALSE; }
LLRect LLScrollContainer::getContentWindowRect() { updateScroll(); LLRect scroller_view_rect; S32 visible_width = 0; S32 visible_height = 0; BOOL show_h_scrollbar = FALSE; BOOL show_v_scrollbar = FALSE; calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar ); S32 border_width = getBorderWidth(); scroller_view_rect.setOriginAndSize(border_width, show_h_scrollbar ? mScrollbar[HORIZONTAL]->getRect().mTop : border_width, visible_width, visible_height); return scroller_view_rect; }
/*----------------------------------------------------------------linesScroll-+ | | +----------------------------------------------------------------------------*/ void linesScroll(int numLinesToScroll, Boolean redraw) { FormPtr frm = FrmGetActiveForm(); FieldPtr field = (FieldPtr)FrmGetObjectPtr( frm, FrmGetObjectIndex(frm, MainConsoleField) ); if (numLinesToScroll < 0) { FldScrollField(field, -numLinesToScroll, winUp); }else { FldScrollField(field, numLinesToScroll, winDown); } if ((FldGetNumberOfBlankLines(field) && numLinesToScroll < 0) || redraw) { updateScroll(); } }
void LuaTableView::resetScroll(){ if(!_scrollBar){ return;} CCSize vs = getViewSize(), cs = getContentSize(); bool vert = getDirection() == kCCScrollViewDirectionVertical; bool v = vert? vs.height < cs.height : vs.width < cs.height; _scrollBar->setVisible(v); CCPoint p = ccp(0, 0), ap = vert? ccp(1,0) : CCPointZero; if(v){ CCSize s = _scrollBar->getPreferredSize(), st = _scrollTrack? _scrollTrack->getPreferredSize() : CCSizeZero; if(vert){ p.x = vs.width + _scrollOffset - (st.width > 0? (st.width - s.width) / 2 : 0); _scrollTrackDelta = st.height > 0? (st.height - s.height) / 2 : 0; s.height = vs.height / cs.height * vs.height - _scrollTrackDelta * 2; }else{ p.y = vs.height + _scrollOffset - (st.height > 0? (st.height - s.height) / 2 : 0); _scrollTrackDelta = st.width > 0? (st.width - s.width) / 2 : 0; s.width = vs.width / cs.width * vs.width - _scrollTrackDelta * 2; } _scrollBar->setAnchorPoint(ap); _scrollBar->setPreferredSize(s); _scrollBar->setPosition(p); //CCLog("LTV vScroll.size=%d,%d vh=%d ch=%d", (int)s.width, (int)s.height, (int)vs.height, (int)cs.height); } if(_scrollTrack){ _scrollTrack->setVisible(v); if(v){ CCSize s = _scrollTrack->getPreferredSize(); if(vert){ p.x = vs.width + _scrollOffset; s.height = vs.height; }else{ p.y = vs.height + _scrollOffset; s.width = vs.width; } _scrollTrack->setAnchorPoint(ap); _scrollTrack->setPreferredSize(s); _scrollTrack->setPosition(p); } } //CCLog("LTV reload vscr=%x visible=%d", _scroller, _scrollBar->isVisible()); updateScroll(); }
void NavDialog::SetScalingFactor() { m_view[0].m_lines = ::SendMessage(m_view[0].m_hView, SCI_GETLINECOUNT, 0, 0); m_view[1].m_lines = ::SendMessage(m_view[1].m_hView, SCI_GETLINECOUNT, 0, 0); m_view[0].m_firstVisible = ::SendMessage(m_view[0].m_hView, SCI_GETFIRSTVISIBLELINE, 0, 0); m_view[1].m_firstVisible = ::SendMessage(m_view[1].m_hView, SCI_GETFIRSTVISIBLELINE, 0, 0); m_maxBmpLines = _MAX(m_view[0].maxBmpLines(), m_view[1].maxBmpLines()); m_syncView = (m_maxBmpLines == m_view[0].maxBmpLines()) ? &m_view[0] : &m_view[1]; RECT r; ::GetClientRect(_hSelf, &r); m_navViewWidth = ((r.right - r.left) - 3 * cSpace - 4) / 2; m_navHeight = (r.bottom - r.top) - 2 * cSpace - 2; m_pixelsPerLine = m_navHeight / m_maxBmpLines; if (m_pixelsPerLine == 0) { m_pixelsPerLine = 1; ShowScroller(r); } else { if (m_pixelsPerLine > 5) m_pixelsPerLine = 5; m_navHeight = m_pixelsPerLine * m_maxBmpLines; if (m_hScroll) ::ShowScrollBar(m_hScroll, SB_CTL, FALSE); } updateScroll(); updateDockingDlg(); if (isVisible()) ::InvalidateRect(_hSelf, NULL, TRUE); }
void NavDialog::Update() { if (!isVisible()) return; // Bitmap needs to be recreated if ((m_view[0].m_lines != ::SendMessage(m_view[0].m_hView, SCI_GETLINECOUNT, 0, 0)) || (m_view[1].m_lines != ::SendMessage(m_view[1].m_hView, SCI_GETLINECOUNT, 0, 0))) { Show(); } else { m_view[0].updateFirstVisible(); m_view[1].updateFirstVisible(); updateScroll(); ::InvalidateRect(_hSelf, NULL, FALSE); } }
void Form::update(float elapsedTime) { if (isDirty()) { updateBounds(); // Cache themed attributes for performance. _skin = getSkin(_state); _opacity = getOpacity(_state); GP_ASSERT(_layout); if (_scroll != SCROLL_NONE) { updateScroll(); } else { _layout->update(this, Vector2::zero()); } } }
BOOL LLScrollContainer::handleKeyHere(KEY key, MASK mask) { // allow scrolled view to handle keystrokes in case it delegated keyboard focus // to the scroll container. // NOTE: this should not recurse indefinitely as handleKeyHere // should not propagate to parent controls, so mScrolledView should *not* // call LLScrollContainer::handleKeyHere in turn if (mScrolledView && mScrolledView->handleKeyHere(key, mask)) { return TRUE; } for( S32 i = 0; i < SCROLLBAR_COUNT; i++ ) { if( mScrollbar[i]->handleKeyHere(key, mask) ) { updateScroll(); return TRUE; } } return FALSE; }
void Container::update(const Control* container, const Vector2& offset) { // Update this container's viewport. Control::update(container, offset); // Get scrollbar images and diminish clipping bounds to make room for scrollbars. if ((_scroll & SCROLL_HORIZONTAL) == SCROLL_HORIZONTAL) { _scrollBarLeftCap = getImage("scrollBarLeftCap", _state); _scrollBarHorizontal = getImage("horizontalScrollBar", _state); _scrollBarRightCap = getImage("scrollBarRightCap", _state); GP_ASSERT(_scrollBarLeftCap && _scrollBarHorizontal && _scrollBarRightCap); _viewportClipBounds.height -= _scrollBarHorizontal->getRegion().height; } if ((_scroll & SCROLL_VERTICAL) == SCROLL_VERTICAL) { _scrollBarTopCap = getImage("scrollBarTopCap", _state); _scrollBarVertical = getImage("verticalScrollBar", _state); _scrollBarBottomCap = getImage("scrollBarBottomCap", _state); GP_ASSERT(_scrollBarTopCap && _scrollBarVertical && _scrollBarBottomCap); _viewportClipBounds.width -= _scrollBarVertical->getRegion().width; } // Sort controls by Z-Order. std::sort(_controls.begin(), _controls.end(), &sortControlsByZOrder); GP_ASSERT(_layout); if (_scroll != SCROLL_NONE) updateScroll(); else _layout->update(this, Vector2::zero()); }
void ListBox::initialiseOverride() { Base::initialiseOverride(); // FIXME нам нужен фокус клавы setNeedKeyFocus(true); // парсим свойства if (isUserString("SkinLine")) mSkinLine = getUserString("SkinLine"); if (isUserString("HeightLine")) mHeightLine = utility::parseInt(getUserString("HeightLine")); if (mHeightLine < 1) mHeightLine = 1; assignWidget(mClient, "Client"); if (mClient != nullptr) { mClient->eventMouseButtonPressed += newDelegate(this, &ListBox::notifyMousePressed); setWidgetClient(mClient); } assignWidget(mWidgetScroll, "VScroll"); if (mWidgetScroll != nullptr) { mWidgetScroll->eventScrollChangePosition += newDelegate(this, &ListBox::notifyScrollChangePosition); mWidgetScroll->eventMouseButtonPressed += newDelegate(this, &ListBox::notifyMousePressed); mWidgetScroll->setScrollPage((size_t)mHeightLine); mWidgetScroll->setScrollViewPage((size_t)mHeightLine); } updateScroll(); updateLine(); }
void ListBox::removeAllItems() { mTopIndex = 0; mIndexSelect = ITEM_NONE; mOffsetTop = 0; mItemsInfo.clear(); int offset = 0; for (size_t pos = 0; pos < mWidgetLines.size(); pos++) { mWidgetLines[pos]->setVisible(false); mWidgetLines[pos]->setPosition(0, offset); offset += mHeightLine; } // обновляем все updateScroll(); updateLine(true); #if MYGUI_DEBUG_MODE == 1 _checkMapping("ListBox::removeAllItems"); #endif }
void LLScrollContainer::goToBottom() { mScrollbar[VERTICAL]->setDocPos(mScrollbar[VERTICAL]->getDocSize()); updateScroll(); }
void LLScrollContainer::goToTop() { mScrollbar[VERTICAL]->setDocPos(0); updateScroll(); }
void LLScrollContainer::pageDown(S32 overlap) { mScrollbar[VERTICAL]->pageDown(overlap); updateScroll(); }