예제 #1
0
bool HelloScene::init()
{
	size = Director::sharedDirector()->getVisibleSize();
	CCLog("%f %f", size.height, size.width);
	_helloLayer = Layer::create();
	this->addChild(_helloLayer);


	auto bkg = Sprite::create("bkg.png");
	_helloLayer->addChild(bkg);
	bkg->setPosition(ccp(0, 0));
	bkg->setAnchorPoint(ccp(0, 0));


	auto playItem = MenuItemFont::create("Start", [&](Ref* sender)
	{
		//start game	
		CCLog("start");
		auto gamescene = GameScene::createScene();
		CCDirector::sharedDirector()->replaceScene(gamescene);
	});
	playItem->setPosition(ccp(size.width / 2, size.height*0.9));
	playItem->setFontSize(40);
	playItem->setFontName("Marker Felt");
	playItem->setColor(ccc3(255, 255, 255));
	auto aboutItem = MenuItemFont::create("About", [&](Ref* sender)
	{
		CCLog("About");
	}
	);
	aboutItem->setPosition(ccp(size.width / 2, size.height*0.6));
	aboutItem->setFontSize(40);
	aboutItem->setFontName("Marker Felt");
	aboutItem->setColor(ccc3(255, 255, 255));
	auto exitItem = MenuItemFont::create("End", [&](Ref* sender)
	{
		//exit game	
		CCLog("exit");
		Director::sharedDirector()->end();
	});
	exitItem->setPosition(ccp(size.width / 2, size.height*0.3));
	exitItem->setFontSize(40);
	exitItem->setFontName("Marker Felt");
	exitItem->setColor(ccc3(255, 255, 255));
	auto menu = Menu::create(playItem, aboutItem, exitItem, nullptr);
	menu->setPosition(ccp(0, 0));
	_helloLayer->addChild(menu);

	return true;
}
예제 #2
0
파일: UIText.cpp 프로젝트: bonlai/3kaigame
void Text::copySpecialProperties(Widget *widget)
{
    Text* label = dynamic_cast<Text*>(widget);
    if (label)
    {
        setFontName(label->_fontName);
        setFontSize(label->getFontSize());
        setTextColor(label->getTextColor());
        setString(label->getString());
        setTouchScaleChangeEnabled(label->_touchScaleChangeEnabled);
        setTextHorizontalAlignment(label->_labelRenderer->getHorizontalAlignment());
        setTextVerticalAlignment(label->_labelRenderer->getVerticalAlignment());
        setTextAreaSize(label->_labelRenderer->getDimensions());
        setContentSize(label->getContentSize());

        LabelEffect effectType = label->getLabelEffectType();
        if (effectType == LabelEffect::GLOW)
        {
            enableGlow(label->getEffectColor());
        }
        else if (effectType == LabelEffect::OUTLINE)
        {
            enableOutline(label->getEffectColor(),label->getOutlineSize());
        }
        if (label->isShadowEnabled())
        {
            enableShadow(label->getShadowColor(),label->getShadowOffset(),label->getShadowBlurRadius());
        }
    }
}
예제 #3
0
bool KstViewLabel::readConfigWidget(QWidget *w) {
  ViewLabelWidget *widget = dynamic_cast<ViewLabelWidget*>(w);
  if (!widget) {
    return false;
  }

  _txt = widget->_text->text();
  // No, this is broken.  It kills latex.
#if 0
  // Replace tabs and newlines in text edit box with \n and \t 
  _txt.replace(QString("\n"), "\\n");
  _txt.replace(QString("\t"), "\\t");
#endif

  setDataPrecision(widget->_precision->value());
  setRotation(widget->_rotation->value());
  setFontSize(widget->_fontSize->value());
  setHorizJustifyWrap(widget->_horizontal->currentItem());
  setForegroundColor(widget->_fontColor->color());
  setFontName(widget->_font->currentFont().toString());

  setTransparent(widget->_transparent->isChecked());
  setBorderWidth(widget->_border->value());
  setBorderColor(widget->_boxColors->color());
  setBackgroundColor(widget->_boxColors->color());
  setLabelMargin(widget->_margin->value());
 
  reparse(); // calls setDirty()
  return true;
}
예제 #4
0
void InputLabel::setIsPassword()
{
    delegate->setInputFlag(ui::EditBox::InputFlag::PASSWORD);
    //Re-apply fontSize and fontName because some devices will happily reset it (Nexus 7 on Android 5.1 for example).
    setFontSize(fontSize);
    setFontName(fontName);
}
예제 #5
0
Menu* WelcomeMenu::_createMenu()
{
    auto startGameItem = MenuItemFont::create("开始游戏", CC_CALLBACK_1(WelcomeMenu::_startGameMenuCallback, this));
    startGameItem->setFontSizeObj(50);
    startGameItem->setFontName("fonts/su_xin_shi_liu_jian_kai.ttf");
    auto menu = Menu::create(startGameItem, NULL);
    menu->alignItemsVertically();
    return menu;
}
bool KstViewLabel::readConfigWidget(QWidget *w, bool editMultipleMode) {
  ViewLabelWidget *widget = dynamic_cast<ViewLabelWidget*>(w);
  if (!widget) {
    return false;
  }

  if (!editMultipleMode || widget->_text->text().compare(QString(" ")) != 0) {
    _txt = widget->_text->text();
  }

  if (!editMultipleMode || widget->_precision->value() != widget->_precision->minValue()) {
    setDataPrecision(widget->_precision->value());
  }

  if (!editMultipleMode || widget->_rotation->value() != widget->_rotation->minValue()) {
    setRotation(widget->_rotation->value());
  }

  if (!editMultipleMode || widget->_fontSize->value() != widget->_fontSize->minValue()) {
    setFontSize(widget->_fontSize->value());
  }

  if (!editMultipleMode || widget->_horizontal->currentText().compare(QString(" ")) != 0) {
    setHorizJustifyWrap(widget->_horizontal->currentItem());
  }

  if (!editMultipleMode || widget->_fontColor->color() != QColor()) {
    setForegroundColor(widget->_fontColor->color());
  }

  if (!editMultipleMode || widget->_font->currentText().compare(QString(" ")) != 0) {
    setFontName(widget->_font->currentFont());
  }

  if (!editMultipleMode || widget->_transparent->state() != QButton::NoChange) {
    setTransparent(widget->_transparent->isChecked());
  }

  if (!editMultipleMode || widget->_border->value() != widget->_border->minValue()) {
    setBorderWidth(widget->_border->value());
  }

  if (!editMultipleMode || widget->_changedFgColor) {
    setBorderColor(widget->_boxColors->foreground());
  }

  if (!editMultipleMode || widget->_changedBgColor) {
    setBackgroundColor(widget->_boxColors->background());
  }

  if (!editMultipleMode || widget->_margin->value() != widget->_margin->minValue()) {
    setLabelMargin(widget->_margin->value());
  }

  reparse(); // calls setDirty()
  return true;
}
예제 #7
0
/*!
 * Set the format properties from the given \a font.
 */
