• <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編程
             
            亚洲精品国产第一综合99久久| 国产成人精品免费久久久久| 久久久精品免费国产四虎| 69久久精品无码一区二区| 亚洲欧美久久久久9999| 久久久www免费人成精品| 亚洲国产精品无码久久久不卡| 久久综合噜噜激激的五月天| 精品久久久久中文字幕一区| 狠狠色婷婷久久一区二区| 色综合合久久天天综合绕视看| 大蕉久久伊人中文字幕| av午夜福利一片免费看久久| 国产精品99久久久久久猫咪| 久久精品无码一区二区WWW| 人人狠狠综合久久亚洲婷婷| 18禁黄久久久AAA片| 久久久久久国产a免费观看黄色大片| 一本色道久久综合狠狠躁| 久久99精品九九九久久婷婷| 无码人妻少妇久久中文字幕蜜桃| 91久久九九无码成人网站| 久久精品国产精品青草| 国产成人精品久久一区二区三区| 久久久久国产精品三级网| 亚洲嫩草影院久久精品| 久久久久亚洲av成人网人人软件| 精品久久久久久国产免费了| 欧美精品一区二区精品久久| 久久精品人人做人人爽电影蜜月| 久久精品国产2020| 久久久久久久综合日本| 国产三级观看久久| 久久青青草原国产精品免费| 精品蜜臀久久久久99网站| 无码人妻久久一区二区三区免费丨 | 久久精品国产69国产精品亚洲| 2021国产精品久久精品| 色天使久久综合网天天| 久久人人爽人人人人片av| 久久久久久曰本AV免费免费|