Skip to content

Commit 0771a9e

Browse files
HiCaminohumdingerb
authored andcommitted
Add checkbox to color picker to use all layers
Fixes #487
1 parent 4022995 commit 0771a9e

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

artpaint/tools/ColorSelectorTool.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,25 @@ ColorSelectorTool::ColorSelectorTool()
281281
fOptionsCount = 2;
282282

283283
SetOption(SIZE_OPTION, 1);
284-
SetOption(MODE_OPTION, HS_ALL_BUTTONS);
284+
SetOption(MODE_OPTION, 0);
285+
286+
fToolSettings.size = 1;
287+
fToolSettings.mode = 0;
285288
}
286289

287290

288291
ToolScript*
289292
ColorSelectorTool::UseTool(ImageView* view, uint32 buttons, BPoint point, BPoint view_point)
290293
{
291294
BWindow* window = view->Window();
292-
BBitmap* bitmap = view->ReturnImage()->ReturnActiveBitmap();
295+
BBitmap* bitmap;
293296

294297
if (window != NULL) {
298+
if (fToolSettings.mode == 0)
299+
bitmap = view->ReturnImage()->ReturnActiveBitmap();
300+
else
301+
bitmap = view->ReturnImage()->ReturnRenderedImage();
302+
295303
BitmapDrawer* drawer = new BitmapDrawer(bitmap);
296304

297305
BPoint original_point, original_view_point, prev_view_point;
@@ -441,9 +449,24 @@ ColorSelectorToolConfigView::ColorSelectorToolConfigView(DrawingTool* tool)
441449

442450
fSizeSlider = new NumberSliderControl(B_TRANSLATE("Size:"), "1", message, 1, 10, false);
443451

452+
BMessage* all_layers_message = new BMessage(OPTION_CHANGED);
453+
all_layers_message->AddInt32("option", MODE_OPTION);
454+
all_layers_message->AddInt32("value", tool->GetCurrentValue(MODE_OPTION));
455+
fAllLayersCheckbox = new BCheckBox(B_TRANSLATE("Sample all layers"), all_layers_message);
456+
444457
BGridLayout* sizeLayout = LayoutSliderGrid(fSizeSlider);
445-
layout->AddView(sizeLayout->View());
458+
459+
layout->AddView(BGroupLayoutBuilder(B_VERTICAL, kWidgetSpacing)
460+
.Add(sizeLayout)
461+
.Add(fAllLayersCheckbox)
462+
.TopView()
463+
);
446464
}
465+
466+
if (tool->GetCurrentValue(MODE_OPTION) == 1)
467+
fAllLayersCheckbox->SetValue(B_CONTROL_ON);
468+
else
469+
fAllLayersCheckbox->SetValue(B_CONTROL_OFF);
447470
}
448471

449472

@@ -453,4 +476,5 @@ ColorSelectorToolConfigView::AttachedToWindow()
453476
DrawingToolConfigView::AttachedToWindow();
454477

455478
fSizeSlider->SetTarget(this);
479+
fAllLayersCheckbox->SetTarget(this);
456480
}

artpaint/tools/ColorSelectorTool.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
#include "DrawingTool.h"
1515

1616

17+
#include "CheckBox.h"
18+
19+
1720
class ImageView;
1821

1922

@@ -45,6 +48,7 @@ class ColorSelectorToolConfigView : public DrawingToolConfigView {
4548

4649
private:
4750
NumberSliderControl* fSizeSlider;
51+
BCheckBox* fAllLayersCheckbox;
4852
};
4953

5054

0 commit comments

Comments
 (0)