Ejemplo n.º 1
0
bool group_symbolizer_helper::find_line_placements(T & path)
{
    if (box_elements_.empty()) return true;

    vertex_cache pp(path);

    bool success = false;
    while (pp.next_subpath())
    {
        if (pp.length() <= 0.001)
        {
            success = check_point_placement(pp.current_position()) || success;
            continue;
        }

        double spacing = get_spacing(pp.length());

        pp.forward(spacing/2.0);
        do
        {
            tolerance_iterator tolerance_offset(text_props_->label_position_tolerance * scale_factor_, spacing); //TODO: Handle halign
            while (tolerance_offset.next())
            {
                vertex_cache::scoped_state state(pp);
                if (pp.move(tolerance_offset.get()) && check_point_placement(pp.current_position()))
                {
                    success = true;
                    break;
                }
            }
        } while (pp.forward(spacing));
    }
    return success;
}
Ejemplo n.º 2
0
char* create_xlfd(font_family* family, font_style* style, uint32 flag) {
  char buf[100];
  sprintf(buf, "-TTFont-%s-%s-%c-normal--0-0-0-0-%c-0-%s",
    *family, get_weight(style), get_slant(style), get_spacing(flag), get_encoding(family));
  char* xlfd = (char*) calloc(strlen(buf) + 1, sizeof(char));
  strcpy(xlfd, buf);
  return xlfd;
}
Ejemplo n.º 3
0
void frame_managed_geom(const WFrame *frame, WRectangle *geom)
{
    uint spacing=get_spacing(frame);

    frame_border_inner_geom(frame, geom);

    /*
    geom->x+=spacing;
    geom->y+=spacing;
    geom->w-=2*spacing;
    geom->h-=2*spacing;
    */

    if(BAR_INSIDE_BORDER(frame) && BAR_EXISTS(frame)){
        geom->y+=frame->bar_h+spacing;
        geom->h-=frame->bar_h+spacing;
    }

    geom->w=MAXOF(geom->w, 0);
    geom->h=MAXOF(geom->h, 0);
}
Ejemplo n.º 4
0
  void ButtonBox::v_rearrange_children()
  {
#ifdef NDEBUG
    testInvariant(TEST_EXPANDABLE_VISIBLE_COUNT);
#endif

    ProxyContainer proxy_container(*this);

    if(is_custom_size_request())
    {
      int a, b;
      on_size_request(a,b);
    }

    if(_n_visible_children==0)
      return;

    Real inv_childrens_size_request = 1.f/Real(_expandable_childrens_size_request);
    Real additional_size = MAX(0.f, Real(proxy_container.get_height() - proxy_container.get_children_size_request_height()));
    Real single_space = additional_size;
    int x_pos;

    int max_child_w;
    int max_child_h;

    if(get_is_horizontal())
    {
      max_child_w = MAX(_max_child_height, _max_child_height);
      max_child_h = MAX(_max_child_width, _max_child_width);
    }else
    {
      max_child_w = MAX(_max_child_width, _max_child_width);
      max_child_h = MAX(_max_child_height, _max_child_height);
    }

    Real cursor  = get_border_width();

    ButtonBoxStyle l = get_layout();
    switch(get_layout())
    {
    case BUTTONBOX_EDGE:
      single_space = additional_size / Real(_n_visible_children-1);
      break;
    case BUTTONBOX_START:
      break;
    case BUTTONBOX_END:
      cursor  += additional_size;
      break;
    case BUTTONBOX_CENTER:
      cursor  += additional_size*0.5f;
      break;
    case BUTTONBOX_SPREAD:
    default:
      single_space = additional_size / Real(_n_visible_children+1);
    }

    x_pos = MAX(get_border_width(), (proxy_container.get_width()-max_child_w)/2);

    int i=0;

    for(BoxChildContainerList::iterator iter = _start_children.begin(); iter!=_end_children.end();)
    {
      if(iter==_start_children.end())
      {
        iter  = _end_children.begin();
        continue;
      }

      g_assert(iter->child);
      g_assert(iter->child->get_size_request_width()>=0);
      g_assert(iter->child->get_size_request_height()>=0);

      ProxyChild child(*this, *iter->child);

      if(iter->child->is_visible())
      {
        switch(get_layout())
        {
        case BUTTONBOX_EDGE:
          break;
        case BUTTONBOX_START:
        case BUTTONBOX_END:
        case BUTTONBOX_CENTER:
          break;
        case BUTTONBOX_SPREAD:
        default:
          cursor  += single_space;
          cursor  += get_spacing();
        }

        child.set_allocation(x_pos, round(cursor), max_child_w, max_child_h);
        cursor  += max_child_h;

        switch(get_layout())
        {
        case BUTTONBOX_EDGE:
          cursor  += single_space;
          cursor  += get_spacing();
          break;
        case BUTTONBOX_START:
        case BUTTONBOX_END:
        case BUTTONBOX_CENTER:
          cursor  += get_spacing();
          break;
        case BUTTONBOX_SPREAD:
        default:
          break;
        }

        ++i;
      }
      ++iter;
    }
  }
bool placement_finder::find_line_placements(T & path, bool points)
{
    if (!layouts_.line_count()) return true; //TODO
    vertex_cache pp(path);

    bool success = false;
    while (pp.next_subpath())
    {
        if (points)
        {
            if (pp.length() <= 0.001)
            {
                success = find_point_placement(pp.current_position()) || success;
                continue;
            }
        }
        else
        {
            if ((pp.length() < text_props_->minimum_path_length * scale_factor_)
                ||
                (pp.length() <= 0.001) // Clipping removed whole geometry
                ||
                (pp.length() < layouts_.width()))
                {
                    continue;
                }
        }

        double spacing = get_spacing(pp.length(), points ? 0. : layouts_.width());

        //horizontal_alignment_e halign = layouts_.back()->horizontal_alignment();

        // halign == H_LEFT -> don't move
        if (horizontal_alignment_ == H_MIDDLE || horizontal_alignment_ == H_AUTO || horizontal_alignment_ == H_ADJUST)
        {
            if (!pp.forward(spacing / 2.0)) continue;
        }
        else if (horizontal_alignment_ == H_RIGHT)
        {
            if (!pp.forward(pp.length())) continue;
        }

        if (move_dx_ != 0.0) path_move_dx(pp, move_dx_);

        do
        {
            tolerance_iterator tolerance_offset(text_props_->label_position_tolerance * scale_factor_, spacing); //TODO: Handle halign
            while (tolerance_offset.next())
            {
                vertex_cache::scoped_state state(pp);
                if (pp.move(tolerance_offset.get())
                    && ((points && find_point_placement(pp.current_position()))
                        || (!points && single_line_placement(pp, text_props_->upright))))
                {
                    success = true;
                    break;
                }
            }
        } while (pp.forward(spacing));
    }
    return success;
}