Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport upstream changes into this fork #6

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
504fe8c
Now the ttk::entry is drawn just like expected ! With it's background…
Geballin May 25, 2020
7c5fbfa
Upgrade version to 0.6 now that the entry widget is corrected.
Geballin May 25, 2020
46b3256
For working on Ubuntu, add the X11 libs
Geballin Jul 14, 2020
ac3619c
Correcting borders of scrollbar.
Geballin Jul 16, 2020
18a48c5
Upgrade version to 0.7
Geballin Jul 16, 2020
830f65a
Draw default background to avoid transparency problems.
Geballin Aug 4, 2022
3b633f3
Correcting the geometry of scrollbar.
Geballin Aug 16, 2022
cc75d83
The radio button now draw entirely, tested a lot with Adwaita and Bre…
Geballin Aug 16, 2022
c24e626
Now the Checkbutton is drawn perfectly with Breeze and Breeze dark.
Geballin Aug 19, 2022
4eec46c
Remove debug printings.
Geballin Aug 19, 2022
9537af5
Height and width must be different for a good looking and placing.
Geballin Aug 23, 2022
dc34206
Make the entry widget looking good.
Geballin Aug 23, 2022
e34864a
Make height in padding.
Geballin Aug 23, 2022
e7daccb
Switch to 0.8 version.
Geballin Aug 24, 2022
ecbf506
tile->ttk on demos
Geballin Aug 24, 2022
fc106b9
Removing filled color from Scale
rdbende Dec 22, 2022
75a535c
Fix radiobutton focused state
rdbende Dec 22, 2022
003245c
Remove unused variable declaration
rdbende Dec 22, 2022
97fb189
Fix glitch on progressbar background
rdbende Dec 22, 2022
595deba
Merge pull request #8 from rdbende/fix-progressbar-bg
Geballin Mar 1, 2023
a3b14e6
Merge pull request #7 from rdbende/radiobutton-focus-fix
Geballin Mar 1, 2023
6f0cdf6
Merge pull request #6 from rdbende/fix-scale
Geballin Mar 1, 2023
776299e
Adding the Treeview style configuration.
Geballin May 8, 2023
69813d6
Better populate the Treeview for testing.
Geballin May 9, 2023
9afa71e
Addding the commented stateinfo
Geballin May 9, 2023
89884af
Set the fieldbackground color of the Treeview
Geballin May 9, 2023
ab7076f
Propogate grid on all frame.
Geballin May 9, 2023
02afbfe
Remove useless Heading options.
Geballin May 9, 2023
06173cb
Upgrade to 0.9 version
Geballin May 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PROJECT ( gtkTtk )
## Package version information.
SET ( PKG_NAME ${PROJECT_NAME} )
SET ( PKG_MAJOR_VERSION 0 )
SET ( PKG_MINOR_VERSION 5 )
SET ( PKG_MINOR_VERSION 9 )
SET ( PKG_BUILD_VERSION 0 )
SET ( PKG_VERSION
"${PKG_MAJOR_VERSION}.${PKG_MINOR_VERSION}" )
Expand Down Expand Up @@ -116,7 +116,6 @@ IF ( LOAD_GTK_DYNAMICALLY )
ENDIF ( LOAD_GTK_DYNAMICALLY )
IF ( CMAKE_BUILD_TYPE STREQUAL Debug )
ADD_DEFINITIONS ( -DGTKTTK_SYNCHRONIZE )
ADD_DEFINITIONS ( -DGTKTTK_VERBOSE_XERROR_HANDLER )
ENDIF ( CMAKE_BUILD_TYPE STREQUAL Debug )
ADD_DEFINITIONS ( -DGTKTTK_INSTALL_XERROR_HANDLER )
ADD_DEFINITIONS ( -DUSE_TCL_STUBS )
Expand Down Expand Up @@ -191,6 +190,9 @@ MESSAGE ( STATUS "===========================================================" )
ADD_LIBRARY ( ${PKG_TARGET_LIB_NAME} SHARED ${PKG_SOURCES} )
TARGET_LINK_LIBRARIES ( ${PKG_TARGET_LIB_NAME} ${TCL_STUB_LIBRARY} )
TARGET_LINK_LIBRARIES ( ${PKG_TARGET_LIB_NAME} ${TK_STUB_LIBRARY} )

