It is currently Fri Jul 20, 2018 6:01 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Customized Windows ?
PostPosted: Tue Apr 03, 2018 11:59 am 
Offline
User
User
User avatar

Joined: Sat Sep 02, 2017 7:30 pm
Posts: 47
*** to Administrator: please delete this post reply ***


Last edited by PedroMartins on Fri Apr 06, 2018 2:30 pm, edited 4 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Wishes for Window and Menu colors
PostPosted: Tue Apr 03, 2018 12:01 pm 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1448
PedroMartins wrote:
To Dude: It's just a wish. Don't kill the wish.

I know it's a wish, but Fred has said in the past that only cross-platform wishes get considered:

We usually only add commands which can be used on all OS.


Top
 Profile  
Reply with quote  
 Post subject: Re: Wishes for Window and Menu colors
PostPosted: Tue Apr 03, 2018 6:24 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2082
Location: Singapore
Most applications with customised windows don't usually override the global system and theme settings, but rather, are custom drawn. Here is a quick and simple example to illustrate this:

Code:
Procedure OpenCustomWindow(x, y, width, height, windowColor, titleText.s,
                           titleHeight, titleFontColor, titleBackColor, centred)
  If centred
    windowFlags = #PB_Window_BorderLess | #PB_Window_ScreenCentered
  Else
    windowFlags = #PB_Window_BorderLess
  EndIf
 
  window = OpenWindow(#PB_Any, x, y, width, height, "", windowFlags)
  SetWindowColor(window, windowColor)
  canvas = CanvasGadget(#PB_Any, 0, 0, width, titleHeight, #PB_Canvas_Keyboard)   
  StartDrawing(CanvasOutput(canvas))
  Box(0, 0, width, titleHeight, titleBackColor)
  titleOffset = (titleHeight - TextHeight("A")) / 2
  controlBoxWidth = TextWidth("X") * 2
  DrawText(titleOffset, titleOffset, titleText, titleFontColor, titleBackColor)
  DrawText(width - controlBoxWidth, titleOffset, "X", titleFontColor, titleBackColor)
  DrawText(width - controlBoxWidth * 2, titleOffset, "_", titleFontColor, titleBackColor)
  StopDrawing()
  SetWindowData(window, canvas)
  SetGadgetData(canvas, controlBoxWidth)
  ProcedureReturn window
EndProcedure

customWindow1 = OpenCustomWindow(100, 100, 300, 300, #Cyan, "My Custom Window 1", 70, #White, #Blue, 0)
customCanvas1 = GetWindowData(customWindow1)
windows + 1

customWindow2 = OpenCustomWindow(200, 200, 300, 300, #Yellow, "My Custom Window 2", 50, #Yellow, #Red, 0)
customCanvas2 = GetWindowData(customWindow2)
windows + 1

customWindow3 = OpenCustomWindow(300, 300, 300, 300, #White, "My Custom Window 3", 30, #White, #Black, 0)
customCanvas3 = GetWindowData(customWindow3)
windows + 1

Repeat
  If dragOn
    ResizeWindow(activeWindow, DesktopMouseX() - windowMouseXOffset,
                 DesktopMouseY() - windowMouseYOffset, #PB_Ignore, #PB_Ignore)
  EndIf
  Select WaitWindowEvent()
    Case #PB_Event_Gadget
      Select EventGadget()
        Case customCanvas1, customCanvas2, customCanvas3
          activeWindow = EventWindow()
          activeCanvas = EventGadget()
          activeWindowControlBoxWidth = GetGadgetData(activeCanvas)
          Select EventType()
            Case #PB_EventType_LeftClick
              canvasDownX = GetGadgetAttribute(activeCanvas, #PB_Canvas_MouseX)
              If canvasDownX > WindowWidth(activeWindow) - activeWindowControlBoxWidth
                CloseWindow(activeWindow)
                windows - 1
              ElseIf canvasDownX > WindowWidth(activeWindow) - (activeWindowControlBoxWidth * 2)
                SetWindowState(activeWindow, #PB_Window_Minimize)
              EndIf             
            Case #PB_EventType_LeftButtonDown
              windowMouseXOffset = DesktopMouseX() - WindowX(activeWindow)
              windowMouseYOffset = DesktopMouseY() - WindowY(activeWindow)
              dragOn = 1
            Case #PB_EventType_LeftButtonUp
              dragOn = 0
          EndSelect
      EndSelect
  EndSelect
Until windows = 0

The windows can be moved, minimised, and closed independently, and the functionalities could be expanded quite easily. It's not tested, but it should work across the three platforms.

_________________
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
 Post subject: Re: Wishes for Window and Menu colors
PostPosted: Tue Apr 03, 2018 6:32 pm 
Offline
User
User
User avatar

Joined: Sat Sep 02, 2017 7:30 pm
Posts: 47
*** to Administrator: please delete this post reply ***


Last edited by PedroMartins on Fri Apr 06, 2018 2:29 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Wishes for Window and Menu colors
PostPosted: Tue Apr 03, 2018 6:53 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jul 03, 2003 6:53 pm
Posts: 1165
Location: England
TI-994A wrote:
Most applications with customised windows don't usually override the global system and theme settings, but rather, are custom drawn. Here is a quick and simple example to illustrate this:
If you try to drag one of those windows by its titlebar on Ubuntu you can't let go of it again :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Wishes for Window and Menu colors
PostPosted: Tue Apr 03, 2018 7:35 pm 
Offline
User
User
User avatar

Joined: Sat Sep 02, 2017 7:30 pm
Posts: 47
*** to Administrator: please delete this post reply ***


Last edited by PedroMartins on Fri Apr 06, 2018 2:29 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Wishes for Window and Menu colors
PostPosted: Wed Apr 04, 2018 9:32 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2082
Location: Singapore
the.weavster wrote:
If you try to drag one of those windows by its titlebar on Ubuntu you can't let go of it again :)

Hi weavster; been quite a while. Thanks for the feedback. The example utilises native cross-platform functions, so that's quite puzzling. Perhaps a sequencing issue, or a clash between the mouse down and mouse click events.

Nonetheless, it's simply a contributory proof of concept; killing time. :D

_________________
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
 Post subject: Re: Wishes for Window and Menu colors
PostPosted: Wed Apr 04, 2018 11:11 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jul 03, 2003 6:53 pm
Posts: 1165
Location: England
PedroMartins wrote:
to the.weavster: Can you change TI-994A code and make it work on ubuntu ?


Sure:
Code:
Procedure OpenCustomWindow(x, y, width, height, windowColor, titleText.s,
                           titleHeight, titleFontColor, titleBackColor, centred)
  If centred
    windowFlags = #PB_Window_BorderLess | #PB_Window_ScreenCentered
  Else
    windowFlags = #PB_Window_BorderLess
  EndIf
 
  window = OpenWindow(#PB_Any, x, y, width, height, "", windowFlags)
  SetWindowColor(window, windowColor)
  canvas = CanvasGadget(#PB_Any, 0, 0, width, titleHeight, #PB_Canvas_Keyboard)   
  StartDrawing(CanvasOutput(canvas))
  Box(0, 0, width, titleHeight, titleBackColor)
  titleOffset = (titleHeight - TextHeight("A")) / 2
  controlBoxWidth = TextWidth("X") * 2
  DrawText(titleOffset, titleOffset, titleText, titleFontColor, titleBackColor)
  DrawText(width - controlBoxWidth, titleOffset, "X", titleFontColor, titleBackColor)
  DrawText(width - controlBoxWidth * 2, titleOffset, "_", titleFontColor, titleBackColor)
  StopDrawing()
  SetWindowData(window, canvas)
  SetGadgetData(canvas, controlBoxWidth)
  ProcedureReturn window
EndProcedure

customWindow1 = OpenCustomWindow(100, 100, 300, 300, #Cyan, "My Custom Window 1", 70, #White, #Blue, 0)
customCanvas1 = GetWindowData(customWindow1)
windows + 1

customWindow2 = OpenCustomWindow(200, 200, 300, 300, #Yellow, "My Custom Window 2", 50, #Yellow, #Red, 0)
customCanvas2 = GetWindowData(customWindow2)
windows + 1

customWindow3 = OpenCustomWindow(300, 300, 300, 300, #White, "My Custom Window 3", 30, #White, #Black, 0)
customCanvas3 = GetWindowData(customWindow3)
windows + 1

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Gadget
      Select EventGadget()
        Case customCanvas1, customCanvas2, customCanvas3
          activeWindow = EventWindow()
          activeCanvas = EventGadget()
          activeWindowControlBoxWidth = GetGadgetData(activeCanvas)
          Select EventType()
            Case #PB_EventType_MouseMove
              If dragOn
                  ResizeWindow(activeWindow, DesktopMouseX() - windowMouseXOffset,DesktopMouseY() - windowMouseYOffset, #PB_Ignore, #PB_Ignore)
              EndIf
            Case #PB_EventType_LeftClick
              canvasDownX = GetGadgetAttribute(activeCanvas, #PB_Canvas_MouseX)
              If canvasDownX > WindowWidth(activeWindow) - activeWindowControlBoxWidth
                CloseWindow(activeWindow)
                windows - 1
              ElseIf canvasDownX > WindowWidth(activeWindow) - (activeWindowControlBoxWidth * 2)
                SetWindowState(activeWindow, #PB_Window_Minimize)
              EndIf             
            Case #PB_EventType_LeftButtonDown
              windowMouseXOffset = DesktopMouseX() - WindowX(activeWindow)
              windowMouseYOffset = DesktopMouseY() - WindowY(activeWindow)
              dragOn = 1
            Case #PB_EventType_LeftButtonUp
              dragOn = 0
          EndSelect
      EndSelect
  EndSelect
Until windows = 0


TI-994A wrote:
The example utilises native cross-platform functions, so that's quite puzzling.
Hi TI-994A :)
Having ResizeWindow() outside of WaitWindowEvent() seems to prevent the #PB_EventType_LeftButtonUp ever getting triggered.


Top
 Profile  
Reply with quote  
 Post subject: Re: Wishes for Window and Menu colors
PostPosted: Wed Apr 04, 2018 12:24 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2082
Location: Singapore
the.weavster wrote:
Hi TI-994A :)
Having ResizeWindow() outside of WaitWindowEvent() seems to prevent the #PB_EventType_LeftButtonUp ever getting triggered.

Nice! OSX has such quirks too, IIRC. Thanks for the debug.

_________________
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
 Post subject: Re: Wishes for Window and Menu colors
PostPosted: Wed Apr 04, 2018 1:54 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1288
Location: Germany
Very nice :D

small update with BindGadgetEvent
Code:
Global CountCustomWindow

Procedure EventCustomWindow()
  Static dragOn, windowMouseXOffset, windowMouseYOffset
  Protected canvasDownX
  Protected activeWindow = EventWindow()
  Protected activeCanvas = EventGadget()
  Protected activeWindowControlBoxWidth = GetGadgetData(activeCanvas)
  Select EventType()
    Case #PB_EventType_MouseMove
      If dragOn
        ResizeWindow(activeWindow, DesktopMouseX() - windowMouseXOffset,DesktopMouseY() - windowMouseYOffset, #PB_Ignore, #PB_Ignore)
      EndIf
    Case #PB_EventType_LeftClick
      canvasDownX = GetGadgetAttribute(activeCanvas, #PB_Canvas_MouseX)
      If canvasDownX > WindowWidth(activeWindow) - activeWindowControlBoxWidth
        CloseWindow(activeWindow)
        CountCustomWindow - 1
      ElseIf canvasDownX > WindowWidth(activeWindow) - (activeWindowControlBoxWidth * 2)
        SetWindowState(activeWindow, #PB_Window_Minimize)
      EndIf             
    Case #PB_EventType_LeftButtonDown
      windowMouseXOffset = DesktopMouseX() - WindowX(activeWindow)
      windowMouseYOffset = DesktopMouseY() - WindowY(activeWindow)
      dragOn = 1
    Case #PB_EventType_LeftButtonUp
      dragOn = 0
  EndSelect
EndProcedure

Procedure OpenCustomWindow(x, y, width, height, windowColor, titleText.s,
                           titleHeight, titleFontColor, titleBackColor, centred)
  If centred
    windowFlags = #PB_Window_BorderLess | #PB_Window_ScreenCentered
  Else
    windowFlags = #PB_Window_BorderLess
  EndIf
 
  window = OpenWindow(#PB_Any, x, y, width, height, "", windowFlags)
  SetWindowColor(window, windowColor)
  canvas = CanvasGadget(#PB_Any, 0, 0, width, titleHeight, #PB_Canvas_Keyboard)   
  StartDrawing(CanvasOutput(canvas))
  Box(0, 0, width, titleHeight, titleBackColor)
  titleOffset = (titleHeight - TextHeight("A")) / 2
  controlBoxWidth = TextWidth("X") * 2
  DrawText(titleOffset, titleOffset, titleText, titleFontColor, titleBackColor)
  DrawText(width - controlBoxWidth, titleOffset, "X", titleFontColor, titleBackColor)
  DrawText(width - controlBoxWidth * 2, titleOffset, "_", titleFontColor, titleBackColor)
  StopDrawing()
  SetWindowData(window, canvas)
  SetGadgetData(canvas, controlBoxWidth)
  CountCustomWindow + 1
  BindGadgetEvent(canvas, @EventCustomWindow())
  ProcedureReturn window
EndProcedure

customWindow1 = OpenCustomWindow(100, 100, 300, 300, #Cyan, "My Custom Window 1", 70, #White, #Blue, 0)
customWindow2 = OpenCustomWindow(200, 200, 300, 300, #Yellow, "My Custom Window 2", 50, #Yellow, #Red, 0)
customWindow3 = OpenCustomWindow(300, 300, 300, 300, #White, "My Custom Window 3", 30, #White, #Black, 0)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Gadget
     
  EndSelect
Until CountCustomWindow = 0

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye