Aktuelle Zeit: 24.08.2019 20:47

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]




Ein neues Thema erstellen Auf das Thema antworten  [ 13 Beiträge ]  Gehe zu Seite Vorherige  1, 2
Autor Nachricht
 Betreff des Beitrags: Re: Magic of GTKCellRenderer :)
BeitragVerfasst: 30.12.2018 21:14 
Offline

Registriert: 27.11.2016 18:13
Wohnort: Erzgebirge
Hallo!

Da ich nach dem "Nichts ist unmöglich"-Prinzip arbeite:

Kann das hier jemand testen!

Code:
ImportC ""
  gtk_css_provider_load_from_data(*css_provider, data_.p-utf8, length, *error.GError)
  gtk_css_provider_new()
  gtk_style_context_add_provider(*context, *provider, priority)
  gtk_style_context_remove_provider(*context, *provider)
  gtk_widget_get_style_context(*widget.GtkWidget)
  g_object_set(*Object.GtkObject, property.p-utf8, value.i, term.i = 0)
  g_type_check_instance_is_a(*Instance.GTypeInstance, *Type.GTypeClass)
  gtk_cell_layout_get_cells(*cell_layout)
  gtk_widget_get_name(*Widget.GtkWidget)
  gtk_style_context_to_string (*Context, flags)
  gtk_style_context_add_class(*CSSContext, *ClassName)
  gtk_style_context_list_classes(*CSSContext)
  gtk_widget_style_get(*Widget.GtkWidget, PropertyName.P-UTF8, *Value, Null)
EndImport

#G_TYPE_INT = 6 << 2
ImportC ""
  gtk_style_get_style_property(*Style.GtkStyle, WidgetType.I, PropertyName.S, *Value.GValue)
EndImport

; *{..} = All
; entry{..} = Exactly the widget-type
; entry:selected, *:selected ,....(selection, hover, ...)

