<commit_before>/*   RSence
 *   Copyright 2010 Riassence Inc.
 *   http://riassence.com/
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this software package. If not, contact <EMAIL>
 */


/*** = Description
  ** Simple small menu component for selecting one value amongst several.
  ** It's limited to 15px height by the default theme.
  ***/
var//RSence.Menus
HMiniMenu = HRadioButtonList.extend({
  
  componentName: 'minimenu',
  
  defaultEvents: {
    draggable: true,
    click: true
  },
  
  repositionMenuItems: function(){
    var
    x = this.pageX(),
    y = this.pageY(),
    w = this.rect.width,
    h = this.listItems.length*15,
    i = 0,
    listItem = null;
    for(;i<this.listItems.length && listItem === null;i++){
      if(this.listItems[i][0]===this.value){
        listItem = this.listItems[i];
      }
    }
    y -= (i-1)*15;
    if(y < 0){
      y = y%15;
    }
    if(this.options['menuItemGeom']){
      if(this.options.menuItemGeom.width){
        w += this.options.menuItemGeom.width;
      }
      if(this.options.menuItemGeom.width){
        x += this.options.menuItemGeom.left;
      }
    }
    this.menuItemView.rect.set( x, y, x+w, y+h );
    this.menuItemView.refresh();
  },
  
  click: function(){
    this.menuShow();
  },
  
  refreshValue: function(){
    this.base();
    if(this.listItems && this.listItems.length !== 0 && this['valueMatrix'] !== undefined ) {
      for(var i=0;i<this.listItems.length;i++){
        if(this.listItems[i][0]===this.value){
          this.setLabel( this.listItems[i][1] );
          return;
        }
      }
    }
  },
  
  menuShow: function(){
    this.repositionMenuItems();
    this.menuItemView.bringToFront();
    this.menuItemView.show();
    return true;
  },
  
  menuHide: function(){
    this.menuItemView.sendToBack();
    this.menuItemView.hide();
  },
  
  startDrag: function(x,y){
    this.dragStart = [x,y];
    this.menuShow();
  },
  
  lostActiveStatus: function(newActive){
    this.menuHide();
  },
  
  endDrag: function(x,y){
    if( (Math.round(this.dragStart[0]*0.2)===Math.round(x*0.2)) &&
        (Math.round(this.dragStart[1]*0.2)===Math.round(y*0.2))
    ){
      this.menuShow();
    }
    else {
      this.menuHide();
    }
  },
  
  die: function(){
    this.valueMatrix = null;
    var _menuItemView = this.menuItemView;
    this.base();
    _menuItemView && _menuItemView.die();
  },
  
  drawSubviews: function(){
    this.menuItemView = HView.nu(
      [ this.rect.left, this.rect.top, this.rect.width, 10 ],
      this.app, {
        visible: false,
        style: [
          ['background-color','#f6f6f6'],
          ['border', '1px solid #999'],
          ['overflow-y', 'auto'],
          ['opacity', 0.9]
        ]
      }
    );
  },
  
  setListItems: function(listItems){
    this.base(listItems);
    this.valueMatrix = this.menuItemView.valueMatrix;
    this.refreshValue();
  },
  
  createComponent: function( i, _label ){
    return HMiniMenuItem.nu(
      [ 0, (i*15), null, 15, 0, null ],
      this.menuItemView, {
        label: _label
      }
    );
  }
  
});<commit_msg>configurable dimensions for sub-items (needed by HMenuItem as a child, like in HPopupMenu)<commit_after>/*   RSence
 *   Copyright 2010 Riassence Inc.
 *   http://riassence.com/
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this software package. If not, contact <EMAIL>
 */


/*** = Description
  ** Simple small menu component for selecting one value amongst several.
  ** It's limited to 15px height by the default theme.
  ***/
var//RSence.Menus
HMiniMenu = HRadioButtonList.extend({
  
  componentName: 'minimenu',
  
  defaultEvents: {
    draggable: true,
    click: true
  },

  subCompenentHeight: 15,
  
  repositionMenuItems: function(){
    var
    x = this.pageX(),
    y = this.pageY(),
    w = this.rect.width,
    h = this.listItems.length*this.subComponentHeight,
    i = 0,
    listItem = null;
    for(;i<this.listItems.length && listItem === null;i++){
      if(this.listItems[i][0]===this.value){
        listItem = this.listItems[i];
      }
    }
    y -= (i-1)*this.subComponentHeight;
    if(y < 0){
      y = y%this.subComponentHeight;
    }
    if(this.options['menuItemGeom']){
      if(this.options.menuItemGeom.width){
        w += this.options.menuItemGeom.width;
      }
      if(this.options.menuItemGeom.width){
        x += this.options.menuItemGeom.left;
      }
    }
    this.menuItemView.rect.set( x, y, x+w, y+h );
    this.menuItemView.refresh();
  },
  
  click: function(){
    this.menuShow();
  },
  
  refreshValue: function(){
    this.base();
    if(this.listItems && this.listItems.length !== 0 && this['valueMatrix'] !== undefined ) {
      for(var i=0;i<this.listItems.length;i++){
        if(this.listItems[i][0]===this.value){
          this.setLabel( this.listItems[i][1] );
          return;
        }
      }
    }
  },
  
  menuShow: function(){
    this.repositionMenuItems();
    this.menuItemView.bringToFront();
    this.menuItemView.show();
    return true;
  },
  
  menuHide: function(){
    this.menuItemView.sendToBack();
    this.menuItemView.hide();
  },
  
  startDrag: function(x,y){
    this.dragStart = [x,y];
    this.menuShow();
  },
  
  lostActiveStatus: function(newActive){
    this.menuHide();
  },
  
  endDrag: function(x,y){
    if( (Math.round(this.dragStart[0]*0.2)===Math.round(x*0.2)) &&
        (Math.round(this.dragStart[1]*0.2)===Math.round(y*0.2))
    ){
      this.menuShow();
    }
    else {
      this.menuHide();
    }
  },
  
  die: function(){
    this.valueMatrix = null;
    var _menuItemView = this.menuItemView;
    this.base();
    _menuItemView && _menuItemView.die();
  },
  
  drawSubviews: function(){
    this.menuItemView = HView.nu(
      [ this.rect.left, this.rect.top, this.rect.width, 10 ],
      this.app, {
        visible: false,
        style: [
          ['background-color','#f6f6f6'],
          ['border', '1px solid #999'],
          ['overflow-y', 'auto'],
          ['opacity', 0.9]
        ]
      }
    );
  },
  
  setListItems: function(listItems){
    this.base(listItems);
    this.valueMatrix = this.menuItemView.valueMatrix;
    this.refreshValue();
  },
  
  createComponent: function( i, _label ){
    return HMiniMenuItem.nu(
      [ 0, (i*this.subComponentHeight), null, this.subComponentHeight, 0, null ],
      this.menuItemView, {
        label: _label
      }
    );
  }
  
});
{'fraction_non_alphanumeric': 0.1617263093226847, 'fraction_numerical': 0.013208416525879282, 'mean_word_length': 2.4455026455026454, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '1182771', 'n_tokens_mistral': 2322, 'n_tokens_neox': 2267, 'n_words': 402}