Qt? ImGUI? wxWidgets? We write our

Hello, Khabrovites! I want to tell you about my UI system, which I wrote for my game engine, on which I make an editor for it. Like this:

So, for the umpteenth time I started writing the engine, and I firmly decided that this time I would do everything well and correctly. One of these "good and right" is a WYSIWYG editor a la Unity3D. By the way, before that I already had experience in developing such editors on Qt. And by that time I already understood that the task is not easy if I want to make a really good editor. And this requires a very good and flexible UI system in which I will be very well versed and know all sorts of subtleties. Indeed, in such an editor there will be a lot of custom widgets, controls, etc. Therefore, there should be no compromise between the quality of the editor and the capabilities of the system's UI.

UI. .. 2D , (- , , , ..), UI .

" , ?" - .

, , , - . - . . , .

UI :

  • UI-

.

UI- : . . - .

UI - , ..

(): , , , . (draw call), , , . API , - .

- , - . , . : , , .

9-slice . , 9 :

, , , , . , .

- , ? ( ) . , - . - .

, , :

Simple sprite, just stretches
,
9-slice sprite, stretches proportionally
9-slice ,
Shows progress with circular filling
Vertical filling
Horizontal filling
Texture repetition
Preserve aspect ratio and fit

- . , , . .

.

, - .

:

:

  • ,

  • FreeType

, .. . - , . - , , , - . - , -. , , .

, , . . :

. , . : , , , . . , . , , . , "...", .

, .

- . , , .

.

IRectDrawable

, IRectDrawable. , ( 23), , , . IRectDrawable IDrawable ( ) Transform ( 23, Basis).

, Graphic API , , . , UI . , , , . , . , . , , .

. : , . . . , .

, - . -, . . , .

- , .

IDrawable , .

, - . - .

( , touch-screen), , , . . .

. -, , . , . - - . , , .

CursorAreaEventsListener. , . , , . , EventsSystem, CursorAreaEventListenersLayer.

? ? ? . , . , , . - , , , , , .

. , . , , .. . , . , "" , , .

. , , .

, . , , . , . , , . . .. IRectDrawable.

Alternate overlap rendering

, , "" . , , , . - , . , .

, , , , .

. ( , IRectDrawable), IDrawable::OnDrawn(). .

. - Actor, , , , , , Actor'. . - Actor'.

Actor' . , . , , , , Actor'.

UI . , UI - Actor'. Widget.

Widget

"" . Actor , , , , Widget' .

Widgt' WidgetLayout, ActorTransform. , , Actor'.

. . . . , "" , . Unity GUI.

WidgetLayer

Actor', Widget' WidgetLayer. - Widget, IRectDrawable WidgetLayout' WidgetLayerLayout.

, . , .. .

Widget', Widget'. , , . , , .

- Widget', Widget'.

WidgetState

- . , . , .. .

Widget' - WidgetState'. -. - , . . . , . . , . .

. - Actor', Widget', Layout', WidgetLayer' .. , - . , children/0/transform/anchor.

, . ,

  • -

  • -

  • -

  • -

, , ..

Widget', .

Widget'

, Widget' Widget, . . - Widget, . - .

, , . Widget', Widget', "" Widget'. , Widget' .

Layout-Widget'

Widget', Widget'. , HorizontalLayout . VerticalLayout, . GridLayout, .

Combination Horizontal / VerticalLayout
Horizontal/VerticalLayout

Layout' ( , ), , . .

An example of a responsive layout in the options editor

Layout' :

  • Widget'. , .

  • , . Layout', , . ", "

  • . - , ,

  • , WidgetLayout

Widget'

UI , . , Widget . Widget , KeyboardEventsListener, CursorAreaEventsListener.

:

  • Checkbox

  • ,

  • / progress-bar

  • / scroll bar

- , . .

PopupWidget. . . . , . , , : , .

Hierarchical context menu

, .

: anti-aliased

. , OpenGL D3D, , "". .

anti-aliasing'. : , , . , , , .

, . , 8 . . ""

, , , . , , . , . , , . , , 60 .

, . ++ .

Unity3D, . Unity3D " ", , , "", . . , Canvas', , Unity3D.

, , . . , Actor', . - Widget. . .

Widget'

, - Widget', . , . , , . - .

. , API , . , . .

, - Widget , , . - , , .

, Widget' CheckClipping, . : , . , Widget'. - -, . .

Widget' . , , . , .

, . , , .

. , . "" . Widget - , , . Widget' , , . , "" , , . , , , .

, , . , .. .

, ? ? , . , .

:

  • Widget' . Widget'

  • Actor'

UI , . .

6 -. . ImGUI, , "" , .

PS: - 2D , . . , .




All Articles