<commit_before>// Copyright (c) 2015 <NAME>.
// Cura is released under the terms of the AGPLv3 or higher.

import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1

import UM 1.0 as UM

Item {
    id: base;

    width: buttons.width;
    height: buttons.height
    property int activeY

    ColumnLayout {
        id: buttons;

        anchors.bottom: parent.bottom;
        anchors.left: parent.left;
        spacing: UM.Theme.getSize("button_lining").width

        Repeater {
            id: repeat

            model: UM.Models.toolModel

            Button {
                text: model.name
                iconSource: UM.Theme.getIcon(model.icon);

                checkable: true;
                checked: model.active;
                enabled: model.enabled && UM.Selection.hasSelection && UM.Controller.toolsEnabled;

                style: UM.Theme.styles.tool_button;

                //Workaround since using ToolButton"s onClicked would break the binding of the checked property, instead
                //just catch the click so we do not trigger that behaviour.
                MouseArea {
                    anchors.fill: parent;
                    onClicked: {
                        parent.checked ? UM.Controller.setActiveTool(null) : UM.Controller.setActiveTool(model.id);
                        base.activeY = parent.y
                    }
                }
            }
        }
    }

    UM.PointingRectangle {
        id: panelBorder;

        anchors.left: parent.right;
        anchors.leftMargin: UM.Theme.getSize("default_margin").width;
        anchors.top: base.top;
        anchors.topMargin: base.activeY
        z: buttons.z -1

        target: Qt.point(parent.right, base.activeY +  UM.Theme.getSize("button").height/2)
        arrowSize: UM.Theme.getSize("default_arrow").width

        width: {
            if (panel.item && panel.width > 0){
                 return Math.max(panel.width + 2 * UM.Theme.getSize("default_margin").width)
            }
            else {
                return 0
            }
        }
        height: panel.item ? panel.height + 2 * UM.Theme.getSize("default_margin").height : 0;

        opacity: panel.item && panel.width > 0 ? 1 : 0
        Behavior on opacity { NumberAnimation { duration: 100 } }

        color: UM.Theme.getColor("lining");
        //border.width: UM.Theme.getSize("default_lining").width
        //border.color: UM.Theme.getColor("lining")

        UM.PointingRectangle {
            id: panelBackground;

            color: UM.Theme.getColor("tool_panel_background");
            anchors.fill: parent
            anchors.margins: UM.Theme.getSize("default_lining").width

            target: Qt.point(-UM.Theme.getSize("default_margin").width, UM.Theme.getSize("button").height/2)
            arrowSize: parent.arrowSize 
        }

        Loader {
            id: panel

            x: UM.Theme.getSize("default_margin").width;
            y: UM.Theme.getSize("default_margin").height;

            source: UM.ActiveTool.valid ? UM.ActiveTool.activeToolPanel : "";
            enabled: UM.Controller.toolsEnabled;
        }
    }
}<commit_msg>Misclicking tool panel no longer hides it<commit_after>// Copyright (c) 2015 Ultimaker B.V.
// Cura is released under the terms of the AGPLv3 or higher.

import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1

import UM 1.0 as UM

Item {
    id: base;

    width: buttons.width;
    height: buttons.height
    property int activeY

    ColumnLayout {
        id: buttons;

        anchors.bottom: parent.bottom;
        anchors.left: parent.left;
        spacing: UM.Theme.getSize("button_lining").width

        Repeater {
            id: repeat

            model: UM.Models.toolModel

            Button {
                text: model.name
                iconSource: UM.Theme.getIcon(model.icon);

                checkable: true;
                checked: model.active;
                enabled: model.enabled && UM.Selection.hasSelection && UM.Controller.toolsEnabled;

                style: UM.Theme.styles.tool_button;

                //Workaround since using ToolButton"s onClicked would break the binding of the checked property, instead
                //just catch the click so we do not trigger that behaviour.
                MouseArea {
                    anchors.fill: parent;
                    onClicked: {
                        parent.checked ? UM.Controller.setActiveTool(null) : UM.Controller.setActiveTool(model.id);
                        base.activeY = parent.y
                    }
                }
            }
        }
    }

    UM.PointingRectangle {
        id: panelBorder;

        anchors.left: parent.right;
        anchors.leftMargin: UM.Theme.getSize("default_margin").width;
        anchors.top: base.top;
        anchors.topMargin: base.activeY
        z: buttons.z -1

        target: Qt.point(parent.right, base.activeY +  UM.Theme.getSize("button").height/2)
        arrowSize: UM.Theme.getSize("default_arrow").width

        width: {
            if (panel.item && panel.width > 0){
                 return Math.max(panel.width + 2 * UM.Theme.getSize("default_margin").width)
            }
            else {
                return 0
            }
        }
        height: panel.item ? panel.height + 2 * UM.Theme.getSize("default_margin").height : 0;

        opacity: panel.item && panel.width > 0 ? 1 : 0
        Behavior on opacity { NumberAnimation { duration: 100 } }

        color: UM.Theme.getColor("lining");
        //border.width: UM.Theme.getSize("default_lining").width
        //border.color: UM.Theme.getColor("lining")

        UM.PointingRectangle {
            id: panelBackground;

            color: UM.Theme.getColor("tool_panel_background");
            anchors.fill: parent
            anchors.margins: UM.Theme.getSize("default_lining").width

            target: Qt.point(-UM.Theme.getSize("default_margin").width, UM.Theme.getSize("button").height/2)
            arrowSize: parent.arrowSize
            MouseArea //Catch all mouse events (so scene doesnt handle them)
            {
                anchors.fill: parent
            }
        }

        Loader {
            id: panel

            x: UM.Theme.getSize("default_margin").width;
            y: UM.Theme.getSize("default_margin").height;

            source: UM.ActiveTool.valid ? UM.ActiveTool.activeToolPanel : "";
            enabled: UM.Controller.toolsEnabled;
        }
    }
}
{'fraction_non_alphanumeric': 0.10416666666666667, 'fraction_numerical': 0.008819951338199513, 'mean_word_length': 1.7347193347193348, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2195788', 'n_tokens_mistral': 1959, 'n_tokens_neox': 1775, 'n_words': 395}