Преглед изворни кода

fixed gui chart to process resize events
added Size() method to gui.Panel

leonsal пре 8 година
родитељ
комит
132f4713ff
2 измењених фајлова са 13 додато и 0 уклоњено
  1. 7 0
      gui/chart.go
  2. 6 0
      gui/panel.go

+ 7 - 0
gui/chart.go

@@ -72,6 +72,7 @@ func NewChart(width, height float32) *Chart {
 	ch.formatY = "%v"
 	ch.fontSizeX = 14
 	ch.fontSizeY = 14
+	ch.Subscribe(OnResize, ch.onResize)
 	return ch
 }
 
@@ -393,6 +394,12 @@ func (ch *Chart) updateGraphs() {
 	}
 }
 
+// onResize process OnResize events for this chart
+func (ch *Chart) onResize(evname string, ev interface{}) {
+
+	ch.recalc()
+}
+
 // recalc recalculates the positions of the inner panels
 func (ch *Chart) recalc() {
 

+ 6 - 0
gui/panel.go

@@ -295,6 +295,12 @@ func (p *Panel) SetContentAspectHeight(height float32) {
 	p.SetContentSize(width, height)
 }
 
+// Size returns this panel current external width and height in pixels
+func (p *Panel) Size() (float32, float32) {
+
+	return p.width, p.height
+}
+
 // Width returns the current panel external width in pixels
 func (p *Panel) Width() float32 {