Files
ai/charting_library/bundles/line-tool-text.b8c6d2c6408e7c292921.js

2 lines
4.0 KiB
JavaScript

"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[2312],{424:(e,t,i)=>{i.r(t),i.d(t,{LineToolText:()=>x,LineToolTextAbsolute:()=>P});var r,n=i(50151),o=i(86441),s=i(88960),a=i(42752),l=i(64147),d=i(12988),h=i(32679),c=i(73305),u=i(44672),p=i(10568);!function(e){e[e.MinWidth=100]="MinWidth"}(r||(r={}));class x extends p.InplaceTextLineDataSource{constructor(e,t,r,n){const o=t??x.createProperties(e.backgroundTheme().spawnOwnership());super(e,o,r,n),this._hasEditableCoordinates=new l.WatchedValue(!1),this._recalculatePointsOnCenter=!1,Promise.all([i.e(2870),i.e(2211),i.e(1583)]).then(i.bind(i,13589)).then((({TextPaneView:t})=>{const i=this._recalculatePointsOnCenter?(e,t)=>{this._recalculatePointsOnCenter&&this._recalculateCenterPosition(e,t)}:void 0;this._paneView=new t(this,e,void 0,void 0,void 0,void 0,void 0,i,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),this.onSelectionChange.bind(this)),this._setPaneViews([this._paneView])})),o.childs().anchored.subscribe(this,this._onAnchoredChange.bind(this))}centerPosition(){this._recalculatePointsOnCenter=!0}setPoint(e,t,i){if(1!==e)return void super.setPoint(e,t,i);const r=this.properties().childs();let o;if(r.wordWrapWidth.value()){const e=this.model().timeScale();o=this.isFixed()?(0,n.ensureDefined)(this.fixedPoint()).x:e.indexToCoordinate(this.points()[0].index);const i=e.indexToCoordinate(t.index)-o-~~(r.fontsize.value()/6);if(!isFinite(i))return;r.wordWrapWidth.setValue(Math.max(100,i))}}pointsCount(){return 1}name(){return"Text"}editableTextProperties(){const e=this.properties().childs();return{text:e.text,textColor:e.color,wordWrap:e.wordWrap}}removeIfEditableTextIsEmpty(){return!0}activateEditingOnCreation(){return!0}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}state(e){const t=super.state(e);return e&&(t.state.barSpacing=this._model.timeScale().barSpacing()),t}shouldBeRemovedOnDeselect(){return""===this._properties.childs().text.value().trim()}isFixed(){return this._properties.childs().anchored.value()}anchorable(){return!0}static createProperties(e,t){const i=new h.DefaultProperty({defaultName:this._defaultName(),state:t,theme:e});return this._configureProperties(i),i}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(3401),i.e(3889),i.e(8009),i.e(6204),i.e(1963),i.e(8537)]).then(i.bind(i,27975)).then((e=>e.TextDefinitionsViewModel))}_createDataSourceBackgroundColorWV(){const{fillBackground:e,backgroundColor:t}=this.properties().childs();return(0,s.combine)((()=>e.value()?t.value():null),(0,a.convertPropertyToWatchedValue)(e).ownership(),(0,a.convertPropertyToWatchedValue)(t).ownership()).ownership()}static _defaultName(){return"linetooltext"}static _anchoredDefaultValue(){return!1}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new d.Property("")),
e.hasChild("anchored")||e.addChild("anchored",new d.Property(this._anchoredDefaultValue())),e.addChild("linesColors",new c.LineToolColorsProperty([e.childs().borderColor])),e.addChild("textsColors",new c.LineToolColorsProperty([e.childs().color])),e.addExcludedKey("text",1),e.addExcludedKey("anchored",1),e.addExcludedKey("linesColors",3),e.addExcludedKey("textsColors",3)}_recalculateCenterPosition(e,t){const i=this.isFixed()?(0,n.ensureDefined)(this.fixedPoint()):(0,n.ensureNotNull)(this.pointToScreenPoint(this._points[0])),r=new o.Point(i.x-e/2,i.y-t/2),s=(0,n.ensureNotNull)(this.screenPointToPoint(r));this.setPoints([{...s,interval:this._model.mainSeries().interval()}]),this._normalizePoints(),this.createServerPoints(),this.updateAllViewsAndRedraw((0,u.sourceChangeEvent)(this.id()))}}class P extends x{constructor(e,t,i,r){super(e,t??P.createProperties(e.backgroundTheme().spawnOwnership()),i,r)}name(){return"Anchored Text"}static _defaultName(){return"linetooltextabsolute"}static _anchoredDefaultValue(){return!0}}}}]);