Esempio n. 1
0
bool GUITabbedPanel::loadXMLSettings(XMLElement *element)
{
  if(!element || element->getName() != "TabbedPanel")
  {
     LOG_PRINT("Need a TabbedPanel node in the xml file");
	 return false;
  }

  XMLElement *child                = 0,
             *subChild             = 0;
  D3DXFROMWINEVECTOR3     bordersColor         = upperPanel->getBordersColor();
  D3DXFROMWINEVECTOR4     bgColor              = upperPanel->getBGColor();
  int         count                = 0;

  if(child = element->getChildByName("hScale"))
    fontScales.y = child->getValuef();

  if(child = element->getChildByName("wScale"))
    fontScales.x = child->getValuef();

  if(child = element->getChildByName("TabButtonsBordersColor"))
    XMLElement::loadRX_GY_BZf(*child, tabButtonsBordersColor);

  if(child = element->getChildByName("TabButtonsColor"))
    XMLElement::loadRX_GY_BZf(*child, tabButtonsColor);

  if(child = element->getChildByName("BordersColor"))
    XMLElement::loadRX_GY_BZf(*child, bordersColor);

  if(child = element->getChildByName("BGColor"))
    XMLElement::loadRX_GY_BZ_AWf(*child, bgColor);

  if(child = element->getChildByName("fontIndex"))
    fontIndex =  clampNS(child->getValuei(), 0, 50);

  setFontScales(fontScales);

  for(size_t i = 0; i < element->getChildrenCount(); i++)
  {
    if(!(child = element->getChild(i)))
      continue;

    const NSString &childName = child->getName();

    if(childName == "Panel")
    {
      GUIPanel *panel = new GUIPanel();
      if(!panel->loadXMLSettings(child) || !addPanel(panel))
        deleteObject(panel);
      continue;
    }
  }

  mainPanel->setBordersColor(bordersColor);
  mainPanel->setBGColor(bgColor);

  return GUIRectangle::loadXMLSettings(element) && lowerPanel->getWidgets().size();
}
	WindowFrameWidget::WindowFrameWidget(const HSceneObject& parent, bool allowResize, const SPtr<Camera>& camera, RenderWindow* parentWindow, const HGUISkin& skin)
		:CGUIWidget(parent, camera), mAllowResize(allowResize), mWindowFramePanel(nullptr), mParentWindow(parentWindow)
	{
		setSkin(skin);

		GUIPanel* backgroundPanel = getPanel()->addNewElement<GUIPanel>(500);
		backgroundPanel->addElement(GUITexture::create(TextureScaleMode::RepeatToFit,
			GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()), "WindowBackground"));

		mWindowFramePanel = getPanel()->addNewElement<GUIPanel>(499);

		mWindowFrame = GUIWindowFrame::create("WindowFrame");
		mWindowFramePanel->addElement(mWindowFrame);

		refreshNonClientAreas();
	}
