<commit_before>// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "atom/browser/ui/views/submenu_button.h"

#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/text_utils.h"

namespace atom {

namespace {

// Filter out the "&" in menu label.
base::string16 FilterAccecelator(const base::string16& label) {
  base::string16 out;
  base::RemoveChars(label, base::ASCIIToUTF16("&").c_str(), &out);
  return out;
}

}  // namespace

SubmenuButton::SubmenuButton(views::ButtonListener* listener,
                             const base::string16& title,
                             views::MenuButtonListener* menu_button_listener)
    : views::MenuButton(listener, FilterAccecelator(title),
                        menu_button_listener, false),
      accelerator_(0),
      show_underline_(false),
      underline_start_(-1),
      underline_end_(-1),
      text_width_(0),
      text_height_(0),
      underline_color_(SK_ColorBLACK) {
  SetStyle(views::Button::STYLE_TEXTBUTTON);
  if (GetUnderlinePosition(title, &accelerator_, &underline_start_,
                           &underline_end_))
    gfx::Canvas::SizeStringInt(GetText(), GetFontList(), &text_width_,
                               &text_height_, 0, 0);
}

SubmenuButton::~SubmenuButton() {
}

void SubmenuButton::SetAcceleratorVisibility(bool visible) {
  if (visible == show_underline_)
    return;

  show_underline_ = visible;
  SchedulePaint();
}

void SubmenuButton::SetUnderlineColor(SkColor color) {<commit_msg>linux: Dont' use native style border.<commit_after>// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "atom/browser/ui/views/submenu_button.h"

#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/text_utils.h"
#include "ui/views/controls/button/label_button_border.h"

namespace atom {

namespace {

// Filter out the "&" in menu label.
base::string16 FilterAccecelator(const base::string16& label) {
  base::string16 out;
  base::RemoveChars(label, base::ASCIIToUTF16("&").c_str(), &out);
  return out;
}

}  // namespace

SubmenuButton::SubmenuButton(views::ButtonListener* listener,
                             const base::string16& title,
                             views::MenuButtonListener* menu_button_listener)
    : views::MenuButton(listener, FilterAccecelator(title),
                        menu_button_listener, false),
      accelerator_(0),
      show_underline_(false),
      underline_start_(-1),
      underline_end_(-1),
      text_width_(0),
      text_height_(0),
      underline_color_(SK_ColorBLACK) {
#if defined(OS_LINUX)
  // Dont' use native style border.
  SetBorder(CreateDefaultBorder().PassAs<views::Border>());
#endif

  if (GetUnderlinePosition(title, &accelerator_, &underline_start_,
                           &underline_end_))
    gfx::Canvas::SizeStringInt(GetText(), GetFontList(), &text_width_,
                               &text_height_, 0, 0);
}

SubmenuButton::~SubmenuButton() {
}

void SubmenuButton::SetAcceleratorVisibility(bool visible) {
  if (visible == show_underline_)
    return;

  show_underline_ = visible;
  SchedulePaint();
}

void SubmenuButton::SetUnderlineColor(SkColor color) {
{'fraction_non_alphanumeric': 0.12183319100483916, 'fraction_numerical': 0.011955593509820665, 'mean_word_length': 3.4707379134860052, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4654973', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1075, 'n_words': 221}