ZenGL

Please login or register.

Login with username, password and session length
Advanced search  

News:

Author Topic: ZenGUI — графический интерфейс для ZenGL  (Read 664 times)

0 Members and 1 Guest are viewing this topic.

Dj_smart

  • Newbie
  • *
  • Offline Offline
  • Posts: 6
    • View Profile

ZenGUI — графический интерфейс пользователя для движка ZenGL.

Текущая версия: 0.1a (альфа)
Необходимая версия ZenGL: 0.3.0+
Преимущества:
  • Большое количество компонент. 16 стандартных, присутствует возможность реализации своих.
  • Реализован на ООП. Можно создать свой компонент на основе любого имеющегося. Все объекты — referececounted (есть нюансы обращения).
  • Оконный редактор из-коробки как в Delphi. Поддерживает RTTI, способен генерировать компилируемый паскалем код, с последующей возможностью эти файлы загружать для дальнейшего редактирования. Есть частичная поддержка событий (код события в редакторе править нельзя, но процедуры под события он генер��рует, остается только заполнить код в сгенерированном файле).
  • Полная поддержка скинов. Все объекты — скинируемые. Скин представляет из себя zip-архив (только *.skin c файлом настроек и текстурами для отображения)
  • Поддержка шрифтов. На любой объект можно назначить шрифт, есть дефолтный шрифт.
  • State-машина. Пока-что примитивная, позволяет в один момент переключать текущие окна другими.
  • Эффекты. На формы можно назначать эффекты появления. В коробке есть несколько эффектов (deZoomIn, deFadeIn, deSlideDown), но и свой эффект на основе других сделать несложно.
Кроме ручного создания объектов, код создания можно сгенерировать редактором (подробнее):
  • WSYIWSG-редактирование окошек как в Delphi. Все свойства компонент можно редактировать в инспекторе объектов.
  • Генерирует файл GUI, который компилируется паскалем. Представляет удобочитаемый формат, который можно отредактировать и вручную. Всегда при сохранении делает *.bak файл, чтобы при возможном краше не испортить файл (альфа же).
  • Поддерживает события, вроде клика по кнопке, можно назначить кнопке события, после чего редактор сгенерирует функцию, в которую останется только вставить код.
  • Если указать рабочую директорию, умеет на лету подгружать графические файлы и шрифты для максимального WYSIWYG.
  • Позволяет натягивать скин на лету, указав файл.
Скины:
  • Скин ZenGUI — zip архив. Содержит файл config.ini, в котором указаны все настройки для каждой из текстур. Тектура имеет имя tx*.tga с очевидным для чего она именем.
  • Скины можно перегружать на лету.
Пример использования:

Для начала, нужно создать объект GUI (предварительно загрузив скин и шрифты):
Code: [Select]
// Load font
  fntMain := font_LoadFromFile('Data/Main.zfi');
  // Create skin (file is a usual zip archive)
  gSkin := zglTGuiSkin.Create('Data/main.skin');
  // Creating an gui object (set skin, screen rect and
  //   default font(normal, active, disabled))
  Gui := zglTGui.Create(gSkin, 0, 0, 800, 600,
    zglTFontContainer.Create(
      zglTFontObject.Create(fntMain, 1, $000000, 255),
      zglTFontObject.Create(fntMain, 1, $101010, 255),
      zglTFontObject.Create(fntMain, 1, $555555, 128)
    ));
Затем, если нужно, создавать объекты, и добавлять их в объект-родитель (например, форму в сам GUI):
Code: [Select]
  // CREATE SOME FORM HERE
  frmSome := zglTForm.Create(Gui, 10, 10, 400, 200, 'I am form', true);
  // Move it to the screen center
  frmSome.MoveToCenter;
  // Make it resiziable
  frmSome.CanResize := true;
  // And moveable
  frmSome.CanMove := true;
  // Add it to the gui that draws last one
  Gui.Items.Add(frmSome);
И напоследок нужно вызвать методы Draw и Update(dt) когда нужно (здесь Draw и Update - процедуры прорисовки и апдейта ZenGL):
Code: [Select]
procedure Draw;
begin
  // Draw gui (last)
  Gui.Draw;
  // and gui's mouse
  Gui.DrawMouse;
end;

procedure Update(dt: Double);
begin
  // Update Gui (first)
  Gui.Update(dt);