Esempio n. 3
0
	DropDownWindow::DropDownWindow(const SPtr<RenderWindow>& parent, const SPtr<Camera>& camera,
		const Vector2I& position, UINT32 width, UINT32 height)
		: mRenderWindow(parent), mFrontHitBox(nullptr), mBackHitBox(nullptr), mRootPanel(nullptr), mPosition(position)
		, mWidth(width), mHeight(height)
	{
		mSceneObject = SceneObject::create("EditorWindow", SOF_Internal | SOF_Persistent | SOF_DontSave);

		mGUI = mSceneObject->addComponent<CGUIWidget>(camera);

		mGUI->setDepth(0); // Needs to be in front of everything
		mGUI->setSkin(BuiltinEditorResources::instance().getSkin());

		mRootPanel = mGUI->getPanel()->addNewElement<GUIPanel>();
		
		GUIPanel* frontHitBoxPanel = mRootPanel->addNewElement<GUIPanel>(std::numeric_limits<INT16>::min());
		mFrontHitBox = GUIDropDownHitBox::create(false, false);
		mFrontHitBox->onFocusLost.connect(std::bind(&DropDownWindow::dropDownFocusLost, this));
		mFrontHitBox->setFocus(true);
		frontHitBoxPanel->addElement(mFrontHitBox);

		GUIPanel* backHitBoxPanel = mRootPanel->addNewElement<GUIPanel>(std::numeric_limits<INT16>::max());
		mBackHitBox = GUIDropDownHitBox::create(false, true);
		backHitBoxPanel->addElement(mBackHitBox);
		
		SPtr<Viewport> viewport = camera->getViewport();
		GUIPanel* captureHitBoxPanel = mGUI->getPanel()->addNewElement<GUIPanel>(std::numeric_limits<INT16>::max());
		GUIDropDownHitBox* captureHitBox = GUIDropDownHitBox::create(true, false);
		captureHitBox->setBounds(Rect2I(0, 0, viewport->getWidth(), viewport->getHeight()));
		captureHitBoxPanel->addElement(captureHitBox);

		setSize(width, height);

		GUIPanel* backgroundPanel = mRootPanel->addNewElement<GUIPanel>(500);
		backgroundPanel->addElement(GUITexture::create(TextureScaleMode::RepeatToFit,
			GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()), "WindowBackground"));

		GUIPanel* windowFramePanel = mRootPanel->addNewElement<GUIPanel>(499);

		GUIWindowFrame* windowFrame = GUIWindowFrame::create("WindowFrame");
		windowFramePanel->addElement(windowFrame);

		mContents = mRootPanel->addNewElement<GUIPanel>();
		mContents->setPosition(1, 1);
		mContents->setWidth(width - 2);
		mContents->setHeight(height - 2);
	}
Esempio n. 4
0
	void GUIWidget::_updateLayout(GUIElementBase* elem)
	{
		GUIElementBase* parent = elem->_getParent();
		bool isPanelOptimized = parent != nullptr && parent->_getType() == GUIElementBase::Type::Panel;

		GUIElementBase* updateParent = nullptr;

		if (isPanelOptimized)
			updateParent = parent;
		else
			updateParent = elem;

		// For GUIPanel we can do a an optimization and update only the element in question instead
		// of all the children
		if (isPanelOptimized)
		{
			GUIPanel* panel = static_cast<GUIPanel*>(updateParent);

			GUIElementBase* dirtyElement = elem;
			dirtyElement->_updateOptimalLayoutSizes();

			LayoutSizeRange elementSizeRange = panel->_getElementSizeRange(dirtyElement);
			Rect2I elementArea = panel->_getElementArea(panel->_getLayoutData().area, dirtyElement, elementSizeRange);

			GUILayoutData childLayoutData = panel->_getLayoutData();
			panel->_updateDepthRange(childLayoutData);
			childLayoutData.area = elementArea;

			panel->_updateChildLayout(dirtyElement, childLayoutData);
		}
		else
		{
			GUILayoutData childLayoutData = updateParent->_getLayoutData();
			updateParent->_updateLayout(childLayoutData);
		}
		
		// Mark dirty contents
		bs_frame_mark();
		{
			FrameStack<GUIElementBase*> todo;
			todo.push(elem);

			while (!todo.empty())
			{
				GUIElementBase* currentElem = todo.top();
				todo.pop();

				if (currentElem->_getType() == GUIElementBase::Type::Element)
					mDirtyContents.insert(static_cast<GUIElement*>(currentElem));

				currentElem->_markAsClean();

				UINT32 numChildren = currentElem->_getNumChildren();
				for (UINT32 i = 0; i < numChildren; i++)
					todo.push(currentElem->_getChild(i));
			}
		}
		bs_frame_clear();
	}
