Created
October 8, 2019 18:09
-
-
Save yuntan/bc3064cf6e07887c97bf0077e07e70e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'gtk3' | |
class MyWidget < Gtk::Widget | |
type_register | |
def initialize() | |
super() | |
self.has_window = true | |
self.redraw_on_allocate = true | |
end | |
def request_mode | |
notice 'request_mode' | |
Gtk::SizeRequestMode::HEIGHT_FOR_WIDTH | |
end | |
def preferred_width | |
notice 'preferred_width' | |
[100, 250] # minimum, natural | |
end | |
def preferred_height | |
notice 'preferred_height' | |
h = preferred_height_for_width 250 | |
[h, h] | |
end | |
def preferred_height_for_width(width) | |
notice "preferred_height_for_width(#{width})" | |
h = 3 * width | |
[h, h] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment