TCategoryPanelGroup not repainting Panels on collapse when using styles - themes

I'm using the style "Charcoal Dark Slate" right out of the box and having issues with the TCategoryPanelGroup not refreshing its category panels.
In this setup all category panels all expanded.
Each panel has ONE control, a TFrame with a few child controls. The TFrame has its Align property set to alClient.
If I collapse the middle one, every following panel isn't redrawing all controls. I have to move the mouse over them to get them redrawn. If I collapse the first panel, panel 2 and 3 aren't redrawn etc... (basically all panels that moved up)
I have tried to Invalidate(), Repaint() and Refresh() the TCategoryPanelGroup on the collapse event OnCollapse. I have also tried to Invalidate(), Repaint() and Refresh() the panel itself in desperation. Nothing helps.
I noticed that all panels are repainted on resize. My workaround now is to have the OnCollapse and OnExpand event handlers to quickly resize the TCategoryPanelGroup control.
void __fastcall TGraph_Form::CategoryPanelCollapse(TObject *Sender) {
TCategoryPanel *p = reinterpret_cast<TCategoryPanel*>(Sender);
TCategoryPanelGroup *g = reinterpret_cast<TCategoryPanelGroup*>(p->PanelGroup);
// Fix style bug on collapse events
// Force a resize to redraw all panels
g->Width++;
g->Width--;
}
Adjusting the Height property of the TCategoryPanelGroup will not force all panels to redraw, it has to be the Width property.
Have I missed something here or is this indeed another VCL style bug?

Related

Disable Transparency on NSPopover for Certain Controls

I have a selectable color palette made up of a bunch of NSButtons. I overload the drawRect function in order to draw the buttons as a central colored circle along with a border that indicates if the button is selected (using NSBezierPath fill and stroke). This all works great, until I place the palette on a NSPopover, which causes the buttons to be drawn partially transparent. Now my colors in the buttons change depending on what's beneath the popover. It's very noticeable for the black button (lower left corner).
Is there a way to disable the transparency for just the center of the button on the popover, without disabling it completely for all controls?
I figured this out - overriding the allowsVibrancy property of the button to return NO disables the transparency effect.
Objective-C:
- (BOOL)allowsVibrancy {
return NO;
}
Swift:
override var allowsVibrancy: Bool { return false }

How to make NSPopover properly follow the mouse pointer and ignore mouse events?

I would like to display an informational NSPopover that tracks the user's mouse cursor.
For this, I am using an NSTrackingArea to update the popover's positioningRect whenever the mouseMoved event fires.
However, this has two drawbacks:
The popover follows the mouse with a slight delay. How can I reduce this delay to make the popover appear more "glued" to the mouse pointer?
When I move the mouse pointer in the direction of the popover, the tracking area's mouseExited method gets called, which causes the popover to "absorb" the mouse movement events, so that the tracking area's mouseMoved event no longer fires. How can I avoid the popover absorbing the mouse events, or at least keep forwarding these events?
This question is very similar to Any way around this NSTrackingArea quirk?, with the distinction that I am using NSPopover, so I have nothing to set ignoresMouseEvents on.
I took a look at your problem. I was not able to eliminate the lag, but it might reduce if you set popover.animates to false.
Wrong approach:
I was able to solve the mouseExited over popover issue by adding a new border (and shadowless) window on top of the other one. The trackingArea is added to the transparent window, the popover to the original one. Depending on the transparent windows level, it is above the popover and therefore they can't interfere with each other.
In the gif below you can see the results of my tests:
Here is some of my code:
The mouse tracking:
override func mouseMoved(with event: NSEvent) {
let location = self.view.convert(event.locationInWindow, from: nil)
popover.positioningRect.origin.x = location.x
popover.positioningRect.origin.y = location.y
}
The custom window:
transparentWindow.backgroundColor = NSColor.clear
transparentWindow.isOpaque = false
transparentWindow.styleMask = .borderless
transparentWindow.makeKeyAndOrderFront(nil)
Update 11/11/2016:
I just read the question in the link you provided. There is a window to set ignoresMouseEvents on. Even though NSPopover inherits from NSObject, you have a contentViewController, which holds an view object, which holds the popovers window. (as explained here)
So simply set
popover.contentViewController?.view.window?.ignoresMouseEvents = true
after the popover is shown.

WM_NCCALCSIZE, custom client area, and scroll bars

I have an MFC app that embeds a Scintilla text edit control. I want to customize the Scintilla control to display some custom controls next to the vertical scrollbar. Essentially, I want to render some controls in the orange area below, where the green area represent the scroll bars:
I tried overriding the WM_NCCALCSIZE message of the Scintilla window and subtracting an offset from the right side of the client rectangle. Here is the code:
void CScintillaCtrl::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
lpncsp->rgrc[0].right -= 100;
}
However, this causes the vertical and horizontal scroll bars to reposition themselves to account for the smaller client width, as shown below:
I'm not sure if this behavior is caused by Scintilla or Windows. Is there a way I can adjust the client area and preserve the positions of the scroll bars?
I found a Scintilla specific solution. I can use the SCI_SETMARGINRIGHT command to add a margin to the right side of the client area, and then render my controls inside that.

VSTO in Powerpoint: Changing custom task pane visibility in WindowSelectionChange moves selected shape

I think I have found a bug.
I am developing a add-in for Powerpoint 2010. The event WindowSelectionChange is fired when a shape (e.g. a picture) is selected/deselected.
However, if I use this event to change the Visibility property of a Custom Task Pane, then the shape moves left/right on the slide. Example:
Private Sub Application_WindowSelectionChange(Sel As Microsoft.Office.Interop.PowerPoint.Selection) Handles Application.WindowSelectionChange
cTaskPane.Visible = Not cTaskPane.Visible
End Sub
I have tried to monitor the Left property of the shape, and that does not change from the beginning to the end of the WindowSelectionChange sub. Thus, it must happen afterwards.
How can I avoid this?
Any workaround?
It's because your mouse is holding the shape, and the shape gets moved to the right when the window is shrunk.
In more detail, the moving occurs in 4 steps:
You press mouse, caused window selection change, then the pane becomes visible, which makes the slide view window shrink;
Since the slide view window shrunk while your mouse's position remains to be the same, your mouse is moved right w.r.t the slide;
Since your mouse is pressing, the shape is anchored with your mouse, thus move to the current position of the mouse;
When pane becomes invisible again, the slide view window changes its size back, the shape is moving accordingly again.
To avoid this, I suggest you use WindowSelectionChange event and check if the selection is shape (code is in c#):
private void WindowSelectionChangedHandler(PowerPoint.Selection selection)
{
if (selection.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
{
//do your stuff
}
}

jquery layout and dynamic draggable div issue

I am using jquery layout plugin and have the following situation that I cannot find a solution. How do I make the center pane increase its size permanently by dragging the div beyond the bottom border.
I have a left pane and a center pane. I dynamically generate div
when the user clicks on the left pane. The divs are generated and
dropped on the center pane. The divs are draggable and resizable.
Everything works fine with dragging and resizing on the visible center
area. The moment I drag the div beyond the bottom, the scroll bar on
the center pane appears and it seems the center pane is extending to
accommodate the new position of the dragged div. But the moment I try
to resize the div or add another div, it jumps to the top section of
the div and resets the scrollbars. I checked the center div height in
firebug and it remains at the same height when initialized
even after dragging the new div beyond the bottom.
Here is the test page html code.
Just copy/paste entirely into a html page. On the left pane, click on the "Add new" button will add new div that is draggable and resizable.
Click on "Add new"
Drag the newly added div beyond the bottom of the center pane.
The center pane shows the scrollbar as it is suppose to.
If you check the center div's height in firebug, it is not changing
Now try resizing the newly added div by dragging its handle
It jumps to the top and the center box loses its scrollbar.
I could not paste the complete html page so here is the reference to the code at the bottom of this thread
http://groups.google.com/group/jquery-ui-layout/browse_thread/thread/ca922aa44c0048ee
And here is the test link http://jsfiddle.net/yZc63/
I am surprised no one has come across this situation before? Even without the layout plugin, my solution is not very pretty. In order to simulate the page without the layout plugin, I had to keep the top and the left pane using position:fixed property in css. And there is no center div at all. I add the new div directly to the body of the html. The reason is I don't want to see additional scrollbars on top the browser scrollbars. In other words the center pane should scroll when the browser scrollbars are moved. I am attaching the solution so you have an idea.
I am open to any solution even without the layout plugin if i can simulate the previous attached file using any other approach. i am attaching my page without the layout plugin but am not sure if that is the only elegant solution left.
You can check the solution here http://jsfiddle.net/c7wrT/
Is adding the dynamic div directly to the html body a good approach?
I ran into same situation and this answer helped.
https://stackoverflow.com/a/33004821/2139859. Updated Fiddle: http://jsfiddle.net/bababalcksheep/yZc63/11/
$(".removalbe-recom").draggable({
appendTo: "body",
helper: "clone",
revert: "invalid",
cursor: "move",
containment: "document",
zIndex: 10000,
scroll:false,
start: function (event, ui) {
$(this).hide();
},
stop: function (event, ui) {
$(this).show();
}
});

Resources