Why the UI keep flicker? - visual-c++

I have a project which have three dialog, Let's say A, B, C.
And A contain B & C, B contains C.
They all are inherited from a DialogBase class
and have a setBitmap function to set a background image.
And I have add the relationship that every time drag on C, B will drag as well.
and B is a transparent dialog!
When onLbuttonDown is triggered, I will set this
m_pParent->ModifyStyleEx(0, WS_EX_TRANSPARENT); which make that the B dialog is transparent.
The problem is : if i set this, the dialog B is transparent, but when I move the B, it will keep flicker.
But if i comment
m_pParent->ModifyStyleEx(0, WS_EX_TRANSPARENT);
Then the dialog B will not be transparent, but it will not flicker.
Can someone give me a solution ?

WS_EX_TRANSPARENT is a hard style to understand. It probably doesn't do what you think it does.
When you set WS_EX_TRANSPARENT for a window, you're not telling Windows to make it transparent - you're telling Windows that you won't be painting the entire window, so it has to draw the windows underneath before it draws your window. All you're really doing is changing the order of the WM_PAINT messages to the various windows.
You're seeing the flicker every time the dialog A repaints.
If you really need to see parts of dialog A through the background of dialog B, you can do some special processing in your OnLButtonDown. Start by setting the visibility of dialog B off, then create a bitmap, assign it to a DC, and have dialog A draw to that DC. Now you can set dialog B to visible again, and every time you paint it you start by copying the appropriate section of the saved bitmap to the background.

Related

How to create a scalable multi-line button in Godot?

A Button in Godot can only hold a single line of text. I can overcome this limitation by placing RichTextLabel node inside the button.
Now the button can contain more lines of text, but its height doesn't change automatically when more lines are needed. Instead the text just overflows:
Of course I can manually resize the button to be higher, but I'd like this to happen automatically depending on the amount of text inside. Specifically, I'm generating a list of these buttons programmatically and showing inside a HBoxContainer, with some buttons having longer and other shorter text.
Is there a way to achieve this with Godot layout tools?
Since the Button is in a Container, it is in control of its rect_size. The best we can do is specify a rect_min_size. There is no layout preset to have a Control depend on children Control. So, to answer the question as posted: No, we cannot achieve this with Godot layout tools. We need some scripting.
We need to set the rect_min_size for the Button depending on the RichTextLabel. We can ask it for the height of its content with get_content_height. Which also means we need to set the width beforehand. However, it will not update right away when we set the text (we are going to use yield).
Apparently you don't want the Container to control the height of the Button. If that is the case, I think you can remove all the flags from size_flags_vertical.
About the width, since as I was explaining before we need to set the width to get the height… I suggest you let the Container expand the width of the Button as much a posible. Which mean setting both the Fill and Expand flags on size_flags_horizontal.
Then, with the RichTextLabel properly set to take as much width of the parent Button as possible, you can read it height, and use it to set the height of the rect_min_size of the Button.
One more thing: you want to set the mouse filter of the RichTextLabel to Ignore or Pass, or it will prevent pressing the Button.
This is the code I came up with:
var b := Button.new()
b.size_flags_vertical = 0
b.size_flags_horizontal = SIZE_EXPAND_FILL
add_child(b)
var l := RichTextLabel.new()
l.mouse_filter = Control.MOUSE_FILTER_IGNORE
l.set_anchors_and_margins_preset(Control.PRESET_WIDE)
l.text = "Some\nMultiline\nText"
b.add_child(l)
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
I'd like this to happen automatically depending on the amount of text inside
Sadly changing the text does not resize, nor change the minimum size of the RichTextLabel. And RichTextLabel does not have a "text changed" signal. Nor "bbcode text changed" signal. Furthermore, it might not be feasible to intercept these properties (see append_bbcode et.al). It is proabaly easier to do with a regular Label.
Anyway, what I'm going to suggest for this is to make a Control that wraps the RichTextLabel, offers whatever interface you actually need, and in any method where you change the text, afterwards, you do the equivalent of this:
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
(Godot 3.x)
Without using scripting, it is also possible to achieve the same goal by wrapping both nodes as sibilings within a container, for example a MarginContainer. Enable the RichTextLabel's fit_content_height property, which will result in the label expanding the container's area as much as necessary, which will in turn resize the Button.

CView inplace editing of control layout

I have a CView that acts as a placeholder for several Ctrl's stacked vertically so as the occupy all available space. What I wish to do is grab a horizontal boundary with the mouse and drag it up or down to resize Ctrl height.
The problem being that the child Ctrl's of the CView intercept the mouse messages and not the CView parent window (WM_LBUTTONDOWN, WM_MOUSEMOVE etc). The Ctrl's also handle these messages for unrelated editing requirements.
Would anyone be able to offer advice or supply a reference to possible solution(s) to this sizing/editing requirement. The situation is some what similar to the resource editor in Visual Studio. Only I wish to edit in a live environment.
I think this could easily be done as follows:
Leave a small gap between the child controls (say 2 or 3 pixels). This could be drawn in the same color, or a slightly different shade.
Set the cursor to IDC_SIZENS for the main CView.
Handle the mouse messages (when the mouse is over that gap) in the main CView (down, move, ..).
On 'dragging' resize the child controls.
That way all messages would still go to te child controls, except when the mouse is above those 2 to 3 pixel 'splitters'.
If leaving a small gap is really no option, than you would have to capture all mouse messages in the CView and check if they are on a border. If not, forward (or default) them to the child window below the mouse cursor.

Cadence Virtuoso Layout L phantom objects

I have a cell (call it A) which is used once in a hierarchically higher cell (call it P). When I place A in P, its borders are rather larger than the actual content of A. When I descend to A and zoom-fit, it is way zoomed out, indicating there is something present way out on the edges.
I may have dragged objects there at one point but currently there is nothing visible. It is driving me crazy in terms of aligning objects, etc.
Is there any way to clean this up or something?
If I recall Cadence used to have a problem with leaving steiners behind when you moved routes. They are not visible but the db treats them as real objects for the bbox calculation. According to Cadence, deleting the objects should not harm anything. Open the layout in edit mode and paste this code into the CIW. This will delete all the steiner objects in your layout. If this was the root cause after saving you should see the bbox return to normal.
cv=geGetEditCellView()
foreach( item cv~>steiners
dbDeleteObject( item )
)
This thread may be considered "dead," but hopefully this helps.
It is possible the layers that are not visible are turned off.
To turn them on, go to the layers pane on the left. (If it is not there you can turn it on by going to Window —> Assistants —> Layers)
You can then click the drop down arrow in the top right corner and click Edit Valid Layers.
Then, click all valid in the Set Valid Layers popup. Click Ok.
Finally, check the Used Layers Only checkbox in the Layers pane. Look for any layers that weren't there before that you don't need.
Usually it happens when you draw the cell in LayoutXL, particularly when you insert pins.
Layer and purpose in these pins are selected separately for some reason, that is why it is easy to enter "impossible" combination.
Nothing happens, then you do it again and continue drawing. But there are several invisible squares that will continuously frustrate your inner perfectionist. You do the following:
Open this cell's layout, switch to Virtuoso window and enter:
lppList=list()
then:
foreach(shape hiGetCurrentWindow()~>cellView~>shapes if( (member(shape~>lpp lppList)==nil) then lppList=cons(shape~>lpp lppList)))
You have created the list with all layers in this layout, you can view it by entering:
lppList
You'll get something like this:
(("NW" "drawing")
("NP" "drawing")
("weird" "guy")
("M1" "pin")
("M3" "pin")
)
If you find a weird guy in this company, just enter the following command:
foreach(shape hiGetCurrentWindow()~>cellView~>shapes if((shape~>lpp == list("weird" "guy")) shape~>lpp = list("prBoundary" "drawing")))
If you see that some squares, labels (or whatever unseen before) appears as prBoundary, just delete it, save, and your layout will be small and shiny again.

coded ui : mouse hover fails on different machine

I have recorded a test, in which mouse hover over a link.
on the same machine(say m/c A), where i recorded the test, mouse hovers over the link correctly.
But when running the same test on different machine(say m/c B), mouse hovers fails.
Since link doesn't have ID associated with it. It takes the co-ordinates and inner text as search property.
Tried recording mouse hover in m/c B, mouse correctly hovers over the link.
How to make sure that same test will run in different m/cs?
Thanks,
Kiran
Try This
When you record It records coordinates of the link in designer file
(Eg:Mouse.Hover(linkObj,(12,8))), After moving the recorded method to .cs file remove the coordinates and run the test.

When two CCMenuItem overlaps each other, is it possible to prioritise one over the other?

I have 2 CCMenuItems A and B
A is a screen-wide transparent button
and B is an actual button that is set to visible when A is touched
Currently, when I'm touching B, A responds with it's selector method and basically B does not respond because the touch is 'taken' by A's selector.
I need B to be responding even though A is a screen-wide button so- Is it possible to prioritise B's selector when it is pushed?
To summarize, I'm toggling B's visibility via A and would like to be able to use B when it is visible.
Is this possible? How can it be done?
for me worked adding one menu in one layer and another menu in other layer
I)
Yes, You can prioritize your CCMenuItems by setting Z-Order.
First button that gets touch is the button with lowest Z-Order.
II)
And if you want to prioritize your CCMenus, you need to setTouchPriority(..) them.
The less priority you give, the earlier your CCMenu will handle the touch. (CCMenu's default value is -128 ).
Either you can set the buttons yourButton.isEnabled to NO or you can just move the A-button off the scene when you don't want it to take input.
It's possible to use an additional CCMenu with a higher z-order for the button B.

Resources