• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Cpper
            C/C++高級工程師 Android高級軟件工程師 IT集成工程師 音頻工程師 熟悉c,c++,java,c#,py,js,asp等多種語言 程序猿
            import QtQuick 2.4

            Rectangle
            {
                id: dragBackground
                visible: 
            true
                color: 
            "#dad1db"
                width:
            720
                height:
            480

                DragRectangle
                {
                    z: 
            10
                    id:dragRectangle
                    width: 
            480
                    height:
            240

                    Component.onCompleted:
                    {
                         dragBackground.makeViewCenter(dragRectangle)
                    }
                }

                
            function makeViewCenter(view)
                {
                    
            var cx = (width-view.width)*0.5
                    
            var cy = (height-view.height)*0.5
                    view.x 
            = cx
                    view.y 
            = cy
                }
            }

            Rectangle
            import QtQuick 2.0

            Rectangle
            {
                id:resizeRectangle
                property int enableSize: 12
                property bool isPressed: false
                property point customPoint
                color: "#00debff3"
                border.color: "#d37e49"
                readonly property int minWidth: 64
                readonly property int minHeight: 64

                MouseArea
                {
                    id: mouseArea
                    anchors.fill: resizeRectangle
                    drag.target: parent

                    onWheel:
                    {
                        var diff_w = 0.0
                        var diff_h = 0.0

                        if(wheel.angleDelta.y > 0)
                        {
                            diff_w = resizeRectangle.width * 0.02
                            diff_h = resizeRectangle.height * 0.02
                        }
                        else if(wheel.angleDelta.y < 0)
                        {
                            diff_w = -resizeRectangle.width * 0.02
                            diff_h = -resizeRectangle.height * 0.02
                        }
                        else
                        {
                            resizeRectangle.width = width
                            resizeRectangle.height = height
                        }

                        fixedRetangle(diff_w,diff_h)

                        drag.minimumX = 0
                        drag.maximumX = dragBackground.width - resizeRectangle.width
                        drag.minimumY = 0
                        drag.maximumY = dragBackground.height - resizeRectangle.height
                    }
                }

                Item
                {
                    id: leftTop
                    width: enableSize
                    height: enableSize
                    anchors.left: parent.left
                    anchors.top: parent.top

                    MouseArea
                    {
                        anchors.fill: parent
                        hoverEnabled: true

                        onPressed: press(mouse)
                        onEntered: enter(1)
                        onReleased: release()
                        onPositionChanged: positionChange(mouse, -1, -1)
                    }
                }

                Item
                {
                    id: top
                    height: enableSize
                    anchors.left: leftTop.right
                    anchors.right: rightTop.left
                    anchors.top: parent.top

                    MouseArea
                    {
                        anchors.fill: parent
                        hoverEnabled: true

                        onPressed: press(mouse)
                        onEntered: enter(2)
                        onReleased: release()
                        onMouseYChanged: positionChange(Qt.point(customPoint.x, mouseY), 1, -1)
                    }
                }

                Item
                {
                    id: rightTop
                    width: enableSize
                    height: enableSize
                    anchors.right: parent.right
                    anchors.top: parent.top

                    MouseArea
                    {
                        anchors.fill: parent
                        hoverEnabled: true

                        onPressed: press(mouse)
                        onEntered: enter(3)
                        onReleased: release()
                        onPositionChanged: positionChange(mouse, 1, -1)
                    }
                }

                Item
                {
                    id: left
                    width: enableSize
                    anchors.left: parent.left
                    anchors.top: leftTop.bottom
                    anchors.bottom: leftBottom.top

                    MouseArea
                    {
                        anchors.fill: parent
                        hoverEnabled: true

                        onPressed: press(mouse)
                        onEntered: enter(4)
                        onReleased: release()

                        onMouseXChanged: positionChange(Qt.point(mouseX, customPoint.y), -1, 1)
                    }
                }

                Item
                {
                    id: center
                    anchors.left: left.right
                    anchors.right: right.left
                    anchors.top: top.bottom
                    anchors.bottom: bottom.top

                    MouseArea
                    {
                        anchors.fill: parent
                        property point clickPos

                        onPressed: clickPos = Qt.point(mouse.x,mouse.y)
                        onPositionChanged:
                        {
                            if(pressed)
                            {
                                var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
                                resizeRectangle.x += delta.x
                                resizeRectangle.y += delta.y
                                fixedRetangle(0,0)
                            }
                        }
                    }
                }

                Item
                {
                    id: right
                    width: enableSize
                    anchors.right: parent.right
                    anchors.top: rightTop.bottom
                    anchors.bottom: rightBottom.top

                    MouseArea
                    {
                        anchors.fill: parent
                        hoverEnabled: true

                        onPressed: press(mouse)
                        onEntered: enter(6)
                        onReleased: release()
                        onMouseXChanged: positionChange(Qt.point(mouseX, customPoint.y), 1, 1)
                    }
                }

                Item
                {
                    id: leftBottom
                    width: enableSize
                    height: enableSize
                    anchors.left: parent.left
                    anchors.bottom: parent.bottom

                    MouseArea
                    {
                        anchors.fill: parent
                        hoverEnabled: true

                        onPressed: press(mouse)
                        onEntered: enter(7)
                        onReleased: release()
                        onPositionChanged: positionChange(mouse, -1, 1)
                    }
                }

                Item
                {
                    id: bottom
                    height: enableSize
                    anchors.left: leftBottom.right
                    anchors.right: rightBottom.left
                    anchors.bottom: parent.bottom

                    MouseArea
                    {
                        anchors.fill: parent
                        hoverEnabled: true

                        onPressed: press(mouse)
                        onEntered: enter(8)
                        onReleased: release()
                        onMouseYChanged: positionChange(Qt.point(customPoint.x, mouseY), 1, 1)
                    }
                }

                Item
                {
                    id:rightBottom
                    width: enableSize
                    height: enableSize
                    anchors.right: parent.right
                    anchors.bottom: parent.bottom

                    MouseArea
                    {
                        anchors.fill: parent
                        hoverEnabled: true

                        onPressed: press(mouse)
                        onEntered: enter(9)
                        onReleased: release()

                        onPositionChanged: positionChange(mouse,1,1)
                    }
                }

                function fixedRetangle(dx,dy)
                {
                    if(resizeRectangle.width <= minWidth && resizeRectangle.height <= minHeight && dx <=0 && dy <= 0)
                        return

                    resizeRectangle.x -= dx*0.5
                    resizeRectangle.y -= dy*0.5
                    resizeRectangle.width += dx
                    resizeRectangle.height += dy

                    if(resizeRectangle.width < minWidth)
                        resizeRectangle.width = minWidth
                    if(resizeRectangle.height < minHeight)
                        resizeRectangle.height = minHeight

                    if(resizeRectangle.width > dragBackground.width)
                        resizeRectangle.width = dragBackground.width
                    if(resizeRectangle.height > dragBackground.height)
                        resizeRectangle.height = dragBackground.height

                    if(resizeRectangle.width + resizeRectangle.x > dragBackground.width)
                        resizeRectangle.x = dragBackground.width - resizeRectangle.width
                    if(resizeRectangle.height + resizeRectangle.y > dragBackground.height)
                        resizeRectangle.y = dragBackground.height - resizeRectangle.height

                    if(resizeRectangle.y < 0)
                        resizeRectangle.y = 0

                    if(resizeRectangle.x < 0)
                        resizeRectangle.x = 0
                }

                function enter(direct)
                {
                }

                function press(mouse)
                {
                    isPressed = true
                    customPoint = Qt.point(mouse.x, mouse.y)
                }

                function release()
                {
                    isPressed = false
                }

                function positionChange(newPosition,directX, directY)
                {
                    if(!isPressed)
                        return

                    var delta = Qt.point(newPosition.x-customPoint.x, newPosition.y-customPoint.y)
                    var tmpW,tmpH

                    if(directX >= 0)
                        tmpW = resizeRectangle.width + delta.x
                    else
                        tmpW = resizeRectangle.width - delta.x

                    if(directY >= 0)
                        tmpH = resizeRectangle.height + delta.y
                    else
                        tmpH = resizeRectangle.height - delta.y

                    if(tmpW < resizeRectangle.minimumWidth)
                    {
                        if(directX < 0)
                            resizeRectangle.x += (resizeRectangle.width - resizeRectangle.minimumWidth)
                        resizeRectangle.width = resizeRectangle.minimumWidth
                    }
                    else
                    {
                        resizeRectangle.width = tmpW
                        if(directX < 0)
                            resizeRectangle.x += delta.x
                    }

                    if(tmpH < resizeRectangle.minimumHeight)
                    {
                        if(directY < 0)
                            resizeRectangle.y += (resizeRectangle.height - resizeRectangle.minimumHeight)
                        resizeRectangle.height = resizeRectangle.minimumHeight
                    }
                    else
                    {
                        resizeRectangle.height = tmpH
                        if(directY < 0)
                            resizeRectangle.y += delta.y
                    }

                    fixedRetangle(0,0)
                }
            }

            posted on 2019-08-22 15:00 ccsdu2009 閱讀(2212) 評論(0)  編輯 收藏 引用 所屬分類: QT編程
             
            亚洲国产精品婷婷久久| 久久精品毛片免费观看| 久久精品无码免费不卡| 亚洲欧美另类日本久久国产真实乱对白 | 久久天天躁狠狠躁夜夜2020一| 中文字幕久久精品 | 99久久精品无码一区二区毛片 | 模特私拍国产精品久久| 久久久久人妻一区二区三区vr| 久久亚洲国产精品一区二区| 久久免费国产精品| a级成人毛片久久| 久久久久久亚洲精品影院| 久久这里只有精品首页| 久久久www免费人成精品| 99久久国产综合精品网成人影院| 久久这里只精品99re66| 93精91精品国产综合久久香蕉| 国内精品久久久久影院亚洲| 国产精品内射久久久久欢欢| 狠狠色婷婷久久一区二区| 久久精品国产亚洲一区二区三区| 精品久久久久中文字幕日本| 久久中文字幕精品| 亚洲国产一成久久精品国产成人综合| 国产精品久久午夜夜伦鲁鲁| 伊人久久综合无码成人网| 四虎久久影院| 久久噜噜久久久精品66| 精品一久久香蕉国产线看播放| 欧美激情精品久久久久| 精品免费tv久久久久久久| 久久久一本精品99久久精品66| 亚洲人成无码www久久久| AA级片免费看视频久久| 国产精品成人99久久久久91gav| 精品少妇人妻av无码久久| 国产V综合V亚洲欧美久久| 国产午夜精品理论片久久影视 | 久久露脸国产精品| 亚洲欧洲中文日韩久久AV乱码|