Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GUI Framework patterns? [closed]

We are developing in an embedded type environment and find ourselves needing to create our own UI framework.

I have done this before, but I am interested in doing a little bit of research around common design patterns for frameworks.

Types of things that I am thinking of as patterns (somewhat far reaching):

  • Widget Focus / defocus
  • Widget Animation
  • Data sharing between elements
  • Attaching commands to widgets
  • Saving state (MVC?)

What recommended reading do you have for GUI Framework patterns?

like image 577
Hortitude Avatar asked Nov 25 '08 19:11

Hortitude


People also ask

Are design patterns still used?

Are they still relevant? Quick answer: yes. Especially when you're at the beginning of your journey, design patterns are a good starting point. Even if you won't use them right away in your first projects, getting to know them will help you understand the existing solutions you're using.

What are the UI design patterns?

User interface (UI) design patterns are reusable/recurring components which designers use to solve common problems in user interface design. For example, the breadcrumbs design pattern lets users retrace their steps. Designers can apply them to a broad range of cases, but must adapt each to the specific context of use.

When should design patterns not be used?

If a problem has two solutions, one that fits in ten lines of code, and another one with hundreds of lines of code along with a pattern, please consider not using the pattern. Their presence isn't a quality measurement.

What is difference between framework and design pattern?

A design pattern is a concept, or a receipt for how to get a specific problem done. A Framework is code ready for use, usually packaged in a way that makes creating an application much easier.


1 Answers

I have two for you, the callback or notification, maybe this is what you call "attaching commands to widgets", somehow you want to react to changes in state in your UI element. The controller needs to be informed that a change has occured.

Cocoa/UIKit has a pattern that is called "Delegation" and notifications to accomplish this, others use callback functions or objects (Java Swing) or "signals and slots" (QT).

I very useful pattern that does not occur in the wild very often is the ability to prevent a state change, the easiest use case for this is input validation, you want to prevent the loss of focus from a widget when the text in the widget does not concur with what you would expect. Windows Forms used to have that on some elements, not all, Cocoa can do this. This can be accomplished by using return values or reference parameters (or pointers) in the callbacks where the callee can communicate back to the originating widget

These days applying styles to ui elements, i.e. changing the look without changing the functionality has also become very popular QT can do this and I am sure a lot of other libraries

The Gang of Four Decorator pattern is also used sometimes for enhancing the capabilities of a widget, making something scrollable could be done via a decorator. It all depends on how far you will need to go with your UI elements. Good Luck, it is not an easy task

EDT: Apply MVC wherever you can. The first candidates are any kind of list displays, don't make them responsible for keeping the items they are displaying. This definitely goes for the combo box, a list box, tables and trees, you could implement this for text inputs but that might not be worth the overhead.

like image 154
Harald Scheirich Avatar answered Nov 11 '22 12:11

Harald Scheirich