Comments (12)
That's the functions documentation, the passed data is undocumented:
https://learn.microsoft.com/en-us/windows/win32/dwm/windowcompositionattrib
The same system updated to windows11 and I get the appearance in your screenshot, whereas when I was using windows 10, I had the previous appearance. So it's not something related to FLTK. Some info can be found here in relation to the attributes:
https://gist.github.com/xv/43bd4c944202a593ac8ec6daa299b471
from fltk-rs.
set_opacity requires the window’s handle which you won’t get until after the window is shown.
Can you place it after the show call.
from fltk-rs.
I don’t believe so. The default background color is applied, then the vibrancy effect takes place. You can change the background color by either changing the window’s color or by setting app::set_background_color().
I don’t think you can create an opaque button on top of a transparent or vibrant window, because FLTK uses drawing routines on top of the window. It doesn’t use subwindows for its widgets.
from fltk-rs.
The issue seems related to this discussion here:
#1324
For opacity, it should work for the whole window, and for vibrancy, it excludes the decorations (this is os specific and fltk has no say in this).
One thing you can try is to disable the decorations/border, create your own and that way it would benefit from the vibrancy effects.
The api itself is non-documented as far as I understand, and certain effects might not be available on all platforms.
from fltk-rs.
I don't know if I should raise issue here or with window-vibrancy. For me it doesn't apply in the background, only at title bar.
Mica | Blur | Acrylic | |
---|---|---|---|
With background color | |||
No background color |
Mica/Blur/Acrylic | |
---|---|
Without background color and border |
from fltk-rs.
It is actually documented -
Use dwmapi setwindowattribute to set DWMWA_SYSTEMBACKDROP_TYPE and DWMSBT_MAINWINDOW.
I probably should've showed it int window-viberancy issues.
from fltk-rs.
Can you try the following progam:
use fltk::{prelude::*, *};
#[repr(C)]
struct Policy {
state: u32,
flags: u32,
gradient: u32,
anim: u32,
}
#[repr(C)]
struct Data {
attrib: u32,
pv_data: *mut (),
cb_data: usize,
}
extern "system" {
fn SetWindowCompositionAttribute(hwnd: *mut (), pwcad: *const Data) -> i32;
}
fn main() {
let a = app::App::default();
let mut w = window::Window::default().with_size(400, 300);
w.end();
w.show();
let mut policy = Policy {
state: 4, // acrylic
flags: 0,
gradient: 0x3b3b3b3b,
anim: 0,
};
let mut data = Data {
attrib: 0x13,
pv_data: &mut policy as *mut _ as _,
cb_data: std::mem::size_of_val(&policy),
};
unsafe { SetWindowCompositionAttribute(w.raw_handle() as _, &mut data as *mut _ as _); }
a.run().unwrap();
}
This uses the older, undocumented, api and gives the previous effect that window-vibrancy gave on windows 10.
from fltk-rs.
It's good but the title bar only seems to have only close button only on hover over the area.
Is there anyway to make it look like this - #1324 (reply in thread).
Also, this is the function's documentation right?
from fltk-rs.
With tabbed window, I've got minor success.
use fltk::{prelude::*, *};
use raw_window_handle::{HasWindowHandle};
use windows_sys::Win32::Foundation::{BOOL, TRUE};
use windows_sys::Win32::Graphics::Dwm::*;
use windows_sys::Win32::UI::Controls::*;
fn main() {
let a = app::App::default();
let mut w = window::Window::default().with_size(400, 300);
w.set_opacity(0.0);
w.end();
w.show();
match w.window_handle().unwrap().as_raw() {
raw_window_handle::RawWindowHandle::Win32(handle) => {
unsafe {
DwmExtendFrameIntoClientArea(
handle.hwnd.get() as _,
&MARGINS {
cxLeftWidth: -1,
cxRightWidth: -1,
cyTopHeight: -1,
cyBottomHeight: -1,
},
);
let value: BOOL = TRUE;
DwmSetWindowAttribute(
handle.hwnd.get() as _,
DWMWA_USE_IMMERSIVE_DARK_MODE as _,
&value as *const BOOL as _,
std::mem::size_of::<BOOL>() as _,
);
DwmSetWindowAttribute(
handle.hwnd.get() as _,
DWMWA_SYSTEMBACKDROP_TYPE as _,
&DWMSBT_TABBEDWINDOW as *const DWM_SYSTEMBACKDROP_TYPE as _,
std::mem::size_of::<DWM_SYSTEMBACKDROP_TYPE>() as _,
);
}
}
_ => panic!("Unsupported platform"),
}
a.run().unwrap();
}
But not having mica/MAINWINDOW is killing me. There seems to be very slight tint change on Mica. But it might not be true. Could there be any problem with opacity? 🤷
FYI: I use latest Windows.
from fltk-rs.
The code for window transparency is defined in cfltk here:
https://github.com/MoAlyousef/cfltk/blob/27514b94e06c2133453059529aa4b663d40c8cdb/src/cfl_window.cpp#L56
I’m not sure if it affects the vibrancy code but I think it shouldn’t.
from fltk-rs.
use fltk::{prelude::*, *};
fn main() {
let a = app::App::default();
let mut w = window::Window::default().with_size(400, 300);
w.set_opacity(0.0);
w.end();
w.show();
a.run().unwrap();
}
Opacity 0 should make it completely transparent, right?
use fltk::{prelude::*, *};
fn main() {
let a = app::App::default();
let mut w = window::Window::default().with_size(400, 300);
w.end();
w.show();
w.set_opacity(0.5);
a.run().unwrap();
}
from fltk-rs.
This seems like an issue in fltk, make sure you can create a fully transparent window using fltk then add the window-vibrancy effect.
tauri-apps/window-vibrancy#128 (comment) This is what the window-vibrancy team said. I also think that vibrancy is being applied but a color is being applied over it. Can you show an example with vibrancy window on windows and and opaque button over it?
set_opacity requires the window’s handle which you won’t get until after the window is shown.
Can you place it after the show call.
This gives me transparency but still can't solve vibrancy.
from fltk-rs.
Related Issues (20)
- [BUG] Can't use `AnimGifImage` HOT 8
- [BUG] Program crashes on start on linux on raspberry pi: [xcb] Unknown sequence number while processing queue HOT 4
- [BUG] Color::from_rgbi should not map RGB values to indexes HOT 3
- [BUG] Cannot get RGB value for Color::Foreground without introducing dependency on fltk-sys HOT 1
- Support `raw-window-handle` 0.6 HOT 4
- why doesnt NativeFileChooser::show return the underlying result of the fltk show call HOT 2
- get_selection and row_selected dont agree in TableRow HOT 4
- I dont see how to call FL_tile::position HOT 3
- sysmenu floats on top of other windows on ubuntu 22 HOT 8
- fl_contrast_mode is not exposed HOT 2
- ignore this
- FL_Tile::size_range is not exposed HOT 8
- Issue with root tree node HOT 1
- [BUG] app init panics with the "single-threaded" feature HOT 2
- Project with fltk cannot be built with Target x86_64-unknown-linux-musl. HOT 4
- Supposedly same code ported from c++ to rust produces different results HOT 3
- [BUG]trying to stop sysmenubar from resizing HOT 3
- Problem converting RGB to RGBA RGBImage HOT 2
- window.fullscreen(true) broken in 1.4.26 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fltk-rs.