Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent DockPanel resizing when parent from resizes #92

Closed
a-yumashin opened this issue Feb 4, 2013 · 14 comments
Closed

Prevent DockPanel resizing when parent from resizes #92

a-yumashin opened this issue Feb 4, 2013 · 14 comments
Labels

Comments

@a-yumashin
Copy link

Hi,

How can I prevent DockPanel resizing when parent from resizes?
For example, I start my form in normal state (it occupies about half of the screen) and then open my bottom DockPanel "Output" - the latter has height, say, 100 (nominal units).
Then - with "Output" DockPanel still open - I maximize my form; DockPanel's height grows from 100 to, say, 120. But I want its height to remain unchanged. How can I do this?

Thank you.

@a-yumashin
Copy link
Author

Up!

@a-yumashin
Copy link
Author

Can anybody help?

@lextm
Copy link
Member

lextm commented Feb 28, 2013

It is currently marked as a bug. Patch is welcome.

@a-yumashin
Copy link
Author

Hi,
any patch available?

@roken
Copy link
Member

roken commented Mar 14, 2013

The current design is that all panes maintain their original width in terms of a percentage rather than by pixel value. I'm sure this decision was originally made to simplify the resizing logic.

This issue will remain open to improve the existing behavior. I believe it should work as follows:

  • Content docked "Document" will resize percentage based.
  • Content docked in a FloatWindow will resize percentage based.
  • Content docked Left or Right will remain fixed width with percentage based height resize.
  • Content docked Top or Bottom will remain fixed height with percentage based width resize.

@a-yumashin
Copy link
Author

Can you suggest a workaround?

@lextm
Copy link
Member

lextm commented Mar 22, 2013

So far, there is no workaround.

@ldn4711
Copy link

ldn4711 commented Apr 2, 2013

I have found the location where the hide window rectangle is being calculated which finally sets the size of the window in the auto hide mode. it's in Dockpanel.AutohideWindow.cs at get of property AutoHideWindowRectangle. There we do have if/else if sections differing between the different docking areas. There the code currently uses ActiveAutoHideContent.DockHandler.AutoHidePortion as a proportion factor for the percentage of the dock window size relative to the parent window. That factor is the same for all docking positions.
As we have docking area related handling there anyway, why not using the DockLeftPortion and the other specific factors/pixelwitdh/height values? Could there be any side effects?
Okay we would lose idependent sizing of dock and autohide modes (which would be fine with me). Alternatively we could introduce another property for setting a locking of the hidemode size with the normal dock mode size.
That'll complicate things a little, but that's also the normal cost of increased flexibility anyway.

@ldn4711
Copy link

ldn4711 commented Apr 3, 2013

I have a suggestion for changing the behaviour as mentioned above and would like to ask the maintainers to check and comment if that's a reasonable solution for I have by far not the full overview over the entire framework:

