Skip to content

Commit

Permalink
Add draft grid color setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Moult authored and yorikvanhavre committed Jun 3, 2019
1 parent 61625b4 commit 687b277
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Mod/Draft/DraftTrackers.py
Expand Up @@ -808,7 +808,7 @@ def update(self,wire,forceclosed=False):
class gridTracker(Tracker):
"A grid tracker"
def __init__(self):
col = [0.2,0.2,0.3]
col = self.getGridColor()
pick = coin.SoPickStyle()
pick.style.setValue(coin.SoPickStyle.UNPICKABLE)
self.trans = coin.SoTransform()
Expand Down Expand Up @@ -844,6 +844,13 @@ def __init__(self):
Tracker.__init__(self,children=[s],name="gridTracker")
self.reset()

def getGridColor(self):
color = Draft.getParam("gridColor", 842157055)
r = ((color>>24)&0xFF)/255
g = ((color>>16)&0xFF)/255
b = ((color>>8)&0xFF)/255
return [r, g, b]

def update(self):
"redraws the grid"
# resize the grid to make sure it fits an exact pair number of main lines
Expand Down
54 changes: 54 additions & 0 deletions src/Mod/Draft/Resources/ui/preferences-draftsnap.ui
Expand Up @@ -468,6 +468,50 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Grid color</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefColorButton" name="gui::prefcolorbutton">
<property name="toolTip">
<string>The default color for new objects</string>
</property>
<property name="color" stdset="0">
<color>
<red>50</red>
<green>50</green>
<blue>75</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>gridColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
Expand All @@ -489,11 +533,21 @@
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Gui::ColorButton</class>
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefColorButton</class>
<extends>Gui::ColorButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
Expand Down

0 comments on commit 687b277

Please sign in to comment.