示例#1
0
void OpenGLCanvas::drawScrollBars()
{
	float scrollBarY = float(getHeight())/float(getTotalHeight());
	float timeSinceScroll = timer->getMillisecondCounter()-scrollTime;
	
	if (scrollBarY < 1.0f && timeSinceScroll < 1300)
	{
		float alpha;

		if (timeSinceScroll < 1000)
			alpha = 1.0f;
		else
			alpha = 1.0f*(1-float(timeSinceScroll-1000)/300.0f);

		float Yoffset = float(scrollPix)/float(getTotalHeight());

		if (showScrollTrack)
			drawScrollBar(0.995f, 2.0f/getHeight(), alpha*0.2f);

		scrollBarBottom = scrollBarY + Yoffset - 2.0f/getHeight();
		scrollBarTop = Yoffset + 2.0f/getHeight();
		
		drawScrollBar(scrollBarBottom, scrollBarTop, alpha*0.5f);

	} else {
		if (!animationIsActive) {
			stopTimer(); 
		}
		showScrollTrack = false;
	}
}
示例#2
0
文件: scrollbar.cpp 项目: suma/hex
void ScrollBar::paintEvent(QPaintEvent *)
{
	QPainter painter(this);
	painter.fillRect(rect(), QBrush(QColor(200,200,255), Qt::BDiagPattern));

	if (!drawScrollBar()) {
		return;
	}

	// bar width(height)
	const int bar_size = base_size_ / 2;

	const int draw_bar_size = drawBarSize();
	const int pos = sliderPositionFromValue(value_, draw_bar_size);

	if (orientation_ == Qt::Horizontal) {
		// absolute bar(down side)

		// relative bar(upper side)
	
	}

	if (orientation_ == Qt::Vertical) {
		//qDebug() << "paint pos:" << pos << " size:" << draw_bar_size;
		// absolute bar(right side)
		painter.fillRect(bar_size, pos, bar_size, draw_bar_size, QBrush(QColor(255, 255, 0, 160)));
		
		// relative bar(left side)
	}
}
示例#3
0
文件: menu.c 项目: AnonEx/3ds_hb_menu
void drawMenu(menu_s* m)
{
	if(!m)return;

	if(!m->numEntries)
	{
		drawError(GFX_BOTTOM,
			"Error",
			"    It seems you don't have any homebrew applications installed on your\n"
			"SD card.\n"
			"    Please take out your SD card, create a folder named \"3ds\" at the root of\n"
			"your card and place homebrew there.\n"
			"    Then, simply insert your SD card back into your 3DS !\n"
			"    The homebrew launcher will take it from there.",
			0);
	}else{
		menuEntry_s* me=m->entries;
		int i=0;
		int h=0;
		while(me)
		{
			h+=drawMenuEntry(me, GFX_BOTTOM, getEntryLocationPx(m,h), 9, i==m->selectedEntry);
			me=me->next;
			i++;
		}
	}

	drawScrollBar(m);
}
示例#4
0
文件: menu.c 项目: AnonEx/3ds_hb_menu
void clearMenuEntries(menu_s* m)
{
	if(!m)return;

	m->selectedEntry=0;
	drawScrollBar(m);

	menuEntry_s* me = m->entries;
	menuEntry_s* temp = NULL;
	while(me)
	{
		temp=me->next;
		me->next = NULL;
		freeMenuEntry(me);
		free(me);
		me = temp;
	}

	m->numEntries = 0;
	m->entries = NULL;

	if(regionFreeAvailable)
	{
		// should always be available
		addMenuEntryCopy(m, &regionfreeEntry);
	}
}
示例#5
0
void GsScrollbar::processRender(const GsRect<float> &RectDispCoordFloat)
{
    // Transform to the display coordinates
    GsRect<float> displayRect = mRect;
    displayRect.transform(RectDispCoordFloat);

    SDL_Rect lRect = displayRect.SDLRect();

    drawScrollBar(lRect);
}
示例#6
0
void ListView::draw() {
  if (activeSubView_) {
    activeSubView_->draw();
    return;
  }

  View::draw();
  drawScrollBar();
  uint8_t position = 0;
  Item* current = visibleHead_;
  while (current != NULL) {
    drawItem(current, position);
    current = current->next;
    ++position;
  }
}
示例#7
0
文件: scrollbar.cpp 项目: suma/hex
bool ScrollBar::isScrollBarArea(const QPoint &mouse_pos) const
{
	if (!drawScrollBar()) {
		return false;
	}

	const int bar_size = base_size_ / 2;
	const int draw_bar_size = drawBarSize();
	const int pos = sliderPositionFromValue(value_, draw_bar_size);

	if (orientation_ == Qt::Horizontal) {
		//return QRect(bar_size, pos, bar_size, draw_bar_size).contains.contains(pos);
	}

	if (orientation_ == Qt::Vertical) {
		return QRect(bar_size, pos, bar_size, draw_bar_size).contains(mouse_pos);
	}

	return false;
}
示例#8
0
文件: mt_lib.c 项目: ghl800/mt_on_sdl
int drawScrollBar_4lua(lua_State *L)
{
	drawScrollBar();
	return 0;
}
示例#9
0
//Used to implement listbox functionality
void Listbox::Draw(GL2DProgram * shaders) {
	//Check selected
	if (selected >= (int)entries.size())
		selected = -1;


	//Calculate if a scroll bar is needed
	bool scrollBarNeeded = (entryHeight*entries.size() > position.Height-6);


	//Set inherited properties
	color = borderColor;
	selectionShape.color = selectedColor;
	selectionShape.position.Width = position.Width-6;
	selectionShape.position.Height = entryHeight;
	selectionShape.position.X = 3;
	backgroundShape.color = backgroundColor;
	backgroundShape.position.Width = position.Width-6;
	backgroundShape.position.Height = position.Height-6;
	backgroundShape.position.X = 3;
	backgroundShape.position.Y = 3;
	hoverShape.color = vec4(selectedColor.x,selectedColor.y,selectedColor.z,.5);
	hoverShape.position.Width = position.Width-6;
	hoverShape.position.Height = entryHeight;
	hoverShape.position.X = 3;

	if (scrollBarNeeded) {
		//Make room for the scroll bar
		selectionShape.position.Width -= scrollButtonWidth;
		hoverShape.position.Width -= scrollButtonWidth;		
	}

	//Draw the border using the background of this control
	drawBackground(shaders);

	//draw the background and selections using children
	if ((selected < 0) || (selected >= (int)entries.size()))
		selectionShape.SetVisible(false);
	else {
		selectionShape.position.Y = scrollPosition+3+entryHeight*selected;
		selectionShape.SetVisible(true);
	}
	if (lastMousePos.x >= 3) {
		//Mouse is over control
		int hoveringOver = (int)((lastMousePos.y-scrollPosition-3)/entryHeight);

		//Check that the cursor is not in the scroll bar
		if (scrollBarNeeded) {
			if (lastMousePos.x >= calculatedPosition.Width-3-scrollButtonWidth)
				hoveringOver = -1;
		}

		if ((hoveringOver < 0) || (hoveringOver >= (int)entries.size()))
			hoverShape.SetVisible(false);
		else {
			hoverShape.position.Y = scrollPosition+3+entryHeight*hoveringOver;
			hoverShape.SetVisible(true);
		}
	}
	else
		hoverShape.SetVisible(false);



	//Add an additional clipping region to protect the border
	shaders->Clipping.PushClippingRect(shaders->Model,backgroundShape.position);
	//Draw the children of this control
	drawChildren(shaders);

	//If the scroll bar is needed protect it as well
	if (scrollBarNeeded) {
		//We use a new clipping region because we wanted to draw the background
		//but we don't want to draw the text in this region
		shaders->Clipping.PopClippingRect();
		shaders->Clipping.PushClippingRect(shaders->Model,Rect(backgroundShape.position.X,backgroundShape.position.Y,
			backgroundShape.position.Width-scrollButtonWidth,backgroundShape.position.Height));
	}


	//Draw all the entries
	//Center text
	shaders->Model.PushMatrix();
	//Center text vertically, but leave it left justified
	shaders->Model.Translate(10,3+scrollPosition,0);
	for (auto entry : entryText) {
		entry.Draw(shaders);
		shaders->Model.Translate(0,entryHeight,0);
	}
	shaders->Model.PopMatrix();
	//Remove the additional clipping region
	shaders->Clipping.PopClippingRect();

	//Draw the scroll bar if needed
	if (scrollBarNeeded) {
		//First draw top and bottom scroll buttons
		if (drawScrollButton(shaders,true)) {
			double now = OS::Now();
			scrollPosition += 100*(float)(now-lastScrollUpdate);
			lastScrollUpdate = now;
		}
		if (drawScrollButton(shaders,false)) {
			double now = OS::Now();
			scrollPosition -= 100*(float)(now-lastScrollUpdate);
			lastScrollUpdate = now;
		}
		//Next draw/process bar
		drawScrollBar(shaders);

		//Force scroll position within valid ranges
		SafeScrollPosition();
	}
}
示例#10
0
    /*--------------------------------------------------------------------------------
        Function    : InventoryScreen::refresh
        Description : draws the InventoryScreen to the game window
        Inputs      : None
        Outputs     : updated InventoryScreen
        Return      : void
    --------------------------------------------------------------------------------*/
    void InventoryScreen::refresh()
    {
        Point dim(screen.getWidth(), screen.getHeight());

        // set the colorscheme of the selected line
        TCODConsole::setColorControl(TCOD_COLCTRL_1, TCODColor::white, TCODColor::blue);

        // create a vector of the different item symbols
        vector< pair<int, TCODColor> > tabChars;
        tabChars.push_back(pair<int, TCODColor>('\\', UI_FORE_COLOR));
        tabChars.push_back(pair<int, TCODColor>('[', UI_FORE_COLOR));
        tabChars.push_back(pair<int, TCODColor>('!', UI_FORE_COLOR));
        tabChars.push_back(pair<int, TCODColor>('*', UI_FORE_COLOR));

        // draw interface
        int x=0, y=2;
        //screen.printEx(dim.X()/2, 0, TCOD_BKGND_SET, TCOD_CENTER, 
        //               (client->personalStats.name() + string("'s Inventory")).c_str());
        screen.printEx(dim.X()/2, 0, TCOD_BKGND_SET, TCOD_CENTER, "Inventory");

        // 'start' is the point at which the folder contents are drawn
        Point start = drawFolders(x, y, dim, tabChars);

        // draw the information line
        x = start.X();
        y = start.Y();
        screen.print(x+1, y++, "Qt.  Item");
        screen.hline(x, y++, dim.X()-3);

        // update start position to where items will be drawn
        start.setY(y);
        
        linesPerPage = dim.Y()-y;
        currentPage = (selectedLine==0) ? 0 : selectedLine / (linesPerPage-1);

        int numItems = client->inventory.getIndexSize(selectedTab);

        if(numItems <= 0) return;

        drawScrollBar(Point(dim.X()-2, y), linesPerPage, currentPage, 
                      (numItems/linesPerPage)+1);

        // determine at what line should be highlighted
        int hlOffset = selectedLine % ((currentPage==0) ? linesPerPage : linesPerPage-1); 

        // set an iterator to the lowest spot that will show the selected line
        vector<ItemPtr>::const_iterator it;
        it = client->inventory.getIndexBegin(selectedTab) + (currentPage*linesPerPage) - currentPage;

        for(; it!=client->inventory.getIndexEnd(selectedTab); ++it, ++y)
        {
            // ignore lines that are off the display area
            if(y >= start.Y()+linesPerPage-1) break;

            // construct the display string
            // three spaces are allocated to the item count number.  The buffer string
            // ensures that this number is right aligned in this space.
            string buffer = "";
            unsigned int c = (*it)->getCount();
            while(c<100) { buffer += " "; c *= 10;}
            string disp = buffer + boost::lexical_cast<string>((*it)->getCount()) + "  " + (*it)->getName();

            // if this is the selected line on the current page, highlight it
            if(y == (hlOffset) + start.Y()) 
            {
                disp = "%c" + disp + "%c";
                screen.printEx(start.X(), y, TCOD_BKGND_SET, TCOD_LEFT, 
                               disp.c_str(), TCOD_COLCTRL_1, TCOD_COLCTRL_STOP);
            }
            else // display the line normally
            {
                screen.printEx(start.X(), y, TCOD_BKGND_SET, TCOD_LEFT, disp.c_str()); 
            }
        }
    }
示例#11
0
void WidgetFiles::render(FilesRenderMode mode) {
	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
	ImageFile &images = *ui._interfaceImages;
	byte color;

	if (mode == RENDER_ALL) {
		_surface.clear(TRANSPARENCY);
		makeInfoArea();

		switch (_fileMode) {
		case SAVEMODE_LOAD:
			_surface.writeString(FIXED(LoadGame),
				Common::Point((_surface.width() - _surface.stringWidth(FIXED(LoadGame))) / 2, 5), INFO_TOP);
			break;

		case SAVEMODE_SAVE:
			_surface.writeString(FIXED(SaveGame),
				Common::Point((_surface.width() - _surface.stringWidth(FIXED(SaveGame))) / 2, 5), INFO_TOP);
			break;

		default:
			break;
		}

		_surface.hLine(3, _surface.fontHeight() + 7, _surface.width() - 4, INFO_TOP);
		_surface.hLine(3, _surface.fontHeight() + 8, _surface.width() - 4, INFO_MIDDLE);
		_surface.hLine(3, _surface.fontHeight() + 9, _surface.width() - 4, INFO_BOTTOM);
		_surface.SHtransBlitFrom(images[4], Common::Point(0, _surface.fontHeight() + 6));
		_surface.SHtransBlitFrom(images[5], Common::Point(_surface.width() - images[5]._width, _surface.fontHeight() + 6));

		int xp = _surface.width() - BUTTON_SIZE - 6;
		_surface.vLine(xp, _surface.fontHeight() + 10, _bounds.height() - 4, INFO_TOP);
		_surface.vLine(xp + 1, _surface.fontHeight() + 10, _bounds.height() - 4, INFO_MIDDLE);
		_surface.vLine(xp + 2, _surface.fontHeight() + 10, _bounds.height() - 4, INFO_BOTTOM);
		_surface.SHtransBlitFrom(images[6], Common::Point(xp - 1, _surface.fontHeight() + 8));
		_surface.SHtransBlitFrom(images[7], Common::Point(xp - 1, _bounds.height() - 4));
	}

	int xp = _surface.stringWidth("00.") + _surface.widestChar() + 5;
	int yp = _surface.fontHeight() + 14;

	for (int idx = _savegameIndex; idx < (_savegameIndex + FILES_LINES_COUNT); ++idx) {
		if (idx == _selector && mode != RENDER_ALL)
			color = COMMAND_HIGHLIGHTED;
		else
			color = INFO_TOP;

		if (mode == RENDER_NAMES_AND_SCROLLBAR)
			_surface.fillRect(Common::Rect(4, yp, _surface.width() - BUTTON_SIZE - 9, yp + _surface.fontHeight()), TRANSPARENCY);

		Common::String numStr = Common::String::format("%d.", idx + 1);
		_surface.writeString(numStr, Common::Point(_surface.widestChar(), yp), color);
		_surface.writeString(_savegames[idx], Common::Point(xp, yp), color);

		yp += _surface.fontHeight() + 1;
	}

	// Draw the Scrollbar if neccessary
	if (mode != RENDER_NAMES)
		drawScrollBar(_savegameIndex, FILES_LINES_COUNT, _savegames.size());
}