<commit_before>/* ***********************************************************************************************

    Unify Project

    Homepage: unify-project.org
    License: MIT + Apache (V2)
    Copyright: 2010-2011, <NAME>, Mainz, Germany, http://unify-training.com

*********************************************************************************************** */

/**
 * EXPERIMENTAL
 *
 * Layout for navigation bar
 */
qx.Class.define("unify.ui.layout.NavigationBar", {
  extend : qx.ui.layout.Abstract,
  
  statics : {
    SPACER : 6
  },
  
  members : {
    __left : null,
    __right : null,
    __title : null,
  
    renderLayout : function(availWidth, availHeight) {
      if (this._invalidChildrenCache) {
        this.__rebuildCache();
      }
      
      var left = this.__left;
      var right = this.__right;
      var title = this.__title;
      
      var SPACER = this.self(arguments).SPACER;
      var i,ii,e,hint,leftx=SPACER,rightx=availWidth-SPACER,top;
      
      for (i=0,ii=left.length;i<ii;i++) {
        e = left[i];
        hint = e.getSizeHint();

        top = availHeight / 2 - hint.height / 2;
        e.renderLayout(leftx, top, hint.width, hint.height);
        leftx += hint.width + SPACER;
      }
      
      for (i=right.length-1;i>=0;i--) {
        e = right[i];
        hint = e.getSizeHint();
        
        rightx -= hint.width + SPACER;
        top = availHeight / 2 - hint.height / 2;
        e.renderLayout(rightx, top, hint.width, hint.height);
      }
      
      //var availTitleWidth = rightx - leftx;
      hint = title.getSizeHint();
      var titleTop = Math.floor(availHeight / 2 - hint.height / 2);
      var titleLeft = Math.floor(availWidth / 2 - hint.width / 2);
      title.renderLayout(titleLeft, titleTop, hint.width, hint.height);
    },
    
    /**
     * Rebuilds cache of layout children
     */
    __rebuildCache : function() {
      var all = this._getLayoutChildren();
      var left = [];
      var right = [];
      var title = null;
      
      for (var i=0,ii=all.length; i<ii; i++) {
        var child = all[i];
        
        var position = child.getLayoutProperties().position;
        if (position == "title" || position == "center") {
          if (title) {
            throw new Error("It is not allowed to have more than one child aligned to 'title'!");
          }
          title = child;
        } else if (position == "left") {
          left.push(child);
        } else if (!position || position == "right") {
          right.push(child);
        } else {
          throw new Error("Position '"+position+"' is not supported!");
        }
      }
      
      this.__left = left;
      this.__right = right;
      this.__title = title;
    }
  }
});
<commit_msg>fixed issue with missing position calculation rounding in NavigationBar layout<commit_after>/* ***********************************************************************************************

    Unify Project

    Homepage: unify-project.org
    License: MIT + Apache (V2)
    Copyright: 2010-2011, <NAME>, Mainz, Germany, http://unify-training.com

*********************************************************************************************** */

/**
 * EXPERIMENTAL
 *
 * Layout for navigation bar
 */
qx.Class.define("unify.ui.layout.NavigationBar", {
  extend : qx.ui.layout.Abstract,
  
  statics : {
    SPACER : 6
  },
  
  members : {
    __left : null,
    __right : null,
    __title : null,
  
    renderLayout : function(availWidth, availHeight) {
      if (this._invalidChildrenCache) {
        this.__rebuildCache();
      }
      
      var left = this.__left;
      var right = this.__right;
      var title = this.__title;
      
      var SPACER = this.self(arguments).SPACER;
      var i,ii,e,hint,leftx=SPACER,rightx=availWidth-SPACER,top;
      
      for (i=0,ii=left.length;i<ii;i++) {
        e = left[i];
        hint = e.getSizeHint();

        top = Math.floor(availHeight / 2 - hint.height / 2);
        e.renderLayout(leftx, top, hint.width, hint.height);
        leftx += hint.width + SPACER;
      }
      
      for (i=right.length-1;i>=0;i--) {
        e = right[i];
        hint = e.getSizeHint();
        
        rightx -= hint.width + SPACER;
        top = Math.floor(availHeight / 2 - hint.height / 2);
        e.renderLayout(rightx, top, hint.width, hint.height);
      }
      
      //var availTitleWidth = rightx - leftx;
      hint = title.getSizeHint();
      var titleTop = Math.floor(availHeight / 2 - hint.height / 2);
      var titleLeft = Math.floor(availWidth / 2 - hint.width / 2);
      title.renderLayout(titleLeft, titleTop, hint.width, hint.height);
    },
    
    /**
     * Rebuilds cache of layout children
     */
    __rebuildCache : function() {
      var all = this._getLayoutChildren();
      var left = [];
      var right = [];
      var title = null;
      
      for (var i=0,ii=all.length; i<ii; i++) {
        var child = all[i];
        
        var position = child.getLayoutProperties().position;
        if (position == "title" || position == "center") {
          if (title) {
            throw new Error("It is not allowed to have more than one child aligned to 'title'!");
          }
          title = child;
        } else if (position == "left") {
          left.push(child);
        } else if (!position || position == "right") {
          right.push(child);
        } else {
          throw new Error("Position '"+position+"' is not supported!");
        }
      }
      
      this.__left = left;
      this.__right = right;
      this.__title = title;
    }
  }
});

{'fraction_non_alphanumeric': 0.19547801317429234, 'fraction_numerical': 0.007833363005162899, 'mean_word_length': 2.124582869855395, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '6539777', 'n_tokens_mistral': 1739, 'n_tokens_neox': 1682, 'n_words': 385}