-
Notifications
You must be signed in to change notification settings - Fork 76
Fixed color selection for map sketching #4274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,77 @@ | ||||||
| import QtQuick | ||||||
| import QtQuick.Controls | ||||||
|
|
||||||
| ScrollView { | ||||||
| id: root | ||||||
|
|
||||||
| required property var colors | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
it would be nice to specify fully what we want there |
||||||
| required property var controller | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't couple controller tightly with this component. Using signals is preferred here |
||||||
| required property bool showEraseButton | ||||||
|
|
||||||
| height: scrollRow.height | ||||||
| ScrollBar.vertical.policy: ScrollBar.AlwaysOff | ||||||
| ScrollBar.horizontal.policy: ScrollBar.AlwaysOff | ||||||
|
|
||||||
| Row { | ||||||
| id: scrollRow | ||||||
| spacing: __style.margin12 | ||||||
| padding: __style.margin4 | ||||||
| anchors.centerIn: parent | ||||||
|
|
||||||
| Repeater { | ||||||
| model: colors ?? null | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will be always specified and never null |
||||||
|
|
||||||
| MMRoundButton { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And it would be also nice to make component out of this button too
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget to use the more explicit notation |
||||||
| anchors.verticalCenter: parent.verticalCenter | ||||||
|
|
||||||
| contentItem: Rectangle { | ||||||
| color: modelData | ||||||
| radius: width / 2 | ||||||
| anchors.fill: parent | ||||||
| } | ||||||
|
|
||||||
| background: Rectangle { | ||||||
| property bool isActive: modelData.toLowerCase() === controller.activeColor.toString().toLowerCase() | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In map sketching no color is selected anymore by default, while in photo sketching it is |
||||||
|
|
||||||
| anchors.verticalCenter: parent.verticalCenter | ||||||
| anchors.horizontalCenter: parent.horizontalCenter | ||||||
| radius: width / 2 | ||||||
| width: __style.margin48 | ||||||
| height: __style.margin48 | ||||||
| color: isActive ? __style.transparentColor : __style.lightGreenColor | ||||||
| border.width: 2 | ||||||
| border.color: isActive ? __style.grassColor : __style.transparentColor | ||||||
| } | ||||||
|
|
||||||
| onClicked: { | ||||||
| if (showEraseButton) { | ||||||
| controller.eraserActive = false; | ||||||
| } | ||||||
| controller.activeColor = modelData; | ||||||
|
Comment on lines
+48
to
+50
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again these two should change only stuff in this component and |
||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| MMButton { | ||||||
| text: qsTr("Eraser") | ||||||
| iconSourceLeft: __style.editIcon | ||||||
| // in some instances the erase button is not needed, because there is an "undo" feature already implemented | ||||||
| visible: showEraseButton | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| type: MMButton.Types.Primary | ||||||
| size: MMButton.Sizes.Small | ||||||
|
|
||||||
| fontColor: controller?.eraserActive ? __style.negativeColor : __style.grapeColor | ||||||
| iconColor: controller?.eraserActive ? __style.negativeColor : __style.grapeColor | ||||||
| bgndColor: controller?.eraserActive ? __style.grapeColor : __style.negativeColor | ||||||
| fontColorHover: controller?.eraserActive ? __style.grapeColor : __style.negativeColor | ||||||
| iconColorHover: controller?.eraserActive ? __style.grapeColor : __style.negativeColor | ||||||
| bgndColorHover: controller?.eraserActive ? __style.negativeColor : __style.grapeColor | ||||||
|
|
||||||
| onClicked: { | ||||||
| controller.activeColor = null; | ||||||
| controller.eraserActive = true; | ||||||
| } | ||||||
|
Comment on lines
+64
to
+74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing as above |
||||||
| } | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -200,56 +200,16 @@ Dialog { | |
|
|
||
| MMComponents.MMListSpacer { implicitHeight: __style.margin20 } | ||
|
|
||
| ScrollView { | ||
| MMComponents.MMPhotoColorPicker{ | ||
| colors: ["#FFFFFF", "#12181F", "#5E9EE4", "#57B46F", "#FDCB2A", "#FF9C40", "#FF8F93"] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should have done this before, but please define these colors in |
||
| showEraseButton: false | ||
| controller: root.controller | ||
|
|
||
| Layout.alignment: Qt.AlignHCenter | ||
| Layout.preferredHeight: scrollRow.height | ||
| Layout.preferredWidth: scrollRow.width | ||
| Layout.maximumWidth: parent.width - ( 2 * __style.pageMargins + __style.safeAreaLeft + __style.safeAreaRight ) | ||
| Layout.bottomMargin: __style.pageMargins + __style.safeAreaBottom | ||
| Layout.leftMargin: __style.pageMargins + __style.safeAreaLeft | ||
| Layout.rightMargin: __style.pageMargins + __style.safeAreaRight | ||
|
|
||
| ScrollBar.vertical.policy: ScrollBar.AlwaysOff | ||
| ScrollBar.horizontal.policy: ScrollBar.AlwaysOff | ||
|
|
||
| Row { | ||
| id: scrollRow | ||
| spacing: __style.margin12 | ||
| padding: __style.margin4 | ||
| anchors.centerIn: parent | ||
|
|
||
| Repeater { | ||
| // we use more vibrant versions of our product colors | ||
| model: ["#FFFFFF", "#12181F", "#5E9EE4", "#57B46F", "#FDCB2A", "#FF9C40", "#FF8F93"] | ||
|
|
||
| MMComponents.MMRoundButton { | ||
| id: colorButton | ||
| required property color modelData | ||
| anchors.verticalCenter: parent.verticalCenter | ||
|
|
||
| contentItem: Rectangle { | ||
| color: colorButton.modelData | ||
| radius: width / 2 | ||
| anchors.fill: parent | ||
| } | ||
| background: Rectangle { | ||
| property bool isActive: colorButton.modelData === root.controller.activeColor | ||
|
|
||
| anchors.centerIn: parent | ||
| radius: width / 2 | ||
| width: __style.margin48 | ||
| height: __style.margin48 | ||
| color: isActive ? __style.transparentColor : __style.lightGreenColor | ||
| border.width: 2 | ||
| border.color: isActive ? __style.grassColor : __style.transparentColor | ||
| } | ||
|
|
||
| onClicked: { | ||
| root.controller.setActiveColor( modelData ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,87 +54,18 @@ MMComponents.MMDrawer { | |
| onClicked: root.sketchingController.undo() | ||
| } | ||
|
|
||
| drawerContent: Column { | ||
| id: mainColumn | ||
|
|
||
| width: parent.width | ||
| spacing: __style.margin10 | ||
|
|
||
| ScrollView { | ||
| width: parent.width | ||
| height: scrollRow.height | ||
|
|
||
| ScrollBar.vertical.policy: ScrollBar.AlwaysOff | ||
| ScrollBar.horizontal.policy: ScrollBar.AlwaysOff | ||
|
|
||
| Row { | ||
| id: scrollRow | ||
| width: parent.width | ||
| spacing: __style.margin12 | ||
| leftPadding: __style.margin6 | ||
|
|
||
| Repeater { | ||
| id: colorsView | ||
|
|
||
| model: root.sketchingController?.availableColors() ?? null | ||
|
|
||
| MMComponents.MMRoundButton { | ||
| anchors.verticalCenter: parent.verticalCenter | ||
|
|
||
| contentItem: Rectangle { | ||
| color: modelData | ||
| radius: width / 2 | ||
| anchors.fill: parent | ||
| } | ||
|
|
||
| background: Rectangle { | ||
| property bool isActive: modelData.toLowerCase() === root.sketchingController.activeColor.toString().toLowerCase() | ||
|
|
||
| anchors.verticalCenter: parent.verticalCenter | ||
| anchors.horizontalCenter: parent.horizontalCenter | ||
| radius: width / 2 | ||
| width: scrollRow.height | ||
| height: scrollRow.height | ||
| color: isActive ? __style.transparentColor : __style.lightGreenColor | ||
| border.width: 2 | ||
| border.color: isActive ? __style.grassColor : __style.transparentColor | ||
| } | ||
|
|
||
| onClicked: { | ||
| root.sketchingController.eraserActive = false | ||
| root.sketchingController.activeColor = modelData | ||
| } | ||
|
|
||
| Component.onCompleted: { | ||
| // set the initial color to be the first one in the list | ||
| if ( index === 0 ) | ||
| { | ||
| root.sketchingController.activeColor = modelData | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| MMComponents.MMButton { | ||
| text: qsTr( "Eraser" ) | ||
| iconSourceLeft: __style.editIcon | ||
|
|
||
| type: MMButton.Types.Primary | ||
| size: MMButton.Sizes.Small | ||
|
|
||
| fontColor: root.sketchingController?.eraserActive ? __style.negativeColor : __style.grapeColor | ||
| iconColor: root.sketchingController?.eraserActive ? __style.negativeColor : __style.grapeColor | ||
| bgndColor: root.sketchingController?.eraserActive ? __style.grapeColor : __style.negativeColor | ||
| fontColorHover: root.sketchingController?.eraserActive ? __style.grapeColor : __style.negativeColor | ||
| iconColorHover: root.sketchingController?.eraserActive ? __style.grapeColor : __style.negativeColor | ||
| bgndColorHover: root.sketchingController?.eraserActive ? __style.negativeColor : __style.grapeColor | ||
|
|
||
| onClicked: { | ||
| root.sketchingController.activeColor = null | ||
| root.sketchingController.eraserActive = true | ||
| } | ||
| } | ||
| } | ||
| drawerContent: ColumnLayout { | ||
| anchors { | ||
| left: parent.left | ||
| right: parent.right | ||
| } | ||
|
Comment on lines
+57
to
+61
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you have to specify |
||
|
|
||
| MMComponents.MMPhotoColorPicker{ | ||
| colors: root.sketchingController?.availableColors() ?? null | ||
| showEraseButton: true | ||
| controller: root.sketchingController | ||
|
|
||
| Layout.fillWidth: true | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer calling it
MMColorPicker, it sounds more descriptive and we don't use it for just photos.