In file DockPanel.AutoHideWindow.cs, property AutoHideWindowRectangle I have added 'autoHideSize = DockLeftPortion;' into the if block and the set 'autoHideSize' to other values in the other if block respectively.

            if (state == DockState.DockLeftAutoHide)
            {
              autoHideSize = DockLeftPortion;

(commented line are the original lines, uncommented lines are the suggested lines)
In file DockPanel.AutoHideWindow.cs, function void ISplitterDragSource.MoveSplitter(int offset):
//if (content.DockHandler.AutoHidePortion < 1)
// content.DockHandler.AutoHidePortion += ((double)offset) / (double)rectDockArea.Width;
//else
// content.DockHandler.AutoHidePortion = Width + offset;
if (content.DockHandler.DockPanel.DockLeftPortion < 1)
content.DockHandler.DockPanel.DockLeftPortion += ((double)offset) / (double)rectDockArea.Width;
else
content.DockHandler.DockPanel.DockLeftPortion = Width + offset;

Same applies with the other code blocks of the same function with the other values such as DockRightPortion etc.

with these two functions modified, I do get the wanted behaviour. The desired behaviour yet does only become active only when you initialize the DockLeftPortion, DockRightPortion, etc. with values larger than 1.

Yet the suggestion remains to be evaluated by those who have more profound knowledge about the details of the framework.
I hope this thing gets solved soon as I wouldn't want to divert from codebase developed here.

@lextm
Copy link
Member

lextm commented Apr 3, 2013

The best way is to fork, hack, and share with us a pull request.

@ldn4711
Copy link

ldn4711 commented Apr 3, 2013

Sorry guys,

I have some trouble doing that with IE8, moreover I have no admin priviledges to do an upgrade. Firefox got filtered out in some way with https.

Therefore, all I can do is dropping the code fragments right here. By the way, I have done the following modifications based on version 2.7 in these two functions:

in file DockPanel.AutoHideWindow.cs I have modified the following functions:

    internal Rectangle AutoHideWindowRectangle
    {
        get
        {
            DockState state = AutoHideWindow.DockState;
            Rectangle rectDockArea = DockArea;
            if (ActiveAutoHideContent == null)
                return Rectangle.Empty;

            if (Parent == null)
                return Rectangle.Empty;

            Rectangle rect = Rectangle.Empty;
            double autoHideSize = ActiveAutoHideContent.DockHandler.AutoHidePortion;
            if (state == DockState.DockLeftAutoHide)
            {
              autoHideSize = DockLeftPortion;
                if (autoHideSize < 1)
                    autoHideSize = rectDockArea.Width * autoHideSize;
                if (autoHideSize > rectDockArea.Width - MeasurePane.MinSize)
                    autoHideSize = rectDockArea.Width - MeasurePane.MinSize;
                rect.X = rectDockArea.X;
                rect.Y = rectDockArea.Y;
                rect.Width = (int)autoHideSize;
                rect.Height = rectDockArea.Height;
            }
            else if (state == DockState.DockRightAutoHide)
            {
              autoHideSize = DockRightPortion;
                if (autoHideSize < 1)
                    autoHideSize = rectDockArea.Width * autoHideSize;
                if (autoHideSize > rectDockArea.Width - MeasurePane.MinSize)
                    autoHideSize = rectDockArea.Width - MeasurePane.MinSize;
                rect.X = rectDockArea.X + rectDockArea.Width - (int)autoHideSize;
                rect.Y = rectDockArea.Y;
                rect.Width = (int)autoHideSize;
                rect.Height = rectDockArea.Height;
            }
            else if (state == DockState.DockTopAutoHide)
            {
              autoHideSize = DockTopPortion;
                if (autoHideSize < 1)
                    autoHideSize = rectDockArea.Height * autoHideSize;
                if (autoHideSize > rectDockArea.Height - MeasurePane.MinSize)
                    autoHideSize = rectDockArea.Height - MeasurePane.MinSize;
                rect.X = rectDockArea.X;
                rect.Y = rectDockArea.Y;
                rect.Width = rectDockArea.Width;
                rect.Height = (int)autoHideSize;
            }
            else if (state == DockState.DockBottomAutoHide)
            {
              autoHideSize = DockBottomPortion;
                if (autoHideSize < 1)
                    autoHideSize = rectDockArea.Height * autoHideSize;
                if (autoHideSize > rectDockArea.Height - MeasurePane.MinSize)
                    autoHideSize = rectDockArea.Height - MeasurePane.MinSize;
                rect.X = rectDockArea.X;
                rect.Y = rectDockArea.Y + rectDockArea.Height - (int)autoHideSize;
                rect.Width = rectDockArea.Width;
                rect.Height = (int)autoHideSize;
            }

            return rect;
        }
    }




        void ISplitterDragSource.MoveSplitter(int offset)
        {
            Rectangle rectDockArea = DockPanel.DockArea;
            IDockContent content = ActiveContent;
            if (DockState == DockState.DockLeftAutoHide && rectDockArea.Width > 0)
            {
              if (content.DockHandler.DockPanel.DockLeftPortion < 1)
                content.DockHandler.DockPanel.DockLeftPortion += ((double)offset) / (double)rectDockArea.Width;
              else
                content.DockHandler.DockPanel.DockLeftPortion = Width + offset;
            }
            else if (DockState == DockState.DockRightAutoHide && rectDockArea.Width > 0)
            {
              if (content.DockHandler.DockPanel.DockRightPortion < 1)
                content.DockHandler.DockPanel.DockRightPortion -= ((double)offset) / (double)rectDockArea.Width;
              else
                content.DockHandler.DockPanel.DockRightPortion = Width - offset;
            }
            else if (DockState == DockState.DockBottomAutoHide && rectDockArea.Height > 0)
            {
              if (content.DockHandler.DockPanel.DockTopPortion < 1)
                content.DockHandler.DockPanel.DockTopPortion -= ((double)offset) / (double)rectDockArea.Height;
              else
                content.DockHandler.DockPanel.DockTopPortion = Height - offset;
            }
            else if (DockState == DockState.DockTopAutoHide && rectDockArea.Height > 0)
            {
              if (content.DockHandler.DockPanel.DockBottomPortion < 1)
                content.DockHandler.DockPanel.DockBottomPortion += ((double)offset) / (double)rectDockArea.Height;
              else
                content.DockHandler.DockPanel.DockBottomPortion = Height + offset;
            }
        }

@lextm
Copy link
Member

lextm commented Apr 4, 2013

I have created a new branch and made the suggested changes,

https://github.com/dockpanelsuite/dockpanelsuite/tree/gh92

We might perform necessary review on the changed behaviors and see if it is ok to be included in either 2.8 or 3.0.

@roken
Copy link
Member

roken commented Apr 13, 2013

Visual studio maintains independent sizes for the docked and autohide states (which I find useful), so we shouldn't give up that functionality. It's handy to be able to give the autohide windows different sizes.

@roken
Copy link
Member

roken commented Apr 14, 2013

I don't believe a bug exists with the core of these questions (there's a little bit of funny business being handled by another issue).

By default, the left/right/top/bottom dock areas of the DockPanel are defined to take up 25% of the total width (for left/right) or height (for top/bottom). This is defined by the four properties:

  • DockPanel.DockBottomPortion
  • DockPanel.DockLeftPortion
  • DockPanel.DockRightPortion
  • DockPanel.DockTopPortion

If the value is less than 1, the sizing will be treated in percentage terms (ie, 0.25 is use 25% of the available size).
If the value is greater than or equal to 1, the sizing will be treated in absolute terms (ie, 100 is 100px).

The description of these properties in the designer explain this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants