void GButton::mouseMoved(int x, int y) { if(is_mouse_inside && state == GBUTTON_NONE) { int* ptr = &texcoords.front(); for(int i = 0; i < num_texcoords; ++i) { gui->getTexCoordPtr(ptr[i])->x += GTCX(31); } state = GBUTTON_HOVER; flagChanged(); return; } if(!is_mouse_inside && state == GBUTTON_HOVER) { int* ptr = &texcoords.front(); for(int i = 0; i < num_texcoords; ++i) { gui->getTexCoordPtr(ptr[i])->x -= GTCX(31); } state = GBUTTON_NONE; flagChanged(); return; } if(!is_mouse_inside && state == GBUTTON_DOWN) { int* ptr = &texcoords.front(); for(int i = 0; i < num_texcoords; ++i) { gui->getTexCoordPtr(ptr[i])->x -= GTCX(62); } state = GBUTTON_NONE; flagChanged(); return; } }
int Font::write(unsigned int dx, const std::string& text, float r, float g, float b, float a) { FontEntry& e = entries[dx]; if(e.num_vertices) { vertices.erase(vertices.begin()+e.start_dx, vertices.begin()+(e.start_dx+e.num_vertices)); } e.col[0] = r, e.col[1] = g, e.col[2] = b, e.col[3] = a; // Create vertices e.w = 0; e.start_dx = vertices.size(); float x = 0; float y = 0; for(int i = 0; i < text.size(); ++i) { char c = text[i]; stbtt_aligned_quad q; stbtt_GetBakedQuad(cdata, w, h, c-32, &x, &y, &q, 1); CharVertex va(q.x0, q.y1, q.s0, q.t1, e.col); CharVertex vb(q.x1, q.y1, q.s1, q.t1, e.col); CharVertex vc(q.x1, q.y0, q.s1, q.t0, e.col); CharVertex vd(q.x0, q.y0, q.s0, q.t0, e.col); CHAR_TRI(va, vb, vc); CHAR_TRI(va, vc, vd); if(q.x1 > e.w) { e.w = q.x1; } } e.needs_update = true; e.num_vertices = vertices.size() - e.start_dx; flagChanged(); return e.num_vertices; }
void GCheckbox::setup() { box_width = 21; box_height = 18; mouse_x = x+gui->metrics.label_width; mouse_y = y; mouse_width = gui->metrics.row_width - (mouse_x); mouse_height = gui->metrics.row_height; // Vertices x += gui->metrics.label_width; y += 3; addVertex(x,y); addVertex(x+box_width,y); addVertex(x+box_width,y+box_height); addVertex(x,y+box_height); x -= gui->metrics.label_width; y -= 3; // Texcoords tex_a = addTexCoord(GTCX(0),GTCY(64)); tex_b = addTexCoord(GTCX(box_width),GTCY(64)); tex_c = addTexCoord(GTCX(box_width),GTCY(64+box_height)); tex_d = addTexCoord(GTCX(0),GTCY(64+box_height)); flagChanged(); }
void Font::alignRight(unsigned int dx, float rightEdge) { FontEntry& e = entries[dx]; e.align = FEA_RIGHT; e.right_edge = rightEdge; e.needs_update = true; flagChanged(); }
void Buttons::setPosition(int xx, int yy) { x = xx; y = yy; positionElements(); updateStaticTextPositions(); static_text->setTextPosition(title_dx, x + 5, y + 2); flagChanged(); }
void GButton::setup() { float string_width = gui->label_font.stringWidth(label); bar_width = 6; button_height = 29; button_width = string_width + 20; x += gui->metrics.label_width; y += 3; mouse_x = x; mouse_y = y; mouse_width = button_width; mouse_height = button_height; // vertices: left bar addVertex(x,y); addVertex(x+bar_width,y); addVertex(x+bar_width,y+button_height); addVertex(x, y+button_height); // vertices: button fill addVertex(x+bar_width,y); addVertex(x+bar_width+button_width-bar_width,y); addVertex(x+bar_width+button_width-bar_width,y+button_height); addVertex(x+bar_width, y+button_height); // vertices: rigth bar float start_x = x+bar_width+button_width-bar_width; addVertex(start_x,y); addVertex(start_x+bar_width,y); addVertex(start_x+bar_width,y+button_height); addVertex(start_x, y+button_height); x -= gui->metrics.label_width; // texcoord: left part of buton. texcoords.push_back(addTexCoord(GTCX(64),GTCY(0))); texcoords.push_back(addTexCoord(GTCX(64+bar_width),GTCY(0))); texcoords.push_back(addTexCoord(GTCX(64+bar_width),GTCY(button_height))); texcoords.push_back(addTexCoord(GTCX(64),GTCY(button_height))); // texcoord: button fill texcoords.push_back(addTexCoord(GTCX(71),GTCY(0))); texcoords.push_back(addTexCoord(GTCX(71),GTCY(0))); texcoords.push_back(addTexCoord(GTCX(71),GTCY(button_height))); texcoords.push_back(addTexCoord(GTCX(71),GTCY(button_height))); // texcoord: right bar texcoords.push_back(addTexCoord(GTCX(73),GTCY(0))); texcoords.push_back(addTexCoord(GTCX(81),GTCY(0))); texcoords.push_back(addTexCoord(GTCX(81),GTCY(button_height))); texcoords.push_back(addTexCoord(GTCX(71),GTCY(button_height))); num_texcoords = texcoords.size(); flagChanged(); y -= 3; }
void GButton::mousePressed(int x, int y) { if(is_mouse_inside && state == GBUTTON_HOVER) { int* ptr = &texcoords.front(); for(int i = 0; i < num_texcoords; ++i) { gui->getTexCoordPtr(ptr[i])->x += GTCX(31); } state = GBUTTON_DOWN; flagChanged(); } }
RevsView::RevsView(MainImpl* mi, Git* g, bool isMain) : Domain(mi, g, isMain) { revTab = new Ui_TabRev(); revTab->setupUi(container); tab()->listViewLog->setup(this, g); tab()->textBrowserDesc->setup(this); tab()->textEditDiff->setup(this, git); tab()->fileList->setup(this, git); m()->treeView->setup(this, git); setTabLogDiffVisible(QGit::testFlag(QGit::LOG_DIFF_TAB_F)); SmartBrowse* sb = new SmartBrowse(this); // restore geometry QVector<QSplitter*> v; v << tab()->horizontalSplitter << tab()->verticalSplitter; QGit::restoreGeometrySetting(QGit::REV_GEOM_KEY, NULL, &v); connect(m(), SIGNAL(typeWriterFontChanged()), tab()->textEditDiff, SLOT(typeWriterFontChanged())); connect(m(), SIGNAL(flagChanged(uint)), sb, SLOT(flagChanged(uint))); connect(git, SIGNAL(newRevsAdded(const FileHistory*, const QVector<ShaString>&)), this, SLOT(on_newRevsAdded(const FileHistory*, const QVector<ShaString>&))); connect(git, SIGNAL(loadCompleted(const FileHistory*, const QString&)), this, SLOT(on_loadCompleted(const FileHistory*, const QString&))); connect(m(), SIGNAL(changeFont(const QFont&)), tab()->listViewLog, SLOT(on_changeFont(const QFont&))); connect(m(), SIGNAL(updateRevDesc()), this, SLOT(on_updateRevDesc())); connect(tab()->listViewLog, SIGNAL(lanesContextMenuRequested(const QStringList&, const QStringList&)), this, SLOT(on_lanesContextMenuRequested (const QStringList&, const QStringList&))); connect(tab()->listViewLog, SIGNAL(revisionsDragged(const QStringList&)), m(), SLOT(revisionsDragged(const QStringList&))); connect(tab()->listViewLog, SIGNAL(revisionsDropped(const QStringList&)), m(), SLOT(revisionsDropped(const QStringList&))); connect(tab()->listViewLog, SIGNAL(contextMenu(const QString&, int)), this, SLOT(on_contextMenu(const QString&, int))); connect(m()->treeView, SIGNAL(contextMenu(const QString&, int)), this, SLOT(on_contextMenu(const QString&, int))); connect(tab()->fileList, SIGNAL(contextMenu(const QString&, int)), this, SLOT(on_contextMenu(const QString&, int))); connect(m(), SIGNAL(changeFont(const QFont&)), tab()->fileList, SLOT(on_changeFont(const QFont&))); connect(m(), SIGNAL(highlightPatch(const QString&, bool)), tab()->textEditDiff, SLOT(on_highlightPatch(const QString&, bool))); }
void Buttons::onMouseLeave(int mx, int my) { BSET_COLOR(header_color_top, 0.07,0.07,0.07,1.0); BSET_COLOR(header_color_bottom, 0.1,0.1,0.1,0.8); flagChanged(); }
void GCheckbox::mouseClick(int x, int y) { *value_ptr = !(*value_ptr); updateTexCoords(); flagChanged(); }