Add event for SectionWidget expand/collapse

This commit is contained in:
John Lewin 2019-02-22 22:25:57 -08:00
parent 9866aba124
commit e0478fc8c8

View file

@ -27,6 +27,7 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using System;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
@ -41,6 +42,8 @@ namespace MatterHackers.MatterControl.CustomWidgets
protected ExpandCheckboxButton checkbox;
protected GuiWidget rightAlignedContent;
public event EventHandler<bool> ExpandedChanged;
private bool setContentVAnchor;
public SectionWidget(string sectionTitle, GuiWidget sectionContent, ThemeConfig theme, GuiWidget rightAlignedContent = null, int headingPointSize = -1, bool expandingContent = true, bool expanded = true, string serializationKey = null, bool defaultExpansion = false, bool setContentVAnchor = true)
@ -76,6 +79,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
if (expandingContent)
{
ContentPanel.Visible = checkbox.Checked;
this.ExpandedChanged?.Invoke(this, checkbox.Checked);
}
// TODO: Remove this Height = 10 and figure out why the layout engine is not sizing these correctly without this.
ContentPanel.Height = 10;