Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add selection modes to "Select > Color Range" command (fix #765)
- Loading branch information
Showing
5 changed files
with
185 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Aseprite | ||
// Copyright (C) 2018 Igara Studio S.A. | ||
// | ||
// This program is distributed under the terms of | ||
// the End-User License Agreement for Aseprite. | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
|
||
#include "app/ui/selection_mode_field.h" | ||
|
||
#include "app/ui/keyboard_shortcuts.h" | ||
#include "app/ui/skin/skin_theme.h" | ||
|
||
namespace app { | ||
|
||
using namespace app::skin; | ||
using namespace ui; | ||
|
||
SelectionModeField::SelectionModeField() | ||
: ButtonSet(4) | ||
{ | ||
auto theme = static_cast<SkinTheme*>(this->theme()); | ||
|
||
addItem(theme->parts.selectionReplace()); | ||
addItem(theme->parts.selectionAdd()); | ||
addItem(theme->parts.selectionSubtract()); | ||
addItem(theme->parts.selectionIntersect()); | ||
|
||
setSelectedItem((int)Preferences::instance().selection.mode()); | ||
} | ||
|
||
void SelectionModeField::setupTooltips(TooltipManager* tooltipManager) | ||
{ | ||
tooltipManager->addTooltipFor( | ||
at(0), "Replace selection", BOTTOM); | ||
|
||
tooltipManager->addTooltipFor( | ||
at(1), key_tooltip("Add to selection", KeyAction::AddSelection), BOTTOM); | ||
|
||
tooltipManager->addTooltipFor( | ||
at(2), key_tooltip("Subtract from selection", KeyAction::SubtractSelection), BOTTOM); | ||
|
||
tooltipManager->addTooltipFor( | ||
at(3), key_tooltip("Intersect selection", KeyAction::IntersectSelection), BOTTOM); | ||
} | ||
|
||
gen::SelectionMode SelectionModeField::selectionMode() | ||
{ | ||
return (gen::SelectionMode)selectedItem(); | ||
} | ||
|
||
void SelectionModeField::setSelectionMode(gen::SelectionMode mode) | ||
{ | ||
setSelectedItem((int)mode, false); | ||
invalidate(); | ||
} | ||
|
||
void SelectionModeField::onItemChange(Item* item) | ||
{ | ||
ButtonSet::onItemChange(item); | ||
onSelectionModeChange(selectionMode()); | ||
} | ||
|
||
} // namespace app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Aseprite | ||
// Copyright (C) 2018 Igara Studio S.A. | ||
// | ||
// This program is distributed under the terms of | ||
// the End-User License Agreement for Aseprite. | ||
|
||
#ifndef APP_UI_SELECTION_MODE_FIELD_H_INCLUDED | ||
#define APP_UI_SELECTION_MODE_FIELD_H_INCLUDED | ||
#pragma once | ||
|
||
#include "app/pref/preferences.h" | ||
#include "app/ui/button_set.h" | ||
|
||
#include <vector> | ||
|
||
namespace ui { | ||
class TooltipManager; | ||
} | ||
|
||
namespace app { | ||
|
||
class SelectionModeField : public ButtonSet { | ||
public: | ||
SelectionModeField(); | ||
|
||
void setupTooltips(ui::TooltipManager* tooltipManager); | ||
|
||
gen::SelectionMode selectionMode(); | ||
void setSelectionMode(gen::SelectionMode mode); | ||
|
||
protected: | ||
void onItemChange(Item* item) override; | ||
|
||
virtual void onSelectionModeChange(gen::SelectionMode mode) { } | ||
}; | ||
|
||
} // namespace app | ||
|
||
#endif |