Example #1
0
void WMenuItem::setMenu(WMenu *menu)
{
  subMenu_ = menu;
  subMenu_->parentItem_ = this;

  Wt::WContainerWidget *sparent
    = dynamic_cast<Wt::WContainerWidget *>(subMenu_->parent());
  if (sparent)
    sparent->removeWidget(subMenu_);

  addWidget(subMenu_);
  if (subMenu_->isPopup() &&
      parentMenu() && parentMenu()->isPopup()) {
    subMenu_->webWidget()->setZIndex(std::max(parentMenu()->zIndex() + 100, subMenu_->zIndex()));
  }

  WPopupMenu *popup = dynamic_cast<WPopupMenu *>(subMenu_);
  if (popup) {
    popup->setJavaScriptMember("wtNoReparent", "true");
    setSelectable(false);
    popup->setButton(anchor());
    updateInternalPath();
    // WPopupMenus are hidden by default, 'show' this WPopupMenu
    // but not really, since the parent is still hidden. This fixes
    // an issue where child widgets would remain unexposed, even
    // though this submenu was open (e.g. in a submenu where items
    // are checkable)
    if (dynamic_cast<WPopupMenu*>(menu_))
      popup->show();
  }
}
Example #2
0
File: WMenuItem.C Project: bend/wt
void WMenuItem::setMenu(WMenu *menu)
{
  subMenu_ = menu;
  subMenu_->parentItem_ = this;

  Wt::WContainerWidget *sparent
    = dynamic_cast<Wt::WContainerWidget *>(subMenu_->parent());
  if (sparent)
    sparent->removeWidget(subMenu_);

  addWidget(subMenu_);

  WPopupMenu *popup = dynamic_cast<WPopupMenu *>(subMenu_);
  if (popup) {
    popup->setJavaScriptMember("wtNoReparent", "true");
    setSelectable(false);
    popup->setButton(anchor());
    updateInternalPath();
  }
}
Example #3
0
MyTreeTableNode *MyTreeTableNode::addNode(MyTreeTableNode *parent, Wt::WString name, const long start, const long stop, bool mini ) {
	MyTreeTableNode *node = new MyTreeTableNode(name, 0, parent);
	Wt::WContainerWidget *labelArea = node->labelArea();
	Wt::WWidget *labelWidget = labelArea->widget(0); //See source of WTreeNode.
	labelArea->removeWidget(labelWidget);
	node->startWidget = new TimeWidget(); //We make these, even if we're doing the mini-tree. We use these widgets to store the actual data, so that if we need the start or stop time, we can get them out of the widget and get the right numbers, even if we haven't saved the fragment set yet.
	node->startWidget->setTime(start);
	node->stopWidget = new TimeWidget();
	node->stopWidget->setTime(stop);
	
	if (mini)
	{
		node->startButton = new Wt::WPushButton(name);
	}
	else
	{
		node->editWidget = new Wt::WInPlaceEdit();
		std::string str = name.toUTF8();
		str.erase(std::remove(str.begin(), str.end(), ' '), str.end()); //This removes whitespace
		if(str.length()<1)
		{
			node->editWidget->setText(Wt::WString::Empty);	
			node->editWidget->setPlaceholderText("New Node");	
		
		}
		else
		{
			node->editWidget->setText(name);	
		}
		node->editWidget->valueChanged().connect(std::bind([=]() {
			
			std::string str = node->editWidget->text().toUTF8();
			str.erase(std::remove(str.begin(), str.end(), ' '), str.end()); //This removes whitespace
			if(str.length()<1)
			{
				node->editWidget->setText(Wt::WString::Empty);	
			}
			node->text = node->editWidget->text();
		}));
	
		node->text = node->editWidget->text();
	
		node->startButton = new Wt::WPushButton("|>");
	}
//todo: add doubleclick trick to allow modal edit
	node->startButton->clicked().connect(std::bind([=]() { 
		if(start == -1)
		{	//We've clicked the startbutton on a group, so we need to find the first non-group widget. 
			if (node->childNodes().size() > 0)
			{
 				//So, there are children.. In this case take the first child and pretend we've clicked that startButton. It'll be recursive. 
				MyTreeTableNode *firstChild = dynamic_cast<MyTreeTableNode*> (*(node->childNodes()).begin());
				return firstChild->startButton->clicked().emit(Wt::WMouseEvent());
			}
			else
			{ //Where in a childless group, so we cannot play anything!
				return;
			}

		}
		Wt::Json::Object jStartBefore = zmq_conn::interact("inputs?"); 
		Wt::Json::Array aStartBefore = jStartBefore.get("before");
		signed long long startBefore = aStartBefore[2];
		zmq_conn::interact(Wt::WString("event:stop")); //Probably needed to help stop the track from stopping the middle of a play

		Wt::WString command="play:"+std::to_string(start - startBefore * 1000); 
		zmq_conn::interact(command);
	}));
	labelArea->addWidget(node->startButton);
	if(mini)
	{
	}
	else
	{ //0 is startbutton now
		//node->setColumnWidget(1, node->startButton);
		node->setColumnWidget(1,node->editWidget );
		node->setColumnWidget(2, node->startWidget); 
		node->setColumnWidget(3, node->stopWidget);
	}
	return node;
    }