Gallery of UIs written in MQL - page 70

 

Topic 14.3: Indicating dangerous values by flashing parts of elements (frames, bases, text, sliders and slider boards).

Flashing of elements is an excellent addition to the colour indication signalling the transition of parameters into the zone of dangerous values. The implementation of the new solution is similar to the previous one, but if the colour indication works according to the principle that the closer the value is to the critical value, the brighter the colour, the blinking only increases the frequency of change of the initial colour with the colour set for blinking. The user can programmatically adjust the flashing delay, gradually decreasing it to 25ms or increasing it to 2.5 seconds. In this case, both mechanisms can be operated simultaneously. The colour shifts from light green to bright red and burgundy and, and the flashing increases in speed. One mechanism does not interfere with the second. Next, we'll break down practical examples.

*Important: the flashing is activated independently of the colour indication functions. The two mechanisms are technically unrelated and can work in parallel or separately.

To implement blinking, new properties have been added to interactive elements:

  • pn_BLINK_frame -. Frame blinking Added to all controls that have a frame. The following elements are excluded: H_SLIDER, V_SLIDER, VALUE , R_BUTTON, CHECKBOX.
  • pn_ BLINK_text - Blinking text Added to all elements that have text. Excluded are elements: P_BAR, D_BAR, H_SLIDER, V_SLIDER.
  • pn_BLINK_base - Blink base Added to all elements that have a base. The following elements are excluded: CHECKBOX, R_BUTTON, D_LIST, C_LIST, VALUE.
  • pn_BLINK_bar - Blinkingbar. Added to items with a bar: P_BAR , D_BAR,H_SLIDER, V_SLIDER.
  • pn_BLINK_handle - Blinking of slider. Added to H_SLIDER, V_SLIDER sliders .


Added new properties to control speed and stop of blinking:

  • pn_BLINK_DELAY - Blink Delay. Added to all main elements without exception. * Important - the delay is set for all flashing parts of the element and cannot differ from one part to another. All parts of the element with software enabled flashing (there can be several of them) will flash synchronously. However, the blinking speed between elements may differ and this is entirely at the user's discretion.
  • pn_BLINK_STOP Thecommand that completely stops flashing of all components of the element.
  • At the current stage, it is possible to enable blinking of the settings window frame. To do this, you need to call the window function and pass the identifier of the pn_BLINK_frame property to it . And the colour. Everything is exactly the same as for elements.

Let's summarise the above:

  • The blink delay pn_BLINK_DELAY is set programmatically and is applied to all blinking parts of the element at once. They flash synchronously.
  • The pn_BLINK_DELAY property has a default value. Unless explicitly specified by the user, the blink delay will be 20, which is just over a second (20*25ms).
  • An element can have flashing of several parts at once, or one part at a time. The decision is made by the user.
  • In the process of flashing it is possible to programmatically change the colour and adjust the speed. The blinking functions will be discussed below.
  • To make another part of the element blink you need to call the function and pass the identifier of the element part and the colour. But if, for example, a frame is blinking and the user wants the text to flash at the desired value, and the frame stops blinking, it is necessary to switch off blinking completely using the pn_BLINK_STOP command, and then switch on text blinking by a program call.
  • At the user's request, the components of the element can blink in different colours. For example, the text can be set to flash in green, the frame in blue, and the base in red. Different variations are available. But let me remind you: the blinking speed of all parts within an element is the same.
  • If a window is minimised and its tab is on Taskbar, and there are blinking elements in the window, the tab will automatically select the fastest blinking element in the closed window (there is no actual redrawing when the window is closed) and adjust to its frequency and colour. That is, the tabs on Taskbar flash the colour and speed of the fastest flashing element in their window. But if elements change their blinking speed while receiving values, then the tab will automatically rebuild itself by finding another element and changing its blinking speed and colour.
  • In case of complete disabling of blinking of elements in the window, the tab stops blinking automatically.

Tomorrow we will move on to practical examples.

Today just a small demo to understand what we are talking about.



Unfortunately, there are lags when recording. The processor is loaded. But the demo shows that elements flash asynchronously and at different speeds. Different parts of the elements are also flashing. All this is set programmatically. And the tab on Taskbar automatically found the fastest blinking element and turned blue. Then, when the element started blinking less often, it found the other fastest blinking element and became red.

We'll explore this in more detail tomorrow.

P.S. We will also discuss options for using these very useful features.