Exemple #1
0
eolComponent *eol_button_new(
    eolUint        id,
    eolWord        name,
    eolRectFloat   rect,
    eolRect        bounds,
    char         * buttonText,
    eolInt         buttonType,
    eolInt         buttonHotkey,
    eolBool        center,
    char         * buttonFileUp,
    char         * buttonFileHigh,
    char         * buttonFileDown
  )
{
  eolComponent *component = NULL;
  component = eol_component_new();
  if (!component)return NULL;
  eol_component_make_button(
    component,
    buttonText,
    buttonType,
    buttonHotkey,
    buttonFileUp,
    buttonFileHigh,
    buttonFileDown
  );
  if (component->componentData == NULL)
  {
    eol_component_free(&component);
    return NULL;
  }
  component->id = id;
  strncpy(component->name,name,EOLWORDLEN);
  eol_rectf_copy(&component->rect,rect);
  component->canHasFocus = eolTrue;
  component->type = eolButtonComponent;
  component->bounds.x = bounds.x + (bounds.w * rect.x);
  component->bounds.y = bounds.y + (bounds.h * rect.y);
  if (center)
  {
    component->bounds.x -= component->bounds.w/2;
    component->bounds.y -= component->bounds.h/2;
    if (bounds.w != 0)
    {
      component->rect.x -= (component->bounds.w/(float)bounds.w)/2;
    }
    if (bounds.h != 0)
    {
      component->rect.y -= (component->bounds.h/(float)bounds.h)/2;
    }
  }
  return component;
}
eolBool eol_keychain_get_hash_value_as_rectfloat(eolRectFloat *output, eolKeychain *hash, eolLine key)
{
  eolRectFloat temp = {0,0,0,0};
  eolLine keyValue;
  eolKeychain *chain;
  if ((!hash) || (!output) || (strlen(key) == 0))return eolFalse;
  chain = eol_keychain_get_hash_value(hash,key);
  if (!chain)return eolFalse;
  if (chain->keyType != eolKeychainString)return eolFalse;
  eol_line_cpy(keyValue,chain->keyValue);
  if (sscanf(keyValue,"%lf,%lf,%lf,%lf",&temp.x,&temp.y,&temp.w,&temp.h) != 4)return eolFalse;
  eol_rectf_copy(output,temp);
  return eolTrue;
}
Exemple #3
0
eolComponent *eol_entry_new(
    eolUint       id,
    eolWord       name,
    eolRectFloat  rect,
    eolRect       bounds,
    char        * output,
    eolInt        outputLimit,
    eolUint       justify,
    eolBool       wordWrap,
    eolUint       fontSize,
    eolLine       fontName,
    eolBool       number,
    eolVec3D      color,
    eolFloat      alpha,
    eolVec3D      bgcolor
)
{
  eolComponent *component = NULL;
  component = eol_component_new();
  if (!component)return NULL;
  eol_component_make_entry(
    component,
    output,
    outputLimit,
    justify,
    fontSize,
    wordWrap,
    fontName,
    color,
    alpha,
    bgcolor
  );
  if (component->componentData == NULL)
  {
    eol_component_free(&component);
    return NULL;
  }

  component->id = id;
  strncpy(component->name,name,EOLWORDLEN);
  eol_rectf_copy(&component->rect,rect);
  component->canHasFocus = eolTrue;
  component->type = eolEntryComponent;
  component->bounds.w = bounds.w;
  component->bounds.h = bounds.h;
  component->bounds.x = bounds.x + (bounds.w * rect.x);
  component->bounds.y = bounds.y + (bounds.h * rect.y);
  
  return component;
}
Exemple #4
0
eolComponent *eol_label_new(
    eolUint        id,
    eolWord        name,
    eolRectFloat   rect,
    eolRect        bounds,
    eolBool        canHasFocus,
    char         * text,
    eolUint        justify,
    eolBool        wordWrap,
    eolInt         fontSize,
    char         * fontName,
    eolVec3D       color,
    eolFloat       alpha
  )
{
  eolComponent *component = NULL;
  if (!text)return NULL;
  component = eol_component_new();
  if (!component)return NULL;
  eol_component_make_label(
    component,
    text,
    justify,
    fontSize,
    wordWrap,
    fontName,
    color,
    alpha
  );
  if (component->componentData == NULL)
  {
    eol_component_free(&component);
    return NULL;
  }
  component->id = id;
  strncpy(component->name,name,EOLWORDLEN);
  eol_rectf_copy(&component->rect,rect);
  component->canHasFocus = canHasFocus;
  component->type = eolLabelComponent;
  component->bounds.x = bounds.x + (bounds.w * rect.x);
  component->bounds.y = bounds.y + (bounds.h * rect.y);
  return component;
}
eolComponent *eol_list_new(
    eolUint       id,
    eolWord       name,
    eolRectFloat  rect,
    eolRect       bounds,
    eolUint       listType,
    eolVec2D      itemDimensions,
    eolVec2D      itemPadding,
    eolBool       showVSlider,
    eolBool       showHSlider,
    eolUint       fontSize
  )
{
  eolRectFloat slideRect = {0,0,1,1};
  eolComponent *component = NULL;
  eolComponentList *list = NULL;
  component = eol_component_new();
  if (!component)return NULL;

  eol_rectf_copy(&component->rect,rect);
  eol_component_get_rect_from_bounds(&component->bounds,bounds, rect);

  eol_component_make_list(
    component,
    listType,
    showHSlider,
    showVSlider,
    itemDimensions,
    itemPadding,
    fontSize
  );

  list = eol_component_get_list_data(component);
  if (list == NULL)
  {
    eol_component_free(&component);
    return NULL;
  }
  component->id = id;
  eol_line_cpy(component->name,name);
  list->itemBounds.x = component->bounds.x;
  list->itemBounds.y = component->bounds.y;
  list->itemBounds.w = component->bounds.w;
  list->itemBounds.h = component->bounds.h;

  if (showVSlider)
  {
    list->vSliderBounds.h = component->bounds.h;
    list->vSliderBounds.y = component->bounds.y;
    list->vSliderBounds.w = 25;/*TODO: make a function for getting width of slider*/
    list->vSliderBounds.x = component->bounds.x + component->bounds.w;
    list->vSlider = eol_slider_common_new(
      0,
      "vertical_scroll",
      slideRect,
      list->vSliderBounds,
      eolTrue,
      eol_vec3d(0,0,0),
      0
    );
  }
  if (showHSlider)
  {
    list->hSliderBounds.w = component->bounds.w;
    list->hSliderBounds.x = component->bounds.x;
    list->hSliderBounds.h = 25;/*TODO: make a function for getting width of slider*/
    list->hSliderBounds.y = component->bounds.y + component->bounds.h;
    list->hSlider = eol_slider_common_new(
      0,
      "horizontal_scroll",
      slideRect,
      list->hSliderBounds,
      eolFalse,
      eol_vec3d(0,0,0),
      0
    );
  }
  return component;
}