void Format::setFont(const QFont &font)
{
    setFontName(font.family());
    setFontSize(font.pointSize());
    setFontBold(font.bold());
    setFontItalic(font.italic());
    setFontUnderline(font.underline() ? FontUnderlineSingle : FontUnderlineNone);
    setFontStrikeOut(font.strikeOut());
}
예제 #8
0
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
{
    _placeHolder = std::string(placeholder);
    setFontName(fontName);
    setFontSize(fontSize);
    Label::setTextColor(_colorSpaceHolder);
    Label::setString(_placeHolder);

    return true;
}
예제 #9
0
파일: UILabel.cpp 프로젝트: CryQ/coclua
void UILabel::copySpecialProperties(UIWidget *widget)
{
    UILabel* label = dynamic_cast<UILabel*>(widget);
    if (label)
    {
        setFontName(label->_fontName.c_str());
        setFontSize(label->_labelRenderer->getFontSize());
        setText(label->getStringValue());
        setTouchScaleChangeEnabled(label->_touchScaleChangeEnabled);
    }
}
예제 #10
0
void CALabel::applyStyle(const CALabelStyle* pLabelStyle)
{
	CC_RETURN_IF(!pLabelStyle);

	setFontName(pLabelStyle->getFontName());
	setFontSize(pLabelStyle->getFontSize());
	setColor(pLabelStyle->getFontColor());
	setLineSpacing(pLabelStyle->getLineSpace());
	setBold(pLabelStyle->isBold());
	setItalics(pLabelStyle->isItalics());
	setWordWrap(pLabelStyle->isWordWrap());
}
예제 #11
0
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
{
    _placeHolder = placeholder;
    setDimensions(dimensions.width,dimensions.height);
    setFontName(fontName);
    setFontSize(fontSize);
    setAlignment(alignment,TextVAlignment::CENTER);
    Label::setTextColor(_colorSpaceHolder);
    Label::setString(_placeHolder);

    return true;
}
예제 #12
0
TTFFontInit::TTFFontInit()
{
    auto s = Director::getInstance()->getWinSize();

    auto font = LabelTTF::create();

    font->setFontName("Marker Felt");
    font->setFontSize(48);
    font->setString("It is working!");
    this->addChild(font);
    font->setPosition(Point(s.width/2,s.height/4*2));
}
예제 #13
0
void LLStyle::init(BOOL is_visible, const LLColor4 &color, const std::string& font_name)
{
	mVisible = is_visible;
	mColor = color;
	setFontName(font_name);
	setLinkHREF(LLStringUtil::null);
	mItalic = FALSE;
	mBold = FALSE;
	mUnderline = FALSE;
	mDropShadow = FALSE;
	mImageHeight = 0;
	mImageWidth = 0;
	mIsEmbeddedItem = FALSE;
}
예제 #14
0
void Text::copySpecialProperties(Widget *widget)
{
    Text* label = dynamic_cast<Text*>(widget);
    if (label)
    {
        setFontName(label->_fontName);
        setFontSize(label->_labelRenderer->getFontSize());
        setText(label->getStringValue());
        setTouchScaleChangeEnabled(label->_touchScaleChangeEnabled);
        setTextHorizontalAlignment(label->_labelRenderer->getHorizontalAlignment());
        setTextVerticalAlignment(label->_labelRenderer->getVerticalAlignment());
        setTextAreaSize(label->_labelRenderer->getDimensions());
    }
}
MovableTextOverlayAttributes::MovableTextOverlayAttributes(const Ogre::String & name, const Ogre::Camera *cam,
						 const Ogre::String & fontName, int charHeight, const Ogre::ColourValue & color, const Ogre::String & materialName)
