コード例 #1
0
HistoryPhoto::HistoryPhoto(
	not_null<Element*> parent,
	not_null<HistoryItem*> realParent,
	not_null<PhotoData*> photo)
: HistoryFileMedia(parent, realParent)
, _data(photo)
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
	_caption = createCaption(realParent);
	create(realParent->fullId());
}
コード例 #2
0
HistoryVideo::HistoryVideo(
	not_null<Element*> parent,
	not_null<HistoryItem*> realParent,
	not_null<DocumentData*> document)
: HistoryFileMedia(parent, realParent)
, _data(document)
, _thumbw(1)
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
	_caption = createCaption(realParent);

	setDocumentLinks(_data, realParent);

	setStatusSize(FileStatusSizeReady);

	_data->thumb->load(realParent->fullId());
}
void HistoryGroupedMedia::updateNeedBubbleState() {
	const auto hasCaption = [&] {
		if (_parts.front().item->emptyText()) {
			return false;
		}
		for (auto i = 1, count = int(_parts.size()); i != count; ++i) {
			if (!_parts[i].item->emptyText()) {
				return false;
			}
		}
		return true;
	}();
	if (hasCaption) {
		_caption = createCaption(_parts.front().item);
	}
	_needBubble = computeNeedBubble();
}
コード例 #4
0
ファイル: gui.cpp プロジェクト: Glyth/xoreos
WidgetLabel *GUI::createCaption(WidgetContext &ctx) {
	if (ctx.type == kWidgetTypeLabel)
		return dynamic_cast<WidgetLabel *>(ctx.widget);

	return createCaption(*ctx.strct, ctx.widget);
}
コード例 #5
0
ファイル: gui.cpp プロジェクト: Glyth/xoreos
void GUI::loadWidget(const Aurora::GFF3Struct &strct, Widget *parent) {
	WidgetContext ctx(strct, parent);

	createWidget(ctx);

	addWidget(ctx.widget);

	if (ctx.parent) {
		if (ctx.strct->getString("Obj_Parent") != ctx.parent->getTag())
			throw Common::Exception("Parent's tag != Obj_Parent");

		parent->addChild(*ctx.widget);

		float pX, pY, pZ;
		parent->getPosition(pX, pY, pZ);

		float x = ctx.strct->getDouble("Obj_X") * 100.0 + pX;
		float y = ctx.strct->getDouble("Obj_Y") * 100.0 + pY;
		float z = pZ - ctx.strct->getDouble("Obj_Z") * 100.0;

		ctx.widget->setPosition(x, y, z);
	} else {
		// We'll ignore these for now, centering the GUI
	}

	initWidget(ctx);

	// Create a caption/label and move the label to its destined position
	WidgetLabel *label = createCaption(ctx);
	if (label && ctx.strct->hasField("Obj_Caption")) {
		const Aurora::GFF3Struct &caption = ctx.strct->getStruct("Obj_Caption");

		float alignH = caption.getDouble("AurString_AlignH");
		float alignV = caption.getDouble("AurString_AlignV");

		float labelX = ctx.strct->getDouble("Obj_Label_X") * 100.0;
		float labelY = ctx.strct->getDouble("Obj_Label_Y") * 100.0;
		float labelZ = ctx.strct->getDouble("Obj_Label_Z") * 100.0;

		if (ctx.type != kWidgetTypeLabel) {
			if (label->getWidth() > ctx.widget->getWidth() || label->getHeight() > ctx.widget->getHeight())
				label->setText(label->getText(), alignH, ctx.widget->getWidth(), ctx.widget->getHeight());

			labelX += ctx.widget->getWidth () * alignV;
			labelY += ctx.widget->getHeight() * alignH;

			labelX -= label->getWidth () / 2;
			labelY -= label->getHeight() / 2;
		} else {
			float labelWidth = 0.0;
			if (ctx.strct->hasField("Obj_Label_Width"))
				labelWidth = ctx.strct->getDouble("Obj_Label_Width") * 100.0;

			float labelHeight = 0.0;
			if (ctx.strct->hasField("Obj_Label_Height"))
				labelHeight = ctx.strct->getDouble("Obj_Label_Height") * 100.0;

			if (alignV == 0.5) {
				bool multilines = false;
				if (label->getWidth() > labelWidth)
					multilines = true;

				label->setText(label->getText(), alignH, labelWidth, labelHeight);
				labelX += labelWidth * alignH;

				if (multilines)
					labelY += label->getHeight() * alignV;
			}

			labelX -= label->getWidth () * alignH;

			labelY -= label->getHeight();
			labelY -= label->getHeight() * alignV;
		}

		label->movePosition(labelX, labelY, -labelZ);
	}

	// uint32 layer = strct.getUint("Obj_Layer");
	// bool locked = strct.getUint("Obj_Locked") != 0;

	// Go down to the children
	if (ctx.strct->hasField("Obj_ChildList")) {
		const Aurora::GFF3List &children = ctx.strct->getList("Obj_ChildList");

		for (Aurora::GFF3List::const_iterator c = children.begin(); c != children.end(); ++c)
			loadWidget(**c, ctx.widget);
	}
}
コード例 #6
0
void HistoryPhoto::parentTextUpdated() {
	_caption = (_parent->media() == this)
		? createCaption(_parent->data())
		: Text();
	history()->owner().requestViewResize(_parent);
}