Skip to content

A free open source IT asset/license management system

adds text_column positioning for the logo

Godfrey Mf3ac596fbdba
diff --git a/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php b/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php
index e3fe42ce50..786a349c4d 100644
--- a/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php
+++ b/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php
@@ -407,6 +407,10 @@ trait RenderCustomLabelContent
protected function syncLogoAnd2DBarcodeHAlign(?string $changedKey = null): void
{
+ if ($this->getLogoPlacement() === 'text_column') {
+ return;
+ }
+
if (!$this->getSupportLogo() || !$this->getSupport2DBarcode()) {
return;
}
diff --git a/app/Models/Labels/CustomLabels/CustomTapeLabel.php b/app/Models/Labels/CustomLabels/CustomTapeLabel.php
index b065ad7ed4..0349b38460 100644
--- a/app/Models/Labels/CustomLabels/CustomTapeLabel.php
+++ b/app/Models/Labels/CustomLabels/CustomTapeLabel.php
@@ -39,6 +39,7 @@ abstract class CustomTapeLabel extends Label
protected float $logoMargin = 2.0;
protected string $logoHAlign = 'L';
protected string $logoVAlign = 'T';
+ protected ?string $logoPlacement = null;
protected float $barcode2DSize = 10.0;
protected string $barcode2DHAlign = 'L';
@@ -213,6 +214,10 @@ abstract class CustomTapeLabel extends Label
return $this->logoVAlign;
}
+ public function getLogoPlacement(): ?string
+ {
+ return $this->logoPlacement;
+ }
public function get2DBarcodeSize(): float
{
return $this->barcode2DSize;
@@ -336,6 +341,7 @@ abstract class CustomTapeLabel extends Label
'logo_margin' => $this->getLogoMargin(),
'logo_h_align' => $this->getLogoHAlign(),
'logo_v_align' => $this->getLogoVAlign(),
+ 'logo_placement' => $this->getLogoPlacement(),
];
}
@@ -447,6 +453,7 @@ abstract class CustomTapeLabel extends Label
'logo_h_align' => 'logoHAlign',
'logo_v_align' => 'logoVAlign',
'tag_alignment' => 'tagAlignment',
+ 'logo_placement' => 'logoPlacement',
];
foreach ($stringContentMap as $key => $property) {
@@ -527,6 +534,7 @@ abstract class CustomTapeLabel extends Label
$this->logoMargin = isset($content['logo_margin']) ? (float)$content['logo_margin'] : $this->logoMargin;
$this->logoHAlign = isset($content['logo_h_align']) ? (string)$content['logo_h_align'] : $this->logoHAlign;
$this->logoVAlign = isset($content['logo_v_align']) ? (string)$content['logo_v_align'] : $this->logoVAlign;
+ $this->logoPlacement = isset($content['logo_placement']) ? (string)$content['logo_placement'] : $this->logoPlacement;
//If the logo and 2D barcode are both present, and one is moved to the other side, they will flip positions.
if (array_key_exists('barcode2D_h_align', $content)) {
@@ -627,27 +635,58 @@ abstract class CustomTapeLabel extends Label
| Resolve positioned elements
|--------------------------------------------------------------------------
*/
- $logoBox = $this->resolveLogoBox($record, $layout['body']);
- $barcode2dBox = $this->resolve2DBarcodeBox($record, $layout['body'], $logoBox);
- $tagBox = $this->resolveTagBox($record, $layout['body'], $barcode2dBox, $logoBox);
+ if ($this->getLogoPlacement() === 'text_column') {
+ $barcode2dBox = $this->resolve2DBarcodeBox($record, $layout['body'], null);
+ $tagBox = $this->resolveTagBox($record, $layout['body'], $barcode2dBox, null);
+
+ $layout['barcode2d'] = $barcode2dBox;
+ $layout['tag'] = $tagBox;
+
+ $layout['text'] = $this->resolveTextBox(
+ $layout['body'],
+ array_filter([
+ $layout['barcode2d'],
+ $layout['tag'],
+ ])
+ );
- $layout['logo'] = $logoBox;
- $layout['barcode2d'] = $barcode2dBox;
- $layout['tag'] = $tagBox;
+ $logoBox = null;
- /*
- |--------------------------------------------------------------------------
- | Derive remaining text box
- |--------------------------------------------------------------------------
- */
- $layout['text'] = $this->resolveTextBox(
- $layout['body'],
- array_filter([
- $layout['logo'],
- $layout['barcode2d'],
- $layout['tag'],
- ])
- );
+ if ($record->has('logo') && $this->getSupportLogo()) {
+ $logoHeight = $this->getLogoMaxHeight() ?? $this->getLogoMaxWidth();
+
+ $logoBox = $this->anchorBox(
+ $layout['text'],
+ $layout['text']['w'],
+ min($logoHeight, $layout['text']['h']),
+ $this->getLogoHAlign(),
+ $this->getLogoVAlign()
+ );
+ }
+ $layout['logo'] = $logoBox;
+
+ if ($logoBox) {
+ $layout['text']['y1'] = $logoBox['y'] + $logoBox['h'] + $this->getLogoMargin();
+ $layout['text']['h'] = max(0, $layout['text']['y2'] - $layout['text']['y1']);
+ }
+ } else {
+ $logoBox = $this->resolveLogoBox($record, $layout['body']);
+ $barcode2dBox = $this->resolve2DBarcodeBox($record, $layout['body'], $logoBox);
+ $tagBox = $this->resolveTagBox($record, $layout['body'], $barcode2dBox, $logoBox);
+
+ $layout['logo'] = $logoBox;
+ $layout['barcode2d'] = $barcode2dBox;
+ $layout['tag'] = $tagBox;
+
+ $layout['text'] = $this->resolveTextBox(
+ $layout['body'],
+ array_filter([
+ $layout['logo'],
+ $layout['barcode2d'],
+ $layout['tag'],
+ ])
+ );
+ }
/*
|--------------------------------------------------------------------------
diff --git a/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape_A.php b/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape_A.php
index 0f81b60177..3d78aac705 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape_A.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape_A.php
@@ -162,6 +162,7 @@ class TZe_62mm_Landscape_A extends TZe_62mm_Landscape
'logo_margin' => $this->getLogoMargin(),
'logo_h_align' => 'L',
'logo_v_align' => 'T',
+ "logo_placement" => 'text_column',
'title_font_size' => $this->getTitleSize(),
'title_margin' => $this->getTitleMargin(),