So I'm onto rolling my own classes for UI use for fun and learning. I've create a bunch of interfaces to manage the UI widgets but I'm at a fork in the road on the more complex widgets I want to create.
Right now my UI code consists of the following:
// Interfaces
IGUIWidget {}
IReactsToClick {}
IReactsToHover {}
IProgressBar : IUIWidget {}
IImage : IUIWidget {}
IButton : IUIWidget, IReactsToClick, IReactsToHover {}
ILabel : IUIWidget {}
// Concrete
Label : ILabel {}
Image : IImage {}
ProgressBar : IProgressBar {}
Button : IButton {}
ImageButton : IImage, IButton {}
LabelButton : ILabel, IButton {}
Now for the 'complex' widget.
I have an object that has the following properties:
- Acts like a button
- Has a background image
- Has a content specific image
- Has multiple smaller images that change (can be any number).
- Has a label
- Has a progress bar
Here is the interface and concrete class I've come up with:
public interface IComplexWidget : IGUIWidget
{
IButton button { get; }
IImage background { get; }
IImage contextImage { get; }
IList<IImage> multiImages { get; }
ILabel label { get; }
IProgressBar progressBar { get; }
}
public class ComplexWidget : IComplexWidget
{
public ComplexWidget()
{ }
public Button button { get; protected set; }
public Image background { get; protected set; }
public Image contextImage { get; protected set; }
public IList<Image> multiImages { get; protected set; }
public Label label { get; protected set; }
public ProgressBar progressBar { get; protected set; }
}
Would this be the correct path for creating more complex widgets?