24 : fHelpMode(kNone_HelpMode) {
25 this->
addCommand(
'h',
"Overlays",
"Show help screen", [
this]() {
26 switch (this->fHelpMode) {
28 this->fHelpMode = kGrouped_HelpMode;
30 case kGrouped_HelpMode:
31 this->fHelpMode = kAlphabetical_HelpMode;
33 case kAlphabetical_HelpMode:
34 this->fHelpMode = kNone_HelpMode;
48 if (Command::kKey_CommandType ==
cmd.fType &&
key ==
cmd.fKey) {
60 if (Command::kChar_CommandType ==
cmd.fType && c ==
cmd.fChar) {
71 if (
cmd.getSoftkeyString().equals(softkey)) {
89bool CommandSet::compareCommandKey(
const Command& first,
const Command& second) {
90 return SK_strcasecmp(first.fKeyName.c_str(), second.fKeyName.c_str()) < 0;
93bool CommandSet::compareCommandGroup(
const Command& first,
const Command& second) {
94 return SK_strcasecmp(first.fGroup.c_str(), second.fGroup.c_str()) < 0;
98 if (kNone_HelpMode == fHelpMode) {
103 std::stable_sort(fCommands.
begin(), fCommands.
end(),
104 kAlphabetical_HelpMode == fHelpMode ? compareCommandKey : compareCommandGroup);
117 paint.setAntiAlias(
true);
118 paint.setColor(0xFFFFFFFF);
131 font.measureText(
cmd.fKeyName.c_str(),
cmd.fKeyName.size(),
138 if (kGrouped_HelpMode != fHelpMode) {
145 if (kGrouped_HelpMode == fHelpMode && lastGroup !=
cmd.fGroup) {
149 x,
y, groupFont, groupPaint);
151 lastGroup =
cmd.fGroup;
158 y +=
font.getSize() + 2;
163 std::vector<SkString>
result;
@ kUTF8
uses bytes to represent UTF-8 or ASCII
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
void drawPaint(const SkPaint &paint)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
void setSize(SkScalar textSize)
void setColor(SkColor color)
void setAntiAlias(bool aa)
void attach(Window *window)
void drawHelp(SkCanvas *canvas)
bool onChar(SkUnichar, skui::ModifierKey modifiers)
bool onKey(skui::Key key, skui::InputState state, skui::ModifierKey modifiers)
std::vector< SkString > getCommandsAsSoftkeys() const
void addCommand(SkUnichar c, const char *group, const char *description, std::function< void(void)> function)
bool onSoftkey(const SkString &softkey)
Dart_NativeFunction function
static float max(float r, float g, float b)
font
Font Metadata and Metrics.