: mpCam(cam)
, mpFont(NULL)
, mName(name)
, mFontName("")
, mMaterialName("")
, mCharHeight(charHeight)
, mColor(ColourValue::ZERO)
{
	if (fontName.length() == 0)
        Ogre::Exception(Ogre::Exception::ERR_INVALIDPARAMS, "Invalid font name", "MovableTextOverlayAttributes::MovableTextOverlayAttributes");

	setFontName(fontName);
	setMaterialName(materialName);
	setColor(color);
}
예제 #16
0
void PanelWindow::readSettings()
{
    setFontName(Settings::value(m_id, "fontName", "default").toString());
    setScreen(Settings::value(m_id, "screen", 0).toInt());

    PanelWindow::Anchor m_verticalAnchor;
    QString verticalPosition = Settings::value(m_id, "verticalPosition", "Bottom").toString();
    if(verticalPosition == "Top")
        m_verticalAnchor = PanelWindow::Min;
    else if(verticalPosition == "Bottom")
        m_verticalAnchor = PanelWindow::Max;

    setVerticalAnchor(m_verticalAnchor);

    m_appletnames = Settings::value(m_id, "applets", QStringList() ).toStringList();

    setApplets();
}
예제 #17
0
void TextField::copySpecialProperties(Widget *widget)
{
    TextField* textField = dynamic_cast<TextField*>(widget);
    if (textField)
    {
        setText(textField->_textFieldRenderer->getString());
        setPlaceHolder(textField->getStringValue());
        setFontSize(textField->_textFieldRenderer->getFontSize());
        setFontName(textField->_textFieldRenderer->getFontName().c_str());
        setMaxLengthEnabled(textField->isMaxLengthEnabled());
        setMaxLength(textField->getMaxLength());
        setPasswordEnabled(textField->isPasswordEnabled());
        setPasswordStyleText(textField->_passwordStyleText.c_str());
        setAttachWithIME(textField->getAttachWithIME());
        setDetachWithIME(textField->getDetachWithIME());
        setInsertText(textField->getInsertText());
        setDeleteBackward(textField->getDeleteBackward());
    }
}
예제 #18
0
void TextField::copySpecialProperties(Widget *widget)
{
    TextField* textField = dynamic_cast<TextField*>(widget);
    if (textField)
    {
        setString(textField->_textFieldRenderer->getString());
        setPlaceHolder(textField->getString());
        setFontSize(textField->_fontSize);
        setFontName(textField->_fontName);
        setMaxLengthEnabled(textField->isMaxLengthEnabled());
        setMaxLength(textField->getMaxLength());
        setPasswordEnabled(textField->isPasswordEnabled());
        setPasswordStyleText(textField->_passwordStyleText.c_str());
        setAttachWithIME(textField->getAttachWithIME());
        setDetachWithIME(textField->getDetachWithIME());
        setInsertText(textField->getInsertText());
        setDeleteBackward(textField->getDeleteBackward());
        _eventCallback = textField->_eventCallback;
        _textFieldEventListener = textField->_textFieldEventListener;
        _textFieldEventSelector = textField->_textFieldEventSelector;
    }
}
예제 #19
0
 void TextBox::setPropertyOverride(const std::string& _key, const std::string& _value)
 {
     if (_key == "TextColour")
         setTextColour(utility::parseValue<Colour>(_value));
     else if (_key == "TextAlign")
         setTextAlign(utility::parseValue<Align>(_value));
     else if (_key == "FontName")
         setFontName(_value);
     else if (_key == "FontHeight")
         setFontHeight(utility::parseValue<int>(_value));
     else if (_key == "Caption")
         setCaptionWithReplacing(_value);
     else if (_key == "TextShadowColour")
         setTextShadowColour(utility::parseValue<Colour>(_value));
     else if (_key == "TextShadow")
         setTextShadow(utility::parseValue<bool>(_value));
     else
     {
         Base::setPropertyOverride(_key, _value);
         return;
     }
     eventChangeProperty(this, _key, _value);
 }
MovableTextOverlayAttributes::~MovableTextOverlayAttributes()
{
	setFontName("");
	setMaterialName("");
}
예제 #21
0
	Widget::Widget(const IntCoord& _coord, Align _align, const WidgetSkinInfoPtr _info, CroppedRectanglePtr _parent, const Ogre::String & _name) :
		CroppedRectangleInterface(IntCoord(_coord.point(), _info->getSize()), _align, _parent), // размер по скину
		mOwner(static_cast<Widget*>(_parent)),
		UserData(),
		mStateInfo(_info->getStateInfo()),
		mMaskPeekInfo(_info->getMask()),
		mText(null),
		mEnabled(true),
		mVisible(true),
		mAlpha(ALPHA_MIN),
		mColour(Ogre::ColourValue::White),
		mName(_name),
		mCountSharedOverlay(0)
	{
		// имя отсылателя сообщений
		mWidgetEventSender = this;

		// подсчитаываем колличество оверлеев для объединения
		for (VectorSubWidgetInfo::const_iterator iter =_info->getBasisInfo().begin(); iter!=_info->getBasisInfo().end(); iter ++) {
			if (SubWidgetManager::getInstance().isSharedOverlay(*iter)) mCountSharedOverlay++;
		}

		// загружаем кирпичики виджета
		size_t id = 0;
		for (VectorSubWidgetInfo::const_iterator iter =_info->getBasisInfo().begin(); iter!=_info->getBasisInfo().end(); iter ++) {
			addSubSkin(*iter, _info->getMaterial(), id);
		}

		// парсим свойства
		const MapString & param = _info->getParams();
		if (false == param.empty()) {
			MapString::const_iterator iter = param.find("FontName");
			if (iter != param.end()) setFontName(iter->second);
			iter = param.find("FontHeight");
			if (iter != param.end()) setFontHeight(utility::parseInt(iter->second));
			iter = param.find("NeedKey");
			if (iter != param.end()) setNeedKeyFocus(iter->second == "true");
			iter = param.find("AlignText");
			if (iter != param.end()) setTextAlign(SkinManager::getInstance().parseAlign(iter->second));
			iter = param.find("Colour");
			if (iter != param.end()) setColour(utility::parseColour(iter->second));
			iter = param.find("Pointer");
			if (iter != param.end()) mPointer = iter->second;
			iter = param.find("Show");
			if (iter != param.end()) {
				if (utility::parseBool(iter->second)) show();
				else hide();
			}
		}

		// этот стиль есть всегда, даже если создатель не хотел его
		setState("normal");
		setAlpha(ALPHA_MAX);
		// альфа отца
		//if ( (mParent != null) && (static_cast<WidgetPtr>(mParent)->getAlpha() != ALPHA_MAX) ) setAlpha(static_cast<WidgetPtr>(mParent)->getAlpha());

		// создаем детей
		const VectorChildSkinInfo& child = _info->getChild();
		for (VectorChildSkinInfo::const_iterator iter=child.begin(); iter!=child.end(); ++iter) {
			WidgetPtr widget = createWidgetT(iter->type, iter->skin, iter->coord, iter->align);
			widget->_setInternalString(iter->name);
			// заполняем UserString пропертями
			for (MapString::const_iterator prop=iter->params.begin(); prop!=iter->params.end(); ++prop) {
				widget->setUserString(prop->first, prop->second);
			}
		}

		// а вот теперь нормальный размер
		setSize(_coord.size());
	}
