How to use ResizerWidget in Dlangui app..?

Rémy Mouëza remy.moueza at gmail.com
Thu Jan 2 05:24:33 UTC 2020


On Monday, 30 December 2019 at 23:32:37 UTC, ShadoLight wrote:
> Hi,
>
> I suspect I'm missing something obvious, but ResizerWidget is 
> not working for me on Windows - it shows the 'dragging'-cursor 
> when hovering the mouse on the ResizerWidget, but dragging with 
> the left mouse button does nothing.
>

I ran into the same issue. The resizeEvent callback is not 
implemented yet. Below is my custom implementation.


/** A completed resizer widget.
   As of 2016-12-30, the ResizerWidget does not work out of the 
box.
   This class implement the missing piece.
  */
class Resizer : ResizerWidget {

     /// Default initialization.
     this () {
         super ();
         initResizeCb ();
     }

     /// Create with ID parameter.
     this (string ID, Orientation orient = Orientation.Vertical) {
         super (ID, orient);
         initResizeCb ();
     }

     /// Initialize the resize on drag behaviour callback.
     protected void initResizeCb () {
         this.resizeEvent
             = (ResizerWidget source,
                ResizerEventType event,
                int currentPosition)
         {
             if (event != ResizerEventType.Dragging) {
                 return;
             }

             if (_orientation == Orientation.Horizontal) {
                 auto delta = _previousWidget.width - 
currentPosition;
                 auto pw    = max (0, _previousWidget.width - 
delta);
                 auto mw    = max (0,     _nextWidget.width + 
delta);

                 _previousWidget
                     .minWidth (pw)
                     .maxWidth (pw);

                 _nextWidget
                     .minWidth (mw)
                     .maxWidth (mw);
             }
             else if (_orientation == Orientation.Vertical) {
                 auto delta = _previousWidget.height - 
currentPosition;
                 auto pw    = max (0, _previousWidget.height - 
delta);
                 auto mw    = max (0,     _nextWidget.height + 
delta);

                 _previousWidget
                     .minHeight (pw)
                     .maxHeight (pw);

                 _nextWidget
                     .minHeight (mw)
                     .maxHeight (mw);
             }

             parent.requestLayout ();
         };
     }
}





More information about the Digitalmars-d-learn mailing list