void TestAppGUI::drawHUD(){

	panel .tryRender();  panel.draw();
	mpanel.tryRender(); mpanel.draw();
	if(focused) Draw2D::drawRectangle(focused->xmin,focused->ymin,focused->xmax,focused->ymax,false);

	//glColor3f(1.0f,1.0f,1.0f);
	//panel.render();
	//Draw2D::drawRectangle ( 100, 100, 300, 200, false    );
	//Draw2D::drawLine      ( {0.0f,0.0f},{100.0f, 200.0f} );
}
Esempio n. 6
0
bool GUIPanel::loadXMLSettings(const TiXmlElement *element)
{
  if(!XMLArbiter::inspectElementInfo(element, "Panel"))
    return Logger::writeErrorLog("Need a Panel node in the xml file");

  const char  *description = element->Attribute("description");
  std::string  type        = element->Attribute("layout") ? element->Attribute("layout") : "UNKNOWN";

  if(description)
    return  loadXMLSettings(description);

  layout = (type == "CEN_YAXIS") ? PL_YAXIS_CEN_LAYOUT :
           (type == "YAXIS"    ) ? PL_YAXIS_LAYOUT     :
           (type == "XAXIS"    ) ? PL_XAXIS_LAYOUT     :
           (type == "GRID"     ) ? PL_GRID_LAYOUT      : PL_FREE_LAYOUT;

  for(const TiXmlElement *child = element->FirstChildElement();
      child;
   	  child = child->NextSiblingElement() )
  {
    std::string childName  = child->Value();
 
    if(!childName.size())
      continue;

    if(childName == "CheckBox")
    {
      GUICheckBox *newCheckBox = new GUICheckBox();
      if(!newCheckBox->loadXMLSettings(child) || !addWidget(newCheckBox))
        deleteObject(newCheckBox);
      continue;
    }

    if(childName == "TabbedPanel")
    {
      GUITabbedPanel *newTabbedPanel = new GUITabbedPanel();
      if(!newTabbedPanel->loadXMLSettings(child) || !addWidget(newTabbedPanel))
        deleteObject(newTabbedPanel);
      continue;
    }

    if(childName == "RadioButton")
    {
      GUIRadioButton *newRadioButton = new GUIRadioButton();
      if(!newRadioButton->loadXMLSettings(child) || !addWidget(newRadioButton))
      {
        deleteObject(newRadioButton);
      }
      else
      {
        if(newRadioButton->isChecked())
          notify(newRadioButton);
      }
      continue;
    }

    if(childName == "ComboBox")
    {
      GUIComboBox *newComboBox = new GUIComboBox();
      if(!newComboBox->loadXMLSettings(child) || !addWidget(newComboBox))
        deleteObject(newComboBox);
      continue;
    }

    if(childName == "TextBox")
    {
      GUITextBox *newTextBox = new GUITextBox();
      if(!newTextBox->loadXMLSettings(child) || !addWidget(newTextBox))
        deleteObject(newTextBox);
      continue;
    }

    if(childName == "Slider")
    {
      GUISlider *newSlider = new GUISlider();
      if(!newSlider->loadXMLSettings(child) || !addWidget(newSlider))
        deleteObject(newSlider);
      continue;
    }

    if(childName == "Separator")
    {
      GUISeparator *newSeparator = new GUISeparator();
      if((layout != PL_YAXIS_LAYOUT &&
          layout != PL_XAXIS_LAYOUT &&
          layout != PL_YAXIS_CEN_LAYOUT) ||
         (!newSeparator->loadXMLSettings(child)))
      {
        deleteObject(newSeparator);
      }
      else
      {
        newSeparator->setParent(this);
        newSeparator->setOrientation((layout != PL_YAXIS_LAYOUT && layout != PL_YAXIS_CEN_LAYOUT));
        elements.push_back(newSeparator);
      }
      continue;
    }

    if(childName == "Button")
    {
      GUIButton *newButton = new GUIButton();
      if(!newButton->loadXMLSettings(child) || !addWidget(newButton))
        deleteObject(newButton);
      continue;
    }

    if(childName == "Label")
    {
      GUILabel *newLabel = new GUILabel();
      if(!newLabel->loadXMLSettings(child) || !addWidget(newLabel))
        deleteObject(newLabel);
      continue;
    }


    if(childName == "Interval")
      setInterval(XMLArbiter::fillComponents2i(child, interval));

    if(childName == "Panel")
    {
      GUIPanel *panel = new GUIPanel();
      if(!panel->loadXMLSettings(child) || !addWidget(panel))
        deleteObject(panel);
      continue;
    }
  }

  return  GUIRectangle::loadXMLSettings(element)  &&
          GUIClippedRectangle::loadXMLClippedRectangleInfo(element);
}