end;

Справка:

Справки по базовом использованию пока нет, но она скоро будет.

Скачать:

Для правильной работы и компиляции демок в статичном режиме gui должен быть положен рядом с другими папками ZenGL'а, например: bin, demos, doc, extra, gui, headers, lib, src, tools и должен быть распакован без подпапок, внутри gui должно быть четыре папки: bin, demos, src, tools.

Внимание: ZenGUI в альфа-стадии, хоть и делался около полугода, возможны баги, если обнаружите такой, не стесняйтесь, пишите о них тут: я постараюсь их исправить.

Сверху вниз: Редактор, откомпилированный сгенерированный редактором  файл, другой пример GUI (с другим скином).
« Last Edit: 2012, Aug, 27, 21:45:08 by Dj_smart »
Logged

ironquark

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 88
    • View Profile

ZenGUI — графический интерфейс пользователя для движка ZenGL.

Текущая версия: 0.1a (альфа)
Необходимая версия ZenGL: 0.3.0+


You made a wonderful job my friend!
Thank you very much!
I think it would be interesting to post this very useful tool in English too!
« Last Edit: 2012, Aug, 31, 15:25:41 by ironquark »
Logged

wagenheimer

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 82
    • View Profile

Very nice!!! Congratulations!!!


I noticed you create an Render Target to each Window.... This would not cause a overload when using a lot of windows?
Logged
Cezar Wagenheimer
Green Sauce Games

hinst

  • Newbie
  • *
  • Offline Offline
  • Posts: 7
    • View Profile

Наконец-то кто-сделал. Как раз мне надо было.
Ииии.... Я уже вижу баг. Поменял в коде скин с main.skin на default.skin, сразу стали кнопки некорректно отображаться. В обоих демонстрационных приложениях

http://img69.imageshack.us/img69/8271/zenguibug001.png


(Что это с кнопкой)
« Last Edit: 2012, Aug, 28, 21:13:10 by hinst »
Logged

Dj_smart

  • Newbie
  • *
  • Offline Offline
  • Posts: 6
    • View Profile

Простите господа, это был баг скина, поправил сам скин. Теперь все ок! Также, поправил один вероятный баг в GUI. Изменения можно получить в SVN или перекачать тот же архив.

I noticed you create an Render Target to each Window.... This would not cause a overload when using a lot of windows?
Render Target uses only when effect appears, but then it destroys itself.
« Last Edit: 2012, Aug, 28, 21:38:42 by Dj_smart »
Logged

ironquark

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 88
    • View Profile

So,

I'm with troubles to load two images on image component...

When I close the application it crashes..

You have suggestion how to fix?
Logged

ironquark

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 88
    • View Profile

So,

I'm with troubles to load two images on image component...

When I close the application it crashes..

You have suggestion how to fix?

So to fix I made this:
Code: [Select]
procedure Quit;
begin
  // Release gui
  Gui.Free;
end;

  zgl_Reg(SYS_EXIT, @Quit );

Its my mistake then? xD

I want request one feature please, put a option to centralize the form from editor, when you open the unit file on editor and save again you lost this code:
Code: [Select]
  TutorialForm1 := zglTForm.CreateDefaults(Gui); {ROOT}
  with TutorialForm1 do begin
    Caption := 'Tutorial';
    DisplayEffect := deSlideDown;
    Name := 'TutorialForm1';
    Rect.H := 272.00;
    Rect.W := 396.00;
    Rect.X := 5.00;
    Rect.Y := 6.00;

    TutorialForm1.MoveToCenter;
  end;

« Last Edit: 2012, Sep, 10, 04:19:06 by ironquark »
Logged

ironquark

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 88
    • View Profile

Hey,

After some tests here, I found a small bug, When you create a form with a button and press the button to open a new window as modal the effect appear white before appear the effect...

Code: [Select]
ExitForm.MoveToCenter;
ExitForm.ShowModal; //changing this line to ExitForm.Show; This correct the "bug"

Download my demo test in attach and press Options Button and Exit Button and you will see what I'm talking about...

Do you have a suggestion how to fix?

I need the modal style with the effect...


« Last Edit: 2012, Sep, 17, 13:21:03 by ironquark »
Logged

ironquark

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 88
    • View Profile

Hey,

After some tests here, I found a small bug, When you create a form with a button and press the button to open a new window as modal the effect appear white before appear the effect...