find_package(X11 REQUIRED)
TARGET_LINK_LIBRARIES ( ${PKG_TARGET_LIB_NAME} ${X11_X11_LIB} )
IF ( TTK_STUB_LIBRARY )
TARGET_LINK_LIBRARIES ( ${PKG_TARGET_LIB_NAME} ${TTK_STUB_LIBRARY} )
ENDIF ( TTK_STUB_LIBRARY )
Expand Down
8 changes: 3 additions & 5 deletions demos/StyleIntrospection.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
## This demo shows information about the Gtk/GNOME style currently in use.
##
###############################################################################
if {[catch {package require Ttk}]} {
package require tile
}
ttk::setTheme tilegtk
package require Tk
ttk::setTheme gtkTtk

set win {}
label $win.lbl_option -text Option:
Expand All @@ -23,7 +21,7 @@ foreach base {fg bg base text light mid dark text_aa} {
label $win.$base -text "$base:" -anchor w
grid $win.$base -row $row -column $col
foreach state {NORMAL PRELIGHT ACTIVE SELECTED INSENSITIVE} {
set colour [ttk::theme::tilegtk::currentThemeColour ${base}($state)]
set colour [ttk::theme::gtkTtk::currentThemeColour ${base}($state)]
label $win.${base}_$state -background $colour \
-relief raised -borderwidth 1
label $win.${base}_${state}_value -text $colour
Expand Down
10 changes: 5 additions & 5 deletions demos/autocomplete.tcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# $Id: autocomplete.tcl,v 1.1 2008/08/03 14:52:09 petasis Exp $
#
# Demonstration of inline auto-completion for Tile combobox widgets.
# Demonstration of inline auto-completion for Ttk combobox widgets.
#
# Usage:
#
Expand All @@ -16,25 +16,25 @@
# overhead.
#

namespace eval tile::combobox {
namespace eval ttk::combobox {
namespace export enableAutocomplete
}

## enableAutocomplete
#
# Enable inline auto-completion for the specified combobox widget.
#
proc tile::combobox::enableAutocomplete { w {presorted 1} } {
proc ttk::combobox::enableAutocomplete { w {presorted 1} } {
bind $w <KeyPress> [namespace code [list DoAutoComplete %W %A $presorted]]
}

## DoAutoComplete
#
# Perform inline auto-completion of typed text in the combobox.
#
proc tile::combobox::DoAutoComplete { w s presorted } {
proc ttk::combobox::DoAutoComplete { w s presorted } {
set old [$w get]
tile::entry::Insert $w $s
ttk::entry::Insert $w $s
set new [$w get]

# Only auto-complete if the string length has changed due to insertion.
Expand Down
8 changes: 6 additions & 2 deletions demos/demo.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ proc tree.pane {w} {
grid $w.t $w.vsb -sticky nwse
grid columnconfigure $w 0 -weight 1
grid rowconfigure $w 0 -weight 1
grid propagate $w 0
grid propagate $w 1

#
# Add initial tree node:
Expand All @@ -529,6 +529,10 @@ proc tree.pane {w} {
$w.t heading Class -text "Class"
bind $w.t <<TreeviewOpen>> [list fillTree $w.t]

lmap child {un deux trois quatre} {
$w.t insert {} end -text $child
}

return $w
}

Expand All @@ -544,7 +548,7 @@ proc fillTree {tv} {
#
# Replace tree item children with current list of child windows.
#
$tv delete [$tv children $id]
# $tv delete [$tv children $id]
set children [winfo children $id]
foreach child $children {
$tv insert $id end -id $child -text [winfo name $child] -open 0 \
Expand Down
9 changes: 6 additions & 3 deletions generic/gtkTtk_CheckButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ static void CheckButtonIndicatorElementGeometry(
"indicator-spacing", &spacing,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad, NULL);
*widthPtr = *heightPtr = size+spacing;
size = focus_pad + focus_width;
*paddingPtr = Ttk_MakePadding(spacing+size, size, spacing+size, size);
*widthPtr = *heightPtr = spacing*2+size+focus_width+focus_pad;
size = focus_width;
*paddingPtr = Ttk_MakePadding(*widthPtr,
size,
*widthPtr,
size);
}

static void CheckButtonIndicatorElementDraw(
Expand Down
3 changes: 3 additions & 0 deletions generic/gtkTtk_Combobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static void ComboboxFieldElementDraw(
GtkTtk_StateShadowTableLookup(NULL, state, gtkState, gtkShadow,
GTKTTK_SECTION_ENTRY|GTKTTK_SECTION_ALL);
GTKTTK_WIDGET_SET_FOCUS(widget);
// GtkTtk_StateInfo(state, gtkState, gtkShadow, tkwin, widget);
GtkTtk_gtk_paint_shadow(style, gdkDrawable, gtkState, gtkShadow, NULL,
widget, "combobox", 0, 0, b.width, b.height);
}
Expand Down Expand Up @@ -127,6 +128,7 @@ static void ComboboxArrowElementDraw(
GTKTTK_ENSURE_WIDGET_OK;
GTKTTK_STYLE_FROM_WIDGET;
GTKTTK_DRAWABLE_FROM_WIDGET;
// GtkTtk_StateInfo(state, gtkState, gtkShadow, tkwin, widget);
GtkTtk_StateShadowTableLookup(NULL, state, gtkState, gtkShadow,
GTKTTK_SECTION_BUTTONS|GTKTTK_SECTION_ALL);
GTKTTK_WIDGET_SET_FOCUS(widget);
Expand All @@ -140,6 +142,7 @@ static void ComboboxArrowElementDraw(
GtkTtk_StateShadowTableLookup(NULL, state, gtkState, gtkShadow,
GTKTTK_SECTION_ENTRY|GTKTTK_SECTION_ALL);
GTKTTK_WIDGET_SET_FOCUS(widget);
// GtkTtk_StateInfo(state, gtkState, gtkShadow, tkwin, widget);
GtkTtk_gtk_paint_flat_box(style, gdkDrawable, gtkState, gtkShadow, NULL,
widget, "combobox", 0, 0, b.width, b.height);
}
Expand Down
6 changes: 4 additions & 2 deletions generic/gtkTtk_Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ static void EntryFieldElementDraw(
GTKTTK_STYLE_FROM_WIDGET;
GtkTtk_StateShadowTableLookup(NULL, state, gtkState, gtkShadow,
GTKTTK_SECTION_ENTRY|GTKTTK_SECTION_ALL);
GtkTtk_gtk_paint_flat_box(style, gdkDrawable, gtkState, gtkShadow, NULL, widget,
"entry_bg", 0, 0, b.width, b.height);
GTKTTK_WIDGET_SET_FOCUS(widget);
GtkTtk_gtk_paint_shadow(style, gdkDrawable, gtkState, gtkShadow, NULL,
widget, "entry", 0, 0, b.width, b.height);
GtkTtk_gtk_paint_shadow(style, gdkDrawable, gtkState, gtkShadow, NULL,
widget, "entry", 0, 0, b.width, b.height);
}
// GtkTtk_StateInfo(state, gtkState, gtkShadow, tkwin, widget);
GtkTtk_CopyGtkPixmapOnToDrawable(gdkDrawable, d, tkwin,
Expand Down
3 changes: 2 additions & 1 deletion generic/gtkTtk_Progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void ProgressTroughElementDraw(
GTKTTK_SECTION_TROUGH|GTKTTK_SECTION_ALL);
// GTKTTK_SETUP_WIDGET_SIZE(b.width, b.height);
GTKTTK_WIDGET_SET_FOCUS(widget);
// GTKTTK_DEFAULT_BACKGROUND;
GTKTTK_DEFAULT_BACKGROUND;
// GtkTtk_StateInfo(state, gtkState, gtkShadow, tkwin, widget);
GtkTtk_gtk_paint_box(style, gdkDrawable, gtkState, GTK_SHADOW_IN, NULL, widget,
"trough", 0, 0, b.width, b.height);
Expand Down Expand Up @@ -118,6 +118,7 @@ static void ProgressBarElementDraw(
GTKTTK_ENSURE_WIDGET_OK;
GTKTTK_STYLE_FROM_WIDGET;
GTKTTK_DRAWABLE_FROM_WIDGET;
GTKTTK_DEFAULT_BACKGROUND;
// Tcl_GetDoubleFromObj(NULL, pbar->valueObj, &value);
// Tcl_GetDoubleFromObj(NULL, pbar->maximumObj, &maximum);
// if (strncmp(Tcl_GetString(pbar->modeObj), "determinate", 10) != 0) {
Expand Down
24 changes: 12 additions & 12 deletions generic/gtkTtk_RadioButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ static void RadioButtonIndicatorElementGeometry(
"indicator-spacing", &spacing,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad, NULL);
*widthPtr = *heightPtr = size+spacing;
size = focus_pad + focus_width;
*paddingPtr = Ttk_MakePadding(spacing+size, size, spacing+size, size);
*widthPtr = size+focus_width+focus_pad;
*heightPtr = size+spacing*2+focus_pad;
size = focus_width;
*paddingPtr = Ttk_MakePadding(*heightPtr, size, *widthPtr, size);
}

static void RadioButtonIndicatorElementDraw(
Expand All @@ -51,29 +52,28 @@ static void RadioButtonIndicatorElementDraw(
{
GTKTTK_GTK_DRAWABLE_DEFINITIONS;
gint indicator_size, x, y;
const gint MAGIC_HEIGHT_WIDTH_COMPLEMENT = 40;
GTKTTK_ENSURE_GTK_STYLE_ENGINE_ACTIVE;
GtkWidget *widget = GtkTtk_GetRadioButton(wc);
GTKTTK_ENSURE_WIDGET_OK;
GTKTTK_DRAWABLE_FROM_WIDGET_SIZE(b.width+20, b.height+20);
GTKTTK_DRAWABLE_FROM_WIDGET_SIZE(b.width+MAGIC_HEIGHT_WIDTH_COMPLEMENT,
b.height+MAGIC_HEIGHT_WIDTH_COMPLEMENT);
GTKTTK_STYLE_BACKGROUND_DEFAULT;
GTKTTK_DEFAULT_BACKGROUND_SIZE(b.width+20, b.height+20);
GTKTTK_DEFAULT_BACKGROUND_SIZE(b.width+MAGIC_HEIGHT_WIDTH_COMPLEMENT,
b.height+MAGIC_HEIGHT_WIDTH_COMPLEMENT);
GTKTTK_STYLE_FROM_WIDGET;
GTKTTK_WIDGET_SET_FOCUS(widget);
GtkTtk_gtk_widget_style_get(widget,
"indicator-size", &indicator_size, NULL);
GtkTtk_StateShadowTableLookup(NULL, state, gtkState, gtkShadow,
GTKTTK_SECTION_BUTTONS|GTKTTK_SECTION_ALL);
if (state & TTK_STATE_FOCUS) {
GtkTtk_gtk_paint_focus(style, gdkDrawable, gtkState, NULL, widget,
"radiobutton", 0, 0, b.width + 20, b.height + 20);
}
// GtkTtk_StateInfo(state, gtkState, gtkShadow, tkwin, widget);
x = 10 + (b.width - indicator_size) / 2;
y = 10 + (b.height - indicator_size) / 2;
x = (b.width - indicator_size) / 2;
y = (b.height - indicator_size) / 2;
GtkTtk_gtk_paint_option(style, gdkDrawable, gtkState, gtkShadow, NULL,
widget, "radiobutton", x, y, indicator_size, indicator_size);
GtkTtk_CopyGtkPixmapOnToDrawable(gdkDrawable, d, tkwin,
10, 10, b.width, b.height, b.x, b.y);
0, 0, b.width, b.height, b.x, b.y);
GTKTTK_CLEANUP_GTK_DRAWABLE;
}

Expand Down
20 changes: 3 additions & 17 deletions generic/gtkTtk_Scale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ static void ScaleTroughElementGeometry(
{
GTKTTK_WIDGET_CACHE_DEFINITION;
gint trough_border = 0;
int xt = 0, yt = 0;
GtkWidget *widget = GtkTtk_GetScale(wc);
GTKTTK_ENSURE_GTK_STYLE_ENGINE_ACTIVE;
GTKTTK_ENSURE_WIDGET_OK;
GtkTtk_gtk_widget_style_get(widget, "trough-border", &trough_border, NULL);
// xt = widget->style->xthickness;
// yt = widget->style->ythickness;
int xt = widget->style->xthickness;
int yt = widget->style->ythickness;
*paddingPtr = Ttk_MakePadding(xt + trough_border,
yt + trough_border,
xt + trough_border,
Expand All @@ -72,21 +71,8 @@ static void ScaleTroughElementDraw(
&trough_side_details, NULL);
// GtkTtk_StateInfo(state, gtkState, gtkShadow, tkwin, widget);
if (trough_side_details) {
int trough_change_pos_x = b.width, trough_change_pos_y = b.height;
if (wc->gtkOrientation == GTK_ORIENTATION_HORIZONTAL)
trough_change_pos_x = b.width / 2;
else
trough_change_pos_y = b.height / 2;
GtkTtk_gtk_paint_box(style, gdkDrawable, gtkState, GTK_SHADOW_IN, NULL,
widget, "trough-upper", 0, 0,
trough_change_pos_x, trough_change_pos_y);
if (wc->gtkOrientation == GTK_ORIENTATION_HORIZONTAL)
trough_change_pos_y = 0;
else
trough_change_pos_x = 0;
GtkTtk_gtk_paint_box(style, gdkDrawable, gtkState, GTK_SHADOW_IN, NULL,
widget, "trough-lower", trough_change_pos_x, trough_change_pos_y,
b.width-trough_change_pos_x, b.height-trough_change_pos_y);
widget, "trough-upper", 0, 0, b.width, b.height);
} else {
GtkTtk_gtk_paint_box(style, gdkDrawable, gtkState, GTK_SHADOW_IN, NULL,
widget, "trough", 0, 0, b.width, b.height);
Expand Down
18 changes: 9 additions & 9 deletions generic/gtkTtk_Scrollbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ static void ScrollbarTroughElementGeometry(
GTKTTK_ENSURE_GTK_STYLE_ENGINE_ACTIVE;
GTKTTK_ENSURE_WIDGET_OK;
GtkTtk_gtk_widget_style_get(widget, "trough-border", &trough_border, NULL);
// xt = widget->style->xthickness;
// yt = widget->style->ythickness;
xt = widget->style->xthickness;
yt = widget->style->ythickness;
*paddingPtr = Ttk_MakePadding(xt + trough_border,
yt + trough_border,
xt + trough_border,
Expand Down Expand Up @@ -147,7 +147,7 @@ static void ScrollbarThumbElementDraw(
GTKTTK_WIDGET_SET_FOCUS(widget);
adj = GtkTtk_gtk_range_get_adjustment((GtkRange *) widget);
GtkTtk_gtk_adjustment_set_value(adj,GtkTtk_ValueFromSlider(wc, tkwin, b));
// GTKTTK_DEFAULT_BACKGROUND;
GTKTTK_DEFAULT_BACKGROUND;
GtkTtk_gtk_paint_box(style, gdkDrawable, gtkState, GTK_SHADOW_IN, NULL, widget,
"trough", 0, 0, b.width, b.height);

Expand Down Expand Up @@ -198,10 +198,10 @@ static void ScrollbarUpArrowElementGeometry(
}
xt = widget->style->xthickness;
yt = widget->style->ythickness;
*paddingPtr = Ttk_MakePadding(xt + trough_border,
yt + trough_border,
xt + trough_border,
yt + trough_border);
*paddingPtr = Ttk_MakePadding(trough_border - xt,
trough_border - yt,
trough_border + xt,
trough_border + yt);
}

static void ScrollbarUpArrowElementDraw(
Expand All @@ -224,7 +224,7 @@ static void ScrollbarUpArrowElementDraw(
GTKTTK_SECTION_STEPPERS|GTKTTK_SECTION_ALL);
// GTKTTK_SETUP_WIDGET_SIZE(b.width, b.height);
GTKTTK_WIDGET_SET_FOCUS(widget);
// GTKTTK_DEFAULT_BACKGROUND;
GTKTTK_DEFAULT_BACKGROUND;
// GtkTtk_StateInfo(state, gtkState, gtkShadow, tkwin, widget);
GtkTtk_gtk_paint_box(style, gdkDrawable, gtkState, GTK_SHADOW_IN, NULL,
widget, horizontal ? "hscrollbar":"vscrollbar",
Expand Down Expand Up @@ -289,7 +289,7 @@ static void ScrollbarDownArrowElementDraw(
GTKTTK_SECTION_STEPPERS|GTKTTK_SECTION_ALL);
// GTKTTK_SETUP_WIDGET_SIZE(b.width, b.height);
GTKTTK_WIDGET_SET_FOCUS(widget);
// GTKTTK_DEFAULT_BACKGROUND;
GTKTTK_DEFAULT_BACKGROUND;
// GtkTtk_StateInfo(state, gtkState, gtkShadow, tkwin, widget);
GtkTtk_gtk_paint_box(style, gdkDrawable, gtkState, GTK_SHADOW_IN, NULL,
widget, horizontal ? "hscrollbar":"vscrollbar",
Expand Down
10 changes: 7 additions & 3 deletions generic/gtkTtk_Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,18 +451,22 @@ unsigned int GtkTtk_StateShadowTableLookup(GtkTtk_StateTable *map,
}
map = NULL; /* Do not search the table */
} else if (section & GTKTTK_SECTION_BUTTONS ||
section & GTKTTK_SECTION_ENTRY ||
section & GTKTTK_SECTION_ENTRY ||
section & GTKTTK_SECTION_SCROLLBAR) {
/* Whether the button is drawn pressed or not, is defined by shadow. */
if (state & TTK_STATE_PRESSED || state & TTK_STATE_SELECTED) {
gtkShadow = GTK_SHADOW_IN;
} else {
gtkShadow = GTK_SHADOW_OUT;
// if (state & TTK_STATE_DISABLED || state & TTK_STATE_READONLY)
// gtkState = GTK_STATE_INSENSITIVE;
if (state & TTK_STATE_DISABLED || state & TTK_STATE_READONLY)
gtkState = GTK_STATE_INSENSITIVE;
// else if (state & TTK_STATE_ACTIVE) gtkState = GTK_STATE_PRELIGHT;
// else if (state & TTK_STATE_FOCUS) gtkState = GTK_STATE_ACTIVE;
}
if (section & GTKTTK_SECTION_ENTRY) {
if (state & TTK_STATE_FOCUS) gtkState = GTK_STATE_NORMAL;
gtkShadow = GTK_SHADOW_IN;
}
if ((state & TTK_STATE_ACTIVE) &&
(!(state & TTK_STATE_PRESSED) && !(state & TTK_STATE_SELECTED))) {
gtkState = GTK_STATE_PRELIGHT;
Expand Down
Loading