Skip to content

Commit

Permalink
Some AAM refactoring #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Sekachev committed Sep 26, 2018
1 parent 4196ad3 commit 9fc7847
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
13 changes: 1 addition & 12 deletions cvat/apps/engine/static/engine/js/attributeAnnotationMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,13 @@ class AAMModel extends Listener {
if (this._activeAAM && this._active) {
let label = this._active.label;
let attrId = +this._attrIdByIdx(label, this._attrNumberByLabel[label].current);
let attrInfo = window.cvat.labelsInfo.attrInfo(attrId);

let [xtl, ytl, xbr, ybr] = this._bbRect(this._currentShapes[this._activeIdx].interpolation.position);
this._focus(xtl - this._margin, xbr + this._margin, ytl - this._margin, ybr + this._margin);

this._active.activeAttribute = attrId;

this.notify();

if (attrInfo.type === 'text' || attrInfo.type === 'number') {
this._active.aamAttributeFocus();
}
}
else {
this.notify();
}
this.notify();
}

_deactivate() {
Expand Down Expand Up @@ -381,7 +372,5 @@ class AAMView {
this._trackManagement.removeClass('hidden');
}
}
// blur on change text attribute to other or on exit from aam
blurAllElements();
}
}
20 changes: 9 additions & 11 deletions cvat/apps/engine/static/engine/js/shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,6 @@ class ShapeModel extends Listener {
return frame in this._positions;
}

aamAttributeFocus() {
this._updateReason = 'attributeFocus';
this.notify();
}

select() {
if (!this._selected) {
this._selected = true;
Expand Down Expand Up @@ -2504,19 +2499,22 @@ class ShapeView extends Listener {
}
break;
}
case 'attributeFocus': {
let attrId = model.activeAAM.attributeId;
this._uis.attributes[attrId].focus();
this._uis.attributes[attrId].select();
break;
}
case 'activeAttribute':
this._setupAAMView(activeAAM.shape, interpolation.position);
setupHidden.call(this, hiddenShape, hiddenText, activeAAM, model.active, interpolation);

if (activeAAM.shape && this._uis.shape) {
this._uis.shape.node.dispatchEvent(new Event('click'));
this._highlightAttribute(activeAAM.attributeId);

let attrInfo = window.cvat.labelsInfo.attrInfo(activeAAM.attributeId);
if (attrInfo.type === 'text' || attrInfo.type === 'number') {
this._uis.attributes[activeAAM.attributeId].focus();
this._uis.attributes[activeAAM.attributeId].select();
}
else {
blurAllElements();
}
}
else {
this._highlightAttribute(null);
Expand Down

0 comments on commit 9fc7847

Please sign in to comment.