예제 #22
0
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    auto closeItem = MenuItemImage::create(
                                           "CloseNormal.png",
                                           "CloseSelected.png",
                                           CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
    
	closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
                                origin.y + closeItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    auto menu = Menu::create(closeItem, NULL);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    
    auto label = LabelTTF::create("Hello World", "Arial", 24);
    
    // position the label on the center of the screen
    label->setPosition(Vec2(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - label->getContentSize().height));

    // add the label as a child to this layer
    this->addChild(label, 1);

    // add "HelloWorld" splash screen"
    auto sprite = Sprite::create("HelloWorld.png");

    // position the sprite on the center of the screen
    sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    // add the sprite as a child to this layer
    this->addChild(sprite, 0);

    Calc *calc = new Calc();
    calc->addValue(1000);
    std::stringstream ss;
    ss << calc->getValue();
    
    auto calcLabel = LabelTTF::create();
    calcLabel->setString(ss.str());
    calcLabel->setFontSize(24);
    calcLabel->setFontName("Arial");
    calcLabel->setPosition(100, 100);
    this->addChild(calcLabel);

    return true;
}
예제 #23
0
void MMSLabelWidget::setFontName(string fontname, bool load, bool refresh) {
    setFontName(MMSLANG_NONE, fontname, load, refresh);
}
예제 #24
0
void
CQFontChooser::
editFont()
{
  setFontName(cedit_->text());
}
예제 #25
0
RightPanel::RightPanel(QWidget *widget):QWidget(widget) {
	// TODO Auto-generated constructor stub
	inputusertextDialog = NULL;
	uid = QString("");
	uid_index = -1;
	selectFlag = false;
	mapcanvasMPP = 0;			// meter per 1 pixcel
	objectpanelMPP = 0;			// meter per 1 pixcel

	// Object Panel define
	selectButton = new QToolButton;
	selectButton->setIcon(QIcon(":/images/object_select.png"));
	selectButton->setToolTip(QString("Selection"));
	selectButton->adjustSize();
	connect(selectButton, SIGNAL(clicked()), this, SLOT(setDownSelect()));

	lineButton = new QToolButton;
	lineButton->setIcon(QIcon(":/images/object_line.png"));
	lineButton->setToolTip(QString("Line"));
	lineButton->adjustSize();
	connect(lineButton, SIGNAL(clicked()), this, SLOT(setDownLine()));

	circleButton = new QToolButton;
	circleButton->setIcon(QIcon(":/images/object_circle.png"));
	circleButton->setToolTip(QString("Circle"));
	circleButton->adjustSize();
	connect(circleButton, SIGNAL(clicked()), this, SLOT(setDownCircle()));

	eclipseButton = new QToolButton;
	eclipseButton->setIcon(QIcon(":/images/object_ellipse.png"));
	eclipseButton->setToolTip(QString("Eclipse"));
	eclipseButton->adjustSize();
	connect(eclipseButton, SIGNAL(clicked()), this, SLOT(setDownEllipse()));

	rectangleButton = new QToolButton;
	rectangleButton->setIcon(QIcon(":/images/object_rectangle.png"));
	rectangleButton->setToolTip(QString("Rectangle"));
	rectangleButton->adjustSize();
	connect(rectangleButton, SIGNAL(clicked()), this, SLOT(setDownRectangle()));

	polygonButton = new QToolButton;
	polygonButton->setIcon(QIcon(":/images/object_polygon.png"));
	polygonButton->setToolTip(QString("Polygon"));
	polygonButton->adjustSize();
	connect(polygonButton, SIGNAL(clicked()), this, SLOT(setDownPolygon()));

	polylineButton = new QToolButton;
	polylineButton->setIcon(QIcon(":/images/object_polyline.png"));
	polylineButton->setToolTip(QString("Polyline"));
	polylineButton->adjustSize();
	connect(polylineButton, SIGNAL(clicked()), this, SLOT(setDownPolyline()));

	textButton = new QToolButton;
	textButton->setIcon(QIcon(":/images/object_text.png"));
	textButton->setToolTip(QString("Text"));
	textButton->adjustSize();
	connect(textButton, SIGNAL(clicked()), this, SLOT(setDownText()));

	arcButton = new QToolButton;
	arcButton->setIcon(QIcon(":/images/object_arc.png"));
	arcButton->setToolTip(QString("Arc"));
	arcButton->adjustSize();
	connect(arcButton, SIGNAL(clicked()), this, SLOT(setDownArc()));

	symbolButton = new QToolButton;
	symbolButton->setIcon(QIcon(":/images/object_symbol.png"));
	symbolButton->setToolTip(QString("Symbol"));
	symbolButton->adjustSize();
	connect(symbolButton, SIGNAL(clicked()), this, SLOT(setDownSymbol()));

	QGroupBox* groupboxDrawObject = new QGroupBox("Draw Object");
	QVBoxLayout* vb1 = new QVBoxLayout;
	QGridLayout* grid = new QGridLayout;
	grid->addWidget(selectButton,       0, 0);
	grid->addWidget(lineButton,         0, 1);
	grid->addWidget(circleButton,       0, 2);
	grid->addWidget(eclipseButton,      0, 3);
	grid->addWidget(arcButton,          0, 4);

	grid->addWidget(rectangleButton,    1, 0);
	grid->addWidget(polygonButton,      1, 1);
	grid->addWidget(polylineButton,     1, 2);
	grid->addWidget(textButton,         1, 3);
	grid->addWidget(symbolButton,       1, 4);

	manualButton = new QPushButton(tr("&Manual Coord. Input"));
	connect(manualButton, SIGNAL(clicked()), this, SLOT(setDownManual()));
	QHBoxLayout* hb1 = new QHBoxLayout;
	hb1->addStretch();
	hb1->addWidget(manualButton);
	hb1->addStretch();
	vb1->addLayout(grid);
	vb1->addLayout(hb1);

	groupboxDrawObject->setLayout(vb1);

	// Line Properties
	QLabel* labelLineType = new QLabel(tr("Type"));
	QLabel* labelLineWidth = new QLabel(tr("Width"));
	QLabel* labelLineColor = new QLabel(tr("Color"));

	comboLineType = new LineTypeCombo;
	connect(comboLineType, SIGNAL(currentIndexChanged(int)), this, SLOT(setLineType(int)));

	spinLineWidth = new QSpinBox;
	spinLineWidth->setValue(1);
	spinLineWidth->setRange(1, 5);
	connect(spinLineWidth, SIGNAL(valueChanged(int)), this, SLOT(setLineWidth(int)));

	rgbLineColor = new ColorRgbPicker;
	connect(rgbLineColor, SIGNAL(changed()), this, SLOT(setLineColor()));

	QGridLayout* gridLine = new QGridLayout;

	gridLine->addWidget(labelLineType, 0, 0);
	gridLine->addWidget(comboLineType, 0, 1);

	gridLine->addWidget(labelLineWidth, 1, 0);
	gridLine->addWidget(spinLineWidth, 1, 1);

	gridLine->addWidget(labelLineColor, 2, 0);
	gridLine->addWidget(rgbLineColor, 2, 1);

	QGroupBox* groupboxLineProperties = new QGroupBox("Line Properties");
	groupboxLineProperties->setLayout(gridLine);

	// Fill Properties
	QLabel* labelLineFillColor = new QLabel(tr("Fill Color"));
	QLabel* labelLinePattern = new QLabel(tr("Pattern"));

	rgbLineFillColor = new ColorRgbPicker;
	connect(rgbLineFillColor, SIGNAL(changed()), this, SLOT(setLineFillColor()));

	comboLinePattern = new FillPatternCombo;
	connect(comboLinePattern, SIGNAL(currentIndexChanged(int)), this, SLOT(setFillPattern(int)));

	QGridLayout* gridFill = new QGridLayout;
	gridFill->addWidget(labelLineFillColor, 0, 0);
	gridFill->addWidget(rgbLineFillColor, 0, 1);

	gridFill->addWidget(labelLinePattern, 1, 0);
	gridFill->addWidget(comboLinePattern, 1, 1);

	QGroupBox* groupboxFillProperties = new QGroupBox("Fill Properties");
	groupboxFillProperties->setLayout(gridFill);

	// Text Properties
	QLabel* labelTextFont = new QLabel(tr("Font"));
	QLabel* labelTextSize = new QLabel(tr("Size"));
	QLabel* labelTextColor = new QLabel(tr("Color"));

	comboTextFont = new QFontComboBox;
	comboTextFont->setFontFilters(QFontComboBox::ScalableFonts);
	comboTextFont->setCurrentFont(QFont("Courier"));
	connect(comboTextFont, SIGNAL(currentFontChanged(QFont)), this, SLOT(setFontName(QFont)));

	spinTextSize = new QSpinBox;
	spinTextSize->setValue(10);
	spinTextSize->setRange(8, 30);
	connect(spinTextSize, SIGNAL(valueChanged(int)), this, SLOT(setTextSize(int)));

	rgbTextColor = new ColorRgbPicker;
	connect(rgbTextColor, SIGNAL(changed()), this, SLOT(setTextColor()));

	QGridLayout* gridText = new QGridLayout;

	gridText->addWidget(labelTextFont,   0, 0);
	gridText->addWidget(comboTextFont,   0, 1);
	gridText->addWidget(labelTextSize,   1, 0);
	gridText->addWidget(spinTextSize,    1, 1);
	gridText->addWidget(labelTextColor,  2, 0);
	gridText->addWidget(rgbTextColor,    2, 1);

	QGroupBox* groupboxTextProperties = new QGroupBox("Text Properties");
	groupboxTextProperties->setLayout(gridText);

	// Usermap id List
	QGroupBox* groupboxUserMapId = new QGroupBox("User Map Id");
	listUserMapId = new CheckListBox;
	listUserMapId->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
	connect(listUserMapId, SIGNAL(currentRowChanged(QString)), this, SLOT(uidChanged(QString)));

	// Usermap delete changename button
	buttonUserMapIdDelete = new QPushButton(tr("&Delete"));
	connect(buttonUserMapIdDelete, SIGNAL(clicked()), this, SLOT(deleteUid()));

	buttonUserIdChange = new QPushButton(tr("&Change Id name"));
	connect(buttonUserIdChange, SIGNAL(clicked()), this, SLOT(changeUidName()));

	QVBoxLayout* umiVLayout = new QVBoxLayout;
	QHBoxLayout* umiHLayout = new QHBoxLayout;
	umiHLayout->addStretch();
	umiHLayout->addWidget(buttonUserMapIdDelete);
	umiHLayout->addWidget(buttonUserIdChange);
	umiHLayout->addStretch();

	umiVLayout->addWidget(listUserMapId);
	umiVLayout->addLayout(umiHLayout);
	groupboxUserMapId->setLayout(umiVLayout);

	// Zoom
	groupboxZoom = new QGroupBox("Zoom");
	groupboxZoom->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);

	spinBoxZoom = new QSpinBox();
	spinBoxZoom->setRange(10, 2000);		// MPP

	hSliderZoom = new QSlider();
	hSliderZoom->setOrientation(Qt::Horizontal);
	hSliderZoom->setRange(10, 2000);
	hSliderZoom->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);

	connect(spinBoxZoom, SIGNAL(valueChanged(int)), hSliderZoom, SLOT(setValue(int)));
	connect(hSliderZoom, SIGNAL(valueChanged(int)), spinBoxZoom, SLOT(setValue(int)));
	connect(spinBoxZoom, SIGNAL(valueChanged(int)), this,        SLOT(changeZoom()));
	connect(hSliderZoom, SIGNAL(valueChanged(int)), this,        SLOT(changeZoom()));

	zoomHLayout = new QHBoxLayout;
	zoomHLayout->addWidget(hSliderZoom);
	zoomHLayout->addWidget(spinBoxZoom);
	groupboxZoom->setLayout(zoomHLayout);

	// Main Setting
	QVBoxLayout* mainLayout = new QVBoxLayout;
	mainLayout->addWidget(groupboxDrawObject);
	mainLayout->addWidget(groupboxLineProperties);
	mainLayout->addWidget(groupboxFillProperties);
	mainLayout->addWidget(groupboxTextProperties);
	mainLayout->addWidget(groupboxUserMapId);
	mainLayout->addWidget(groupboxZoom);
	mainLayout->addStretch();

	setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
	setLayout(mainLayout);

	property = new LayerProperty;
	nowDrawType = Select;

	setDown(Select);
}
예제 #26
0
//------------------------------------------------------------------
//
// MenuLayerMainMenu
//
//------------------------------------------------------------------
MenuLayerMainMenu::MenuLayerMainMenu()
{
    _touchListener = EventListenerTouchOneByOne::create();
    _touchListener->setSwallowTouches(true);
    _touchListener->onTouchBegan = CC_CALLBACK_2(MenuLayerMainMenu::onTouchBegan, this);
    _touchListener->onTouchMoved = CC_CALLBACK_2(MenuLayerMainMenu::onTouchMoved, this);
    _touchListener->onTouchEnded = CC_CALLBACK_2(MenuLayerMainMenu::onTouchEnded, this);
    _touchListener->onTouchCancelled = CC_CALLBACK_2(MenuLayerMainMenu::onTouchCancelled, this);
    
    _eventDispatcher->addEventListenerWithFixedPriority(_touchListener, 1);

    // Font Item    
    auto spriteNormal = Sprite::create(s_MenuItem, Rect(0,23*2,115,23));
    auto spriteSelected = Sprite::create(s_MenuItem, Rect(0,23*1,115,23));
    auto spriteDisabled = Sprite::create(s_MenuItem, Rect(0,23*0,115,23));

    auto item1 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback, this) );
    
    // Image Item
    auto item2 = MenuItemImage::create(s_SendScore, s_PressSendScore, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback2, this) );

    // Label Item (LabelAtlas)
    auto labelAtlas = LabelAtlas::create("0123456789", "fonts/labelatlas.png", 16, 24, '.');
    auto item3 = MenuItemLabel::create(labelAtlas, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackDisabled, this) );
    item3->setDisabledColor( Color3B(32,32,64) );
    item3->setColor( Color3B(200,200,255) );
    
    // Font Item
    auto item4 = MenuItemFont::create("I toggle enable items", [&](Ref *sender) {
		_disabledItem->setEnabled(! _disabledItem->isEnabled() );
	});

    item4->setFontSizeObj(20);
    item4->setFontName("fonts/Marker Felt.ttf");
    
    // Label Item (LabelBMFont)
    auto label = Label::createWithBMFont("fonts/bitmapFontTest3.fnt", "configuration");
    auto item5 = MenuItemLabel::create(label, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackConfig, this));

    // Testing issue #500
    item5->setScale( 0.8f );

    // Events
    MenuItemFont::setFontName("fonts/Marker Felt.ttf");
    // Bugs Item
    auto item6 = MenuItemFont::create("Bugs", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackBugsTest, this));

    // Font Item
    auto item7= MenuItemFont::create("Quit", CC_CALLBACK_1(MenuLayerMainMenu::onQuit, this));
    
    auto item8 = MenuItemFont::create("Remove menu item when moving", CC_CALLBACK_1(MenuLayerMainMenu::menuMovingCallback, this));
    
    auto color_action = TintBy::create(0.5f, 0, -255, -255);
    auto color_back = color_action->reverse();
    auto seq = Sequence::create(color_action, color_back, nullptr);
    item7->runAction(RepeatForever::create(seq));

    auto menu = Menu::create( item1, item2, item3, item4, item5, item6, item7, item8,  nullptr);
    menu->alignItemsVertically();
    
    
    // elastic effect
    auto s = Director::getInstance()->getWinSize();
    
    int i=0;
    for(const auto &child : menu->getChildren()) {
        auto dstPoint = child->getPosition();
        int offset = (int) (s.width/2 + 50);
        if( i % 2 == 0)
            offset = -offset;
        
        child->setPosition( Vec2( dstPoint.x + offset, dstPoint.y) );
        child->runAction(
                         EaseElasticOut::create(MoveBy::create(2, Vec2(dstPoint.x - offset,0)), 0.35f)
                         );
        i++;
    }

    _disabledItem = item3; item3->retain();
    _disabledItem->setEnabled( false );

    addChild(menu);
    menu->setPosition(Vec2(s.width/2, s.height/2));
    menu->setScale(0);
    menu->runAction(ScaleTo::create(1,1));
}
예제 #27
0
	Widget::Widget(const IntCoord& _coord, Align _align, const WidgetSkinInfoPtr _info, CroppedRectanglePtr _parent, WidgetCreator * _creator, const Ogre::String & _name) :
		CroppedRectangleInterface(IntCoord(_coord.point(), _info->getSize()), _align, _parent), // размер по скину
		mOwner(static_cast<Widget*>(_parent)),
		UserData(),
		LayerItem(),
		mStateInfo(_info->getStateInfo()),
		mMaskPeekInfo(_info->getMask()),
		mText(null),
		mEnabled(true),
		mVisible(true),
		mInheritedShow(true),
		mAlpha(ALPHA_MIN),
		mName(_name),
		mTexture(_info->getTextureName()),
		mMainSkin(null),
		mWidgetCreator(_creator),
		mInheritsAlpha(true),
		mNeedKeyFocus(false),
		mNeedMouseFocus(true),
		mNeedDragDrop(false),
		mWidgetClient(null)
	{
		// корректируем абсолютные координаты
		mAbsolutePosition = _coord.point();
		if (null != mParent) mAbsolutePosition += mParent->getAbsolutePosition();

		// имя отсылателя сообщений
		mWidgetEventSender = this;

		// загружаем кирпичики виджета
		SubWidgetManager & manager = SubWidgetManager::getInstance();
		for (VectorSubWidgetInfo::const_iterator iter =_info->getBasisInfo().begin(); iter!=_info->getBasisInfo().end(); ++iter) {
			CroppedRectangleInterface * sub = manager.createSubWidget(*iter, this);
			mSubSkinChild.push_back(sub);
			if (sub->_isText()) mText = static_cast<SubWidgetTextInterfacePtr>(sub);
			else if (null == mMainSkin) mMainSkin = sub;
		}

		if (false == isRootWidget()) {
			// если отец уже приаттачен, то и мы аттачимся ??? проверить что уже аттачиться при сет текстуре
			if ((null != getParent()->getLayerItemKeeper())) _attachToLayerItemKeeper(getParent()->getLayerItemKeeper());

			// проверяем наследуемую скрытость
			if ((!mParent->isShow()) || (!getParent()->_isInheritedShow())) {
				mInheritedShow = false;
				// скрываем только саб скины, детей у нас еще нет
				for (VectorCroppedRectanglePtr::iterator skin = mSubSkinChild.begin(); skin != mSubSkinChild.end(); ++skin) (*skin)->hide();
			}
		}

		// этот стиль есть всегда, даже если создатель не хотел его
		setState("normal");

		// парсим свойства
		const MapString & param = _info->getParams();
		if (false == param.empty()) {
			MapString::const_iterator iter = param.find("FontName");
			if (iter != param.end()) setFontName(iter->second);
			iter = param.find("FontHeight");
			if (iter != param.end()) setFontHeight(utility::parseInt(iter->second));
			iter = param.find("NeedKey");
			if (iter != param.end()) setNeedKeyFocus(iter->second == "true");
			iter = param.find("NeedMouse");
			if (iter != param.end()) setNeedMouseFocus(iter->second == "true");
			iter = param.find("AlignText");
			if (iter != param.end()) setTextAlign(SkinManager::parseAlign(iter->second));
			iter = param.find("Colour");
			if (iter != param.end()) setColour(utility::parseColour(iter->second));
			iter = param.find("Pointer");
			if (iter != param.end()) mPointer = iter->second;
			iter = param.find("Show");
			if (iter != param.end()) {
				if (utility::parseBool(iter->second)) show();
				else hide();
			}
		}

		// выставляем альфу, корректировка по отцу автоматически
		setAlpha(ALPHA_MAX);

		// создаем детей
		const VectorChildSkinInfo& child = _info->getChild();
		for (VectorChildSkinInfo::const_iterator iter=child.begin(); iter!=child.end(); ++iter) {
			WidgetPtr widget = createWidgetT(iter->type, iter->skin, iter->coord, iter->align);
			widget->_setInternalString(iter->name);
			// заполняем UserString пропертями
			for (MapString::const_iterator prop=iter->params.begin(); prop!=iter->params.end(); ++prop) {
				widget->setUserString(prop->first, prop->second);
			}
		}

		// а вот теперь нормальный размер
		setSize(_coord.size());

	}