示例#1
0
static void
popup_layout(glw_t *w, const glw_rctx_t *rc)
{
  glw_rctx_t rc0;
  glw_popup_t *p = (glw_popup_t *)w;

  glw_t *c = TAILQ_FIRST(&w->glw_childs);
  if(c == NULL || c->glw_flags & GLW_HIDDEN)
    return;

  int f = glw_filter_constraints(c);
  if(f & GLW_CONSTRAINT_X)
    p->width = MIN(c->glw_req_size_x, rc->rc_width);
  else
    p->width = rc->rc_width / 2;

  if(f & GLW_CONSTRAINT_Y)
    p->height = MIN(c->glw_req_size_y, rc->rc_height);
  else
    p->height = rc->rc_height / 2;

  rc0 = *rc;
  rc0.rc_width  = p->width;
  rc0.rc_height = p->height;

  glw_layout0(c, &rc0);
}
示例#2
0
static void
update_constraints(glw_expander_t *exp)
{
  glw_t *c = TAILQ_FIRST(&exp->w.glw_childs);
  int e, o;
  
  int f = c ? glw_filter_constraints(c->glw_flags) : 0;

  if(exp->w.glw_class == &glw_expander_x) {
    e = exp->expansion * (c != NULL ? c->glw_req_size_x : 0);
    o =                  (c != NULL ? c->glw_req_size_y : 0);
    f &= GLW_CONSTRAINT_Y;
  } else {
    e = exp->expansion * (c != NULL ? c->glw_req_size_y : 0);
    o =                  (c != NULL ? c->glw_req_size_x : 0);
    f &= GLW_CONSTRAINT_X;
  }

  if(e == 0)
    glw_focus_close_path(&exp->w);
  else if(exp->w.glw_flags & GLW_FOCUS_BLOCKED)
    glw_focus_open_path(&exp->w);

  if(exp->w.glw_class == &glw_expander_x)
    glw_set_constraints(&exp->w, e, o, 0, GLW_CONSTRAINT_X | f, 0);
  else
    glw_set_constraints(&exp->w, o, e, 0, GLW_CONSTRAINT_Y | f, 0);
}
示例#3
0
static void
glw_slider_layout(glw_t *w, const glw_rctx_t *rc)
{
  glw_slider_t *s = (glw_slider_t *)w;
  glw_t *c;
  glw_rctx_t rc0;
  int f;

  if((c = TAILQ_FIRST(&w->glw_childs)) == NULL || 
     rc->rc_width == 0 || rc->rc_height == 0)
    return;

  f = glw_filter_constraints(c);

  if(s->fixed_knob_size) {
    if(w->glw_class == &glw_slider_x) {
      s->knob_size_px = s->knob_size_fixed * rc->rc_width;
    } else {
      s->knob_size_px = s->knob_size_fixed * rc->rc_height;
    }

  } else if(f & GLW_CONSTRAINT_X && w->glw_class == &glw_slider_x) {
    s->knob_size_px = c->glw_req_size_x;
  } else if(f & GLW_CONSTRAINT_Y && w->glw_class == &glw_slider_y) {
    s->knob_size_px = c->glw_req_size_y;
  } else if(w->glw_class == &glw_slider_x) {
    s->knob_size_px = rc->rc_height;
  } else {
    s->knob_size_px = rc->rc_width;
  }

  int p;

  rc0 = *rc;

  if(w->glw_class == &glw_slider_x) {
    p = s->value * (rc->rc_width - s->knob_size_px) + s->knob_size_px / 2;
    rc0.rc_width  = s->knob_size_px;
    s->slider_size_px = rc->rc_width;
  } else {
    p = (1 - s->value) *
      (rc->rc_height - s->knob_size_px) + s->knob_size_px / 2;
    rc0.rc_height  = s->knob_size_px;
    s->slider_size_px = rc->rc_height;
  }

  if(s->interpolate)
    glw_lp(&s->knob_pos_px, w->glw_root, p, 0.25);
  else
    s->knob_pos_px = p;
  
  glw_layout0(c, &rc0);
}
示例#4
0
static void
glw_segway_layout(glw_t *w, const glw_rctx_t *rc)
{
  glw_segway_t *s = (glw_segway_t *)w;
  glw_t *c;

  if((c = TAILQ_FIRST(&w->glw_childs)) == NULL)
    return;

  s->req_width = 0;
  int f = glw_filter_constraints(c);

  if(f & GLW_CONSTRAINT_X) {
    s->req_width = glw_req_width(c);
  } else if(f & GLW_CONSTRAINT_W && c->glw_req_weight < 0) {
    s->req_width = rc->rc_height * -c->glw_req_weight;
  }

  glw_rctx_t rc0 = *rc;
  float alpha;
  if(s->req_width == 0 || !s->direction) {
    rc0.rc_width = w->glw_root->gr_width;
    rc0.rc_segwayed = 1;
    alpha = 0;
  } else {
    rc0.rc_width = s->req_width;
    alpha = 1;
  }

  glw_lp(&s->alpha, w->glw_root, alpha, 0.25);
  glw_lp(&s->actual_width, w->glw_root, s->req_width, 0.25);
  s->actual_width_rounded = rintf(s->actual_width);

  rc0.rc_alpha *= s->alpha;
  glw_layout0(c, &rc0);
  glw_set_constraints(w, s->actual_width_rounded, 0, 0, GLW_CONSTRAINT_X);
}