<commit_before>local InputContainer = require("ui/widget/container/inputcontainer")
local TextWidget = require("ui/widget/textwidget")
local ImageWidget = require("ui/widget/imagewidget")
local Font = require("ui/font")
local Geom = require("ui/geometry")
local GestureRange = require("ui/gesturerange")
local FrameContainer = require("ui/widget/container/framecontainer")
local CenterContainer = require("ui/widget/container/centercontainer")
local UIManager = require("ui/uimanager")
local Device = require("ui/device")
local DEBUG = require("dbg")
local _ = require("gettext")

--[[
a button widget that shows text or a icon and handles callback when tapped
--]]
local Button = InputContainer:new{
    text = nil, -- mandatory
    icon = nil,
    preselect = false,
    callback = nil,
    enabled = true,
    margin = 0,
    bordersize = 3,
    background = 0,
    radius = 15,
    padding = 2,
    width = nil,
    text_font_face = "cfont",
    text_font_size = 20,
}

function Button:init()
    if self.text then
        self.label_widget = TextWidget:new{
            text = self.text,
            fgcolor = self.enabled and 1.0 or 0.5,
            bold = true,
            face = Font:getFace(self.text_font_face, self.text_font_size)
        }
    else
        self.label_widget = ImageWidget:new{
            file = self.icon,
            dim = self.enabled,
        }
    end
    local widget_size = self.label_widget:getSize()<commit_msg>don't dim icon button by default<commit_after>local InputContainer = require("ui/widget/container/inputcontainer")
local TextWidget = require("ui/widget/textwidget")
local ImageWidget = require("ui/widget/imagewidget")
local Font = require("ui/font")
local Geom = require("ui/geometry")
local GestureRange = require("ui/gesturerange")
local FrameContainer = require("ui/widget/container/framecontainer")
local CenterContainer = require("ui/widget/container/centercontainer")
local UIManager = require("ui/uimanager")
local Device = require("ui/device")
local DEBUG = require("dbg")
local _ = require("gettext")

--[[
a button widget that shows text or a icon and handles callback when tapped
--]]
local Button = InputContainer:new{
    text = nil, -- mandatory
    icon = nil,
    preselect = false,
    callback = nil,
    enabled = true,
    margin = 0,
    bordersize = 3,
    background = 0,
    radius = 15,
    padding = 2,
    width = nil,
    text_font_face = "cfont",
    text_font_size = 20,
}

function Button:init()
    if self.text then
        self.label_widget = TextWidget:new{
            text = self.text,
            fgcolor = self.enabled and 1.0 or 0.5,
            bold = true,
            face = Font:getFace(self.text_font_face, self.text_font_size)
        }
    else
        self.label_widget = ImageWidget:new{
            file = self.icon,
            dim = not self.enabled,
        }
    end
    local widget_size = self.label_widget:getSize()
{'fraction_non_alphanumeric': 0.11323982210058159, 'fraction_numerical': 0.008210742387957578, 'mean_word_length': 3.010973936899863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1756836', 'n_tokens_mistral': 879, 'n_tokens_neox': 859, 'n_words': 225}