Skip to content

[Feature Request] Custom Widget#measure virtual method #170

Description

@BigBoyBarney

Hi!

This is either:

  • a bug
  • unimplemented
  • me being incompetent :D

I would like to create a custom widget and implement its #measure virtual method, according to https://docs.gtk.org/gtk4/class.Widget.html

in Vala, it would look something like (snippet from Highscore

protected override void measure (
    Gtk.Orientation orientation,
    int for_size,
    out int minimum,
    out int natural,
    out int minimum_baseline,
    out int natural_baseline
) {
    stack.measure (orientation, for_size, out minimum, null, null, null);

    minimum = int.max (minimum, 64);

    if ((orientation == HORIZONTAL) == width_for_height)
        natural = for_size >= 0 ? for_size : 64;
    else
        natural = int.min (minimum, 64);

    minimum_baseline = natural_baseline = -1;
}

In a similar case for a custom Paintable's snapshot vfunc, what I did was:

@[GObject::Virtual]
def snapshot(snapshot : Gdk::Snapshot, width : Float64, height : Float64) : Nil
end

so I tried the same here

@[GObject::Virtual]
def measure(orientation : Gtk::Orientation, for_size : Int32, minimum : Int32, natural : Int32, minimum_baseline : Int32, natural_baseline : Int32) : Nil
end

But it still resulted in the following error:

Error: undefined local variable or method 'minimum' for MyWidget.class

Thanks in advance!


EDIT:
It appears to be the macro method in src/auto/gtk-4.0/widget.cr#L3818

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions