Author Topic: Adding floating window  (Read 5330 times)

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Adding floating window
« on: February 17, 2017, 02:47:06 AM »
So , anyone can make me a little example on how to add a little "floating window" on an existent layout to show some extra info or wathever we want?
Is this posible?
Thanks.

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Adding floating window
« Reply #1 on: February 17, 2017, 06:11:08 PM »
You might need to be more specific on what you mean by floating window but likely you want to create a surface, then add the info on it - this way you can move the surface (aka your floating window) wherever you want on the screen, or animate it or whatever...

Code: [Select]
local window = fe.add_surface(640, 360)
local window_bg = window.add_image("images/bg.png", 0, 0, window.width, window.height)
local window_title = window.add_text("[Title]", 0, 0, window.width, 20)
local window_cat = window.add_text("[Category]", 0, 25, window.width, 20)
window.set_pos(100, 100)
« Last Edit: February 17, 2017, 06:12:58 PM by liquid8d »

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Adding floating window
« Reply #2 on: February 18, 2017, 08:26:02 AM »
Thanks liquid8d , let me try to explain what I´m trying to do.

On this post I was trying to find a way to show game descriptions like on emulationstation.
http://forum.attractmode.org/index.php?topic=1349.0

Is working fine now and what I would like to do is showing this "extra" info on a floating window.
I just add this line to my layout.nut

Code: [Select]
local textoverview =fe.add_text("[Overview]", 960,450,380,700)
So, it shows correctly.But now what I like to do is to show only when I press a button
Maybe with a little animation like a "help screen".

« Last Edit: February 18, 2017, 08:28:41 AM by qqplayer »

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Adding floating window
« Reply #3 on: February 18, 2017, 09:10:18 AM »
Thanks liquid8d , let me try to explain what I´m trying to do.

On this post I was trying to find a way to show game descriptions like on emulationstation.
http://forum.attractmode.org/index.php?topic=1349.0

Is working fine now and what I would like to do is showing this "extra" info on a floating window.
I just add this line to my layout.nut

Code: [Select]
local textoverview =fe.add_text("[Overview]", 960,450,380,700)
So, it shows correctly.But now what I like to do is to show only when I press a button
Maybe with a little animation like a "help screen".



Create a class that will add a transition callback and change the state of the class to and either show or hide your object. I might upload an example as i have an example that seems to help multiple threads.

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: Adding floating window
« Reply #4 on: February 18, 2017, 10:02:02 AM »
here is what i was given by  liquid8d
works great...under controls choose you buttom for custom1
and then you can toggle on and off.

also modify as needed for text of vid, pic
Code: [Select]
class PopUpImage
{
        _my_image=null;

        constructor()
        {
  _my_image = fe.add_text("[Title]", flx*0.230, fly*0.360, flw*0.360, flh*0.490 );
                _my_image.visible=false;
                _my_image.charsize = 20;
//_my_image.alpha= 100;
                fe.add_signal_handler( this, "on_signal" )
     
        }


        function on_signal( signal )
        {
                if ( signal == "custom1" )
                {
                        _my_image.visible=!_my_image.visible;
                        return true;
                }
                return false;
        }
}

local blah = PopUpImage();
help a friend....

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Adding floating window
« Reply #5 on: February 23, 2017, 10:19:58 AM »
Thank you guys , Jedione your code is working perfectly.

This is what I made to show the "overview" extra info.

Code: [Select]
class PopUpImage
{
        _my_image=null;

        constructor()
        {
  _my_image = fe.add_text("[Overview]", flx*0.230, fly*0.360, flw*0.360, flh*0.490 );
                _my_image.visible=false;
                _my_image.charsize = 12;
                _my_image.align = Align.Left;
                _my_image.word_wrap = true;
                _my_image.alpha = 255;
                _my_image.style = Style.Bold;
//_my_image.alpha= 100;
                fe.add_signal_handler( this, "on_signal" )
     
        }


        function on_signal( signal )
        {
                if ( signal == "custom1" )
                {
                        _my_image.visible=!_my_image.visible;
                        return true;
                }
                return false;
        }
}

local blah = PopUpImage();

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Adding floating window
« Reply #6 on: February 23, 2017, 12:29:51 PM »
Sorry for repost , I need more help.

Trying to add a custom background to the float text:

Code: [Select]
class PopUpBgImage
{
        _my_image_bg=null;

        constructor()
        {
  _my_image_bg = fe.add_image( "backgrounds/xbmc/bg_overview.png", 0, 0 ,640 ,480 );   
                 _my_image_bg.visible=false;
                 _my_image_bg.alpha = 255;
                 fe.add_signal_handler( this, "on_signal" )
     
        }


        function on_signal( signal )
        {
                if ( signal == "custom1" )
                {
                        _my_image_bg.visible=!_my_image_bg.visible;
                        return true;
                }
                return false;
        }
}

local blah_bg = PopUpBgImage();

Works good individually but if I add to my layout.nut with the "overview text" function doesnt work.