Skip to content

Commit

Permalink
Fixes renderer creation
Browse files Browse the repository at this point in the history
Issue #39 - calling the inside object `CreateRenderer` breaks several
native behaviors (text wrapping, clickable, and many others).

Removing this call and using NewSimpleRenderer on the reponsiveWidget
fixes the problems.

I don't have precise explanation.
  • Loading branch information
metal3d committed Jul 5, 2023
1 parent 34a0b17 commit 119002e
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions layout/responsive.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ type responsiveConfig map[responsiveBreakpoint]float32
// newResponsiveConf return a new responsive configuration.
// The optional ratios must
// be 0 < ratio <= 1 and passed in this order:
// Responsive(object, smallRatio, mediumRatio, largeRatio, xlargeRatio)
//
// Responsive(object, smallRatio, mediumRatio, largeRatio, xlargeRatio)
//
// They are set to previous value if a value is not passed, or 1.0 if there is no previous value.
func newResponsiveConf(ratios ...float32) responsiveConfig {
responsive := responsiveConfig{}
Expand Down Expand Up @@ -232,12 +234,13 @@ func (resp *ResponsiveLayout) maxFloat32(a, b float32) float32 {
// configure the rule, each object could be encapsulated by a "Responsive" object.
//
// Example:
// container := NewResponsiveLayout(
// Responsive(label, 1, .5, .25), // 100% for small, 50% for medium, 25% for large
// Responsive(button, 1, .5, .25), // ...
// label2, // this will be placed and resized with default behaviors
// // => 1, 1, 1
// )
//
// container := NewResponsiveLayout(
// Responsive(label, 1, .5, .25), // 100% for small, 50% for medium, 25% for large
// Responsive(button, 1, .5, .25), // ...
// label2, // this will be placed and resized with default behaviors
// // => 1, 1, 1
// )
func NewResponsiveLayout(o ...fyne.CanvasObject) *fyne.Container {
r := &ResponsiveLayout{}

Expand All @@ -264,7 +267,9 @@ var _ fyne.Widget = (*responsiveWidget)(nil)
// Responsive register the object with a responsive configuration.
// The optional ratios must
// be 0 < ratio <= 1 and passed in this order:
// Responsive(object, smallRatio, mediumRatio, largeRatio, xlargeRatio)
//
// Responsive(object, smallRatio, mediumRatio, largeRatio, xlargeRatio)
//
// They are set to previous value if a value is not passed, or 1.0 if there is no previous value.
// The returned object is not modified.
func Responsive(object fyne.CanvasObject, breakpointRatio ...float32) fyne.CanvasObject {
Expand All @@ -277,8 +282,5 @@ func (ro *responsiveWidget) CreateRenderer() fyne.WidgetRenderer {
if ro.render == nil {
return nil
}
if o, ok := ro.render.(fyne.Widget); ok {
return o.CreateRenderer()
}
return widget.NewSimpleRenderer(ro.render)
}

0 comments on commit 119002e

Please sign in to comment.