Пример #1
0
void TabOrderEditor::paintEvent(QPaintEvent *e)
{
    QPainter p(this);
    p.setClipRegion(e->region());

    int cur = m_current_index - 1;
    if (m_beginning == false && cur < 0)
        cur = m_tab_order_list.size() - 1;

    for (int i = 0; i < m_tab_order_list.size(); ++i) {
        QWidget *widget = m_tab_order_list.at(i);
        if (!isWidgetVisible(widget))
            continue;

        const QRect r = indicatorRect(i);

        QColor c = Qt::darkGreen;
        if (i == cur)
            c = Qt::red;
        else if (i > cur)
            c = Qt::blue;
        p.setPen(c);
        c.setAlpha(BG_ALPHA);
        p.setBrush(c);
        p.drawRect(fixRect(r));

        p.setPen(Qt::white);
        p.drawText(r, QString::number(i + 1), QTextOption(Qt::AlignCenter));
    }
}
Пример #2
0
IMGUIBox& IMGUI::endBox(){
	IMGUIBox &group = m_boxStack[m_boxIndex];
	float b = group.m_border;

	Box rect = group.m_box;
	// if(!(group.m_flags & FixedSize)){
		if(group.m_flags & LayoutVertical)
			rect.w = std::max((abs(group.m_box.y - group.m_currStart.y)+b), std::abs(group.m_box.w))*sign(rect.w);

		else if(group.m_flags & LayoutHorizontal)
			rect.z = std::max((abs(group.m_box.x - group.m_currStart.x)+b), std::abs(group.m_box.z))*sign(rect.z);
	// }

	rect = fixRect(rect);

	if(group.m_flags & Draw){
		m_UIContainer->change(UI::BigBox, group.m_rectIdx, m_styles[m_style].background, rect);
		// m_specRects[currentLayer][group.m_rectIdx] = rect;
		// m_specRectsColor[currentLayer][group.m_rectIdx] = m_styles[m_style].background;

	}

	m_boxStack[m_boxIndex].m_box = rect;
	m_boxIndex--;
	if(!(m_boxStack[m_boxIndex+1].m_flags & AbsolutePosition))
		m_boxStack[m_boxIndex].insertRect(rect+Box(-1,-1,0.5f,1));
	return group;
}
Пример #3
0
bool IMGUI::outOfTable(){
	auto &&rect = fixRect(m_boxStack[m_boxIndex+1].m_box);
	// if(currentLayer == maxLayer)
		return this->ks.lClick && !(ks.mousePosition.x >= rect.x && ks.mousePosition.x < rect.x+rect.z &&
					ks.mousePosition.y >= rect.y && ks.mousePosition.y < rect.y+rect.w);


}
Пример #4
0
IMGUIBox& IMGUI::table(Box spawnPosition, int flags){
	m_group.m_box = spawnPosition;
	m_group.m_border = 0;
	m_group.m_flags = flags;
	m_group.m_currStart = m_group.m_box;
	//m_group.m_currStart.x = 0;
	//m_group.m_currStart.y = 0;
	m_group.m_freeRect = fixRect(spawnPosition); // czy to jest do czegoœ u¿ywane?, nie
	// m_boxStack[0] = m_group;
	spawnPosition.z = 0;
	spawnPosition.w = 0;
	return m_boxStack[++m_boxIndex].box(flags, spawnPosition, this);
}
Пример #5
0
IMGUIBox& IMGUI::endTable(){
	endBox();
	m_fontSize = m_defaultFontSize;
	m_font = m_defaultFont;
	m_indentation = 0;
	IMGUIBox &group = m_boxStack[m_boxIndex+1];
	float b = group.m_border;

	Box rect = group.m_box;
	if((group.m_flags & FixedSize) != FixedSize){
		if(group.m_flags & LayoutVertical)
			rect.w = (abs(group.m_box.y - group.m_currStart.y)+b)*sign(rect.w);

		else if(group.m_flags & LayoutHorizontal)
			rect.z = (abs(group.m_box.x - group.m_currStart.x)+b)*sign(rect.z);
	}

	rect = fixRect(rect);
	if((group.m_flags & AbsolutePosition) != AbsolutePosition)
		m_collRects.push_back(rect);
	return group;
}
Пример #6
0
static void paintEndPoint(QPainter *p, const QPoint &pos)
{
    const QRect r(pos + QPoint(-LINE_PROXIMITY_RADIUS, -LINE_PROXIMITY_RADIUS),
                  QSize(2*LINE_PROXIMITY_RADIUS, 2*LINE_PROXIMITY_RADIUS));
    p->fillRect(fixRect(r), p->pen().color());
}
Пример #7
0
void snap( sf::Font& font )
{
	sf::RenderWindow window( sf::VideoMode( getScreenSize().x, getScreenSize().y ), "QuickSnap - Snap", sf::Style::None );
	window.setFramerateLimit( 30 );
	setTransparent( window, 128 );
	moveToPos( window, getScreenPos() );
	
	sf::CircleShape circ;
	circ.setRadius( 4 );
	circ.setFillColor( sf::Color::Black );
	circ.setOrigin( 4, 4 );
	
	sf::RectangleShape rect;
	rect.setOutlineColor( sf::Color::Black );
	rect.setOutlineThickness( 3 );
	rect.setFillColor( sf::Color( 255, 255, 255, 64 ) );
	
	bool didFirstClick = false;
	bool didFirstRelease = false;
	
	bool isRunning = true;
	while ( isRunning )
	{
		moveToTop( window );
		focus( window );
		
		sf::Event event;
		while ( window.pollEvent( event ) )
		{
			if ( event.type == sf::Event::KeyPressed )
			{
				if ( event.key.code == sf::Keyboard::Return )
				{
					window.close();
					takeSnapshot( rect );
					isRunning = false;
				}
				else if ( event.key.code == sf::Keyboard::Escape )
				{
					isRunning = false;
				}
			}
			else if ( event.type == sf::Event::MouseButtonPressed )
			{
				if ( event.mouseButton.button == sf::Mouse::Left )
				{
					didFirstClick = true;
					didFirstRelease = false;
					rect.setPosition( event.mouseButton.x, event.mouseButton.y );
				}
			}
			else if ( event.type == sf::Event::MouseButtonReleased )
			{
				if ( event.mouseButton.button == sf::Mouse::Left )
				{
					didFirstRelease = true;
					fixRect( window, rect );
				}
			}
		}
		
		fixCircle( window, circ );
		if ( !didFirstRelease )
		{
			fixRect( window, rect );
		}
		
		window.clear( sf::Color( 255, 255, 255, 64 ) );
		if ( didFirstClick )
		{
			window.draw( rect );
		}
		window.draw( circ );
		window.display();
	}
}