Recent

Author Topic: RESOLVIDO - Problema de transparencia no RadioGroup (e outros)  (Read 2705 times)

TeoUrbana

  • New Member
  • *
  • Posts: 43
    • Distração For Fun
Salve a todos.

Pessoal, meu problema é o seguinte. Estou usando o TBCPanel, da paleta BGRAControls, que permite um Panel colorido, em degradê e etc.

Estou colocando um RadioGroup neste Panel e o fundo do RadioGroup não está transparente.

Descobri que está ocorrendo porque o Panel está dentro de um PageControl.
Se colocar o Panel direto no Form, o fundo do RadioGroup fica transparente.

O parent de cada RadioGroup é o seu Panel e o Owner dos 2 é o Form.

Tirei um print para entenderem melhor e vou "attachar" aqui.

Por favor, preciso de uma solução. :'(
« Last Edit: May 09, 2020, 11:09:10 pm by TeoUrbana »

andersonscinfo

  • Full Member
  • ***
  • Posts: 126
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #1 on: April 28, 2020, 02:42:25 am »
Faltou o print anexado, se puder postar, tbm facilitaria se colocar um pequeno exemplo.

Att.

lainz

  • Hero Member
  • *****
  • Posts: 3828
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #2 on: April 28, 2020, 02:50:57 am »
RadioGroup is not transparent because is a TWinControl. What is doing in the form is using the form color, so you need to set the radiogroup color to match your TPanel or TBCPanel. Gradients will not work anyways...

TeoUrbana

  • New Member
  • *
  • Posts: 43
    • Distração For Fun
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #3 on: April 28, 2020, 11:32:08 pm »
Faltou o print anexado, se puder postar, tbm facilitaria se colocar um pequeno exemplo.

Att.

Desculpe, é que ele não estava indo. Mas agora foi.
É o mesmo Panel, só dei um ctrl+c ctrl+v para o PageControl.

Testei colocando o TBCPanel em um TNotebook e funciona corretamente. Aparentemente o problema ocorre somente com o TPageControl.

TeoUrbana

  • New Member
  • *
  • Posts: 43
    • Distração For Fun
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #4 on: April 28, 2020, 11:41:36 pm »
Realizei novo teste, uma nova imagem.

No primeiro, coloquei um TPanel e dentro coloquei o TBCPanel com o RadioGroup. A transparencia está ok, pois o Caption do TBCPanel pode ser lido através do RadioGroup.

No teste sequinte copiei o TBCPanel e colei dentro do TNotebook, e continua com a transparencia ok, dando para ver as cores e ler o caption do TBCPanel.

No 3º colei o TBCPanel dentro do TPageControl, e como pode ser visto na imagem ele perde a transparência, cobrindo assim o componente de trás, impedindo a leitura do caption do TBCPanel.

No último teste, em vez de copiar somente o TBCPanel, copiei também o componente pai, no caso o TPanel e colei dentro do PageControl e vejam o resultado.

Então, será que alguém tem uma solução?

wp

  • Hero Member
  • *****
  • Posts: 8573
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #5 on: April 29, 2020, 12:42:19 am »
I repeated your test with the standard TPanel, and transparency seems to work correctly. The only "issue" is that it is not possible the change the color of tabsheets (at least on Windows).

The standard TPanel cannot be drawn with a gradient fill at designtime. Therefore I applied this code in its OnPaint event:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Panel1Paint(Sender: TObject);
  2. var
  3.   panel: TPanel;
  4. begin
  5.   panel := Sender as TPanel;
  6.   panel.Canvas.GradientFill(
  7.     Rect(0, 0, panel.Width, panel.Height div 2),
  8.     rgb(244, 249, 254),
  9.     rgb(231, 240, 250),
  10.     gdVertical
  11.   );
  12.   panel.Canvas.GradientFill(
  13.     Rect(0, panel.Height div 2, panel.Width, panel.Height),
  14.     rgb(219, 229, 242),
  15.     rgb(220, 232, 245),
  16.     gdVertical
  17.   );
  18.   panel.Canvas.Pen.Color := clOlive;
  19.   panel.Canvas.Pen.Width := 12;
  20.   panel.Canvas.Brush.Style := bsClear;
  21.   panel.Canvas.Rectangle(0, 0, panel.Width, panel.Height);
  22. end;                  
« Last Edit: April 29, 2020, 12:46:31 am by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

lainz

  • Hero Member
  • *****
  • Posts: 3828
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #6 on: April 29, 2020, 01:53:41 am »
@wp I have a question, how transparency works in RadioGroup if is a descendant of TWinControl?

It uses some kind of hack?

TeoUrbana

  • New Member
  • *
  • Posts: 43
    • Distração For Fun
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #7 on: April 29, 2020, 02:25:47 am »
Quote
I repeated your test with the standard TPanel, and transparency seems to work correctly.

I hadn't noticed that with normal Panel it works.

The code was very functional, very cool, but it doesn't solve the problem.
TBCPanel within TPanel was just a test. The entire system is based on the TBCPanel. You have to resolve the issue of transparency.

