void NodeConnectionControl::setHangingPos(APoint h_pos) { if(fromNode && !toNode) { pTo = h_pos; } else if(toNode && !fromNode) { pFrom = h_pos; } adjustPos(); }
/*! Moves the left/top edge of the splitter handle with id \a id as close as possible to \a p which is the distance from the left (or top) edge of the widget. \sa idAfter() */ void QSplitter::moveSplitter( QCOORD p, int id ) { p = adjustPos( p, id ); QSplitterLayoutStruct *s = data->list.at(id); int oldP = orient == Horizontal? s->wid->x() : s->wid->y(); bool upLeft = p < oldP; moveAfter( p, id, upLeft ); moveBefore( p-1, id-1, upLeft ); storeSizes(); }
NodeConnectionControl::NodeConnectionControl(NodeGraphDisplay *parent_, NodeControl *from_node, NodeControl *to_node, NCID from_id, NCID to_id) : Control(parent_, APoint(), AVec(), true, false), ngd_parent(parent_), //baseIoType(NodeConnector::getNodeConnector(from_id)->ioType),//baseNc(NodeConnector::getNodeConnector(from_id)), fromNode(from_node), toNode(to_node), fromNc(NodeConnector::getNodeConnector(from_id)), toNc(NodeConnector::getNodeConnector(to_id)) { pFrom = (fromNode ? (fromNode->getConnectorPoint(fromNc->ioType)) : APoint(0, 0)); pTo = (toNode ? (toNode->getConnectorPoint(toNc->ioType)) : pFrom); pFrom = (fromNode ? pFrom : pTo); adjustPos(); //Used as multipliers for color setBackgroundColor(ControlState::NONE, Color(0.5f, 0.5f, 0.5f, 1.0f)); setBackgroundColor(ControlState::HOVERING, Color(0.9f, 0.9f, 0.9f, 1.0f)); setBackgroundColor(ControlState::CLICKING, Color(1.0f, 1.0f, 1.0f, 1.0f)); setBackgroundColor(ControlState::DRAGGING, Color(1.0f, 1.0f, 1.0f, 1.0f)); }
void NodeConnectionControl::setOtherNode(NodeControl *other_node, NodeConnector *other_nc) { if(fromNode && !toNode) { toNode = other_node; toNc = other_nc; pTo = other_node->getConnectorPoint(toNc->ioType); } else if(toNode && !fromNode) { fromNode = other_node; fromNc = other_nc; pFrom = other_node->getConnectorPoint(fromNc->ioType); } else std::cout << "ERROR: Node control set other node!\n"; adjustPos(); }
void StatusFrame::addClients() { list<StatusLabel*> lbls; QObjectList* l = m_frame->queryList("StatusLabel"); QObjectListIt itObject(*l); QObject *obj; while ((obj=itObject.current()) != NULL){ ++itObject; lbls.push_back(static_cast<StatusLabel*>(obj)); } delete l; for (list<StatusLabel*>::iterator it = lbls.begin(); it != lbls.end(); ++it) delete *it; for (unsigned i = 0; i < getContacts()->nClients(); i++){ Client *client = getContacts()->getClient(i); QWidget *w = new StatusLabel(m_frame, client, CmdClient + i); m_lay->addWidget(w); w->show(); } adjustPos(); repaint(); }
void StatusFrame::resizeEvent(QResizeEvent *e) { QFrame::resizeEvent(e); adjustPos(); }
void NodeConnectionControl::draw(GlInterface &gl) { if(visible) { if(fromNode) pFrom = fromNode->getConnectorPoint(fromNc->ioType); if(toNode) pTo = toNode->getConnectorPoint(toNc->ioType); adjustPos(); const float length = (pTo - pFrom).length(), angle = atan2(pTo.y - pFrom.y, pTo.x - pFrom.x), cos_a = cos(angle), sin_a = sin(angle); APoint start = pFrom; AVec step = AVec(cos_a, sin_a); AVec perp = AVec(sin_a, -cos_a); step.normalize(); perp.normalize(); //Multiply color channels by background color Color color_mult = bgStateColors[cState], inactive_col(inactiveColor.r*color_mult.r, inactiveColor.g*color_mult.g, inactiveColor.b*color_mult.b, inactiveColor.a*color_mult.a), base_col(baseColor.r*color_mult.r, baseColor.g*color_mult.g, baseColor.b*color_mult.b, baseColor.a*color_mult.a), arrow_col(arrowColor.r*color_mult.r, arrowColor.g*color_mult.g, arrowColor.b*color_mult.b, arrowColor.a*color_mult.a); std::vector<TVertex> points; //points.reserve(2*ceil((length - ARROW_LENGTH)/spacing)*(length > ARROW_LENGTH)); Color col; /* for(float r = 0.0f; r < length - ARROW_LENGTH; r += spacing, even = !even) { APoint p = start + step*r; float omega_t = SIN_OMEGA*PHYSICS_CLOCK.t, phi = SIN_K*r*0.05f, height1 = amplitude*(sin(omega_t + phi) + 0.5f)*(sin(omega_t + phi*0.25f) + 1.0f)*0.5f, //height of sin wave offset = width*0.0*amplitude*cos(omega_t*1.0 + phi*0.5f), tilt = 0.0f*amplitude*cos(omega_t + phi*0.2), even_mult = even ? lerp(1.0f, 0.5f, height) : 1.0f; //TODO: Make it look more like its rotating // Maybe have a separate height for each line endpoint with different phases? height1 *= even_mult; col = lerp(inactive_col, base_col, height1); AVec height_vec1 = perp*lerp(width, (width + radius)*height, amplitude), height_vec2 = perp*lerp(width tilt_vec = step*tilt, offset_vec = perp*offset; points.push_back(TVertex(p - height_vec - tilt_vec + offset_vec, col)); points.push_back(TVertex(p + height_vec + tilt_vec + offset_vec, col)); } */ //Add rotating line vertices for(float r = 0.0f; r < length - ARROW_LENGTH; r += spacing) { APoint p = start + step*r; float omega_t = SIN_OMEGA*Clock::getGlobalTime(), phi = -SIN_K*r, height = amplitude*sin(omega_t + phi), //height of sin wave offset = 0.0f,//amplitude*cos(omega_t*0.5f + phi*0.05f), tilt = 2.0f*amplitude*cos(-omega_t + phi); //TODO: Make it look more like its rotating col = lerp(inactive_col, base_col, -abs(height)*(1.0f + 2.0f*std::max(0.0f, 8.0f*amplitude*(cos(-omega_t*2.0f + phi*0.01f) - 0.9f)))); //col = lerp(col, Color(0.5f, 0.5f, 0.0f, 1.0f), std::max(0.0f, amplitude*sin(omega_t*40.0f + phi*3.0f))); AVec height_vec = perp*(width + radius*height), tilt_vec = step*tilt, offset_vec = perp*offset; points.push_back(TVertex(p - height_vec - tilt_vec + offset_vec, col)); points.push_back(TVertex(p + height_vec + tilt_vec + offset_vec, col)); } //Draw lines gl.drawShape(GL_LINES, points); points.clear(); col = lerp(inactive_col, arrow_col, amplitude); //Add arrow point vertices points.push_back(TVertex(start + step*(length - ARROW_LENGTH) - perp*width*1.5f, col)); points.push_back(TVertex(start + step*(length - ARROW_LENGTH) + perp*width*1.5f, col)); points.push_back(TVertex(start + step*length, col)); //Draw arrow gl.drawShape(GL_TRIANGLES, points); } }
UserBox::UserBox(unsigned long grpId) : QMainWindow(NULL, NULL, (WType_TopLevel | WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | (pMain->UserWndOnTop() ? WStyle_StaysOnTop : 0)) #ifdef USE_KDE | (pMain->UserWindowInTaskManager() ? WStyle_Minimize : 0) #endif ), GrpId(this, "Group"), CurrentUser(this, "CurrentUser"), mLeft(this, "Left"), mTop(this, "Top"), mWidth(this, "Width"), mHeight(this, "Height"), ToolbarDock(this, "ToolbarDock", "Top"), ToolbarOffset(this, "ToolbarOffset"), ToolbarY(this, "ToolbarY") { ToolbarDock = pMain->UserBoxToolbarDock(); ToolbarOffset = pMain->UserBoxToolbarOffset(); ToolbarY = pMain->UserBoxToolbarY(); users = NULL; GrpId = grpId; progress = NULL; infoPage = 0; setWFlags(WDestructiveClose); infoWnd = NULL; historyWnd = NULL; transparent = new TransparentTop(this, pMain->UseTransparentContainer, pMain->TransparentContainer); menuUser = new QPopupMenu(this); menuUser->setCheckable(true); connect(menuUser, SIGNAL(activated(int)), this, SLOT(selectedUser(int))); curWnd = NULL; frm = new QFrame(this); setCentralWidget(frm); lay = new QVBoxLayout(frm); vSplitter = new QSplitter(Horizontal, frm); vSplitter->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); lay->addWidget(vSplitter); frmUser = new QFrame(vSplitter); layUser = new QVBoxLayout(frmUser); tabSplitter = new Splitter(frm); tabSplitter->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); tabs = new UserTabBar(tabSplitter); tabs->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); QSize s; status = new QStatusBar(tabSplitter); { QProgressBar p(status); status->addWidget(&p); s = status->minimumSizeHint(); } status->setMinimumSize(QSize(0, s.height())); tabSplitter->setResizeMode(status, QSplitter::KeepSize); lay->addWidget(tabSplitter); setIcon(Pict(pClient->getStatusIcon())); connect(tabs, SIGNAL(selected(int)), this, SLOT(selectedUser(int))); connect(tabs, SIGNAL(showUserPopup(int, QPoint)), this, SLOT(showUserPopup(int, QPoint))); toolbar = new QToolBar(this); toolbar->setHorizontalStretchable(true); toolbar->setVerticalStretchable(true); menuType = new QPopupMenu(this); connect(menuType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); btnType = new PictButton(toolbar); btnType->setPopup(menuType); btnType->setPopupDelay(0); toolbar->addSeparator(); btnUser = new PictButton(toolbar); btnUser->setPopup(menuUser); btnUser->setPopupDelay(0); toolbar->addSeparator(); btnIgnore = new QToolButton(toolbar); btnIgnore->setIconSet(Icon("ignorelist")); btnIgnore->setTextLabel(i18n("Add to ignore list")); connect(btnIgnore, SIGNAL(clicked()), this, SLOT(toIgnore())); menuGroup = new QPopupMenu(this); connect(menuGroup, SIGNAL(aboutToShow()), this, SLOT(showGrpMenu())); connect(menuGroup, SIGNAL(activated(int)), this, SLOT(moveUser(int))); btnGroup = new CToolButton(toolbar); btnGroup->setIconSet(Icon("grp_on")); btnGroup->setTextLabel(i18n("Move to group")); btnGroup->setPopup(menuGroup); btnGroup->setPopupDelay(0); toolbar->addSeparator(); btnInfo = new QToolButton(toolbar); btnInfo->setIconSet(Icon("info")); btnInfo->setTextLabel(i18n("User info")); btnInfo->setToggleButton(true); connect(btnInfo, SIGNAL(toggled(bool)), this, SLOT(toggleInfo(bool))); btnHistory = new QToolButton(toolbar); btnHistory->setIconSet(Icon("history")); btnHistory->setTextLabel(i18n("History")); btnHistory->setToggleButton(true); connect(btnHistory, SIGNAL(toggled(bool)), this, SLOT(toggleHistory(bool))); menuEncoding = new QPopupMenu(this); menuEncoding->setCheckable(true); int index = 0; for (QStringList::Iterator it = pClient->encodings->begin(); it != pClient->encodings->end(); ++it){ menuEncoding->insertItem(*it, ++index); } connect(menuEncoding, SIGNAL(activated(int)), this, SLOT(setUserEncoding(int))); connect(menuEncoding, SIGNAL(aboutToShow()), this, SLOT(showEncodingPopup())); btnEncoding = new CToolButton(toolbar); btnEncoding->setIconSet(Icon("encoding")); btnEncoding->setTextLabel(i18n("Encoding")); btnEncoding->setPopup(menuEncoding); btnEncoding->setPopupDelay(0); toolbar->addSeparator(); btnQuit = new QToolButton(Icon("exit"), i18n("Close"), "", this, SLOT(quit()), toolbar); connect(pClient, SIGNAL(event(ICQEvent*)), this, SLOT(processEvent(ICQEvent*))); connect(pClient, SIGNAL(messageRead(ICQMessage*)), this, SLOT(messageRead(ICQMessage*))); connect(pMain, SIGNAL(iconChanged()), this, SLOT(iconChanged())); connect(pMain, SIGNAL(wmChanged()), this, SLOT(wmChanged())); connect(this, SIGNAL(toolBarPositionChanged(QToolBar*)), this, SLOT(toolBarChanged(QToolBar*))); connect(pClient, SIGNAL(messageReceived(ICQMessage*)), this, SLOT(messageReceived(ICQMessage*))); setGroupButtons(); wmChanged(); adjustPos(); adjustToolbar(); connect(pMain, SIGNAL(modeChanged(bool)), this, SLOT(modeChanged(bool))); }