Giter Club home page Giter Club logo

catui's Issues

根据当前输出改变滚动条位置应该怎么写?

我给UILabel加了一个自动高度的函数

-- 宽度不变,自动高度
function UILabel:setAutoHeight()
  local width,height = self:getSize()
  local autoHeight = self.drawable:getHeight()
  self:setSize(width, autoHeight)
  return autoHeight
end

然后初始化控件

function InitContenter()
  love.graphics.setBackgroundColor(35/255, 42/255, 50/255, 1)
  local mgr = UIManager:getInstance()
  local content = UIContent:new()
  content:setPos(10, 10)
  local win_width = love.graphics.getWidth()
  local win_height= love.graphics.getHeight()
  
  content:setSize(win_width, win_height)
  content:setContentSize(win_width, win_height)
  content.backgroundColor = {31/255, 36/255, 43/255, 0.5}
  -- content:removeChild(content.hBar) -- 移除控件的子对象使用这个
  --UIControl.removeChild(content, content.vBar) 
  UIControl.removeChild(content, content.hBar) -- 移除控件的原生对象用这个
  --content.isCross = true
  content.visible = false
  mgr.rootCtrl.coreContainer:addChild(content)
  
  local label = UILabel:new("catui/font/visat.ttf", "show text", 14)
  label:setAnchor(0, 0.5)
  label:setAutoSize(false)
  label:setSize(content:getWidth(),content:getHeight())
  label:setAnchor(0,0)
  label:setClip(false)
  label:setFontColor({1, 1, 0, 1})
  content:addChild(label)
  content:setClip(false)
  content:setPos(0,0)
  content.visible = true
  return mgr
end

之后显示文本

function ShowDebugText(show_text,...)
  local text = ""
  for i,v in ipairs({...}) do
      text = text .. " " .. tostring(v)
  end
  local root = UIManager:getInstance():getRootCtrl()
  local content = (root.coreContainer:getChildren())[1]
  local label = content.contentCtrl.children[1]
  show_text = show_text .."\n".. text
  label:setText(show_text)
  --print(show_text)
  local labelHeight = label:setAutoHeight()
  local contentHeight = content:getContentHeight()
  local barHeight = math.floor(contentHeight*math.min(1.0,contentHeight*1.0/labelHeight))
  -- 要根据当前显示的行数,改变滚动条的位置
  content.vBar.bar:setHeight(barHeight)
  content.contentCtrl:setY(math.min(0,contentHeight-labelHeight))
  print("update barHeight:"..tostring(barHeight))
  return show_text
end

Love 11.0 color scheme change

All colors specified are in the range 0..255, but as of Love 11.0 colors are in a 0..1 range. Here are all the occurrences I was able to find with grep 'color = {' -rinI ., there might be more:

     1	./doc/modules/catui.Control.UIButton.html:369:         color = {r, g, b, a}
     2	./doc/modules/catui.Control.UIButton.html:390:         color = {r, g, b, a}
     3	./doc/modules/catui.Control.UIButton.html:411:         color = {r, g, b, a}
     4	./doc/modules/catui.Control.UIButton.html:432:         color = {r, g, b, a}
     5	./doc/modules/catui.Control.UIButton.html:476:         color = {r, g, b, a}
     6	./catui/UITheme.lua:35:theme.button.upColor = {57, 69, 82, 255}
     7	./catui/UITheme.lua:36:theme.button.downColor = {30, 35, 41, 255}
     8	./catui/UITheme.lua:37:theme.button.hoverColor = {71, 87, 103, 255}
     9	./catui/UITheme.lua:38:theme.button.disableColor = {48, 57, 66, 255}
    10	./catui/UITheme.lua:39:theme.button.strokeColor = {25, 30, 35, 255}
    11	./catui/UITheme.lua:43:theme.button.fontColor = {255, 255, 255, 255}
    12	./catui/UITheme.lua:47:theme.scrollBar.upColor = {84, 108, 119, 255}
    13	./catui/UITheme.lua:48:theme.scrollBar.hoverColor = {112, 158, 184, 255}
    14	./catui/UITheme.lua:49:theme.scrollBar.downColor = {84, 108, 119, 255}
    15	./catui/UITheme.lua:50:theme.scrollBar.backgroundColor = {47, 59, 69, 255}
    16	./catui/UITheme.lua:52:theme.content.backgroundColor = {31, 36, 43, 255}
    17	./catui/UITheme.lua:55:theme.checkBox.upColor = {255, 255, 255, 255}
    18	./catui/UITheme.lua:56:theme.checkBox.downColor = {0, 150, 224, 255}
    19	./catui/UITheme.lua:57:theme.checkBox.hoverColor = {0, 150, 224, 255}
    20	./catui/UITheme.lua:58:theme.checkBox.disableColor = {84, 108, 119, 255}
    21	./catui/UITheme.lua:61:theme.progressBar.color = {57, 104, 149, 255}
    22	./catui/UITheme.lua:62:theme.progressBar.backgroundColor = {47, 59, 69, 255}
    23	./catui/UITheme.lua:64:theme.editText.backgroundColor = {255, 255, 255, 255}
    24	./catui/UITheme.lua:65:theme.editText.focusStrokeColor = {57, 104, 149, 255}
    25	./catui/UITheme.lua:66:theme.editText.unfocusStrokeColor = {41, 50, 59, 255}
    26	./catui/UITheme.lua:67:theme.editText.cursorColor = {82, 139, 255, 255}
    27	./catui/Control/UILabel.lua:39:    color = {0, 0, 0, 255},
    28	./catui/Control/UIButton.lua:219:-- @tab color color = {r, g, b, a}
    29	./catui/Control/UIButton.lua:227:-- @tab color color = {r, g, b, a}
    30	./catui/Control/UIButton.lua:235:-- @tab color color = {r, g, b, a}
    31	./catui/Control/UIButton.lua:243:-- @tab color color = {r, g, b, a}
    32	./catui/Control/UIButton.lua:259:-- @tab color color = {r, g, b, a}

scrollbar按钮拖拽时消失

-------------------------------------
-- (callback)
-- on bar move
-------------------------------------
function UIScrollBar:onBarMove(x, y, dx, dy)
    if not self.barDown then return end

    local bar = self.bar

    if self.dir == "vertical" then
        local after = bar:getY() + dy
        if after < 0 then
            after = 0
        elseif after + bar:getHeight() > self:getHeight() then
            after = self:getHeight() - bar:getHeight()
        end
-- 增加除数为0的判定
        local spaceHeight = self:getHeight() - bar:getHeight()
        if spaceHeight == 0 then spaceHeight = 1 end
        self.barPosRatio = after / spaceHeight
    else
        local after = bar:getX() + dx
        if after < 0 then
            after = 0
        elseif after + bar:getWidth() > self:getWidth() then
            after = self:getWidth() - bar:getWidth()
        end
-- 增加除数为0的判定
        local spaceWidth = self:getWidth() - bar:getWidth()
        if spaceWidth == 0 then spaceWidth = 1 end
        self.barPosRatio = after / spaceWidth
    end
    self:setBarPos(self.barPosRatio)
end

Textbox is not showing text!

I am executed folder catui-master but when I started to write in text field, nothing happend! Blue cursor was moving, but text did not appear. Everything except this was working

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.