Your code has repainted, and has hidden the caption of the panel, which is not ideal. Transparency is the ideal.

Thanks for trying wp.

lainz

  • Hero Member
  • *****
  • Posts: 3828
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #8 on: April 29, 2020, 04:10:18 am »
I'm trying to understand how it works to fix TBCPanel. The problem is TBCPanel I think.
« Last Edit: April 29, 2020, 04:12:30 am by lainz »

wp

  • Hero Member
  • *****
  • Posts: 8573
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #9 on: April 29, 2020, 07:05:35 am »
[Your code has repainted, and has hidden the caption of the panel, which is not ideal.
I added my own panel painting code to mimic the TBCPanel gradient. Using an OnPaint handler means that everything must be drawn by yourself. I did not think of the caption because I normally don't need it. But there is no problem to include it:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Panel1Paint(Sender: TObject);
  2. var
  3.   panel: TPanel;
  4. begin
  5.   panel := Sender as TPanel;
  6.   panel.Canvas.GradientFill(
  7.     Rect(0, 0, panel.Width, panel.Height div 2),
  8.     rgb(244, 249, 254),
  9.     rgb(231, 240, 250),
  10.     gdVertical
  11.   );
  12.   panel.Canvas.GradientFill(
  13.     Rect(0, panel.Height div 2, panel.Width, panel.Height),
  14.     rgb(219, 229, 242),
  15.     rgb(220, 232, 245),
  16.     gdVertical
  17.   );
  18.   panel.Canvas.Pen.Color := clOlive;
  19.   panel.Canvas.Pen.Width := 12;
  20.   panel.Canvas.Brush.Style := bsClear;
  21.   panel.Canvas.Rectangle(0, 0, panel.Width, panel.Height);
  22.  
  23.   panel.Canvas.Font.Assign(panel.Font);
  24.   panel.canvas.TextOut(
  25.     (panel.Width - panel.Canvas.TextWidth(panel.Caption)) div 2,
  26.     (panel.Height - panel.Canvas.TextHeight(panel.Caption)) div 2,
  27.     panel.Caption
  28.   );
  29. end;

@wp I have a question, how transparency works in RadioGroup if is a descendant of TWinControl?
Is this statement true? I never understood the background drawing thing... Another "transparent" control is TPanel which derives from TCustomControl and thus from TWinControl. BTW, for testing the truth of last sentence I custom-painted a gradient on the form, and now the background of the radiogroup is no longer that of the panel, but that of the form. It may also depend on the widgetset (I only tested Windows).
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

TeoUrbana

  • New Member
  • *
  • Posts: 43
    • Distração For Fun
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #10 on: April 30, 2020, 12:27:28 am »
I'm trying to understand how it works to fix TBCPanel. The problem is TBCPanel I think.

Português
Lainz, seria o caso de abrir uma issue no GitHub?

English
Lainz, would it be the case to open an issue on GitHub?

lainz

  • Hero Member
  • *****
  • Posts: 3828
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #11 on: April 30, 2020, 01:53:06 am »
Quote
Is this statement true? I never understood the background drawing thing... Another "transparent" control is TPanel which derives from TCustomControl and thus from TWinControl. BTW, for testing the truth of last sentence I custom-painted a gradient on the form, and now the background of the radiogroup is no longer that of the panel, but that of the form. It may also depend on the widgetset (I only tested Windows).

I always though that there was no transparency, and it only inherited the parent color property, not as well the parent drawing.

I'm trying to understand how it works to fix TBCPanel. The problem is TBCPanel I think.

Português
Lainz, seria o caso de abrir uma issue no GitHub?

English
Lainz, would it be the case to open an issue on GitHub?

Yes please open a bug report, I will try to fix it when I have time.

lainz

  • Hero Member
  • *****
  • Posts: 3828

lainz

  • Hero Member
  • *****
  • Posts: 3828
Re: Problema de transparencia no RadioGroup (e outros)
« Reply #13 on: April 30, 2020, 04:58:01 am »
Fixed in dev-BGRAControls. You must download from GitHub and switch to the dev branch.

TeoUrbana

  • New Member
  • *
  • Posts: 43
    • Distração For Fun
RESOLVIDO - Re: Problema de transparencia no RadioGroup (e outros)
« Reply #14 on: May 09, 2020, 11:06:05 pm »
Conforme post anterior, o Lainz realizou a alteração no componente, fazendo com que a transparência funcionasse corretamente.

Se por acaso não estiver funcionando, pode ser porque deve marcar a opção de "Usar recurdo de manifesto (e habilitar temas)" que fica em Projeto -> Opções de Projeto -> Aplicação, opção "Para Windows".

Marcando tal item, a transparência é respeitada, porém a cor da fonte, e o tipo de fonte do RadioGroup por exemplo não se alteram sendo utilizados os default.

Como o problema era a transparência vindo do TBCPanel que não estava funcionando corretamente e agora está, considero este assunto como resolvido.

 

TinyPortal © 2005-2018