2017-03-29 22:25:50 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Manialinks;
|
|
|
|
|
|
|
|
use FML\Controls\Frame;
|
|
|
|
use FML\Controls\Label;
|
|
|
|
use FML\Controls\Labels\Label_Text;
|
|
|
|
use ManiaControl\General\UsageInformationAble;
|
|
|
|
use ManiaControl\General\UsageInformationTrait;
|
|
|
|
|
2017-03-29 23:26:03 +02:00
|
|
|
/**
|
|
|
|
* Class providing easy labels in a line
|
|
|
|
*
|
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
|
|
|
* @copyright 2014-2017 ManiaControl Team
|
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
|
|
|
*/
|
2017-03-29 22:25:50 +02:00
|
|
|
class LabelLine implements UsageInformationAble {
|
|
|
|
use UsageInformationTrait;
|
|
|
|
|
|
|
|
private $frame;
|
|
|
|
private $entries = array();
|
|
|
|
|
|
|
|
private $horizontalAlign = Label::LEFT;
|
|
|
|
private $style = Label_Text::STYLE_TextCardSmall;
|
|
|
|
private $textSize = 1.5;
|
|
|
|
private $textColor = 'FFF';
|
|
|
|
private $posZ = 0;
|
2017-03-29 23:26:03 +02:00
|
|
|
private $prefix = '';
|
2017-03-29 22:25:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
public function __construct(Frame $frame) {
|
|
|
|
$this->frame = $frame;
|
|
|
|
}
|
|
|
|
|
2017-03-29 23:26:03 +02:00
|
|
|
|
2017-03-29 22:25:50 +02:00
|
|
|
/**
|
|
|
|
* Create a new text label
|
|
|
|
*
|
2017-03-29 23:26:03 +02:00
|
|
|
* @param $labelText
|
|
|
|
* @param $posX
|
|
|
|
* @param int $width
|
|
|
|
* @param string $action
|
2017-03-29 22:25:50 +02:00
|
|
|
*/
|
2017-03-29 23:26:03 +02:00
|
|
|
public function addLabelEntryText($labelText, $posX, $width = 0, $action = '') {
|
2017-03-29 22:25:50 +02:00
|
|
|
$label = new Label_Text();
|
2017-03-29 23:26:03 +02:00
|
|
|
$this->frame->addChild($label);
|
2017-03-29 22:25:50 +02:00
|
|
|
$label->setText($labelText);
|
|
|
|
$label->setX($posX);
|
2017-03-29 23:26:03 +02:00
|
|
|
if ($action) {
|
|
|
|
$label->setAction($action);
|
|
|
|
}
|
2017-03-29 22:25:50 +02:00
|
|
|
if ($width) {
|
|
|
|
$label->setWidth($width);
|
2017-03-30 17:11:27 +02:00
|
|
|
$label->setHeight(5); //TODO verify if 5 is ok for everywhere
|
2017-03-29 22:25:50 +02:00
|
|
|
}
|
|
|
|
$this->addLabel($label);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a label to private attribute
|
|
|
|
*
|
|
|
|
* @param \FML\Controls\Labels\Label_Text $label
|
|
|
|
*/
|
|
|
|
private function addLabel(Label_Text $label) {
|
|
|
|
array_push($this->entries, $label);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the labels to your frame
|
|
|
|
*/
|
2017-03-29 23:26:03 +02:00
|
|
|
|
2017-03-29 22:25:50 +02:00
|
|
|
public function render() {
|
|
|
|
/** @var Label $entry */
|
|
|
|
foreach ($this->entries as $entry) {
|
|
|
|
$entry->setHorizontalAlign($this->horizontalAlign);
|
|
|
|
$entry->setStyle($this->style);
|
|
|
|
$entry->setTextSize($this->textSize);
|
|
|
|
$entry->setTextColor($this->textColor);
|
|
|
|
$entry->setZ($this->posZ);
|
2017-03-29 23:26:03 +02:00
|
|
|
$entry->setTextPrefix($this->prefix);
|
2017-03-29 22:25:50 +02:00
|
|
|
|
|
|
|
$this->frame->addChild($entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getHorizontalAlign() {
|
|
|
|
return $this->horizontalAlign;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $horizontalAlign
|
|
|
|
*/
|
|
|
|
public function setHorizontalAlign($horizontalAlign) {
|
|
|
|
$this->horizontalAlign = $horizontalAlign;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getStyle() {
|
|
|
|
return $this->style;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $style
|
|
|
|
*/
|
|
|
|
public function setStyle($style) {
|
|
|
|
$this->style = $style;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return float
|
|
|
|
*/
|
|
|
|
public function getTextSize() {
|
|
|
|
return $this->textSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param float $textSize
|
|
|
|
*/
|
|
|
|
public function setTextSize($textSize) {
|
|
|
|
$this->textSize = $textSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getTextColor() {
|
|
|
|
return $this->textColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $textColor
|
|
|
|
*/
|
|
|
|
public function setTextColor($textColor) {
|
|
|
|
$this->textColor = $textColor;
|
|
|
|
}
|
2017-03-29 23:26:03 +02:00
|
|
|
|
2017-03-29 22:25:50 +02:00
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getPosZ() {
|
|
|
|
return $this->posZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $posZ
|
|
|
|
*/
|
|
|
|
public function setPosZ($posZ) {
|
|
|
|
$this->posZ = $posZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \FML\Controls\Labels\Label_Text[]
|
|
|
|
*/
|
|
|
|
public function getEntries() {
|
|
|
|
return $this->entries;
|
|
|
|
}
|
2017-03-29 23:26:03 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getPrefix() {
|
|
|
|
return $this->prefix;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $prefix
|
|
|
|
*/
|
|
|
|
public function setPrefix($prefix) {
|
|
|
|
$this->prefix = $prefix;
|
|
|
|
}
|
2017-03-29 22:25:50 +02:00
|
|
|
}
|