<commit_before>package pman.ui.hud;

import tannus.io.*;
import tannus.ds.*;
import tannus.geom.*;
import tannus.events.*;
import tannus.graphics.Color;
import tannus.math.*;

import gryffin.core.*;
import gryffin.display.*;

import pman.core.*;
import pman.display.*;
import pman.display.media.*;
import pman.ui.*;
import pman.ui.ctrl.*;

import tannus.math.TMath.*;
import gryffin.Tools.*;

import motion.Actuate;
import motion.easing.*;

using StringTools;
using tannus.ds.StringUtils;
using Lambda;
using tannus.ds.ArrayTools;
using Slambda;

class TitleItem extends PlayerHUDItem {
    /* Constructor Function */
    public function new(hud : PlayerHUD):Void {
        super( hud );

        tb = new TextBox();
        tb.fontFamily = 'Ubuntu';
        tb.fontSize = 20;
        tb.fontSizeUnit = 'px';
        tb.color = new Color(255, 255, 255);
    }

/* === Instance Methods === */

    /**
      * initialize [this]
      */
    override function init(stage : Stage):Void {
        super.init( stage );
    }

    /**
      * update [this]
      */
    override function update(stage : Stage):Void {
        super.update( stage );

        if (player.track != null) {
            var t = player.track;

            tb.text = t.title;
        }
    }

    /**
      * render [this]
      */
    override function render(stage:Stage, c:Ctx):Void {
        super.render(stage, c);

        if (enabled && player.track != null) {
            c.drawComponent(tb, 0, 0, tb.width, tb.height, x, y, w, h);
        }
    }

    /**
      * calculate [this]'s geometry
      */
    override function calculateGeometry(r : Rectangle):Void {
        var hr = hud.rect;

        w = tb.width;
        h = tb.height;
        x = (hr.x + margin);
        y = (hr.y + margin);

        super.calculateGeometry( r );
    }

    /**
      * get whether [this] is enabled
      */
    override function getEnabled():Bool {
        var mrs = player.getMostRecentOccurrenceTime( 'change:nowPlaying' );
        if (mrs == null) {
            return false;
        }
        else {
            return ((now - mrs.getTime()) <= duration);
        }
    }

/* === Instance Fields === */

    private var tb : TextBox;
}<commit_msg>refactored pman.ui.hud.TitleItem to be a child of TextualHUDItem<commit_after>package pman.ui.hud;

import tannus.io.*;
import tannus.ds.*;
import tannus.geom.*;
import tannus.events.*;
import tannus.graphics.Color;
import tannus.math.*;

import gryffin.core.*;
import gryffin.display.*;

import pman.core.*;
import pman.display.*;
import pman.display.media.*;
import pman.ui.*;
import pman.ui.ctrl.*;

import tannus.math.TMath.*;
import gryffin.Tools.*;

import motion.Actuate;
import motion.easing.*;

using StringTools;
using tannus.ds.StringUtils;
using Lambda;
using tannus.ds.ArrayTools;
using Slambda;

class TitleItem extends TextualHUDItem {
    /* Constructor Function */
    public function new(hud : PlayerHUD):Void {
        super( hud );

        tb.fontFamily = 'Ubuntu';
        tb.fontSize = 20;
    }

/* === Instance Methods === */

    /**
      * initialize [this]
      */
    override function init(stage : Stage):Void {
        super.init( stage );
    }

    /**
      * update [this]
      */
    override function update(stage : Stage):Void {
        super.update( stage );

        if (player.track != null) {
            var t = player.track;

            tb.text = t.title;
        }
    }

    /**
      * render [this]
      */
    override function render(stage:Stage, c:Ctx):Void {
        super.render(stage, c);
    }

    override function shouldRenderText():Bool return (super.shouldRenderText() && player.track != null);

    /**
      * calculate [this]'s geometry
      */
    override function calculateGeometry(r : Rectangle):Void {
        var hr = hud.rect;

        super.calculateGeometry( r );
        x = (hr.x + margin);
        y = (hr.y + margin);
    }

    /**
      * get whether [this] is enabled
      */
    override function getEnabled():Bool {
        var mrs = player.getMostRecentOccurrenceTime( 'change:nowPlaying' );
        if (mrs == null) {
            return false;
        }
        else {
            return ((now - mrs.getTime()) <= duration);
        }
    }
}
{'fraction_non_alphanumeric': 0.14073899741115556, 'fraction_numerical': 0.0035302424099788185, 'mean_word_length': 2.1067251461988303, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '96015', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1345, 'n_words': 319}