Code: [Select]
ExitForm.MoveToCenter;
ExitForm.ShowModal; //changing this line to ExitForm.Show; This correct the "bug"

Download my demo test in attach and press Options Button and Exit Button and you will see what I'm talking about...

Do you have a suggestion how to fix?

I need the modal style with the effect...


So... I still with this rendertarget problem

DesertKun is employed now and is without time to fix, all help is welcome to fix this little problem
Logged

Andru

  • Administrator
  • Hero Member
  • *****
  • Online Online
  • Posts: 824
  • Developer of ZenGL
    • View Profile

Quote
After some tests here, I found a small bug, When you create a form with a button and press the button to open a new window as modal the effect appear white before appear the effect...
Try to replace zglTGuiEffect.Init method with this one:
Code: Pascal
  1. procedure zglTGuiEffect.Init;
  2. begin
  3.   Render := rtarget_Add(
  4.     tex_CreateZero(
  5.       round(Component.Rect.W),
  6.       round(Component.Rect.H),
  7.       $00000000,
  8.       TEX_DEFAULT_2D),
  9.     RT_CLEAR_COLOR);
  10. end;
Logged

ironquark

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 88
    • View Profile
Re: ZenGUI — графический интерфейс для ZenGL
« Reply #10 on: 2012, Oct, 01, 00:00:18 »

Quote
After some tests here, I found a small bug, When you create a form with a button and press the button to open a new window as modal the effect appear white before appear the effect...
Try to replace zglTGuiEffect.Init method with this one:
Code: Pascal
  1. procedure zglTGuiEffect.Init;
  2. begin
  3.   Render := rtarget_Add(
  4.     tex_CreateZero(
  5.       round(Component.Rect.W),
  6.       round(Component.Rect.H),
  7.       $00000000,
  8.       TEX_DEFAULT_2D),
  9.     RT_CLEAR_COLOR);
  10. end;

Instead appear white, aparently the effect appear transparent and show the form without the effect.

What do u think about this? For me its strange...
Logged

Andru

  • Administrator
  • Hero Member
  • *****
  • Online Online
  • Posts: 824
  • Developer of ZenGL
    • View Profile
Re: ZenGUI — графический интерфейс для ZenGL
« Reply #11 on: 2012, Oct, 01, 15:45:46 »

Now I see where is a problem. zglTGuiEffect.Init should be:
Code: Pascal
  1. procedure zglTGuiEffect.Init;
  2. begin
  3.   batch2d_Flush();
  4.   Render := rtarget_Add(
  5.     tex_CreateZero(
  6.       round(Component.Rect.W),
  7.       round(Component.Rect.H),
  8.       $FFFFFFFF,
  9.       TEX_DEFAULT_2D),
  10.     RT_CLEAR_COLOR);
  11. end;

Problem that you should call batch2d_Flush before loading or creating any texture/render target.
Logged

ironquark

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 88
    • View Profile
Re: ZenGUI — графический интерфейс для ZenGL
« Reply #12 on: 2012, Oct, 01, 16:42:14 »

Now I see where is a problem. zglTGuiEffect.Init should be:
Code: Pascal
  1. procedure zglTGuiEffect.Init;
  2. begin
  3.   batch2d_Flush();
  4.   Render := rtarget_Add(
  5.     tex_CreateZero(
  6.       round(Component.Rect.W),
  7.       round(Component.Rect.H),
  8.       $FFFFFFFF,
  9.       TEX_DEFAULT_2D),
  10.     RT_CLEAR_COLOR);
  11. end;

Problem that you should call batch2d_Flush before loading or creating any texture/render target.

Thanks
Logged

Andru

  • Administrator
  • Hero Member
  • *****
  • Online Online
  • Posts: 824
  • Developer of ZenGL
    • View Profile
Re: ZenGUI — графический интерфейс для ZenGL
« Reply #13 on: 2012, Oct, 02, 21:51:53 »

Обновил и добавил на extra-страничку. Среди исправлений баг с ShowModal и правка для GuiEditor, что бы сохранялся правильный путь к файлам используя / вместо \.

I updated and added ZenGUI to extra-page. Uploaded archive includes fix for bug above and fix for GuiEditor, now it will use correct path for files with / instead of \.
Logged
 

Page created in 0.787 seconds with 16 queries.