• <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++高級(jí)工程師 Android高級(jí)軟件工程師 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 閱讀(2223) 評(píng)論(0)  編輯 收藏 引用 所屬分類: QT編程
             
            婷婷久久精品国产| 久久人爽人人爽人人片AV| 青青草国产精品久久久久| 97久久超碰成人精品网站| 国产三级观看久久| 国产69精品久久久久APP下载| 婷婷久久五月天| 久久精品亚洲精品国产色婷| 国产一区二区三精品久久久无广告| 精品久久久无码中文字幕| 久久香综合精品久久伊人| 国产精品禁18久久久夂久 | 午夜精品久久久久久中宇| 久久久91精品国产一区二区三区| 亚洲嫩草影院久久精品| 欧美亚洲国产精品久久高清| 大伊人青草狠狠久久| 一本一本久久a久久精品综合麻豆| 无码久久精品国产亚洲Av影片| 国产精品99久久久久久www| 久久精品国产亚洲AV不卡| 精品久久久无码中文字幕天天| 色偷偷久久一区二区三区| 无码8090精品久久一区| 日本精品久久久久中文字幕| 狠狠88综合久久久久综合网| 2019久久久高清456| 国产精品一区二区久久精品无码| 久久夜色精品国产网站| 久久人人爽人人爽人人av东京热| 欧美久久久久久精选9999| 18岁日韩内射颜射午夜久久成人| 久久久精品2019免费观看| 亚洲国产精品无码久久久秋霞2| 色偷偷88欧美精品久久久| 99久久精品免费看国产| 亚洲国产精久久久久久久| 日本三级久久网| 伊人久久大香线蕉精品| 久久久久久久综合日本亚洲 | 久久婷婷五月综合色99啪ak|