Beispiel #1
0
unsigned QuickWidget::GetNominalHeight(unsigned width)
{
	if (m_nominal_height != WidgetSizes::UseDefault)
		return max(m_nominal_height, GetMinimumHeight(width));

	return max(GetDefaultNominalHeight(width), GetMinimumHeight(width));
}
Beispiel #2
0
gcc_pure
static unsigned
GetMaximumHeight(const WndProperty &control, const DialogLook &look,
                 bool vertical)
{
  unsigned height = GetMinimumHeight(control, look, vertical);
  if (!control.IsReadOnly() && height < Layout::GetMaximumControlHeight())
    height = Layout::GetMaximumControlHeight();

  return height;
}
Beispiel #3
0
PixelSize
RowFormWidget::GetMinimumSize() const
{
  const UPixelScalar value_width =
    look.text_font->TextSize(_T("Foo Bar Foo Bar")).cx;

  const bool expert = UIGlobals::GetDialogSettings().expert;

  PixelSize size{ PixelScalar(GetRecommendedCaptionWidth() + value_width), 0 };
  for (auto i = rows.begin(), end = rows.end(); i != end; ++i)
    if (i->available && (!i->expert || expert))
      size.cy += i->GetMinimumHeight();

  return size;
}
void Icon::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
{
  if (texture() == nullptr)
    return;

  unity::ui::RenderArg arg;
  arg.icon = icon_texture_source_.GetPointer();
  arg.colorify            = nux::color::White;
  arg.running_arrow       = true;
  arg.running_on_viewport = true;
  arg.render_center       = nux::Point3(GetMinimumWidth() / 2.0f, GetMinimumHeight() / 2.0f, 0.0f);
  arg.logical_center      = arg.render_center;
  arg.window_indicators   = true;
  arg.backlight_intensity = 1.0f;
  arg.alpha               = 1.0f;

  std::list<unity::ui::RenderArg> args;
  args.push_front(arg);

  auto toplevel = GetToplevel();
  icon_renderer_.PreprocessIcons(args, toplevel->GetGeometry());
  icon_renderer_.RenderIcon(GfxContext, arg, toplevel->GetGeometry(), toplevel->GetGeometry());
}
Beispiel #5
0
 /**
  * Will this row grow when there is excess screen space?
  */
 bool IsElastic(const DialogLook &look, bool vertical) const {
   return GetMaximumHeight(look, vertical)
     > GetMinimumHeight(look, vertical);
 }
Beispiel #6
0
void
RowFormWidget::UpdateLayout()
{
  PixelRect current_rect = GetWindow()->GetClientRect();
  const unsigned total_width = current_rect.right - current_rect.left;
  const unsigned total_height = current_rect.bottom - current_rect.top;
  current_rect.bottom = current_rect.top;

  const bool expert = UIGlobals::GetDialogSettings().expert;

  /* first row traversal: count the number of "elastic" rows and
     determine the minimum total height */
  unsigned min_height = 0;
  unsigned n_elastic = 0;
  unsigned caption_width = 0;
  for (auto i = rows.begin(), end = rows.end(); i != end; ++i) {
    if (!i->available || (i->expert && !expert))
      continue;

    min_height += i->GetMinimumHeight();
    if (i->IsElastic())
      ++n_elastic;

    if (i->type == Row::Type::EDIT) {
      unsigned cw = i->GetControl().GetRecommendedCaptionWidth();
      if (cw > caption_width)
        caption_width = cw;
    }
  }

  if (caption_width * 3 > total_width * 2)
    caption_width = total_width * 2 / 3;

  /* how much excess height in addition to the minimum height? */
  unsigned excess_height = min_height < total_height
    ? total_height - min_height
    : 0;

  /* second row traversal: now move and resize the rows */
  for (auto i = rows.begin(), end = rows.end(); i != end; ++i) {
    if (i->type == Row::Type::DUMMY)
      continue;

    Window &window = i->GetWindow();

    if (!i->available) {
      window.Hide();
      continue;
    }

    if (i->expert) {
      if (!expert) {
        window.Hide();
        continue;
      }

      if (i->visible)
        window.Show();
    }

    if (caption_width > 0 && i->type == Row::Type::EDIT &&
        i->GetControl().HasCaption())
      i->GetControl().SetCaptionWidth(caption_width);

    /* determine this row's height */
    UPixelScalar height = i->GetMinimumHeight();
    if (excess_height > 0 && i->IsElastic()) {
      assert(n_elastic > 0);

      /* distribute excess height among all elastic rows */
      unsigned grow_height = excess_height / n_elastic;
      if (grow_height > 0) {
        height += grow_height;
        const UPixelScalar max_height = i->GetMaximumHeight();
        if (height > max_height) {
          /* never grow beyond declared maximum height */
          height = max_height;
          grow_height = max_height - height;
        }

        excess_height -= grow_height;
      }

      --n_elastic;
    }

    /* finally move and resize */
    NextControlRect(current_rect, height);
    window.Move(current_rect);
  }

  assert(excess_height == 0 || n_elastic == 0);
}
Beispiel #7
0
 /**
  * Will this row grow when there is excess screen space?
  */
 bool IsElastic() const {
   return GetMaximumHeight() > GetMinimumHeight();
 }