Procedure SetBackgroundColor(Gadget, bgcolor)
  Protected *gProvider= gtk_css_provider_new()
  Protected.s CSS = "*{background: rgb("+Red(bgcolor)+","+Green(bgcolor)+","+Blue(bgcolor)+")}"
 
  gtk_css_provider_load_from_data(*gProvider, CSS, -1, #Null)
  gtk_style_context_add_provider(gtk_widget_get_style_context(GadgetID(Gadget)), *gProvider, 600)
  g_object_unref_(*gProvider)
EndProcedure

Procedure SetForegroundColor(Gadget, fgcolor)
  Protected *gProvider= gtk_css_provider_new()
  Protected.s CSS = "*{color: rgb("+Red(fgcolor)+","+Green(fgcolor)+","+Blue(fgcolor)+")}"
 
  gtk_css_provider_load_from_data(*gProvider, CSS, -1, #Null)
  gtk_style_context_add_provider(gtk_widget_get_style_context(GadgetID(Gadget)), *gProvider, 600)
  g_object_unref_(*gProvider)
EndProcedure

Procedure SetMarkingColor(Gadget, fgcolor, bgcolor = 0)
  Protected *gProvider= gtk_css_provider_new()
  Protected.s CSS = "*selection{color: rgb("+Red(fgcolor)+","+Green(fgcolor)+","+Blue(fgcolor)+"); background-color: rgb("+Red(bgcolor)+","+Green(bgcolor)+","+Blue(bgcolor)+")}"
 
  gtk_css_provider_load_from_data(*gProvider, CSS, -1, #Null)
  gtk_style_context_add_provider(gtk_widget_get_style_context(GadgetID(Gadget)), *gProvider, 600)
  g_object_unref_(*gProvider)
EndProcedure

Procedure SetSelectedColor(Gadget, fgcolor, bgcolor = 0)
  Protected *gProvider= gtk_css_provider_new()
  Protected.s CSS = "*:selected{color: rgb("+Red(fgcolor)+","+Green(fgcolor)+","+Blue(fgcolor)+"); background-color: rgb("+Red(bgcolor)+","+Green(bgcolor)+","+Blue(bgcolor)+")}"
 
  gtk_css_provider_load_from_data(*gProvider, CSS, -1, #Null)
  gtk_style_context_add_provider(gtk_widget_get_style_context(GadgetID(Gadget)), *gProvider, 600)
  g_object_unref_(*gProvider)
EndProcedure

Procedure SetCursorColor(Gadget, ccolor)
  Protected *gProvider= gtk_css_provider_new()
  Protected.s CSS = "*{caret-color: rgb("+Red(ccolor)+","+Green(ccolor)+","+Blue(ccolor)+")}"
 
  gtk_css_provider_load_from_data(*gProvider, CSS, -1, #Null)
  gtk_style_context_add_provider(gtk_widget_get_style_context(GadgetID(Gadget)), *gProvider, 600)
  g_object_unref_(*gProvider)
EndProcedure

Procedure SetListColor(Gadget, even_row_color, odd_row_color)
  ;Protected *string = gtk_style_context_to_string(gtk_widget_get_style_context(GadgetID(Gadget)), 1)
  Protected.s CSS = ".view {background: transparent};"
  Protected.s CSS2
  Protected *Column.GtkTreeViewColumn
  Protected RendererList.i, *Renderer.GtkCellRenderer
  Protected RowHeight.i, VerticalSeparator.i, th.i
  Protected *CSSProvider, *CSSProvider2
  Protected *CSSContext, *CSSContext2
  Protected *Layer1, *Layer2, *Layer3 ;Muss immer angepasst werden !!!
 
  *Column = gtk_tree_view_get_column_(GadgetID(Gadget), 0)
  gtk_tree_view_column_cell_get_size_(*Column, 0, 0, 0, 0, @RowHeight)
  gtk_widget_style_get(GadgetID(GadgetID), "vertical-separator", @VerticalSeparator, 0)
 
  th = RowHeight + VerticalSeparator
 
  *CSSProvider = gtk_css_provider_new()
  *CSSProvider2 = gtk_css_provider_new()
 
  *Layer = gtk_widget_get_parent_(GadgetID(Gadget)) ;!!!
  *Layer2 = gtk_widget_get_parent_(*Layer)          ;!!!
  *Layer3 = gtk_widget_get_parent_(*Layer2)         ;!!!
                                                    ;*Layer = gtk_widget_get_toplevel_(GadgetID(Gadget))
 
  *CSSContext2 = gtk_widget_get_style_context(*Layer)
  *CSSContext = gtk_widget_get_style_context(GadgetID(Gadget))
 
  gtk_style_context_add_class(*CSSContext2, UTF8("tbox"))
 
  ;Debug th
 
  CSS2.s = ".tbox {background-image: linear-gradient(To bottom, rgb("+Red(even_row_color)+","+Green(even_row_color)+","+Blue(even_row_color)+") 50%, rgb("+Red(odd_row_color)+","+Green(odd_row_color)+","+Blue(odd_row_color)+") 50%); background-size: 100% " + Str(th * 2) + "px;}"
 
  gtk_css_provider_load_from_data(*CSSProvider2, CSS2, -1, #Null)
  gtk_style_context_add_provider(*CSSContext2, *CSSProvider2, 600)
 
  gtk_css_provider_load_from_data(*CSSProvider, CSS, -1, #Null)
  gtk_style_context_add_provider(*CSSContext, *CSSProvider, 600)
 
  g_object_unref_(*CSSProvider2)
  g_object_unref_(*CSSProvider)
EndProcedure

Procedure SetWindowColorEx(Window, wcolor)
  Protected *gProvider= gtk_css_provider_new()
  Protected.s CSS = "*{background: rgb("+Red(wcolor)+","+Green(wcolor)+","+Blue(wcolor)+")}"
 
  gtk_css_provider_load_from_data(*gProvider, CSS, -1, #Null)
  gtk_style_context_add_provider(gtk_widget_get_style_context(WindowID(Window)), *gProvider, 600)
  g_object_unref_(*gProvider)
EndProcedure


If OpenWindow(0, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
  SetWindowColorEx(0, RGB(0,0,0))
 
  ListViewGadget(0, 10, 10, 250, 120)
  For a = 1 To 12
    AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview")
  Next
  Debug PeekS(gtk_widget_get_name_(GadgetID(0)), -1, #PB_UTF8)
 
  ;SetGadgetColor(0, #PB_Gadget_FrontColor, $EAEBE1)
  SetBackgroundColor(0, RGB(255,255,0))
  SetForegroundColor(0, RGB(255,255,0))
  SetMarkingColor(0, RGB(255,0,255), RGB(0,0,0))
  SetSelectedColor(0, RGB(0,0,0), RGB(0,255,0)) ;ListView, ...
  SetCursorColor(0, RGB(255,0,0))
  SetListColor(0, RGB(0,200,0), RGB(200,0,0))
  ;SetGadgetItemColor(0,  9, #PB_Gadget_BackColor,  RGB(255,0,0),  0)
 
 
  SetGadgetState(0, 9) ; set (beginning with 0) the tenth item as the active one
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf


Es sieht aber beim "Scrollen" schei** aus.

Irgendwie bekommt man das mit den Scrollen sicherlich auch noch hin.

Ich denke da in Richtung CSS-Animation und Animation-Events.
Aber da bin ich noch nicht dahinter gestiegen.
Die Position des Hintergrunds kann man ja sehr schön über CSS beeinflussen.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Magic of GTKCellRenderer :)
BeitragVerfasst: 31.12.2018 16:56 
Offline

Registriert: 25.03.2013 09:59
Hallo ccode_new,

wie ich Deinen Ergeiz mittlerweile kenne bist Du eh schon dahintergekommen :wink: .

Ich hab schnell in Deinen Code was zusammen-geDrag&Dropped und zur Demonstration ausgedünnt und poste es trotzdem mal. (Wie immer mit zufällig funktionierendem Gültigkeitsbereich)
Zu sehen sein sollte eine Animation inmitten des ListViews (jetzt nur auf Xubuntu 18.04/x64 + PB5.70B3/Gtk3 getestet) die hoffentlich nicht nur bei mir läuft.
Code:
ImportC ""
  gtk_css_provider_load_from_data(*css_provider, data_.p-utf8, length, *error.GError)
  gtk_css_provider_new()
  gtk_style_context_add_provider(*context, *provider, priority)
  gtk_style_context_remove_provider(*context, *provider)
  gtk_widget_get_style_context(*widget.GtkWidget)
  g_object_set(*Object.GtkObject, property.p-utf8, value.i, term.i = 0)
  g_type_check_instance_is_a(*Instance.GTypeInstance, *Type.GTypeClass)
  gtk_cell_layout_get_cells(*cell_layout)
  gtk_widget_get_name(*Widget.GtkWidget)
  gtk_style_context_to_string (*Context, flags)
  gtk_style_context_add_class(*CSSContext, *ClassName)
  gtk_style_context_list_classes(*CSSContext)
  gtk_widget_style_get(*Widget.GtkWidget, PropertyName.P-UTF8, *Value, Null)
EndImport

#G_TYPE_INT = 6 << 2
ImportC ""
  gtk_style_get_style_property(*Style.GtkStyle, WidgetType.I, PropertyName.S, *Value.GValue)
EndImport


Procedure SetSelectedColor(Gadget, fgcolor, bgcolor = 0)
  Protected *gProvider= gtk_css_provider_new()
  Protected.s CSS = "*:selected{color: rgb("+Red(fgcolor)+","+Green(fgcolor)+","+Blue(fgcolor)+"); background-color: rgb("+Red(bgcolor)+","+Green(bgcolor)+","+Blue(bgcolor)+")}"
 
  gtk_css_provider_load_from_data(*gProvider, CSS, -1, #Null)
  gtk_style_context_add_provider(gtk_widget_get_style_context(GadgetID(Gadget)), *gProvider, 600)
  g_object_unref_(*gProvider)
EndProcedure

Procedure SetListColor(Gadget, even_row_color, odd_row_color)
  Protected.s CSS = ".view {background: transparent};"
  Protected *CSSProvider, *CSSProvider2
  Protected *CSSContext, *CSSContext2
  Protected.s WinBkGndCSS= "* .frame {" + #LF$ +
                           "background-image: url(" + #DQUOTE$   + #PB_Compiler_Home + "./logo.png" + #DQUOTE$ + ");" + #LF$ +
                           "background-position: "  + "center center" + ";" + #LF$ +
                           "background-color: "  + "white" + ";" + #LF$ +
                            "background-repeat: "    + "no-repeat"   + ";" + #LF$ +
                            "animation: size-the-image infinite alternate ease-in-out 0.50s;" + #LF$ + "}"
  Protected.s gPumpingImage= "@keyframes size-the-image {" + #LF$ +
                        "0%   { background-size: 64px }" + #LF$ +
                        "100% { background-size: 36px }" + #LF$ + "}"
   
 
  *CSSProvider = gtk_css_provider_new()
  *CSSProvider2 = gtk_css_provider_new()
 
  *Layer = gtk_widget_get_parent_(GadgetID(Gadget)) ;!!!
 
  *CSSContext2 = gtk_widget_get_style_context(*Layer)
  *CSSContext = gtk_widget_get_style_context(GadgetID(Gadget))
 
  gtk_css_provider_load_from_data(*CSSProvider, CSS, -1, #Null)
  gtk_style_context_add_provider(*CSSContext, *CSSProvider, 600)
 
  gtk_css_provider_load_from_data(*CSSProvider2, gPumpingImage + WinBkGndCSS, -1, #Null)
   gtk_style_context_add_provider(*CSSContext2, *CSSProvider2, 800)
 
  g_object_unref_(*CSSProvider2)
  g_object_unref_(*CSSProvider)
EndProcedure

Procedure SetWindowColorEx(Window, wcolor)
  Protected *gProvider= gtk_css_provider_new()
  Protected.s CSS = "*{background: rgb("+Red(wcolor)+","+Green(wcolor)+","+Blue(wcolor)+")}"
 
  gtk_css_provider_load_from_data(*gProvider, CSS, -1, #Null)
  gtk_style_context_add_provider(gtk_widget_get_style_context(WindowID(Window)), *gProvider, 600)
  g_object_unref_(*gProvider)
EndProcedure


If OpenWindow(0, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
  SetWindowColorEx(0, RGB(0,0,0))
 
  ListViewGadget(0, 10, 10, 250, 120)
  For a = 1 To 12
    AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview")
  Next

  SetSelectedColor(0, RGB(0,0,0), RGB(0,255,0)) ;ListView, ...
  SetListColor(0, RGB(0,200,0), RGB(200,0,0))
 
 
  SetGadgetState(0, 9) ; set (beginning with 0) the tenth item as the active one
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Dann guten Rutsch, Charly

_________________
PureBasic Linux-API-Library: http://www.chabba.de


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Magic of GTKCellRenderer :)
BeitragVerfasst: 31.12.2018 20:55 
Offline

Registriert: 27.11.2016 18:13
Wohnort: Erzgebirge
Cool!

Danke!

Ich hatte auch schon bisschen rumprobiert,
habe es dann aber erst mal ruhen lassen.


Guten Rutsch!


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 13 Beiträge ]  Gehe zu Seite Vorherige  1, 2

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 2 Gäste


Sie dürfen keine neuen Themen in diesem Forum erstellen.
Sie dürfen keine Antworten zu Themen in diesem Forum erstellen.
Sie dürfen Ihre Beiträge in diesem Forum nicht ändern.
Sie dürfen Ihre Beiträge in diesem Forum nicht löschen.

Suche nach:
Gehe zu:  

 


Powered by phpBB © 2008 phpBB Group | Deutsche Übersetzung durch phpBB.de
subSilver+ theme by Canver Software, sponsor Sanal Modifiye