From e2a88e671d5726c2525c108d50c2064ea4dd35c2 Mon Sep 17 00:00:00 2001
From: Valzant <qisoster@gmail.com>
Date: Thu, 5 Jan 2017 01:07:09 +0000
Subject: [PATCH] Backgrounds: #3746 Can't reset default background colour in
Screen Preferences
* Added 'Defaults' button, before 'Revert' button, similar in layout to 'Appearance'.
* When clicked, it sets the color picker to RGB = (51, 102, 152 ), the default color.
---
src/preferences/backgrounds/BackgroundsView.cpp | 21 +++++++++++++++++++++
src/preferences/backgrounds/BackgroundsView.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/src/preferences/backgrounds/BackgroundsView.cpp b/src/preferences/backgrounds/BackgroundsView.cpp
index 71853c8..c5fc04a 100644
a
|
b
|
|
42 | 42 | |
43 | 43 | |
44 | 44 | static const uint32 kMsgApplySettings = 'aply'; |
| 45 | static const uint32 kMsgDefaultSettings = 'dflt'; |
45 | 46 | static const uint32 kMsgRevertSettings = 'rvrt'; |
46 | 47 | |
47 | 48 | static const uint32 kMsgUpdateColor = 'upcl'; |
… |
… |
BackgroundsView::BackgroundsView()
|
212 | 213 | .SetInsets(B_USE_DEFAULT_SPACING) |
213 | 214 | .View()); |
214 | 215 | |
| 216 | fDefaults = new BButton(B_TRANSLATE("Defaults"), |
| 217 | new BMessage(kMsgDefaultSettings)); |
215 | 218 | fRevert = new BButton(B_TRANSLATE("Revert"), |
216 | 219 | new BMessage(kMsgRevertSettings)); |
217 | 220 | fApply = new BButton(B_TRANSLATE("Apply"), |
218 | 221 | new BMessage(kMsgApplySettings)); |
219 | 222 | |
| 223 | fDefaults->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, |
| 224 | B_ALIGN_NO_VERTICAL)); |
220 | 225 | fRevert->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, |
221 | 226 | B_ALIGN_NO_VERTICAL)); |
222 | 227 | fApply->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, |
… |
… |
BackgroundsView::BackgroundsView()
|
234 | 239 | .Add(rightbox) |
235 | 240 | .End() |
236 | 241 | .AddGroup(B_HORIZONTAL, 0) |
| 242 | .Add(fDefaults) |
237 | 243 | .Add(fRevert) |
| 244 | .AddGlue() |
238 | 245 | .Add(fApply) |
239 | 246 | .SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0) |
240 | 247 | .End(); |
… |
… |
BackgroundsView::AllAttached()
|
262 | 269 | fIconLabelOutline->SetTarget(this); |
263 | 270 | fPicker->SetTarget(this); |
264 | 271 | fApply->SetTarget(this); |
| 272 | fDefaults->SetTarget(this); |
265 | 273 | fRevert->SetTarget(this); |
266 | 274 | |
267 | 275 | BPath path; |
… |
… |
BackgroundsView::AllAttached()
|
290 | 298 | } |
291 | 299 | |
292 | 300 | fApply->SetEnabled(false); |
| 301 | fDefaults->SetEnabled(false); |
293 | 302 | fRevert->SetEnabled(false); |
294 | 303 | } |
295 | 304 | |
… |
… |
BackgroundsView::MessageReceived(BMessage* message)
|
423 | 432 | _UpdateButtons(); |
424 | 433 | break; |
425 | 434 | } |
| 435 | |
| 436 | case kMsgDefaultSettings: |
| 437 | { |
| 438 | rgb_color color = {51, 102, 152, 255}; |
| 439 | fPicker->SetValue(color); |
| 440 | |
| 441 | _UpdatePreview(); |
| 442 | _UpdateButtons(); |
| 443 | break; |
| 444 | } |
| 445 | |
426 | 446 | case kMsgRevertSettings: |
427 | 447 | _UpdateWithCurrent(); |
428 | 448 | break; |
… |
… |
BackgroundsView::_UpdateButtons()
|
964 | 984 | } |
965 | 985 | |
966 | 986 | fApply->SetEnabled(hasChanged); |
| 987 | fDefaults->SetEnabled(hasChanged); |
967 | 988 | fRevert->SetEnabled(hasChanged); |
968 | 989 | } |
969 | 990 | |
diff --git a/src/preferences/backgrounds/BackgroundsView.h b/src/preferences/backgrounds/BackgroundsView.h
index eece562..b2120ef 100644
a
|
b
|
protected:
|
141 | 141 | |
142 | 142 | BColorControl* fPicker; |
143 | 143 | BButton* fApply; |
| 144 | BButton* fDefaults; |
144 | 145 | BButton* fRevert; |
145 | 146 | BCheckBox* fIconLabelOutline; |
146 | 147 | BMenu* fPlacementMenu; |